blob: 93fdce173f12eb842732a105b83334fa136f6df6 [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;
20import static org.mockito.Mockito.mock;
21import static org.mockito.Mockito.reset;
22import static org.mockito.Mockito.times;
23import static org.mockito.Mockito.verify;
24
Lucas Dupin51d24e02018-11-13 10:46:51 -080025import android.testing.AndroidTestingRunner;
26import android.testing.TestableLooper;
27
Brett Chabot84151d92019-02-27 15:37:59 -080028import androidx.test.filters.SmallTest;
29
Lucas Dupin51d24e02018-11-13 10:46:51 -080030import com.android.systemui.SysuiTestCase;
31import com.android.systemui.statusbar.CommandQueue;
32import com.android.systemui.statusbar.phone.LightBarTransitionsController.DarkIntensityApplier;
33
34import org.junit.Before;
35import org.junit.Test;
36import org.junit.runner.RunWith;
37import org.mockito.Mock;
38import org.mockito.MockitoAnnotations;
39
40@SmallTest
41@RunWith(AndroidTestingRunner.class)
42@TestableLooper.RunWithLooper
43public class LightBarTransitionsControllerTest extends SysuiTestCase {
44
45 @Mock
46 private DarkIntensityApplier mApplier;
47 private LightBarTransitionsController mLightBarTransitionsController;
48
49 @Before
50 public void setup() {
51 MockitoAnnotations.initMocks(this);
52 mContext.putComponent(CommandQueue.class, mock(CommandQueue.class));
53 mLightBarTransitionsController = new LightBarTransitionsController(mContext, mApplier);
54 }
55
56 @Test
57 public void setIconsDark_lightAndDark() {
58 mLightBarTransitionsController.setIconsDark(true /* dark */, false /* animate */);
59 verify(mApplier).applyDarkIntensity(eq(1f));
60
61 mLightBarTransitionsController.setIconsDark(false /* dark */, false /* animate */);
62 verify(mApplier).applyDarkIntensity(eq(0f));
63 }
64
65 @Test
66 public void onDozeAmountChanged_lightWhenDozing() {
67 mLightBarTransitionsController.onDozeAmountChanged(1f /* linear */, 1f /* eased */);
68 mLightBarTransitionsController.setIconsDark(true /* dark */, false /* animate */);
69 verify(mApplier, times(2)).applyDarkIntensity(eq(0f));
70
71 reset(mApplier);
72 mLightBarTransitionsController.setIconsDark(false /* dark */, false /* animate */);
73 verify(mApplier).applyDarkIntensity(eq(0f));
74 }
75
76}