1/*
2 * Copyright (C) 2018 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 static junit.framework.Assert.assertEquals;
20import static junit.framework.Assert.assertFalse;
21import static junit.framework.Assert.assertNotNull;
22import static junit.framework.Assert.assertNull;
23import static junit.framework.Assert.assertTrue;
24
25import static org.mockito.ArgumentMatchers.any;
26import static org.mockito.ArgumentMatchers.eq;
27import static org.mockito.Mockito.doReturn;
28import static org.mockito.Mockito.mock;
29import static org.mockito.Mockito.spy;
30
31import android.support.test.filters.SmallTest;
32import android.support.test.runner.AndroidJUnit4;
33import android.view.LayoutInflater;
34import android.view.View;
35
36import com.android.systemui.R;
37import com.android.systemui.SysuiTestCase;
38
39import org.junit.Before;
40import org.junit.Test;
41import org.junit.runner.RunWith;
42
43@SmallTest
44@RunWith(AndroidJUnit4.class)
45public class FooterViewTest extends SysuiTestCase {
46
47    FooterView mView;
48
49    @Before
50    public void setUp() {
51        mView = (FooterView) LayoutInflater.from(mContext).inflate(
52                R.layout.status_bar_notification_footer, null, false);
53        mView.setDuration(0);
54    }
55
56    @Test
57    public void testViewsNotNull() {
58        assertNotNull(mView.findContentView());
59        assertNotNull(mView.findSecondaryView());
60    }
61
62    @Test
63    public void setDismissOnClick() {
64        mView.setDismissButtonClickListener(mock(View.OnClickListener.class));
65        assertTrue(mView.findSecondaryView().hasOnClickListeners());
66    }
67
68    @Test
69    public void setManageOnClick() {
70        mView.setManageButtonClickListener(mock(View.OnClickListener.class));
71        assertTrue(mView.findViewById(R.id.manage_text).hasOnClickListeners());
72    }
73
74    @Test
75    public void testPerformVisibilityAnimation() {
76        mView.setVisible(false /* visible */, false /* animate */);
77        assertFalse(mView.isVisible());
78
79        mView.setVisible(true /* visible */, true /* animate */);
80    }
81
82    @Test
83    public void testPerformSecondaryVisibilityAnimation() {
84        mView.setSecondaryVisible(false /* visible */, false /* animate */);
85        assertFalse(mView.isSecondaryVisible());
86
87        mView.setSecondaryVisible(true /* visible */, true /* animate */);
88    }
89}
90
91