2 * Copyright (C) 2017 The Android Open Source Project
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
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
15 package com.android.systemui.statusbar.phone;
17 import static org.junit.Assert.assertFalse;
18 import static org.junit.Assert.assertTrue;
19 import static org.mockito.ArgumentMatchers.anyInt;
20 import static org.mockito.Mockito.mock;
21 import static org.mockito.Mockito.spy;
22 import static org.mockito.Mockito.when;
24 import android.support.test.filters.SmallTest;
25 import android.testing.AndroidTestingRunner;
26 import android.testing.TestableLooper.RunWithLooper;
27 import android.view.IWindowManager;
29 import com.android.systemui.SysuiTestCase;
30 import com.android.systemui.statusbar.CommandQueue;
32 import org.junit.Before;
33 import org.junit.Test;
34 import org.junit.runner.RunWith;
36 @RunWith(AndroidTestingRunner.class)
39 public class NavigationBarTransitionsTest extends SysuiTestCase {
41 private NavigationBarTransitions mTransitions;
45 mDependency.injectMockDependency(IWindowManager.class);
46 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);
54 public void setIsLightsOut_NoAutoDim() {
55 mTransitions.setAutoDim(false);
57 assertFalse(mTransitions.isLightsOut(BarTransitions.MODE_OPAQUE));
59 assertTrue(mTransitions.isLightsOut(BarTransitions.MODE_LIGHTS_OUT));
63 public void setIsLightsOut_AutoDim() {
64 mTransitions.setAutoDim(true);
66 assertTrue(mTransitions.isLightsOut(BarTransitions.MODE_OPAQUE));
68 assertTrue(mTransitions.isLightsOut(BarTransitions.MODE_LIGHTS_OUT));