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