Jason Monk | c2beef5 | 2017-08-29 18:58:00 -0400 | [diff] [blame] | 1 | /* |
| 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 | |
| 15 | package com.android.systemui.statusbar.phone; |
| 16 | |
| 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; |
| 23 | |
Jason Monk | c2beef5 | 2017-08-29 18:58:00 -0400 | [diff] [blame] | 24 | import android.testing.AndroidTestingRunner; |
| 25 | import android.testing.TestableLooper.RunWithLooper; |
Jason Monk | 2044e6e | 2017-10-13 10:34:40 -0400 | [diff] [blame] | 26 | import android.view.IWindowManager; |
Jason Monk | c2beef5 | 2017-08-29 18:58:00 -0400 | [diff] [blame] | 27 | |
Brett Chabot | 84151d9 | 2019-02-27 15:37:59 -0800 | [diff] [blame] | 28 | import androidx.test.filters.SmallTest; |
| 29 | |
Jason Monk | c2beef5 | 2017-08-29 18:58:00 -0400 | [diff] [blame] | 30 | import com.android.systemui.SysuiTestCase; |
| 31 | import com.android.systemui.statusbar.CommandQueue; |
| 32 | |
| 33 | import org.junit.Before; |
| 34 | import org.junit.Test; |
| 35 | import org.junit.runner.RunWith; |
| 36 | |
| 37 | @RunWith(AndroidTestingRunner.class) |
| 38 | @RunWithLooper |
| 39 | @SmallTest |
| 40 | public class NavigationBarTransitionsTest extends SysuiTestCase { |
| 41 | |
| 42 | private NavigationBarTransitions mTransitions; |
| 43 | |
| 44 | @Before |
| 45 | public void setup() { |
Jason Monk | 2044e6e | 2017-10-13 10:34:40 -0400 | [diff] [blame] | 46 | mDependency.injectMockDependency(IWindowManager.class); |
Jason Monk | c2beef5 | 2017-08-29 18:58:00 -0400 | [diff] [blame] | 47 | 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 Monk | c2beef5 | 2017-08-29 18:58:00 -0400 | [diff] [blame] | 71 | } |