blob: 948e0014a451e9234af828f164947c59bedbe45c [file] [log] [blame]
Selim Cinek3acdc8e72017-04-06 17:38:27 -07001/*
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
Jason Monka716bac2018-12-05 15:48:21 -050019import static org.mockito.ArgumentMatchers.any;
20import static org.mockito.Mockito.mock;
21import static org.mockito.Mockito.when;
22
Selim Cinek3acdc8e72017-04-06 17:38:27 -070023import android.animation.ObjectAnimator;
24import android.content.Context;
Selim Cinek3acdc8e72017-04-06 17:38:27 -070025import android.support.test.annotation.UiThreadTest;
26import android.support.test.filters.SmallTest;
Jason Monk6dceace2018-05-15 20:24:07 -040027import android.testing.AndroidTestingRunner;
Jason Monka716bac2018-12-05 15:48:21 -050028import android.testing.TestableLooper;
Jason Monk6dceace2018-05-15 20:24:07 -040029import android.testing.TestableLooper.RunWithLooper;
Selim Cinek3acdc8e72017-04-06 17:38:27 -070030
Selim Cinek3acdc8e72017-04-06 17:38:27 -070031import com.android.systemui.statusbar.NotificationTestHelper;
Jason Monka716bac2018-12-05 15:48:21 -050032import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
33import com.android.systemui.util.Assert;
Selim Cinek3acdc8e72017-04-06 17:38:27 -070034
35import org.junit.Before;
36import org.junit.Test;
37import org.junit.runner.RunWith;
38
Selim Cinek3acdc8e72017-04-06 17:38:27 -070039@SmallTest
Jason Monk6dceace2018-05-15 20:24:07 -040040@RunWith(AndroidTestingRunner.class)
Jason Monka716bac2018-12-05 15:48:21 -050041@RunWithLooper
Selim Cinek3acdc8e72017-04-06 17:38:27 -070042public class ExpandHelperTest extends SysuiTestCase {
43
44 private ExpandableNotificationRow mRow;
45 private ExpandHelper mExpandHelper;
46 private ExpandHelper.Callback mCallback;
47
48 @Before
Selim Cinek5ba22542017-04-20 15:16:10 -070049 public void setUp() throws Exception {
Jason Monka716bac2018-12-05 15:48:21 -050050 Assert.sMainLooper = TestableLooper.get(this).getLooper();
Selim Cinek3acdc8e72017-04-06 17:38:27 -070051 Context context = getContext();
52 mRow = new NotificationTestHelper(context).createRow();
53 mCallback = mock(ExpandHelper.Callback.class);
Jason Monk6dceace2018-05-15 20:24:07 -040054 mExpandHelper = new ExpandHelper(context, mCallback, 10, 100);
Selim Cinek3acdc8e72017-04-06 17:38:27 -070055 }
56
57 @Test
58 @UiThreadTest
59 public void testAnimationDoesntClearViewIfNewExpansionStarted() {
60 when(mCallback.getMaxExpandHeight(any())).thenReturn(100);
61 mExpandHelper.startExpanding(mRow, 0);
62 mExpandHelper.finishExpanding(false, 0);
63 mExpandHelper.startExpanding(mRow, 0);
64 ObjectAnimator scaleAnimation = mExpandHelper.getScaleAnimation();
65 scaleAnimation.end();
66 mExpandHelper.updateExpansion();
67 }
68
69}