blob: fecf90181fa24d4378f45090b61aea5f28f0074b [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;
Geoffrey Pitsch70950de2017-05-23 17:13:38 -040022import android.support.test.filters.FlakyTest;
Adrian Roose18033c2017-01-17 15:22:49 -080023import android.support.test.filters.SmallTest;
24import android.support.test.runner.AndroidJUnit4;
25import android.view.View;
26
27import org.junit.Assert;
28import org.junit.Before;
Geoffrey Pitsch351a3212017-05-22 15:20:20 -040029import org.junit.Ignore;
Adrian Roose18033c2017-01-17 15:22:49 -080030import org.junit.Test;
31import org.junit.runner.RunWith;
32
Selim Cinekf868efe2017-02-01 11:43:18 -080033import static org.mockito.ArgumentMatchers.anyFloat;
34import static org.mockito.Mockito.doNothing;
35import static org.mockito.Mockito.doReturn;
36import static org.mockito.Mockito.spy;
37
Adrian Roose18033c2017-01-17 15:22:49 -080038@SmallTest
39@RunWith(AndroidJUnit4.class)
Geoffrey Pitsch70950de2017-05-23 17:13:38 -040040@FlakyTest
Adrian Roose18033c2017-01-17 15:22:49 -080041public class NotificationContentViewTest {
42
43 NotificationContentView mView;
44 Context mContext;
45
46 @Before
Selim Cinekf868efe2017-02-01 11:43:18 -080047 @UiThreadTest
Adrian Roose18033c2017-01-17 15:22:49 -080048 public void setup() {
Adrian Roose18033c2017-01-17 15:22:49 -080049 mContext = InstrumentationRegistry.getTargetContext();
50 mView = new NotificationContentView(mContext, null);
Selim Cinekf868efe2017-02-01 11:43:18 -080051 ExpandableNotificationRow row = new ExpandableNotificationRow(mContext, null);
52 ExpandableNotificationRow mockRow = spy(row);
53 doNothing().when(mockRow).updateBackgroundAlpha(anyFloat());
54 doReturn(10).when(mockRow).getIntrinsicHeight();
55
56 mView.setContainingNotification(mockRow);
Adrian Roose18033c2017-01-17 15:22:49 -080057 mView.setHeights(10, 20, 30, 40);
58
59 mView.setContractedChild(createViewWithHeight(10));
60 mView.setExpandedChild(createViewWithHeight(20));
61 mView.setHeadsUpChild(createViewWithHeight(30));
62 mView.setAmbientChild(createViewWithHeight(40));
63
64 mView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
65 mView.layout(0, 0, mView.getMeasuredWidth(), mView.getMeasuredHeight());
66 }
67
68 private View createViewWithHeight(int height) {
69 View view = new View(mContext, null);
70 view.setMinimumHeight(height);
71 return view;
72 }
73
74 @Test
75 @UiThreadTest
76 public void animationStartType_getsClearedAfterUpdatingVisibilitiesWithoutAnimation() {
77 mView.setHeadsUp(true);
78 mView.setDark(true, false, 0);
79 mView.setDark(false, true, 0);
80 mView.setHeadsUpAnimatingAway(true);
81 Assert.assertFalse(mView.isAnimatingVisibleType());
82 }
83}