Added tests for network restrictions while the screen is off. am: 2882cd2a7a
am: f602c8fd12 Change-Id: Ie4ac91c0b23ceb0c3ed56cfba16ea2651f5bfb7c
This commit is contained in:
@@ -85,16 +85,24 @@ abstract class AbstractBatterySaverModeTestCase extends AbstractRestrictBackgrou
|
||||
assertsForegroundAlwaysHasNetworkAccess();
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
// Make sure foreground app doesn't lose access upon enabling it.
|
||||
// Make sure foreground app doesn't lose access upon Battery Saver.
|
||||
setBatterySaverMode(false);
|
||||
launchActivity();
|
||||
assertForegroundNetworkAccess();
|
||||
setBatterySaverMode(true);
|
||||
assertForegroundNetworkAccess();
|
||||
|
||||
// Although it should not have access while the screen is off.
|
||||
turnScreenOff();
|
||||
assertBackgroundNetworkAccess(false);
|
||||
turnScreenOn();
|
||||
assertForegroundNetworkAccess();
|
||||
|
||||
// Goes back to background state.
|
||||
finishActivity();
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
// Same for foreground service.
|
||||
// Make sure foreground service doesn't lose access upon enabling Battery Saver.
|
||||
setBatterySaverMode(false);
|
||||
startForegroundService();
|
||||
assertForegroundNetworkAccess();
|
||||
|
||||
@@ -244,7 +244,7 @@ abstract class AbstractRestrictBackgroundNetworkTestCase extends Instrumentation
|
||||
if (isBackground(state.state)) {
|
||||
return;
|
||||
}
|
||||
Log.d(TAG, "App not on background state on attempt #" + i
|
||||
Log.d(TAG, "App not on background state (" + state + ") on attempt #" + i
|
||||
+ "; sleeping 1s before trying again");
|
||||
SystemClock.sleep(SECOND_IN_MS);
|
||||
}
|
||||
|
||||
@@ -98,16 +98,24 @@ public class DataSaverModeTest extends AbstractRestrictBackgroundNetworkTestCase
|
||||
assertsForegroundAlwaysHasNetworkAccess();
|
||||
assertDataSaverStatusOnBackground(RESTRICT_BACKGROUND_STATUS_ENABLED);
|
||||
|
||||
// Make sure foreground app doesn't lose access upon enabling it.
|
||||
// Make sure foreground app doesn't lose access upon enabling Data Saver.
|
||||
setRestrictBackground(false);
|
||||
launchActivity();
|
||||
assertForegroundNetworkAccess();
|
||||
setRestrictBackground(true);
|
||||
assertForegroundNetworkAccess();
|
||||
|
||||
// Although it should not have access while the screen is off.
|
||||
turnScreenOff();
|
||||
assertBackgroundNetworkAccess(false);
|
||||
turnScreenOn();
|
||||
assertForegroundNetworkAccess();
|
||||
|
||||
// Goes back to background state.
|
||||
finishActivity();
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
// Same for foreground service.
|
||||
// Make sure foreground service doesn't lose access upon enabling Data Saver.
|
||||
setRestrictBackground(false);
|
||||
startForegroundService();
|
||||
assertForegroundNetworkAccess();
|
||||
|
||||
Reference in New Issue
Block a user