summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Robert Horvath <robhor@google.com> 2023-08-07 16:21:58 +0200
committer Robert Horvath <robhor@google.com> 2023-08-07 16:21:58 +0200
commit1441ebb13f61da8d668c7bb8e44ecf99f2159999 (patch)
tree3fa9e339c53c3aa0908ac47a386fa56f3faa6483
parent98565574856ae39c2133b9b10058fad1edce782d (diff)
PowerManagerServiceTest: Set dreams as supported & enabled by default
Some tests depend on dreams being supported & enabled. This change sets the corresponding config values in the test setup. Bug: 293660604 Test: atest PowerManagerServiceTest Change-Id: I022f69f49ef0a7380a7d772b43db4ed7e3fb28b9
-rw-r--r--services/tests/powerservicetests/src/com/android/server/power/PowerManagerServiceTest.java16
1 files changed, 4 insertions, 12 deletions
diff --git a/services/tests/powerservicetests/src/com/android/server/power/PowerManagerServiceTest.java b/services/tests/powerservicetests/src/com/android/server/power/PowerManagerServiceTest.java
index 9bce5367f075..0fe8ece8ee77 100644
--- a/services/tests/powerservicetests/src/com/android/server/power/PowerManagerServiceTest.java
+++ b/services/tests/powerservicetests/src/com/android/server/power/PowerManagerServiceTest.java
@@ -235,6 +235,10 @@ public class PowerManagerServiceTest {
cr.addProvider(Settings.AUTHORITY, new FakeSettingsProvider());
when(mContextSpy.getContentResolver()).thenReturn(cr);
+ when(mResourcesSpy.getBoolean(com.android.internal.R.bool.config_dreamsSupported))
+ .thenReturn(true);
+ when(mResourcesSpy.getBoolean(com.android.internal.R.bool.config_dreamsEnabledByDefault))
+ .thenReturn(true);
Settings.Global.putInt(mContextSpy.getContentResolver(),
Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0);
Settings.Secure.putInt(mContextSpy.getContentResolver(),
@@ -1079,13 +1083,9 @@ public class PowerManagerServiceTest {
@SuppressWarnings("GuardedBy")
@Test
public void testScreensaverActivateOnSleepEnabled_powered_afterTimeout_goesToDreaming() {
- when(mResourcesSpy.getBoolean(com.android.internal.R.bool.config_dreamsSupported))
- .thenReturn(true);
when(mBatteryManagerInternalMock.isPowered(anyInt())).thenReturn(true);
Settings.Secure.putInt(mContextSpy.getContentResolver(),
Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP, 1);
- Settings.Secure.putInt(mContextSpy.getContentResolver(),
- Settings.Secure.SCREENSAVER_ENABLED, 1);
doAnswer(inv -> {
when(mDreamManagerInternalMock.isDreaming()).thenReturn(true);
@@ -1107,8 +1107,6 @@ public class PowerManagerServiceTest {
public void testAmbientSuppression_disablesDreamingAndWakesDevice() {
Settings.Secure.putInt(mContextSpy.getContentResolver(),
Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP, 1);
- Settings.Secure.putInt(mContextSpy.getContentResolver(),
- Settings.Secure.SCREENSAVER_ENABLED, 1);
setDreamsDisabledByAmbientModeSuppressionConfig(true);
setMinimumScreenOffTimeoutConfig(10000);
@@ -1136,8 +1134,6 @@ public class PowerManagerServiceTest {
public void testAmbientSuppressionDisabled_shouldNotWakeDevice() {
Settings.Secure.putInt(mContextSpy.getContentResolver(),
Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP, 1);
- Settings.Secure.putInt(mContextSpy.getContentResolver(),
- Settings.Secure.SCREENSAVER_ENABLED, 1);
setDreamsDisabledByAmbientModeSuppressionConfig(false);
setMinimumScreenOffTimeoutConfig(10000);
@@ -1164,8 +1160,6 @@ public class PowerManagerServiceTest {
public void testAmbientSuppression_doesNotAffectDreamForcing() {
Settings.Secure.putInt(mContextSpy.getContentResolver(),
Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP, 1);
- Settings.Secure.putInt(mContextSpy.getContentResolver(),
- Settings.Secure.SCREENSAVER_ENABLED, 1);
setDreamsDisabledByAmbientModeSuppressionConfig(true);
setMinimumScreenOffTimeoutConfig(10000);
@@ -1191,8 +1185,6 @@ public class PowerManagerServiceTest {
public void testBatteryDrainDuringDream() {
Settings.Secure.putInt(mContextSpy.getContentResolver(),
Settings.Secure.SCREENSAVER_ACTIVATE_ON_SLEEP, 1);
- Settings.Secure.putInt(mContextSpy.getContentResolver(),
- Settings.Secure.SCREENSAVER_ENABLED, 1);
setMinimumScreenOffTimeoutConfig(100);
setDreamsBatteryLevelDrainConfig(5);