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:
Felipe Leme
2016-02-11 11:56:30 -08:00
parent 38300a564a
commit a557ba6818
2 changed files with 14 additions and 3 deletions

View File

@@ -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);

View File

@@ -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");