Updated tests cases after to assert the proper number of notifications.
Previously NMPS was broadcasting an intent every time add|removeRestrictBackgroundWhitelistedUid() was called, but that behavior has been changed to just broadcast an intent when there is a change. BUG: 26685616 Change-Id: I4eb7a4fda864a28ea23b661d1a88e18bfb80533d
This commit is contained in:
@@ -80,6 +80,11 @@ public class ConnectivityManagerTest extends InstrumentationTestCase {
|
||||
assertRestrictBackgroundStatus(RESTRICT_BACKGROUND_STATUS_ENABLED);
|
||||
}
|
||||
|
||||
public void testRestrictBackgroundChangedNotReceived() throws Exception {
|
||||
assertRestrictBackgroundChangedReceived(DYNAMIC_RECEIVER, 0);
|
||||
assertRestrictBackgroundChangedReceived(MANIFEST_RECEIVER, 0);
|
||||
}
|
||||
|
||||
public void testRestrictBackgroundChangedReceivedOnce() throws Exception {
|
||||
assertRestrictBackgroundChangedReceived(DYNAMIC_RECEIVER, 1);
|
||||
assertRestrictBackgroundChangedReceived(MANIFEST_RECEIVER, 0);
|
||||
|
||||
@@ -55,12 +55,13 @@ public class HostsideRestrictBackgroundNetworkTests extends HostsideNetworkTestC
|
||||
public void testGetRestrictBackgroundStatus_disabled() throws Exception {
|
||||
removeRestrictBackgroundWhitelist(mUid);
|
||||
assertRestrictBackgroundStatusDisabled();
|
||||
assertRestrictBackgroundChangedReceivedOnce();
|
||||
// From the app's point of view, nothing changed, it still have access
|
||||
assertRestrictBackgroundChangedNotReceived();
|
||||
|
||||
// Sanity check: make sure status is always disabled, never whitelisted
|
||||
addRestrictBackgroundWhitelist(mUid);
|
||||
assertRestrictBackgroundStatusDisabled();
|
||||
assertRestrictBackgroundChangedReceivedTwice();
|
||||
assertRestrictBackgroundChangedNotReceived();
|
||||
}
|
||||
|
||||
public void testGetRestrictBackgroundStatus_whitelisted() throws Exception {
|
||||
@@ -78,7 +79,7 @@ public class HostsideRestrictBackgroundNetworkTests extends HostsideNetworkTestC
|
||||
|
||||
removeRestrictBackgroundWhitelist(mUid);
|
||||
assertRestrictBackgroundStatusEnabled();
|
||||
assertRestrictBackgroundChangedReceivedTwice();
|
||||
assertRestrictBackgroundChangedReceivedOnce();
|
||||
}
|
||||
|
||||
public void testGetRestrictBackgroundStatus_uninstall() throws Exception {
|
||||
@@ -121,6 +122,11 @@ public class HostsideRestrictBackgroundNetworkTests extends HostsideNetworkTestC
|
||||
"testGetRestrictBackgroundStatus_enabled");
|
||||
}
|
||||
|
||||
private void assertRestrictBackgroundChangedNotReceived() throws DeviceNotAvailableException {
|
||||
runDeviceTests(TEST_PKG, TEST_PKG + ".ConnectivityManagerTest",
|
||||
"testRestrictBackgroundChangedNotReceived");
|
||||
}
|
||||
|
||||
private void assertRestrictBackgroundChangedReceivedOnce() throws DeviceNotAvailableException {
|
||||
runDeviceTests(TEST_PKG, TEST_PKG + ".ConnectivityManagerTest",
|
||||
"testRestrictBackgroundChangedReceivedOnce");
|
||||
|
||||
Reference in New Issue
Block a user