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