blob: 436849c9d700ae9ffde11eb8762ae4d88b4350d1 [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
Selim Cinekf868efe2017-02-01 11:43:18 -080019import static org.mockito.ArgumentMatchers.anyFloat;
20import static org.mockito.Mockito.doNothing;
21import static org.mockito.Mockito.doReturn;
22import static org.mockito.Mockito.spy;
23
Jason Monkc429f692017-06-27 13:13:49 -040024import android.support.test.annotation.UiThreadTest;
25import android.support.test.filters.SmallTest;
26import android.support.test.runner.AndroidJUnit4;
27import android.view.View;
28
Jason Monkfba8faf2017-05-23 10:42:59 -040029import com.android.systemui.SysuiTestCase;
30
Jason Monkc429f692017-06-27 13:13:49 -040031import org.junit.Assert;
32import org.junit.Before;
33import org.junit.Test;
34import org.junit.runner.RunWith;
35
Adrian Roose18033c2017-01-17 15:22:49 -080036@SmallTest
37@RunWith(AndroidJUnit4.class)
Jason Monkfba8faf2017-05-23 10:42:59 -040038public class NotificationContentViewTest extends SysuiTestCase {
Adrian Roose18033c2017-01-17 15:22:49 -080039
40 NotificationContentView mView;
Adrian Roose18033c2017-01-17 15:22:49 -080041
42 @Before
Selim Cinekf868efe2017-02-01 11:43:18 -080043 @UiThreadTest
Adrian Roose18033c2017-01-17 15:22:49 -080044 public void setup() {
Adrian Roose18033c2017-01-17 15:22:49 -080045 mView = new NotificationContentView(mContext, null);
Selim Cinekf868efe2017-02-01 11:43:18 -080046 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 Roose18033c2017-01-17 15:22:49 -080052 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}