diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-07-25 18:05:57 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-07-25 18:05:57 +0000 |
commit | 425676edcb8853bd5aff996a0be6974b06246e46 (patch) | |
tree | 4b262dbd7d8131888767812410ef0b71446e2c6b /tests | |
parent | 6db34c0303b84c1c212a8f013ec90b257fb96052 (diff) | |
parent | 0f41a6a3df4a2cedcad60324d91e1fffc968cfbb (diff) |
Merge "ONA: Track screen state in WifiNotificationController." into oc-dr1-dev
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java | 14 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiNotificationControllerTest.java | 28 |
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() { |