summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorStephen Chen <stewchen@google.com>2017-09-07 15:27:27 -0700
committerStephen Chen <stewchen@google.com>2017-09-07 15:27:27 -0700
commitb6103294dc1e6785c8ba236582e53801e1f9f2cd (patch)
tree0fa20231d3b2abb2e0b8d05ab807c162b49bb97c /tests
parent20361dcf2d45262685c8dec334c11f0b2c987702 (diff)
ONA: Enable new UI and connection flow.
The new Open Network Available notification UI introduces a connection flow in which users can connect to a recommended open network directly by interacting with the notification. "Connect" and "See all" action buttons are introduced to initiate the flow, and once a connection attempt is made, the connection status will be reflected on the notification. Bug: 37357441 Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Change-Id: I30231c4f71476a7417a3b423848575d5488f51f7
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/OpenNetworkNotifierTest.java109
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java9
2 files changed, 63 insertions, 55 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/OpenNetworkNotifierTest.java b/tests/wifitests/src/com/android/server/wifi/OpenNetworkNotifierTest.java
index 3af19e163..46ec1597e 100644
--- a/tests/wifitests/src/com/android/server/wifi/OpenNetworkNotifierTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/OpenNetworkNotifierTest.java
@@ -120,7 +120,7 @@ public class OpenNetworkNotifierTest {
mNotificationController.handleScanResults(mOpenNetworks);
verify(mOpenNetworkRecommender).recommendNetwork(mOpenNetworks, mBlacklistedSsids);
- verify(mNotificationBuilder).createConnectToNetworkNotification(1);
+ verify(mNotificationBuilder).createConnectToNetworkNotification(mDummyNetwork);
verify(mNotificationManager).notify(anyInt(), any());
}
@@ -144,42 +144,48 @@ public class OpenNetworkNotifierTest {
mNotificationController.handleScanResults(mOpenNetworks);
verify(mOpenNetworkRecommender).recommendNetwork(mOpenNetworks, mBlacklistedSsids);
- verify(mNotificationBuilder).createConnectToNetworkNotification(1);
+ verify(mNotificationBuilder).createConnectToNetworkNotification(mDummyNetwork);
verify(mNotificationManager).notify(anyInt(), any());
mNotificationController.handleScanResults(new ArrayList<>());
verify(mNotificationManager).cancel(anyInt());
}
+
/**
- * When a notification is showing, screen is off, and scan results with no open networks are
- * handled, the notification is cleared.
+ * When a notification is showing and no recommendation is made for the new scan results, the
+ * notification is cleared.
*/
@Test
- public void handleScanResults_notificationShown_screenOff_emptyList_notificationCleared() {
+ public void handleScanResults_notificationShown_noRecommendation_notificationCleared() {
mNotificationController.handleScanResults(mOpenNetworks);
verify(mOpenNetworkRecommender).recommendNetwork(mOpenNetworks, mBlacklistedSsids);
- verify(mNotificationBuilder).createConnectToNetworkNotification(1);
+ verify(mNotificationBuilder).createConnectToNetworkNotification(mDummyNetwork);
verify(mNotificationManager).notify(anyInt(), any());
- mNotificationController.handleScreenStateChanged(false);
- mNotificationController.handleScanResults(new ArrayList<>());
+ when(mOpenNetworkRecommender.recommendNetwork(any(), any())).thenReturn(null);
+ mNotificationController.handleScanResults(mOpenNetworks);
verify(mNotificationManager).cancel(anyInt());
}
/**
- * If notification is showing, do not post another notification.
+ * 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_notificationShowing_doesNotRepostNotification() {
- mNotificationController.handleScanResults(mOpenNetworks);
+ public void handleScanResults_notificationShown_screenOff_emptyList_notificationCleared() {
mNotificationController.handleScanResults(mOpenNetworks);
verify(mOpenNetworkRecommender).recommendNetwork(mOpenNetworks, mBlacklistedSsids);
- verify(mNotificationBuilder).createConnectToNetworkNotification(1);
+ verify(mNotificationBuilder).createConnectToNetworkNotification(mDummyNetwork);
verify(mNotificationManager).notify(anyInt(), any());
+
+ mNotificationController.handleScreenStateChanged(false);
+ mNotificationController.handleScanResults(new ArrayList<>());
+
+ verify(mNotificationManager).cancel(anyInt());
}
/**
@@ -191,7 +197,7 @@ public class OpenNetworkNotifierTest {
mNotificationController.handleScanResults(mOpenNetworks);
verify(mOpenNetworkRecommender).recommendNetwork(mOpenNetworks, mBlacklistedSsids);
- verify(mNotificationBuilder).createConnectToNetworkNotification(1);
+ verify(mNotificationBuilder).createConnectToNetworkNotification(mDummyNetwork);
verify(mNotificationManager).notify(anyInt(), any());
mNotificationController.clearPendingNotification(true);
@@ -215,7 +221,7 @@ public class OpenNetworkNotifierTest {
* new scan results with open networks.
*/
@Test
- public void screenOff_handleScanResults_notificationNotDisplayed() {
+ public void screenOff_notificationNotShowing_handleScanResults_notificationNotDisplayed() {
mNotificationController.handleScreenStateChanged(false);
mNotificationController.handleScanResults(mOpenNetworks);
@@ -224,69 +230,69 @@ public class OpenNetworkNotifierTest {
}
/**
- * When a notification is posted and cleared without resetting delay, the next scan with open
- * networks should not post another notification.
+ * When screen is off and notification is displayed, the notification can be updated with a new
+ * recommendation.
*/
@Test
- public void postNotification_clearNotificationWithoutDelayReset_shouldNotPostNotification() {
+ public void screenOff_notificationShowing_handleScanResults_recommendationCanBeUpdated() {
mNotificationController.handleScanResults(mOpenNetworks);
verify(mOpenNetworkRecommender).recommendNetwork(mOpenNetworks, mBlacklistedSsids);
- verify(mNotificationBuilder).createConnectToNetworkNotification(1);
+ verify(mNotificationBuilder).createConnectToNetworkNotification(mDummyNetwork);
verify(mNotificationManager).notify(anyInt(), any());
- mNotificationController.clearPendingNotification(false);
-
+ mNotificationController.handleScreenStateChanged(false);
mNotificationController.handleScanResults(mOpenNetworks);
- // Recommendation made twice but no new notification posted.
+ // Recommendation made twice
verify(mOpenNetworkRecommender, times(2)).recommendNetwork(
mOpenNetworks, mBlacklistedSsids);
- verify(mNotificationManager).notify(anyInt(), any());
- verify(mNotificationBuilder).createConnectToNetworkNotification(1);
- verify(mNotificationManager).cancel(anyInt());
+ verify(mNotificationBuilder, times(2)).createConnectToNetworkNotification(mDummyNetwork);
+ verify(mNotificationManager, times(2)).notify(anyInt(), any());
}
/**
* When a notification is posted and cleared without resetting delay, the next scan with open
- * networks should post a notification.
+ * networks should not post another notification.
*/
@Test
- public void postNotification_clearNotificationWithDelayReset_shouldPostNotification() {
+ public void postNotification_clearNotificationWithoutDelayReset_shouldNotPostNotification() {
mNotificationController.handleScanResults(mOpenNetworks);
verify(mOpenNetworkRecommender).recommendNetwork(mOpenNetworks, mBlacklistedSsids);
- verify(mNotificationBuilder).createConnectToNetworkNotification(1);
+ verify(mNotificationBuilder).createConnectToNetworkNotification(mDummyNetwork);
verify(mNotificationManager).notify(anyInt(), any());
- mNotificationController.clearPendingNotification(true);
+ mNotificationController.clearPendingNotification(false);
+
+ verify(mNotificationManager).cancel(anyInt());
mNotificationController.handleScanResults(mOpenNetworks);
- verify(mOpenNetworkRecommender, times(2)).recommendNetwork(
- mOpenNetworks, mBlacklistedSsids);
- verify(mNotificationBuilder, times(2)).createConnectToNetworkNotification(1);
- verify(mNotificationManager, times(2)).notify(anyInt(), any());
+ // no new notification posted
+ verify(mNotificationManager).notify(anyInt(), any());
}
/**
- * When a notification is tapped, open Wi-Fi settings.
+ * When a notification is posted and cleared without resetting delay, the next scan with open
+ * networks should post a notification.
*/
@Test
- public void notificationTap_opensWifiSettings() {
+ public void postNotification_clearNotificationWithDelayReset_shouldPostNotification() {
mNotificationController.handleScanResults(mOpenNetworks);
verify(mOpenNetworkRecommender).recommendNetwork(mOpenNetworks, mBlacklistedSsids);
- verify(mNotificationBuilder).createConnectToNetworkNotification(1);
+ verify(mNotificationBuilder).createConnectToNetworkNotification(mDummyNetwork);
verify(mNotificationManager).notify(anyInt(), any());
- mBroadcastReceiver.onReceive(
- mContext,
- new Intent(ConnectToNetworkNotificationBuilder.ACTION_USER_TAPPED_CONTENT));
+ mNotificationController.clearPendingNotification(true);
- ArgumentCaptor<Intent> pickerIntentCaptor = ArgumentCaptor.forClass(Intent.class);
- verify(mContext).startActivity(pickerIntentCaptor.capture());
- assertEquals(pickerIntentCaptor.getValue().getAction(), Settings.ACTION_WIFI_SETTINGS);
+ mNotificationController.handleScanResults(mOpenNetworks);
+
+ verify(mOpenNetworkRecommender, times(2)).recommendNetwork(
+ mOpenNetworks, mBlacklistedSsids);
+ verify(mNotificationBuilder, times(2)).createConnectToNetworkNotification(mDummyNetwork);
+ verify(mNotificationManager, times(2)).notify(anyInt(), any());
}
/**
@@ -298,7 +304,7 @@ public class OpenNetworkNotifierTest {
mNotificationController.handleScanResults(mOpenNetworks);
verify(mOpenNetworkRecommender).recommendNetwork(mOpenNetworks, mBlacklistedSsids);
- verify(mNotificationBuilder).createConnectToNetworkNotification(1);
+ verify(mNotificationBuilder).createConnectToNetworkNotification(mDummyNetwork);
verify(mNotificationManager).notify(anyInt(), any());
mBroadcastReceiver.onReceive(
@@ -307,7 +313,9 @@ public class OpenNetworkNotifierTest {
verify(mWifiConfigManager).saveToStore(false /* forceWrite */);
- mNotificationController.handleScanResults(mOpenNetworks);
+ mNotificationController.clearPendingNotification(true);
+ List<ScanDetail> scanResults = mOpenNetworks;
+ mNotificationController.handleScanResults(scanResults);
Set<String> expectedBlacklist = new ArraySet<>();
expectedBlacklist.add(mDummyNetwork.SSID);
@@ -323,7 +331,7 @@ public class OpenNetworkNotifierTest {
mNotificationController.handleScanResults(mOpenNetworks);
verify(mOpenNetworkRecommender).recommendNetwork(mOpenNetworks, mBlacklistedSsids);
- verify(mNotificationBuilder).createConnectToNetworkNotification(1);
+ verify(mNotificationBuilder).createConnectToNetworkNotification(mDummyNetwork);
verify(mNotificationManager).notify(anyInt(), any());
mNotificationController.clearPendingNotification(false);
@@ -335,6 +343,7 @@ public class OpenNetworkNotifierTest {
verify(mOpenNetworkRecommender, times(2)).recommendNetwork(
mOpenNetworks, mBlacklistedSsids);
+ verify(mNotificationBuilder, times(2)).createConnectToNetworkNotification(mDummyNetwork);
verify(mNotificationManager, times(2)).notify(anyInt(), any());
}
@@ -356,7 +365,7 @@ public class OpenNetworkNotifierTest {
mNotificationController.handleScanResults(mOpenNetworks);
verify(mOpenNetworkRecommender).recommendNetwork(mOpenNetworks, mBlacklistedSsids);
- verify(mNotificationBuilder).createConnectToNetworkNotification(1);
+ verify(mNotificationBuilder).createConnectToNetworkNotification(mDummyNetwork);
verify(mNotificationManager).notify(anyInt(), any());
when(mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_WIFI, UserHandle.CURRENT))
@@ -389,7 +398,7 @@ public class OpenNetworkNotifierTest {
verify(mOpenNetworkRecommender).recommendNetwork(mOpenNetworks, mBlacklistedSsids);
// Initial Notification
- verify(mNotificationBuilder).createConnectToNetworkNotification(1);
+ verify(mNotificationBuilder).createConnectToNetworkNotification(mDummyNetwork);
verify(mNotificationManager).notify(anyInt(), any());
mBroadcastReceiver.onReceive(mContext,
@@ -421,7 +430,7 @@ public class OpenNetworkNotifierTest {
verify(mOpenNetworkRecommender).recommendNetwork(mOpenNetworks, mBlacklistedSsids);
// Initial Notification
- verify(mNotificationBuilder).createConnectToNetworkNotification(1);
+ verify(mNotificationBuilder).createConnectToNetworkNotification(mDummyNetwork);
verify(mNotificationManager).notify(anyInt(), any());
mNotificationController.handleWifiConnected();
@@ -439,7 +448,7 @@ public class OpenNetworkNotifierTest {
verify(mOpenNetworkRecommender).recommendNetwork(mOpenNetworks, mBlacklistedSsids);
// Initial Notification
- verify(mNotificationBuilder).createConnectToNetworkNotification(1);
+ verify(mNotificationBuilder).createConnectToNetworkNotification(mDummyNetwork);
verify(mNotificationManager).notify(anyInt(), any());
mBroadcastReceiver.onReceive(mContext,
@@ -477,7 +486,7 @@ public class OpenNetworkNotifierTest {
verify(mOpenNetworkRecommender).recommendNetwork(mOpenNetworks, mBlacklistedSsids);
// Initial Notification
- verify(mNotificationBuilder).createConnectToNetworkNotification(1);
+ verify(mNotificationBuilder).createConnectToNetworkNotification(mDummyNetwork);
verify(mNotificationManager).notify(anyInt(), any());
mBroadcastReceiver.onReceive(mContext,
@@ -505,7 +514,7 @@ public class OpenNetworkNotifierTest {
verify(mOpenNetworkRecommender).recommendNetwork(mOpenNetworks, mBlacklistedSsids);
// Initial Notification
- verify(mNotificationBuilder).createConnectToNetworkNotification(1);
+ verify(mNotificationBuilder).createConnectToNetworkNotification(mDummyNetwork);
verify(mNotificationManager).notify(anyInt(), any());
mBroadcastReceiver.onReceive(mContext,
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
index cb1160cc1..6420fac88 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
@@ -637,18 +637,17 @@ public class WifiConnectivityManagerTest {
}
/**
- * When wifi is connected, {@link OpenNetworkNotifier} tries to clear the pending
- * notification and does not reset notification repeat delay.
+ * When wifi is connected, {@link OpenNetworkNotifier} handles the Wi-Fi connected behavior.
*
- * Expected behavior: ONA clears pending notification and does not reset repeat delay.
+ * Expected behavior: ONA handles connected behavior
*/
@Test
- public void wifiConnected_openNetworkNotifierClearsPendingNotification() {
+ public void wifiConnected_openNetworkNotifierHandlesConnection() {
// Set WiFi to connected state
mWifiConnectivityManager.handleConnectionStateChanged(
WifiConnectivityManager.WIFI_STATE_CONNECTED);
- verify(mOpenNetworkNotifier).clearPendingNotification(false /* resetRepeatDelay*/);
+ verify(mOpenNetworkNotifier).handleWifiConnected();
}
/**