blob: 651d2b7af7db3f6fc1f8e3fddf07c4a93f1299e6 [file] [log] [blame]
Bill Lin32ed3d62018-10-02 18:10:09 +08001/*
2 * Copyright (C) 2018 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.power;
18
19import static com.google.common.truth.Truth.assertThat;
20
21import static org.mockito.Mockito.spy;
22import static org.mockito.Mockito.verify;
23
24import android.test.suitebuilder.annotation.SmallTest;
25import android.testing.AndroidTestingRunner;
26import android.testing.TestableLooper.RunWithLooper;
27
28import com.android.systemui.SysuiTestCase;
29
30import org.junit.After;
31import org.junit.Before;
32import org.junit.Test;
33import org.junit.runner.RunWith;
34
35@RunWith(AndroidTestingRunner.class)
36@RunWithLooper
37@SmallTest
38public class OverheatAlarmControllerTest extends SysuiTestCase{
39 OverheatAlarmController mOverheatAlarmController;
40 OverheatAlarmController mSpyOverheatAlarmController;
41
42 @Before
43 public void setUp() {
44 mOverheatAlarmController = OverheatAlarmController.getInstance(mContext);
45 mSpyOverheatAlarmController = spy(mOverheatAlarmController);
46 }
47
48 @After
49 public void tearDown() {
50 mSpyOverheatAlarmController.stopAlarm();
51 }
52
53 @Test
54 public void testGetInstance() {
55 assertThat(mOverheatAlarmController).isNotNull();
56 }
57
58 @Test
59 public void testStartAlarm_PlaySound() {
60 mSpyOverheatAlarmController.startAlarm(mContext);
61 verify(mSpyOverheatAlarmController).playSound(mContext);
62 }
63
64 @Test
65 public void testStartAlarm_InitVibrate() {
66 mSpyOverheatAlarmController.startAlarm(mContext);
67 verify(mSpyOverheatAlarmController).startVibrate();
68 }
69
70 @Test
71 public void testStartAlarm_StartVibrate() {
72 mSpyOverheatAlarmController.startAlarm(mContext);
73 verify(mSpyOverheatAlarmController).performVibrate();
74 }
75
76 @Test
77 public void testStopAlarm_StopPlayer() {
78 mSpyOverheatAlarmController.stopAlarm();
79 verify(mSpyOverheatAlarmController).stopPlayer();
80 }
81
82 @Test
83 public void testStopAlarm_StopVibrate() {
84 mSpyOverheatAlarmController.stopAlarm();
85 verify(mSpyOverheatAlarmController).stopVibrate();
86 }
87}