Adrian Roos | e18033c | 2017-01-17 15:22:49 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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.statusbar; |
| 18 | |
Selim Cinek | f868efe | 2017-02-01 11:43:18 -0800 | [diff] [blame] | 19 | import static org.mockito.ArgumentMatchers.anyFloat; |
| 20 | import static org.mockito.Mockito.doNothing; |
| 21 | import static org.mockito.Mockito.doReturn; |
| 22 | import static org.mockito.Mockito.spy; |
| 23 | |
Jason Monk | c429f69 | 2017-06-27 13:13:49 -0400 | [diff] [blame] | 24 | import android.support.test.annotation.UiThreadTest; |
| 25 | import android.support.test.filters.SmallTest; |
| 26 | import android.support.test.runner.AndroidJUnit4; |
| 27 | import android.view.View; |
| 28 | |
Jason Monk | fba8faf | 2017-05-23 10:42:59 -0400 | [diff] [blame] | 29 | import com.android.systemui.SysuiTestCase; |
| 30 | |
Jason Monk | c429f69 | 2017-06-27 13:13:49 -0400 | [diff] [blame] | 31 | import org.junit.Assert; |
| 32 | import org.junit.Before; |
| 33 | import org.junit.Test; |
| 34 | import org.junit.runner.RunWith; |
| 35 | |
Adrian Roos | e18033c | 2017-01-17 15:22:49 -0800 | [diff] [blame] | 36 | @SmallTest |
| 37 | @RunWith(AndroidJUnit4.class) |
Jason Monk | fba8faf | 2017-05-23 10:42:59 -0400 | [diff] [blame] | 38 | public class NotificationContentViewTest extends SysuiTestCase { |
Adrian Roos | e18033c | 2017-01-17 15:22:49 -0800 | [diff] [blame] | 39 | |
| 40 | NotificationContentView mView; |
Adrian Roos | e18033c | 2017-01-17 15:22:49 -0800 | [diff] [blame] | 41 | |
| 42 | @Before |
Selim Cinek | f868efe | 2017-02-01 11:43:18 -0800 | [diff] [blame] | 43 | @UiThreadTest |
Adrian Roos | e18033c | 2017-01-17 15:22:49 -0800 | [diff] [blame] | 44 | public void setup() { |
Adrian Roos | e18033c | 2017-01-17 15:22:49 -0800 | [diff] [blame] | 45 | mView = new NotificationContentView(mContext, null); |
Selim Cinek | f868efe | 2017-02-01 11:43:18 -0800 | [diff] [blame] | 46 | ExpandableNotificationRow row = new ExpandableNotificationRow(mContext, null); |
| 47 | ExpandableNotificationRow mockRow = spy(row); |
| 48 | doNothing().when(mockRow).updateBackgroundAlpha(anyFloat()); |
| 49 | doReturn(10).when(mockRow).getIntrinsicHeight(); |
| 50 | |
| 51 | mView.setContainingNotification(mockRow); |
Adrian Roos | e18033c | 2017-01-17 15:22:49 -0800 | [diff] [blame] | 52 | mView.setHeights(10, 20, 30, 40); |
| 53 | |
| 54 | mView.setContractedChild(createViewWithHeight(10)); |
| 55 | mView.setExpandedChild(createViewWithHeight(20)); |
| 56 | mView.setHeadsUpChild(createViewWithHeight(30)); |
| 57 | mView.setAmbientChild(createViewWithHeight(40)); |
| 58 | |
| 59 | mView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); |
| 60 | mView.layout(0, 0, mView.getMeasuredWidth(), mView.getMeasuredHeight()); |
| 61 | } |
| 62 | |
| 63 | private View createViewWithHeight(int height) { |
| 64 | View view = new View(mContext, null); |
| 65 | view.setMinimumHeight(height); |
| 66 | return view; |
| 67 | } |
| 68 | |
| 69 | @Test |
| 70 | @UiThreadTest |
| 71 | public void animationStartType_getsClearedAfterUpdatingVisibilitiesWithoutAnimation() { |
| 72 | mView.setHeadsUp(true); |
| 73 | mView.setDark(true, false, 0); |
| 74 | mView.setDark(false, true, 0); |
| 75 | mView.setHeadsUpAnimatingAway(true); |
| 76 | Assert.assertFalse(mView.isAnimatingVisibleType()); |
| 77 | } |
| 78 | } |