Split testFillResponseAuthServiceHasNoData into 2 cases:
- testFillResponseAuthServiceHasNoData
- testFillResponseAuthServiceHasNoDataButCanSave
Test: cts-tradefed run commandAndExit cts-dev -m CtsAutoFillServiceTestCases
Bug: 64985246
Change-Id: I5c36a4fa40ea324f168264fbfd6db1d23284c525
diff --git a/tests/autofillservice/src/android/autofillservice/cts/AuthenticationActivity.java b/tests/autofillservice/src/android/autofillservice/cts/AuthenticationActivity.java
index b20e844..570de4e 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/AuthenticationActivity.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/AuthenticationActivity.java
@@ -16,6 +16,8 @@
package android.autofillservice.cts;
+import static android.autofillservice.cts.CannedFillResponse.ResponseType.NULL;
+
import static com.google.common.truth.Truth.assertWithMessage;
import android.app.Activity;
@@ -196,7 +198,12 @@
final Parcelable result;
if (response != null) {
- result = response.asFillResponse((id) -> Helper.findNodeByResourceId(structure, id));
+ if (response.getResponseType() == NULL) {
+ result = null;
+ } else {
+ result = response
+ .asFillResponse((id) -> Helper.findNodeByResourceId(structure, id));
+ }
} else if (dataset != null) {
result = dataset.asDataset((id) -> Helper.findNodeByResourceId(structure, id));
} else {
diff --git a/tests/autofillservice/src/android/autofillservice/cts/LoginActivityTest.java b/tests/autofillservice/src/android/autofillservice/cts/LoginActivityTest.java
index 206f180..0c8970d 100644
--- a/tests/autofillservice/src/android/autofillservice/cts/LoginActivityTest.java
+++ b/tests/autofillservice/src/android/autofillservice/cts/LoginActivityTest.java
@@ -1800,16 +1800,29 @@
}
@Test
+ public void testFillResponseAuthServiceHasNoDataButCanSave() throws Exception {
+ fillResponseAuthServiceHasNoDataTest(true);
+ }
+
+ @Test
public void testFillResponseAuthServiceHasNoData() throws Exception {
+ fillResponseAuthServiceHasNoDataTest(false);
+ }
+
+ private void fillResponseAuthServiceHasNoDataTest(boolean canSave) throws Exception {
// Set service.
enableService();
final MyAutofillCallback callback = mActivity.registerCallback();
// Prepare the authenticated response
- final IntentSender authentication = AuthenticationActivity.createSender(mContext, 1,
- new CannedFillResponse.Builder()
+ final CannedFillResponse response = canSave
+ ? new CannedFillResponse.Builder()
.setRequiredSavableIds(SAVE_DATA_TYPE_PASSWORD, ID_USERNAME, ID_PASSWORD)
- .build());
+ .build()
+ : CannedFillResponse.NO_RESPONSE;
+
+ final IntentSender authentication =
+ AuthenticationActivity.createSender(mContext, 1, response);
// Configure the service behavior
sReplier.addResponse(new CannedFillResponse.Builder()