Lucas Dupin | 51d24e0 | 2018-11-13 10:46:51 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.systemui.statusbar.phone; |
| 18 | |
| 19 | import static org.mockito.ArgumentMatchers.eq; |
| 20 | import static org.mockito.Mockito.mock; |
| 21 | import static org.mockito.Mockito.reset; |
| 22 | import static org.mockito.Mockito.times; |
| 23 | import static org.mockito.Mockito.verify; |
| 24 | |
| 25 | import android.support.test.filters.SmallTest; |
| 26 | import android.testing.AndroidTestingRunner; |
| 27 | import android.testing.TestableLooper; |
| 28 | |
| 29 | import com.android.systemui.SysuiTestCase; |
| 30 | import com.android.systemui.statusbar.CommandQueue; |
| 31 | import com.android.systemui.statusbar.phone.LightBarTransitionsController.DarkIntensityApplier; |
| 32 | |
| 33 | import org.junit.Before; |
| 34 | import org.junit.Test; |
| 35 | import org.junit.runner.RunWith; |
| 36 | import org.mockito.Mock; |
| 37 | import org.mockito.MockitoAnnotations; |
| 38 | |
| 39 | @SmallTest |
| 40 | @RunWith(AndroidTestingRunner.class) |
| 41 | @TestableLooper.RunWithLooper |
| 42 | public class LightBarTransitionsControllerTest extends SysuiTestCase { |
| 43 | |
| 44 | @Mock |
| 45 | private DarkIntensityApplier mApplier; |
| 46 | private LightBarTransitionsController mLightBarTransitionsController; |
| 47 | |
| 48 | @Before |
| 49 | public void setup() { |
| 50 | MockitoAnnotations.initMocks(this); |
| 51 | mContext.putComponent(CommandQueue.class, mock(CommandQueue.class)); |
| 52 | mLightBarTransitionsController = new LightBarTransitionsController(mContext, mApplier); |
| 53 | } |
| 54 | |
| 55 | @Test |
| 56 | public void setIconsDark_lightAndDark() { |
| 57 | mLightBarTransitionsController.setIconsDark(true /* dark */, false /* animate */); |
| 58 | verify(mApplier).applyDarkIntensity(eq(1f)); |
| 59 | |
| 60 | mLightBarTransitionsController.setIconsDark(false /* dark */, false /* animate */); |
| 61 | verify(mApplier).applyDarkIntensity(eq(0f)); |
| 62 | } |
| 63 | |
| 64 | @Test |
| 65 | public void onDozeAmountChanged_lightWhenDozing() { |
| 66 | mLightBarTransitionsController.onDozeAmountChanged(1f /* linear */, 1f /* eased */); |
| 67 | mLightBarTransitionsController.setIconsDark(true /* dark */, false /* animate */); |
| 68 | verify(mApplier, times(2)).applyDarkIntensity(eq(0f)); |
| 69 | |
| 70 | reset(mApplier); |
| 71 | mLightBarTransitionsController.setIconsDark(false /* dark */, false /* animate */); |
| 72 | verify(mApplier).applyDarkIntensity(eq(0f)); |
| 73 | } |
| 74 | |
| 75 | } |