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 17 package com.android.systemui; 18 19 import android.animation.ObjectAnimator; 20 import android.content.Context; 21 import android.support.test.InstrumentationRegistry; 22 import android.support.test.annotation.UiThreadTest; 23 import android.support.test.filters.SmallTest; 24 import android.support.test.runner.AndroidJUnit4; 25 26 import com.android.systemui.statusbar.ExpandableNotificationRow; 27 import com.android.systemui.statusbar.NotificationTestHelper; 28 29 import org.junit.Before; 30 import org.junit.Test; 31 import org.junit.runner.RunWith; 32 33 import static org.mockito.ArgumentMatchers.any; 34 import static org.mockito.Mockito.mock; 35 import static org.mockito.Mockito.when; 36 37 @SmallTest 38 @RunWith(AndroidJUnit4.class) 39 public class ExpandHelperTest extends SysuiTestCase { 40 41 private ExpandableNotificationRow mRow; 42 private ExpandHelper mExpandHelper; 43 private ExpandHelper.Callback mCallback; 44 45 @Before setUp()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 testAnimationDoesntClearViewIfNewExpansionStarted()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