blob: debc840394b5e8a1c16153ba777ea03798b70f47 [file] [log] [blame]
Adrian Roos5753f052016-07-13 10:30:37 -07001/*
2 * Copyright (C) 2016 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
Geoffrey Pitschfc2b64e2016-09-02 09:05:25 -040017package com.android.systemui.statusbar.phone;
Adrian Roos5753f052016-07-13 10:30:37 -070018
Brett Chabot84151d92019-02-27 15:37:59 -080019import static org.mockito.ArgumentMatchers.eq;
Brett Chabot84151d92019-02-27 15:37:59 -080020import static org.mockito.Mockito.reset;
21import static org.mockito.Mockito.verify;
22
Dave Mankoff2aff6c32019-10-14 17:40:37 -040023import android.content.res.Resources;
24import android.hardware.display.AmbientDisplayConfiguration;
Lucas Dupin16cfe452018-02-08 13:14:50 -080025import android.os.PowerManager;
Adrian Roos5753f052016-07-13 10:30:37 -070026import android.test.suitebuilder.annotation.SmallTest;
Jason Monkfba8faf2017-05-23 10:42:59 -040027
Brett Chabot84151d92019-02-27 15:37:59 -080028import androidx.test.runner.AndroidJUnit4;
29
Jason Monkfba8faf2017-05-23 10:42:59 -040030import com.android.systemui.SysuiTestCase;
Dave Mankoff2aff6c32019-10-14 17:40:37 -040031import com.android.systemui.doze.AlwaysOnDisplayPolicy;
Lucas Dupincbe05962018-04-26 16:44:05 -070032import com.android.systemui.doze.DozeScreenState;
Dave Mankoff2aff6c32019-10-14 17:40:37 -040033import com.android.systemui.tuner.TunerService;
Lucas Dupin16cfe452018-02-08 13:14:50 -080034
35import org.junit.Assert;
Dave Mankoff2aff6c32019-10-14 17:40:37 -040036import org.junit.Before;
Geoffrey Pitsch2c403db2016-08-26 09:09:39 -040037import org.junit.Test;
38import org.junit.runner.RunWith;
Dave Mankoff2aff6c32019-10-14 17:40:37 -040039import org.mockito.Mock;
40import org.mockito.MockitoAnnotations;
Geoffrey Pitsch2c403db2016-08-26 09:09:39 -040041
Adrian Roos5753f052016-07-13 10:30:37 -070042@SmallTest
Geoffrey Pitsch2c403db2016-08-26 09:09:39 -040043@RunWith(AndroidJUnit4.class)
Jason Monkfba8faf2017-05-23 10:42:59 -040044public class DozeParametersTest extends SysuiTestCase {
Adrian Roos5753f052016-07-13 10:30:37 -070045
Dave Mankoff2aff6c32019-10-14 17:40:37 -040046 private DozeParameters mDozeParameters;
47
48 @Mock Resources mResources;
49 @Mock private AmbientDisplayConfiguration mAmbientDisplayConfiguration;
50 @Mock private AlwaysOnDisplayPolicy mAlwaysOnDisplayPolicy;
51 @Mock private PowerManager mPowerManager;
52 @Mock private TunerService mTunerService;
53
54 @Before
55 public void setup() {
56 MockitoAnnotations.initMocks(this);
57 mDozeParameters = new DozeParameters(
58 mResources,
59 mAmbientDisplayConfiguration,
60 mAlwaysOnDisplayPolicy,
61 mPowerManager,
62 mTunerService
63 );
64 }
Geoffrey Pitsch2c403db2016-08-26 09:09:39 -040065 @Test
Lucas Dupin16cfe452018-02-08 13:14:50 -080066 public void test_setControlScreenOffAnimation_setsDozeAfterScreenOff_false() {
Dave Mankoff2aff6c32019-10-14 17:40:37 -040067 mDozeParameters.setControlScreenOffAnimation(true);
68 reset(mPowerManager);
69 mDozeParameters.setControlScreenOffAnimation(false);
70 verify(mPowerManager).setDozeAfterScreenOff(eq(true));
Lucas Dupin16cfe452018-02-08 13:14:50 -080071 }
72
73 @Test
74 public void test_setControlScreenOffAnimation_setsDozeAfterScreenOff_true() {
Dave Mankoff2aff6c32019-10-14 17:40:37 -040075 mDozeParameters.setControlScreenOffAnimation(false);
76 reset(mPowerManager);
77 mDozeParameters.setControlScreenOffAnimation(true);
78 verify(mPowerManager).setDozeAfterScreenOff(eq(false));
Lucas Dupin16cfe452018-02-08 13:14:50 -080079 }
80
Lucas Dupincbe05962018-04-26 16:44:05 -070081 @Test
82 public void test_getWallpaperAodDuration_when_shouldControlScreenOff() {
Dave Mankoff2aff6c32019-10-14 17:40:37 -040083 mDozeParameters.setControlScreenOffAnimation(true);
84 Assert.assertEquals(
85 "wallpaper hides faster when controlling screen off",
86 mDozeParameters.getWallpaperAodDuration(),
Lucas Dupincbe05962018-04-26 16:44:05 -070087 DozeScreenState.ENTER_DOZE_HIDE_WALLPAPER_DELAY);
88 }
Geoffrey Pitsch2c403db2016-08-26 09:09:39 -040089}