summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNate Jiang <qiangjiang@google.com>2020-03-18 22:57:24 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-03-18 22:57:24 +0000
commitac798f2ce039778139e24966af87e391d451ac6d (patch)
tree59e639d229d25539cf6c743f73ea6a93aa9097e2 /tests
parent06610231a412585e265e297afa7a11619b7d0fa0 (diff)
parent4022d947442b1042e6db37454b8adfcbc57f4bca (diff)
Merge "Imsi protection exemption notification with dialog" into rvc-dev
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java41
1 files changed, 33 insertions, 8 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
index 58a47841f..0ec2eb92c 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
@@ -222,16 +222,29 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
.thenReturn("blah");
// setup resource strings for IMSI protection notification.
- when(mResources.getString(eq(R.string.wifi_suggestion_imsi_privacy_title)))
- .thenReturn("blah");
- when(mResources.getString(eq(R.string.wifi_suggestion_imsi_privacy_content), anyString()))
+ when(mResources.getString(eq(R.string.wifi_suggestion_imsi_privacy_title), anyString()))
.thenAnswer(s -> "blah" + s.getArguments()[1]);
+ when(mResources.getString(eq(R.string.wifi_suggestion_imsi_privacy_content)))
+ .thenReturn("blah");
when(mResources.getText(
eq(R.string.wifi_suggestion_action_allow_imsi_privacy_exemption_carrier)))
.thenReturn("blah");
when(mResources.getText(
eq(R.string.wifi_suggestion_action_disallow_imsi_privacy_exemption_carrier)))
.thenReturn("blah");
+ when(mResources.getString(
+ eq(R.string.wifi_suggestion_imsi_privacy_exemption_confirmation_title)))
+ .thenReturn("blah");
+ when(mResources.getString(
+ eq(R.string.wifi_suggestion_imsi_privacy_exemption_confirmation_content),
+ anyString())).thenAnswer(s -> "blah" + s.getArguments()[1]);
+ when(mResources.getText(
+ eq(R.string.wifi_suggestion_action_allow_imsi_privacy_exemption_confirmation)))
+ .thenReturn("blah");
+ when(mResources.getText(
+ eq(R.string.wifi_suggestion_action_disallow_imsi_privacy_exemption_confirmation)))
+ .thenReturn("blah");
+
// Our app Info. Needed for notification builder.
ApplicationInfo ourAppInfo = new ApplicationInfo();
@@ -2719,12 +2732,12 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
verify(mNotificationManger, atLeastOnce()).notify(
eq(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE),
eq(mNotification));
- ArgumentCaptor<Notification.BigTextStyle> contentCaptor =
- ArgumentCaptor.forClass(Notification.BigTextStyle.class);
- verify(mNotificationBuilder, atLeastOnce()).setStyle(contentCaptor.capture());
- Notification.BigTextStyle content = contentCaptor.getValue();
+ ArgumentCaptor<CharSequence> contentCaptor =
+ ArgumentCaptor.forClass(CharSequence.class);
+ verify(mNotificationBuilder, atLeastOnce()).setContentTitle(contentCaptor.capture());
+ CharSequence content = contentCaptor.getValue();
assertNotNull(content);
- assertTrue(content.getBigText().toString().contains(carrierName));
+ assertTrue(content.toString().contains(carrierName));
}
private void validateUserApprovalDialog(String... anyOfExpectedAppNames) {
@@ -3398,7 +3411,19 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
sendBroadcastForUserActionOnImsi(NOTIFICATION_USER_ALLOWED_CARRIER_INTENT_ACTION,
TEST_CARRIER_NAME, TEST_CARRIER_ID);
verify(mNotificationManger).cancel(SystemMessage.NOTE_NETWORK_SUGGESTION_AVAILABLE);
+ validateUserApprovalDialog(TEST_CARRIER_NAME);
+ // Simulate user clicking on allow in the dialog.
+ ArgumentCaptor<DialogInterface.OnClickListener> clickListenerCaptor =
+ ArgumentCaptor.forClass(DialogInterface.OnClickListener.class);
+ verify(mAlertDialogBuilder, atLeastOnce()).setPositiveButton(
+ any(), clickListenerCaptor.capture());
+ assertNotNull(clickListenerCaptor.getValue());
+ clickListenerCaptor.getValue().onClick(mAlertDialog, 0);
+ mLooper.dispatchAll();
+ ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class);
+ verify(mContext).sendBroadcast(intentCaptor.capture());
+ assertEquals(Intent.ACTION_CLOSE_SYSTEM_DIALOGS, intentCaptor.getValue().getAction());
verify(mWifiConfigManager, times(2)).saveToStore(true);
assertTrue(mImsiDataSource.hasNewDataToSerialize());
matchedSuggestion = mWifiNetworkSuggestionsManager