summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorxshu <xshu@google.com>2018-06-21 14:51:51 -0700
committerxshu <xshu@google.com>2018-06-22 11:49:33 -0700
commitf436a0286fb8624fd00585657ff7daf0291abee6 (patch)
tree4e409b82387e761f167264cd0379d62346e3ad89 /tests
parentf73cbce57b25efec3bba41e59ac09b847226f5e5 (diff)
ONA notification: blacklist connected SSIDs
If the user connect to a open network and then later remove it, we should not bombard them with the same ONA notification. Bug: 68918131 Test: compile, unit test Manual testing: flash device sees ONA notification "Google-OSU" press "Connect" forget the network ONA notification for "Google-OSU" no longer shows up Change-Id: Id08acfe842a1ae98fa70f7ad550b7f8d6818cbb4
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/CarrierNetworkNotifierTest.java31
-rw-r--r--tests/wifitests/src/com/android/server/wifi/OpenNetworkNotifierTest.java31
2 files changed, 54 insertions, 8 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/CarrierNetworkNotifierTest.java b/tests/wifitests/src/com/android/server/wifi/CarrierNetworkNotifierTest.java
index 747531bde..e5fe05317 100644
--- a/tests/wifitests/src/com/android/server/wifi/CarrierNetworkNotifierTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/CarrierNetworkNotifierTest.java
@@ -398,10 +398,33 @@ public class CarrierNetworkNotifierTest {
List<ScanDetail> scanResults = mCarrierNetworks;
mNotificationController.handleScanResults(scanResults);
- Set<String> expectedBlacklist = new ArraySet<>();
- expectedBlacklist.add(mDummyNetwork.SSID);
- verify(mWifiMetrics).setNetworkRecommenderBlacklistSize(CARRIER_NET_NOTIFIER_TAG,
- expectedBlacklist.size());
+ verify(mWifiMetrics).setNetworkRecommenderBlacklistSize(CARRIER_NET_NOTIFIER_TAG, 1);
+ }
+
+ /**
+ * When the user chooses to connect to recommended network, network ssid should be
+ * blacklisted so that if the user removes the network in the future the same notification
+ * won't show up again.
+ */
+ @Test
+ public void userConnectedNotification_shouldBlacklistNetwork() {
+ mNotificationController.handleScanResults(mCarrierNetworks);
+
+ verify(mNotificationBuilder).createConnectToAvailableNetworkNotification(
+ CARRIER_NET_NOTIFIER_TAG, mDummyNetwork);
+ verify(mWifiMetrics).incrementConnectToNetworkNotification(CARRIER_NET_NOTIFIER_TAG,
+ ConnectToNetworkNotificationAndActionCount.NOTIFICATION_RECOMMEND_NETWORK);
+ verify(mNotificationManager).notify(anyInt(), any());
+
+ mBroadcastReceiver.onReceive(mContext, createIntent(ACTION_CONNECT_TO_NETWORK));
+
+ verify(mWifiConfigManager).saveToStore(false /* forceWrite */);
+
+ mNotificationController.clearPendingNotification(true);
+ List<ScanDetail> scanResults = mCarrierNetworks;
+ mNotificationController.handleScanResults(scanResults);
+
+ verify(mWifiMetrics).setNetworkRecommenderBlacklistSize(CARRIER_NET_NOTIFIER_TAG, 1);
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/OpenNetworkNotifierTest.java b/tests/wifitests/src/com/android/server/wifi/OpenNetworkNotifierTest.java
index 828dcfb15..8467f6b30 100644
--- a/tests/wifitests/src/com/android/server/wifi/OpenNetworkNotifierTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/OpenNetworkNotifierTest.java
@@ -395,10 +395,33 @@ public class OpenNetworkNotifierTest {
List<ScanDetail> scanResults = mOpenNetworks;
mNotificationController.handleScanResults(scanResults);
- Set<String> expectedBlacklist = new ArraySet<>();
- expectedBlacklist.add(mDummyNetwork.SSID);
- verify(mWifiMetrics).setNetworkRecommenderBlacklistSize(OPEN_NET_NOTIFIER_TAG,
- expectedBlacklist.size());
+ verify(mWifiMetrics).setNetworkRecommenderBlacklistSize(OPEN_NET_NOTIFIER_TAG, 1);
+ }
+
+ /**
+ * When the user chooses to connect to recommended network, network ssid should be
+ * blacklisted so that if the user removes the network in the future the same notification
+ * won't show up again.
+ */
+ @Test
+ public void userConnectedNotification_shouldBlacklistNetwork() {
+ mNotificationController.handleScanResults(mOpenNetworks);
+
+ verify(mNotificationBuilder).createConnectToAvailableNetworkNotification(
+ OPEN_NET_NOTIFIER_TAG, mDummyNetwork);
+ verify(mWifiMetrics).incrementConnectToNetworkNotification(OPEN_NET_NOTIFIER_TAG,
+ ConnectToNetworkNotificationAndActionCount.NOTIFICATION_RECOMMEND_NETWORK);
+ verify(mNotificationManager).notify(anyInt(), any());
+
+ mBroadcastReceiver.onReceive(mContext, createIntent(ACTION_CONNECT_TO_NETWORK));
+
+ verify(mWifiConfigManager).saveToStore(false /* forceWrite */);
+
+ mNotificationController.clearPendingNotification(true);
+ List<ScanDetail> scanResults = mOpenNetworks;
+ mNotificationController.handleScanResults(scanResults);
+
+ verify(mWifiMetrics).setNetworkRecommenderBlacklistSize(OPEN_NET_NOTIFIER_TAG, 1);
}
/**