blob: 0bcc3afe027d8ca3139c9a167f1589c30fa0299a [file] [log] [blame]
Lucas Dupin51d24e02018-11-13 10:46:51 -08001/*
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
17package com.android.systemui.statusbar.phone;
18
19import static org.mockito.ArgumentMatchers.eq;
Lucas Dupin51d24e02018-11-13 10:46:51 -080020import static org.mockito.Mockito.reset;
21import static org.mockito.Mockito.times;
22import static org.mockito.Mockito.verify;
23
Lucas Dupin51d24e02018-11-13 10:46:51 -080024import android.testing.AndroidTestingRunner;
25import android.testing.TestableLooper;
26
Brett Chabot84151d92019-02-27 15:37:59 -080027import androidx.test.filters.SmallTest;
28
Lucas Dupin51d24e02018-11-13 10:46:51 -080029import com.android.systemui.SysuiTestCase;
Lucas Dupind236ee32019-10-08 15:33:59 -070030import com.android.systemui.plugins.statusbar.StatusBarStateController;
Lucas Dupin51d24e02018-11-13 10:46:51 -080031import com.android.systemui.statusbar.CommandQueue;
32import com.android.systemui.statusbar.phone.LightBarTransitionsController.DarkIntensityApplier;
Lucas Dupind236ee32019-10-08 15:33:59 -070033import com.android.systemui.statusbar.policy.KeyguardStateController;
Lucas Dupin51d24e02018-11-13 10:46:51 -080034
35import org.junit.Before;
36import org.junit.Test;
37import org.junit.runner.RunWith;
38import org.mockito.Mock;
39import org.mockito.MockitoAnnotations;
40
41@SmallTest
42@RunWith(AndroidTestingRunner.class)
43@TestableLooper.RunWithLooper
44public 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 Dupind236ee32019-10-08 15:33:59 -070053 mDependency.injectMockDependency(KeyguardStateController.class);
54 mDependency.injectMockDependency(StatusBarStateController.class);
Dave Mankoffbcaca8a2019-10-31 18:04:08 -040055 mLightBarTransitionsController = new LightBarTransitionsController(mContext, mApplier,
56 new CommandQueue(mContext));
Lucas Dupin51d24e02018-11-13 10:46:51 -080057 }
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}