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; |
Lucas Dupin | 51d24e0 | 2018-11-13 10:46:51 -0800 | [diff] [blame] | 20 | import static org.mockito.Mockito.reset; |
| 21 | import static org.mockito.Mockito.times; |
| 22 | import static org.mockito.Mockito.verify; |
| 23 | |
Lucas Dupin | 51d24e0 | 2018-11-13 10:46:51 -0800 | [diff] [blame] | 24 | import android.testing.AndroidTestingRunner; |
| 25 | import android.testing.TestableLooper; |
| 26 | |
Brett Chabot | 84151d9 | 2019-02-27 15:37:59 -0800 | [diff] [blame] | 27 | import androidx.test.filters.SmallTest; |
| 28 | |
Lucas Dupin | 51d24e0 | 2018-11-13 10:46:51 -0800 | [diff] [blame] | 29 | import com.android.systemui.SysuiTestCase; |
Lucas Dupin | d236ee3 | 2019-10-08 15:33:59 -0700 | [diff] [blame] | 30 | import com.android.systemui.plugins.statusbar.StatusBarStateController; |
Lucas Dupin | 51d24e0 | 2018-11-13 10:46:51 -0800 | [diff] [blame] | 31 | import com.android.systemui.statusbar.CommandQueue; |
| 32 | import com.android.systemui.statusbar.phone.LightBarTransitionsController.DarkIntensityApplier; |
Lucas Dupin | d236ee3 | 2019-10-08 15:33:59 -0700 | [diff] [blame] | 33 | import com.android.systemui.statusbar.policy.KeyguardStateController; |
Lucas Dupin | 51d24e0 | 2018-11-13 10:46:51 -0800 | [diff] [blame] | 34 | |
| 35 | import org.junit.Before; |
| 36 | import org.junit.Test; |
| 37 | import org.junit.runner.RunWith; |
| 38 | import org.mockito.Mock; |
| 39 | import org.mockito.MockitoAnnotations; |
| 40 | |
| 41 | @SmallTest |
| 42 | @RunWith(AndroidTestingRunner.class) |
| 43 | @TestableLooper.RunWithLooper |
| 44 | public class LightBarTransitionsControllerTest extends SysuiTestCase { |
| 45 | |
| 46 | @Mock |
| 47 | private DarkIntensityApplier mApplier; |
| 48 | private LightBarTransitionsController mLightBarTransitionsController; |
| 49 | |
| 50 | @Before |
| 51 | public void setup() { |
| 52 | MockitoAnnotations.initMocks(this); |
Lucas Dupin | d236ee3 | 2019-10-08 15:33:59 -0700 | [diff] [blame] | 53 | mDependency.injectMockDependency(KeyguardStateController.class); |
| 54 | mDependency.injectMockDependency(StatusBarStateController.class); |
Dave Mankoff | bcaca8a | 2019-10-31 18:04:08 -0400 | [diff] [blame] | 55 | mLightBarTransitionsController = new LightBarTransitionsController(mContext, mApplier, |
| 56 | new CommandQueue(mContext)); |
Lucas Dupin | 51d24e0 | 2018-11-13 10:46:51 -0800 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | @Test |
| 60 | public void setIconsDark_lightAndDark() { |
| 61 | mLightBarTransitionsController.setIconsDark(true /* dark */, false /* animate */); |
| 62 | verify(mApplier).applyDarkIntensity(eq(1f)); |
| 63 | |
| 64 | mLightBarTransitionsController.setIconsDark(false /* dark */, false /* animate */); |
| 65 | verify(mApplier).applyDarkIntensity(eq(0f)); |
| 66 | } |
| 67 | |
| 68 | @Test |
| 69 | public void onDozeAmountChanged_lightWhenDozing() { |
| 70 | mLightBarTransitionsController.onDozeAmountChanged(1f /* linear */, 1f /* eased */); |
| 71 | mLightBarTransitionsController.setIconsDark(true /* dark */, false /* animate */); |
| 72 | verify(mApplier, times(2)).applyDarkIntensity(eq(0f)); |
| 73 | |
| 74 | reset(mApplier); |
| 75 | mLightBarTransitionsController.setIconsDark(false /* dark */, false /* animate */); |
| 76 | verify(mApplier).applyDarkIntensity(eq(0f)); |
| 77 | } |
| 78 | |
| 79 | } |