Selim Cinek | 3acdc8e7 | 2017-04-06 17:38:27 -0700 | [diff] [blame] | 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 | |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 19 | import static org.mockito.ArgumentMatchers.any; |
| 20 | import static org.mockito.Mockito.mock; |
| 21 | import static org.mockito.Mockito.when; |
| 22 | |
Selim Cinek | 3acdc8e7 | 2017-04-06 17:38:27 -0700 | [diff] [blame] | 23 | import android.animation.ObjectAnimator; |
| 24 | import android.content.Context; |
Jason Monk | 6dceace | 2018-05-15 20:24:07 -0400 | [diff] [blame] | 25 | import android.testing.AndroidTestingRunner; |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 26 | import android.testing.TestableLooper; |
Jason Monk | 6dceace | 2018-05-15 20:24:07 -0400 | [diff] [blame] | 27 | import android.testing.TestableLooper.RunWithLooper; |
Selim Cinek | 3acdc8e7 | 2017-04-06 17:38:27 -0700 | [diff] [blame] | 28 | |
Brett Chabot | 84151d9 | 2019-02-27 15:37:59 -0800 | [diff] [blame] | 29 | import androidx.test.annotation.UiThreadTest; |
| 30 | import androidx.test.filters.SmallTest; |
| 31 | |
Selim Cinek | 3acdc8e7 | 2017-04-06 17:38:27 -0700 | [diff] [blame] | 32 | import com.android.systemui.statusbar.NotificationTestHelper; |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 33 | import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; |
| 34 | import com.android.systemui.util.Assert; |
Selim Cinek | 3acdc8e7 | 2017-04-06 17:38:27 -0700 | [diff] [blame] | 35 | |
| 36 | import org.junit.Before; |
| 37 | import org.junit.Test; |
| 38 | import org.junit.runner.RunWith; |
| 39 | |
Selim Cinek | 3acdc8e7 | 2017-04-06 17:38:27 -0700 | [diff] [blame] | 40 | @SmallTest |
Jason Monk | 6dceace | 2018-05-15 20:24:07 -0400 | [diff] [blame] | 41 | @RunWith(AndroidTestingRunner.class) |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 42 | @RunWithLooper |
Selim Cinek | 3acdc8e7 | 2017-04-06 17:38:27 -0700 | [diff] [blame] | 43 | public class ExpandHelperTest extends SysuiTestCase { |
| 44 | |
| 45 | private ExpandableNotificationRow mRow; |
| 46 | private ExpandHelper mExpandHelper; |
| 47 | private ExpandHelper.Callback mCallback; |
| 48 | |
| 49 | @Before |
Selim Cinek | 5ba2254 | 2017-04-20 15:16:10 -0700 | [diff] [blame] | 50 | public void setUp() throws Exception { |
Jason Monk | a716bac | 2018-12-05 15:48:21 -0500 | [diff] [blame] | 51 | Assert.sMainLooper = TestableLooper.get(this).getLooper(); |
Selim Cinek | 3acdc8e7 | 2017-04-06 17:38:27 -0700 | [diff] [blame] | 52 | Context context = getContext(); |
| 53 | mRow = new NotificationTestHelper(context).createRow(); |
| 54 | mCallback = mock(ExpandHelper.Callback.class); |
Jason Monk | 6dceace | 2018-05-15 20:24:07 -0400 | [diff] [blame] | 55 | mExpandHelper = new ExpandHelper(context, mCallback, 10, 100); |
Selim Cinek | 3acdc8e7 | 2017-04-06 17:38:27 -0700 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | @Test |
| 59 | @UiThreadTest |
| 60 | public void testAnimationDoesntClearViewIfNewExpansionStarted() { |
| 61 | when(mCallback.getMaxExpandHeight(any())).thenReturn(100); |
| 62 | mExpandHelper.startExpanding(mRow, 0); |
| 63 | mExpandHelper.finishExpanding(false, 0); |
| 64 | mExpandHelper.startExpanding(mRow, 0); |
| 65 | ObjectAnimator scaleAnimation = mExpandHelper.getScaleAnimation(); |
| 66 | scaleAnimation.end(); |
| 67 | mExpandHelper.updateExpansion(); |
| 68 | } |
| 69 | |
| 70 | } |