Home | History | Annotate | Download | only in phone
      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 
     24 import android.support.test.filters.SmallTest;
     25 import android.testing.AndroidTestingRunner;
     26 import android.testing.TestableLooper.RunWithLooper;
     27 import android.view.IWindowManager;
     28 
     29 import com.android.systemui.SysuiTestCase;
     30 import com.android.systemui.statusbar.CommandQueue;
     31 
     32 import org.junit.Before;
     33 import org.junit.Test;
     34 import org.junit.runner.RunWith;
     35 
     36 @RunWith(AndroidTestingRunner.class)
     37 @RunWithLooper
     38 @SmallTest
     39 public class NavigationBarTransitionsTest extends SysuiTestCase {
     40 
     41     private NavigationBarTransitions mTransitions;
     42 
     43     @Before
     44     public void setup() {
     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);
     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     }
     70 
     71 }