blob: 75f97a2efa8f1114ef204ce70b71488077dcfaa9 [file] [log] [blame]
Adrian Roosff2c4562016-11-03 12:13:36 -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
17package com.android.systemui.doze;
18
Adrian Roos2981eb02017-05-26 18:40:09 -070019import android.os.PowerManager;
Adrian Roosff2c4562016-11-03 12:13:36 -070020import android.view.Display;
21
Adrian Roos5502b892017-08-22 15:42:12 +020022/**
23 * Fake implementation of {@link DozeMachine.Service} for tests.
24 *
25 * Useful instead of mocking because it allows verifying state instead of interactions.
26 */
Adrian Roosff2c4562016-11-03 12:13:36 -070027public class DozeServiceFake implements DozeMachine.Service {
28
29 public boolean finished;
30 public int screenState;
Adrian Roos5502b892017-08-22 15:42:12 +020031 public boolean screenStateSet;
Adrian Roos4fb1f512017-02-14 14:01:32 +010032 public boolean requestedWakeup;
Adrian Roos2981eb02017-05-26 18:40:09 -070033 public int screenBrightness;
Adrian Roosff2c4562016-11-03 12:13:36 -070034
35 public DozeServiceFake() {
36 reset();
37 }
38
39 @Override
40 public void finish() {
41 finished = true;
42 }
43
44 @Override
45 public void setDozeScreenState(int state) {
46 screenState = state;
Adrian Roos5502b892017-08-22 15:42:12 +020047 screenStateSet = true;
Adrian Roosff2c4562016-11-03 12:13:36 -070048 }
49
Adrian Roos4fb1f512017-02-14 14:01:32 +010050 @Override
51 public void requestWakeUp() {
52 requestedWakeup = true;
53 }
Adrian Roos2981eb02017-05-26 18:40:09 -070054
55 @Override
56 public void setDozeScreenBrightness(int brightness) {
57 screenBrightness = brightness;
58 }
59
60 public void reset() {
61 finished = false;
62 screenState = Display.STATE_UNKNOWN;
Adrian Roos5502b892017-08-22 15:42:12 +020063 screenStateSet = false;
64 requestedWakeup = false;
Adrian Roos2981eb02017-05-26 18:40:09 -070065 screenBrightness = PowerManager.BRIGHTNESS_DEFAULT;
66 }
Adrian Roosff2c4562016-11-03 12:13:36 -070067}