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 import android.testing.AndroidTestingRunner;
26 import android.testing.TestableLooper.RunWithLooper;
27 
28 import com.android.systemui.statusbar.ExpandableNotificationRow;
29 import com.android.systemui.statusbar.NotificationTestHelper;
30 
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.junit.runner.RunWith;
34 
35 import static org.mockito.ArgumentMatchers.any;
36 import static org.mockito.Mockito.mock;
37 import static org.mockito.Mockito.when;
38 
39 @SmallTest
40 @RunWith(AndroidTestingRunner.class)
41 @RunWithLooper(setAsMainLooper = true)
42 public class ExpandHelperTest extends SysuiTestCase {
43 
44     private ExpandableNotificationRow mRow;
45     private ExpandHelper mExpandHelper;
46     private ExpandHelper.Callback mCallback;
47 
48     @Before
setUp()49     public void setUp() throws Exception {
50         Context context = getContext();
51         mRow = new NotificationTestHelper(context).createRow();
52         mCallback = mock(ExpandHelper.Callback.class);
53         mExpandHelper = new ExpandHelper(context, mCallback, 10, 100);
54     }
55 
56     @Test
57     @UiThreadTest
testAnimationDoesntClearViewIfNewExpansionStarted()58     public void testAnimationDoesntClearViewIfNewExpansionStarted() {
59         when(mCallback.getMaxExpandHeight(any())).thenReturn(100);
60         mExpandHelper.startExpanding(mRow, 0);
61         mExpandHelper.finishExpanding(false, 0);
62         mExpandHelper.startExpanding(mRow, 0);
63         ObjectAnimator scaleAnimation = mExpandHelper.getScaleAnimation();
64         scaleAnimation.end();
65         mExpandHelper.updateExpansion();
66     }
67 
68 }
69