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 | |
| 19 | import static org.mockito.Mockito.mock; |
| 20 | import static org.mockito.Mockito.when; |
| 21 | |
| 22 | import android.content.Context; |
| 23 | import android.support.test.InstrumentationRegistry; |
| 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 | |
| 29 | import org.junit.Assert; |
| 30 | import org.junit.Before; |
| 31 | import org.junit.Test; |
| 32 | import org.junit.runner.RunWith; |
| 33 | |
| 34 | @SmallTest |
| 35 | @RunWith(AndroidJUnit4.class) |
| 36 | public class NotificationContentViewTest { |
| 37 | |
| 38 | NotificationContentView mView; |
| 39 | Context mContext; |
| 40 | |
| 41 | @Before |
| 42 | public void setup() { |
| 43 | ExpandableNotificationRow rowMock = mock(ExpandableNotificationRow.class); |
| 44 | when(rowMock.getIntrinsicHeight()).thenReturn(10); |
| 45 | |
| 46 | mContext = InstrumentationRegistry.getTargetContext(); |
| 47 | mView = new NotificationContentView(mContext, null); |
| 48 | mView.setContainingNotification(rowMock); |
| 49 | mView.setHeights(10, 20, 30, 40); |
| 50 | |
| 51 | mView.setContractedChild(createViewWithHeight(10)); |
| 52 | mView.setExpandedChild(createViewWithHeight(20)); |
| 53 | mView.setHeadsUpChild(createViewWithHeight(30)); |
| 54 | mView.setAmbientChild(createViewWithHeight(40)); |
| 55 | |
| 56 | mView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); |
| 57 | mView.layout(0, 0, mView.getMeasuredWidth(), mView.getMeasuredHeight()); |
| 58 | } |
| 59 | |
| 60 | private View createViewWithHeight(int height) { |
| 61 | View view = new View(mContext, null); |
| 62 | view.setMinimumHeight(height); |
| 63 | return view; |
| 64 | } |
| 65 | |
| 66 | @Test |
| 67 | @UiThreadTest |
| 68 | public void animationStartType_getsClearedAfterUpdatingVisibilitiesWithoutAnimation() { |
| 69 | mView.setHeadsUp(true); |
| 70 | mView.setDark(true, false, 0); |
| 71 | mView.setDark(false, true, 0); |
| 72 | mView.setHeadsUpAnimatingAway(true); |
| 73 | Assert.assertFalse(mView.isAnimatingVisibleType()); |
| 74 | } |
| 75 | } |