Tests for idle parole when charging
Make sure that when switching between idle, paroled and battery saver, the network availability of the app is correctly updated. Bug: 31399882 Test: cts-tradefed run commandAndExit cts -m CtsHostsideNetworkTests -t com.android.cts.net.HostsideRestrictBackgroundNetworkTests#testAppIdleNonMetered_whenCharging Test: cts-tradefed run commandAndExit cts -m CtsHostsideNetworkTests -t com.android.cts.net.HostsideRestrictBackgroundNetworkTests#testAppIdleMetered_whenCharging Change-Id: I060a0d5f9c3297430b5b623b389c1afdf6abde87
This commit is contained in:
@@ -138,4 +138,28 @@ abstract class AbstractAppIdleTestCase extends AbstractRestrictBackgroundNetwork
|
||||
assertsForegroundAlwaysHasNetworkAccess();
|
||||
assertBackgroundNetworkAccess(true);
|
||||
}
|
||||
|
||||
public void testAppIdleNetworkAccess_whenCharging() throws Exception {
|
||||
if (!isSupported()) return;
|
||||
|
||||
// Check that app is paroled when charging
|
||||
setAppIdle(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
turnBatteryOn();
|
||||
assertBackgroundNetworkAccess(true);
|
||||
turnBatteryOff();
|
||||
assertBackgroundNetworkAccess(false);
|
||||
|
||||
// Check that app is restricted when not idle but power-save is on
|
||||
setAppIdle(false);
|
||||
assertBackgroundNetworkAccess(true);
|
||||
setBatterySaverMode(true);
|
||||
assertBackgroundNetworkAccess(false);
|
||||
turnBatteryOn();
|
||||
assertBackgroundNetworkAccess(true);
|
||||
|
||||
// And when no longer charging, it still has network access, since it's not idle
|
||||
turnBatteryOff();
|
||||
assertBackgroundNetworkAccess(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,6 +171,16 @@ public class HostsideRestrictBackgroundNetworkTests extends HostsideNetworkTestC
|
||||
"testBackgroundNetworkAccess_enabled");
|
||||
}
|
||||
|
||||
public void testAppIdleNonMetered_whenCharging() throws Exception {
|
||||
runDeviceTests(TEST_PKG, TEST_PKG + ".AppIdleNonMeteredTest",
|
||||
"testAppIdleNetworkAccess_whenCharging");
|
||||
}
|
||||
|
||||
public void testAppIdleMetered_whenCharging() throws Exception {
|
||||
runDeviceTests(TEST_PKG, TEST_PKG + ".AppIdleMeteredTest",
|
||||
"testAppIdleNetworkAccess_whenCharging");
|
||||
}
|
||||
|
||||
/********************
|
||||
* Doze Mode tests. *
|
||||
********************/
|
||||
|
||||
Reference in New Issue
Block a user