1 /* 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 17 package com.android.systemui.doze; 18 19 import android.os.PowerManager; 20 import android.view.Display; 21 22 /** 23 * Fake implementation of {@link DozeMachine.Service} for tests. 24 * 25 * Useful instead of mocking because it allows verifying state instead of interactions. 26 */ 27 public class DozeServiceFake implements DozeMachine.Service { 28 29 public boolean finished; 30 public int screenState; 31 public boolean screenStateSet; 32 public boolean requestedWakeup; 33 public int screenBrightness; 34 DozeServiceFake()35 public DozeServiceFake() { 36 reset(); 37 } 38 39 @Override finish()40 public void finish() { 41 finished = true; 42 } 43 44 @Override setDozeScreenState(int state)45 public void setDozeScreenState(int state) { 46 screenState = state; 47 screenStateSet = true; 48 } 49 50 @Override requestWakeUp(@ozeLog.Reason int reason)51 public void requestWakeUp(@DozeLog.Reason int reason) { 52 requestedWakeup = true; 53 } 54 55 @Override setDozeScreenBrightness(int brightness)56 public void setDozeScreenBrightness(int brightness) { 57 screenBrightness = brightness; 58 } 59 reset()60 public void reset() { 61 finished = false; 62 screenState = Display.STATE_UNKNOWN; 63 screenStateSet = false; 64 requestedWakeup = false; 65 screenBrightness = PowerManager.BRIGHTNESS_DEFAULT; 66 } 67 } 68