blob: 40d5415a9a471a01b038b02411760870b110fded [file] [log] [blame]
Jason Monkc2beef52017-08-29 18:58:00 -04001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5 * except in compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the
10 * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11 * KIND, either express or implied. See the License for the specific language governing
12 * permissions and limitations under the License.
13 */
14
15package com.android.systemui.statusbar.phone;
16
17import static org.junit.Assert.assertFalse;
18import static org.junit.Assert.assertTrue;
19import static org.mockito.ArgumentMatchers.anyInt;
20import static org.mockito.Mockito.mock;
21import static org.mockito.Mockito.spy;
22import static org.mockito.Mockito.when;
23
24import android.support.test.filters.SmallTest;
25import android.testing.AndroidTestingRunner;
26import android.testing.TestableLooper.RunWithLooper;
Jason Monk2044e6e2017-10-13 10:34:40 -040027import android.view.IWindowManager;
Jason Monkc2beef52017-08-29 18:58:00 -040028
29import com.android.systemui.SysuiTestCase;
30import com.android.systemui.statusbar.CommandQueue;
31
32import org.junit.Before;
33import org.junit.Test;
34import org.junit.runner.RunWith;
35
36@RunWith(AndroidTestingRunner.class)
37@RunWithLooper
38@SmallTest
39public class NavigationBarTransitionsTest extends SysuiTestCase {
40
41 private NavigationBarTransitions mTransitions;
42
43 @Before
44 public void setup() {
Jason Monk2044e6e2017-10-13 10:34:40 -040045 mDependency.injectMockDependency(IWindowManager.class);
Jason Monkc2beef52017-08-29 18:58:00 -040046 mContext.putComponent(CommandQueue.class, mock(CommandQueue.class));
47 NavigationBarView navBar = spy(new NavigationBarView(mContext, null));
48 when(navBar.getCurrentView()).thenReturn(navBar);
49 when(navBar.findViewById(anyInt())).thenReturn(navBar);
50 mTransitions = new NavigationBarTransitions(navBar);
51 }
52
53 @Test
54 public void setIsLightsOut_NoAutoDim() {
55 mTransitions.setAutoDim(false);
56
57 assertFalse(mTransitions.isLightsOut(BarTransitions.MODE_OPAQUE));
58
59 assertTrue(mTransitions.isLightsOut(BarTransitions.MODE_LIGHTS_OUT));
60 }
61
62 @Test
63 public void setIsLightsOut_AutoDim() {
64 mTransitions.setAutoDim(true);
65
66 assertTrue(mTransitions.isLightsOut(BarTransitions.MODE_OPAQUE));
67
68 assertTrue(mTransitions.isLightsOut(BarTransitions.MODE_LIGHTS_OUT));
69 }
Jason Monkc2beef52017-08-29 18:58:00 -040070}