blob: bb109bd931deeb10c67756e8b8d7fd79237c322c [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
Jason Monkc2beef52017-08-29 18:58:00 -040024import android.testing.AndroidTestingRunner;
25import android.testing.TestableLooper.RunWithLooper;
Jason Monk2044e6e2017-10-13 10:34:40 -040026import android.view.IWindowManager;
Jason Monkc2beef52017-08-29 18:58:00 -040027
Brett Chabot84151d92019-02-27 15:37:59 -080028import androidx.test.filters.SmallTest;
29
Jason Monkc2beef52017-08-29 18:58:00 -040030import com.android.systemui.SysuiTestCase;
31import com.android.systemui.statusbar.CommandQueue;
32
33import org.junit.Before;
34import org.junit.Test;
35import org.junit.runner.RunWith;
36
37@RunWith(AndroidTestingRunner.class)
38@RunWithLooper
39@SmallTest
40public class NavigationBarTransitionsTest extends SysuiTestCase {
41
42 private NavigationBarTransitions mTransitions;
43
44 @Before
45 public void setup() {
Jason Monk2044e6e2017-10-13 10:34:40 -040046 mDependency.injectMockDependency(IWindowManager.class);
Jason Monkc2beef52017-08-29 18:58:00 -040047 mContext.putComponent(CommandQueue.class, mock(CommandQueue.class));
48 NavigationBarView navBar = spy(new NavigationBarView(mContext, null));
49 when(navBar.getCurrentView()).thenReturn(navBar);
50 when(navBar.findViewById(anyInt())).thenReturn(navBar);
51 mTransitions = new NavigationBarTransitions(navBar);
52 }
53
54 @Test
55 public void setIsLightsOut_NoAutoDim() {
56 mTransitions.setAutoDim(false);
57
58 assertFalse(mTransitions.isLightsOut(BarTransitions.MODE_OPAQUE));
59
60 assertTrue(mTransitions.isLightsOut(BarTransitions.MODE_LIGHTS_OUT));
61 }
62
63 @Test
64 public void setIsLightsOut_AutoDim() {
65 mTransitions.setAutoDim(true);
66
67 assertTrue(mTransitions.isLightsOut(BarTransitions.MODE_OPAQUE));
68
69 assertTrue(mTransitions.isLightsOut(BarTransitions.MODE_LIGHTS_OUT));
70 }
Jason Monkc2beef52017-08-29 18:58:00 -040071}