Commit d851e3e0 authored by Tao Bai's avatar Tao Bai Committed by Commit Bot

Fix the Autofill Test failure in debug build

In debug build, there is assert to verify the expected callback is
larger than zero, so the previous test won't work.

This patch simulates user triggering autofill and verifies autofill
is triggered once, that proves javascript change didn't trigger the
autofill.

Bug: 1001309
Change-Id: I2cb9e384f14e98cee9380ccef51b3cc8b8bbc2f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1802683
Commit-Queue: Tao Bai <michaelbai@chromium.org>
Reviewed-by: default avatarChangwan Ryu <changwan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697792}
parent f4a2ba13
...@@ -79,11 +79,11 @@ public class AwAutofillTest { ...@@ -79,11 +79,11 @@ public class AwAutofillTest {
public static final String FILE = "/login.html"; public static final String FILE = "/login.html";
public static final String FILE_URL = "file:///android_asset/autofill.html"; public static final String FILE_URL = "file:///android_asset/autofill.html";
public final static int AUTOFILL_VIEW_ENTERED = 1; public static final int AUTOFILL_VIEW_ENTERED = 1;
public final static int AUTOFILL_VIEW_EXITED = 2; public static final int AUTOFILL_VIEW_EXITED = 2;
public final static int AUTOFILL_VALUE_CHANGED = 3; public static final int AUTOFILL_VALUE_CHANGED = 3;
public final static int AUTOFILL_COMMIT = 4; public static final int AUTOFILL_COMMIT = 4;
public final static int AUTOFILL_CANCEL = 5; public static final int AUTOFILL_CANCEL = 5;
/** /**
* This class only implements the necessary methods of ViewStructure for testing. * This class only implements the necessary methods of ViewStructure for testing.
...@@ -509,7 +509,7 @@ public class AwAutofillTest { ...@@ -509,7 +509,7 @@ public class AwAutofillTest {
} }
private static class AwAutofillSessionUMATestHelper { private static class AwAutofillSessionUMATestHelper {
private final static String DATA = private static final String DATA =
"<html><head></head><body><form action='a.html' name='formname' id='formid'>" "<html><head></head><body><form action='a.html' name='formname' id='formid'>"
+ "<label>User Name:</label>" + "<label>User Name:</label>"
+ "<input type='text' id='text1' name='username'" + "<input type='text' id='text1' name='username'"
...@@ -518,9 +518,9 @@ public class AwAutofillTest { ...@@ -518,9 +518,9 @@ public class AwAutofillTest {
+ "</form>" + "</form>"
+ "<form><input type='text' id='text2'/></form></body></html>"; + "<form><input type='text' id='text2'/></form></body></html>";
private final static int TOTAL_CONTROLS = 1; // text1 private static final int TOTAL_CONTROLS = 1; // text1
public final static int NO_FORM_SUBMISSION = -1; public static final int NO_FORM_SUBMISSION = -1;
public AwAutofillSessionUMATestHelper(AwAutofillTest test) { public AwAutofillSessionUMATestHelper(AwAutofillTest test) {
mTest = test; mTest = test;
...@@ -1437,7 +1437,19 @@ public class AwAutofillTest { ...@@ -1437,7 +1437,19 @@ public class AwAutofillTest {
try { try {
final String url = webServer.setResponse(FILE, data, null); final String url = webServer.setResponse(FILE, data, null);
loadUrlSync(url); loadUrlSync(url);
waitForCallbackAndVerifyTypes(cnt, new Integer[] {}); // There is no good way to verify no callback occurred, we just simulate user trigger
// the autofill and verify autofill is only triggered once, then this proves javascript
// didn't trigger the autofill, since
// testUserInitiatedJavascriptSelectControlChangeNotification verified user's triggering
// work.
dispatchDownAndUpKeyEvents(KeyEvent.KEYCODE_DPAD_CENTER);
cnt += waitForCallbackAndVerifyTypes(cnt,
new Integer[] {AUTOFILL_CANCEL, AUTOFILL_VIEW_ENTERED, AUTOFILL_VIEW_EXITED,
AUTOFILL_VIEW_ENTERED, AUTOFILL_VALUE_CHANGED});
ArrayList<Pair<Integer, AutofillValue>> values = getChangedValues();
assertEquals(1, values.size());
assertTrue(values.get(0).second.isList());
assertEquals(1, values.get(0).second.getListValue());
} finally { } finally {
webServer.shutdown(); webServer.shutdown();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment