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
diff --git a/tests/cts/hostside/app/src/com/android/cts/net/hostside/ConnectivityManagerTest.java b/tests/cts/hostside/app/src/com/android/cts/net/hostside/ConnectivityManagerTest.java
index b27c80a..8975dab 100644
--- a/tests/cts/hostside/app/src/com/android/cts/net/hostside/ConnectivityManagerTest.java
+++ b/tests/cts/hostside/app/src/com/android/cts/net/hostside/ConnectivityManagerTest.java
@@ -80,6 +80,11 @@
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);
diff --git a/tests/cts/hostside/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java b/tests/cts/hostside/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
index 2b0b1c1..1804740 100644
--- a/tests/cts/hostside/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
+++ b/tests/cts/hostside/src/com/android/cts/net/HostsideRestrictBackgroundNetworkTests.java
@@ -55,12 +55,13 @@
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 @@
removeRestrictBackgroundWhitelist(mUid);
assertRestrictBackgroundStatusEnabled();
- assertRestrictBackgroundChangedReceivedTwice();
+ assertRestrictBackgroundChangedReceivedOnce();
}
public void testGetRestrictBackgroundStatus_uninstall() throws Exception {
@@ -121,6 +122,11 @@
"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");