Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 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 | |
Adrian Roos | 2981eb0 | 2017-05-26 18:40:09 -0700 | [diff] [blame] | 19 | import android.os.PowerManager; |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 20 | import android.view.Display; |
| 21 | |
Adrian Roos | 5502b89 | 2017-08-22 15:42:12 +0200 | [diff] [blame] | 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 | */ |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 27 | public class DozeServiceFake implements DozeMachine.Service { |
| 28 | |
| 29 | public boolean finished; |
| 30 | public int screenState; |
Adrian Roos | 5502b89 | 2017-08-22 15:42:12 +0200 | [diff] [blame] | 31 | public boolean screenStateSet; |
Adrian Roos | 4fb1f51 | 2017-02-14 14:01:32 +0100 | [diff] [blame] | 32 | public boolean requestedWakeup; |
Adrian Roos | 2981eb0 | 2017-05-26 18:40:09 -0700 | [diff] [blame] | 33 | public int screenBrightness; |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 34 | |
| 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 Roos | 5502b89 | 2017-08-22 15:42:12 +0200 | [diff] [blame] | 47 | screenStateSet = true; |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 48 | } |
| 49 | |
Adrian Roos | 4fb1f51 | 2017-02-14 14:01:32 +0100 | [diff] [blame] | 50 | @Override |
| 51 | public void requestWakeUp() { |
| 52 | requestedWakeup = true; |
| 53 | } |
Adrian Roos | 2981eb0 | 2017-05-26 18:40:09 -0700 | [diff] [blame] | 54 | |
| 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 Roos | 5502b89 | 2017-08-22 15:42:12 +0200 | [diff] [blame] | 63 | screenStateSet = false; |
| 64 | requestedWakeup = false; |
Adrian Roos | 2981eb0 | 2017-05-26 18:40:09 -0700 | [diff] [blame] | 65 | screenBrightness = PowerManager.BRIGHTNESS_DEFAULT; |
| 66 | } |
Adrian Roos | ff2c456 | 2016-11-03 12:13:36 -0700 | [diff] [blame] | 67 | } |