blob: 0031c32a98463d051c52fdc6acdf0e0bdff6b85e [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
25import android.support.test.filters.SmallTest;
26import android.testing.AndroidTestingRunner;
27import android.testing.TestableLooper;
28
29import com.android.systemui.SysuiTestCase;
30import com.android.systemui.statusbar.CommandQueue;
31import com.android.systemui.statusbar.phone.LightBarTransitionsController.DarkIntensityApplier;
32
33import org.junit.Before;
34import org.junit.Test;
35import org.junit.runner.RunWith;
36import org.mockito.Mock;
37import org.mockito.MockitoAnnotations;
38
39@SmallTest
40@RunWith(AndroidTestingRunner.class)
41@TestableLooper.RunWithLooper
42public 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}