summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorStephen Chen <stewchen@google.com>2017-07-18 11:43:39 -0700
committerStephen Chen <stewchen@google.com>2017-07-24 11:08:23 -0700
commit0f41a6a3df4a2cedcad60324d91e1fffc968cfbb (patch)
tree6a985556e65e357a9d4701dfeb016a1a0e4331db /tests
parent3f8483262cf59572d0c0b3c42e72d8ce65a096ff (diff)
ONA: Track screen state in WifiNotificationController.
The Open Networks Available notification should not be shown when the screen is off. Bug: 38460614 Bug: 37357441 Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Change-Id: I445f95a624009f492c3abd8a9f815706e221ea44
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java14
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNotificationControllerTest.java28
2 files changed, 42 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
index 11e220e7f..bdb6b14ed 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
@@ -679,6 +679,20 @@ public class WifiConnectivityManagerTest {
}
/**
+ * Verify that the ONA controller tracks screen state changes.
+ */
+ @Test
+ public void openNetworkNotificationControllerTracksScreenStateChanges() {
+ mWifiConnectivityManager.handleScreenStateChanged(false);
+
+ verify(mWifiNotificationController).handleScreenStateChanged(false);
+
+ mWifiConnectivityManager.handleScreenStateChanged(true);
+
+ verify(mWifiNotificationController).handleScreenStateChanged(true);
+ }
+
+ /**
* Verify that scan interval for screen on and wifi disconnected scenario
* is in the exponential backoff fashion.
*
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNotificationControllerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNotificationControllerTest.java
index 9aa5ee938..27055a885 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNotificationControllerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNotificationControllerTest.java
@@ -70,6 +70,7 @@ public class WifiNotificationControllerTest {
mNotificationController = new WifiNotificationController(
mContext, mock_looper.getLooper(), mFrameworkFacade,
mock(Notification.Builder.class));
+ mNotificationController.handleScreenStateChanged(true);
}
private List<ScanDetail> createOpenScanResults() {
@@ -114,6 +115,21 @@ public class WifiNotificationControllerTest {
verify(mNotificationManager).cancelAsUser(any(), anyInt(), any());
}
+ /**
+ * When a notification is showing, screen is off, and scan results with no open networks are
+ * handled, the notification is cleared.
+ */
+ @Test
+ public void handleScanResults_notificationShown_screenOff_emptyList_notificationCleared() {
+ mNotificationController.handleScanResults(createOpenScanResults());
+
+ verify(mNotificationManager).notifyAsUser(any(), anyInt(), any(), any());
+
+ mNotificationController.handleScreenStateChanged(false);
+ mNotificationController.handleScanResults(new ArrayList<>());
+
+ verify(mNotificationManager).cancelAsUser(any(), anyInt(), any());
+ }
/**
* If notification is showing, do not post another notification.
@@ -152,6 +168,18 @@ public class WifiNotificationControllerTest {
verify(mNotificationManager, never()).cancelAsUser(any(), anyInt(), any());
}
+ /**
+ * When screen is off and notification is not displayed, notification is not posted on handling
+ * new scan results with open networks.
+ */
+ @Test
+ public void screenOff_handleScanResults_notificationNotDisplayed() {
+ mNotificationController.handleScreenStateChanged(false);
+ mNotificationController.handleScanResults(createOpenScanResults());
+
+ verify(mNotificationManager, never()).notifyAsUser(any(), anyInt(), any(), any());
+ }
+
/** Verifies that {@link UserManager#DISALLOW_CONFIG_WIFI} disables the feature. */
@Test
public void userHasDisallowConfigWifiRestriction_notificationNotDisplayed() {