• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 static org.mockito.ArgumentMatchers.any;
20 import static org.mockito.Mockito.mock;
21 import static org.mockito.Mockito.when;
22 
23 import android.animation.ObjectAnimator;
24 import android.content.Context;
25 import android.testing.AndroidTestingRunner;
26 import android.testing.TestableLooper;
27 import android.testing.TestableLooper.RunWithLooper;
28 
29 import androidx.test.annotation.UiThreadTest;
30 import androidx.test.filters.SmallTest;
31 
32 import com.android.keyguard.KeyguardUpdateMonitor;
33 import com.android.systemui.statusbar.NotificationMediaManager;
34 import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
35 import com.android.systemui.statusbar.notification.row.NotificationTestHelper;
36 
37 import org.junit.Before;
38 import org.junit.Test;
39 import org.junit.runner.RunWith;
40 
41 @SmallTest
42 @RunWith(AndroidTestingRunner.class)
43 @RunWithLooper
44 public class ExpandHelperTest extends SysuiTestCase {
45 
46     private ExpandableNotificationRow mRow;
47     private ExpandHelper mExpandHelper;
48     private ExpandHelper.Callback mCallback;
49 
50     @Before
setUp()51     public void setUp() throws Exception {
52         mDependency.injectMockDependency(KeyguardUpdateMonitor.class);
53         mDependency.injectMockDependency(NotificationMediaManager.class);
54         allowTestableLooperAsMainThread();
55         Context context = getContext();
56         NotificationTestHelper helper = new NotificationTestHelper(
57                 mContext,
58                 mDependency,
59                 TestableLooper.get(this));
60         mRow = helper.createRow();
61         mCallback = mock(ExpandHelper.Callback.class);
62         mExpandHelper = new ExpandHelper(context, mCallback, 10, 100);
63     }
64 
65     @Test
66     @UiThreadTest
testAnimationDoesntClearViewIfNewExpansionStarted()67     public void testAnimationDoesntClearViewIfNewExpansionStarted() {
68         when(mCallback.getMaxExpandHeight(any())).thenReturn(100);
69         mExpandHelper.startExpanding(mRow, 0);
70         mExpandHelper.finishExpanding(false, 0);
71         mExpandHelper.startExpanding(mRow, 0);
72         ObjectAnimator scaleAnimation = mExpandHelper.getScaleAnimation();
73         scaleAnimation.end();
74         mExpandHelper.updateExpansion();
75     }
76 
77 }
78