1/* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License 15 */ 16 17package com.android.systemui; 18 19import android.animation.ObjectAnimator; 20import android.content.Context; 21import android.support.test.InstrumentationRegistry; 22import android.support.test.annotation.UiThreadTest; 23import android.support.test.filters.SmallTest; 24import android.support.test.runner.AndroidJUnit4; 25 26import com.android.systemui.statusbar.ExpandableNotificationRow; 27import com.android.systemui.statusbar.NotificationTestHelper; 28 29import org.junit.Before; 30import org.junit.Test; 31import org.junit.runner.RunWith; 32 33import static org.mockito.ArgumentMatchers.any; 34import static org.mockito.Mockito.mock; 35import static org.mockito.Mockito.when; 36 37@SmallTest 38@RunWith(AndroidJUnit4.class) 39public class ExpandHelperTest extends SysuiTestCase { 40 41 private ExpandableNotificationRow mRow; 42 private ExpandHelper mExpandHelper; 43 private ExpandHelper.Callback mCallback; 44 45 @Before 46 public void setUp() throws Exception { 47 Context context = getContext(); 48 mRow = new NotificationTestHelper(context).createRow(); 49 mCallback = mock(ExpandHelper.Callback.class); 50 InstrumentationRegistry.getInstrumentation().runOnMainSync( 51 () -> mExpandHelper = new ExpandHelper(context, mCallback, 10, 100)); 52 53 } 54 55 @Test 56 @UiThreadTest 57 public void testAnimationDoesntClearViewIfNewExpansionStarted() { 58 when(mCallback.getMaxExpandHeight(any())).thenReturn(100); 59 mExpandHelper.startExpanding(mRow, 0); 60 mExpandHelper.finishExpanding(false, 0); 61 mExpandHelper.startExpanding(mRow, 0); 62 ObjectAnimator scaleAnimation = mExpandHelper.getScaleAnimation(); 63 scaleAnimation.end(); 64 mExpandHelper.updateExpansion(); 65 } 66 67} 68