blob: 77f96b8a7b19d455bc69ce7a41462c2287868024 [file] [log] [blame]
Adrian Roose18033c2017-01-17 15:22:49 -08001/*
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
17package com.android.systemui.statusbar;
18
Adrian Roose18033c2017-01-17 15:22:49 -080019import android.content.Context;
20import android.support.test.InstrumentationRegistry;
21import android.support.test.annotation.UiThreadTest;
22import android.support.test.filters.SmallTest;
23import android.support.test.runner.AndroidJUnit4;
24import android.view.View;
25
26import org.junit.Assert;
27import org.junit.Before;
28import org.junit.Test;
29import org.junit.runner.RunWith;
30
Selim Cinekf868efe2017-02-01 11:43:18 -080031import static org.mockito.ArgumentMatchers.anyFloat;
32import static org.mockito.Mockito.doNothing;
33import static org.mockito.Mockito.doReturn;
34import static org.mockito.Mockito.spy;
35
Adrian Roose18033c2017-01-17 15:22:49 -080036@SmallTest
37@RunWith(AndroidJUnit4.class)
38public class NotificationContentViewTest {
39
40 NotificationContentView mView;
41 Context mContext;
42
43 @Before
Selim Cinekf868efe2017-02-01 11:43:18 -080044 @UiThreadTest
Adrian Roose18033c2017-01-17 15:22:49 -080045 public void setup() {
Adrian Roose18033c2017-01-17 15:22:49 -080046 mContext = InstrumentationRegistry.getTargetContext();
47 mView = new NotificationContentView(mContext, null);
Selim Cinekf868efe2017-02-01 11:43:18 -080048 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 Roose18033c2017-01-17 15:22:49 -080054 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}