Added autofill tests for dismissing UI on cancel().
Test: they are!
Bug: 64756889
Change-Id: Iaf4dd53abee419d3330050f442df9746f59f7588
diff --git a/tests/autofillservice/src/android/autofillservice/cts/DismissType.java b/tests/autofillservice/src/android/autofillservice/cts/DismissType.java
index ae9b9cd..17ee144 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/DismissType.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/DismissType.java
@@ -26,5 +26,6 @@
HOME_BUTTON,
RECENTS_BUTTON,
TOUCH_OUTSIDE,
- FOCUS_OUTSIDE
+ FOCUS_OUTSIDE,
+ AFM_CANCEL
}
diff --git a/tests/autofillservice/src/android/autofillservice/cts/LoginActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/LoginActivityTest.java
index 4354ad1..03c9bb7 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/LoginActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/LoginActivityTest.java
@@ -1211,6 +1211,10 @@
saveGoesAway(DismissType.TOUCH_OUTSIDE);
}
+ public void testSaveGoesAwayWhenCallingCancel() throws Exception {
+ saveGoesAway(DismissType.AFM_CANCEL);
+ }
+
private void saveGoesAway(DismissType dismissType) throws Exception {
enableService();
@@ -1256,6 +1260,9 @@
sUiBot.switchAppsUsingRecents();
sUiBot.assertShownByRelativeId(CheckoutActivity.ID_ADDRESS);
break;
+ case AFM_CANCEL:
+ mActivity.getAutofillManager().cancel();
+ break;
default:
throw new IllegalArgumentException("invalid dismiss type: " + dismissType);
}
@@ -3233,6 +3240,31 @@
listener.assertOnCancelCalled();
}
+ @Test
+ public void testDatasetPickerGoesAwayOnCancel() throws Exception {
+ // Set service.
+ enableService();
+
+ // Set expectations.
+ sReplier.addResponse(new CannedDataset.Builder()
+ .setField(ID_USERNAME, "dude")
+ .setPresentation(createPresentation("The Dude"))
+ .build());
+
+ // Trigger auto-fill.
+ mActivity.onUsername(View::requestFocus);
+ sReplier.getNextFillRequest();
+
+ // Make sure it's shown.
+ sUiBot.assertDatasets("The Dude");
+
+ // Then cancel..
+ mActivity.getAutofillManager().cancel();
+
+ // ...and make sure it isn't shown anymore.
+ sUiBot.assertNoDatasets();
+ }
+
private void startCheckoutActivityAsNewTask() {
final Context context = getContext();
final Intent intent = new Intent(context, CheckoutActivity.class);
diff --git a/tests/autofillservice/src/android/autofillservice/cts/SimpleSaveActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/SimpleSaveActivityTest.java
index b63f098..7add4fb 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/SimpleSaveActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/SimpleSaveActivityTest.java
@@ -189,6 +189,12 @@
dismissSaveTest(DismissType.RECENTS_BUTTON);
}
+ @Test
+ public void testDismissSave_byCallingCancel() throws Exception {
+ startActivity();
+ dismissSaveTest(DismissType.AFM_CANCEL);
+ }
+
private void dismissSaveTest(DismissType dismissType) throws Exception {
// Set service.
enableService();
@@ -229,6 +235,9 @@
sUiBot.switchAppsUsingRecents();
WelcomeActivity.assertShowingDefaultMessage(sUiBot);
break;
+ case AFM_CANCEL:
+ mActivity.getAutofillManager().cancel();
+ break;
default:
throw new IllegalArgumentException("invalid dismiss type: " + dismissType);
}