Commit 44bdf4ba authored by Changwan Ryu's avatar Changwan Ryu Committed by Commit Bot

Refactor AwAutofillTest

1) Move WebServer instantiation and shutdown into setUp() and tearDown()
2) UMATestHelper to have mWebServer
3) Move field block to the beginning of UMATestHelper
4) Reformatting due to git cl format

This makes the test more readable at the expense of doing additional
WebServer setUp/shutDown for a couple of test cases.

Otherwise, there is no other logic change.

Bug: 1065160
Test: AwAutofillTest test time remains the same. Doesn't seem to add new test flakiness.
Change-Id: Ideb659a20b4fb9bf998f8701c8ee6a8e182c9aae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2128985
Commit-Queue: Changwan Ryu <changwan@chromium.org>
Reviewed-by: default avatarTao Bai <michaelbai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756501}
parent 124a48bd
......@@ -31,6 +31,7 @@ import android.view.WindowManager;
import android.view.autofill.AutofillId;
import android.view.autofill.AutofillValue;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
......@@ -547,8 +548,24 @@ public class AwAutofillTest {
public static final int NO_FORM_SUBMISSION = -1;
public AwAutofillSessionUMATestHelper(AwAutofillTest test) {
private int mCnt;
private AwAutofillTest mTest;
private TestWebServer mWebServer;
private volatile Integer mSessionValue;
private HashMap<MetricsUtils.HistogramDelta, Integer> mSessionDelta;
private MetricsUtils.HistogramDelta mAutofillWebViewViewEnabled;
private MetricsUtils.HistogramDelta mAutofillWebViewViewDisabled;
private MetricsUtils.HistogramDelta mUserChangedAutofilledField;
private MetricsUtils.HistogramDelta mUserChangedNonAutofilledField;
private MetricsUtils.HistogramDelta mAutofillWebViewCreatedByActivityContext;
private MetricsUtils.HistogramDelta mAutofillWebViewCreatedByAppContext;
private volatile Integer mSourceValue;
private HashMap<MetricsUtils.HistogramDelta, Integer> mSubmissionSourceDelta;
private volatile Integer mHistogramSimpleCount;
public AwAutofillSessionUMATestHelper(AwAutofillTest test, TestWebServer webServer) {
mTest = test;
mWebServer = webServer;
initDeltaSamples();
}
......@@ -575,8 +592,8 @@ public class AwAutofillTest {
return value;
}
public void triggerAutofill(TestWebServer webServer) throws Throwable {
final String url = webServer.setResponse(FILE, DATA, null);
public void triggerAutofill() throws Throwable {
final String url = mWebServer.setResponse(FILE, DATA, null);
mTest.loadUrlSync(url);
mTest.executeJavaScriptAndWaitForResult("document.getElementById('text1').select();");
mTest.dispatchDownAndUpKeyEvents(KeyEvent.KEYCODE_A);
......@@ -715,25 +732,12 @@ public class AwAutofillTest {
assertEquals(0, mAutofillWebViewCreatedByAppContext.getDelta());
});
}
private int mCnt;
private AwAutofillTest mTest;
private volatile Integer mSessionValue;
private HashMap<MetricsUtils.HistogramDelta, Integer> mSessionDelta;
private MetricsUtils.HistogramDelta mAutofillWebViewViewEnabled;
private MetricsUtils.HistogramDelta mAutofillWebViewViewDisabled;
private MetricsUtils.HistogramDelta mUserChangedAutofilledField;
private MetricsUtils.HistogramDelta mUserChangedNonAutofilledField;
private MetricsUtils.HistogramDelta mAutofillWebViewCreatedByActivityContext;
private MetricsUtils.HistogramDelta mAutofillWebViewCreatedByAppContext;
private volatile Integer mSourceValue;
private HashMap<MetricsUtils.HistogramDelta, Integer> mSubmissionSourceDelta;
private volatile Integer mHistogramSimpleCount;
}
@Rule
public AwActivityTestRule mRule = new AwActivityTestRule();
private TestWebServer mWebServer;
private AwTestContainerView mTestContainerView;
private AwAutofillTestClient mContentsClient;
private CallbackHelper mCallbackHelper = new CallbackHelper();
......@@ -745,8 +749,9 @@ public class AwAutofillTest {
private AwAutofillSessionUMATestHelper mUMATestHelper;
@Before
public void setUp() {
mUMATestHelper = new AwAutofillSessionUMATestHelper(this);
public void setUp() throws Exception {
mWebServer = TestWebServer.start();
mUMATestHelper = new AwAutofillSessionUMATestHelper(this, mWebServer);
mContentsClient = new AwAutofillTestClient();
mTestContainerView = mRule.createAwTestContainerViewOnMainSync(
mContentsClient, false, new TestDependencyFactory() {
......@@ -762,6 +767,11 @@ public class AwAutofillTest {
AwActivityTestRule.enableJavaScriptOnUiThread(mAwContents);
}
@After
public void tearDown() {
mWebServer.shutdown();
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
......@@ -785,15 +795,13 @@ public class AwAutofillTest {
}
private void internalTestTriggerTest() throws Throwable {
TestWebServer webServer = TestWebServer.start();
final String data = "<html><head></head><body><form action='a.html' name='formname'>"
+ "<input type='text' id='text1' name='username'"
+ " placeholder='placeholder@placeholder.com' autocomplete='username name'>"
+ "<input type='submit'>"
+ "</form></body></html>";
try {
int cnt = 0;
final String url = webServer.setResponse(FILE, data, null);
final String url = mWebServer.setResponse(FILE, data, null);
loadUrlSync(url);
DOMUtils.waitForNonZeroNodeBounds(mAwContents.getWebContents(), "text1");
// Note that we currently depend on keyboard app's behavior.
......@@ -806,16 +814,12 @@ public class AwAutofillTest {
executeJavaScriptAndWaitForResult("document.getElementById('text1').blur();");
waitForCallbackAndVerifyTypes(cnt, new Integer[] {AUTOFILL_VIEW_EXITED});
} finally {
webServer.shutdown();
}
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
public void testBasicAutofill() throws Throwable {
TestWebServer webServer = TestWebServer.start();
final String data = "<html><head></head><body><form action='a.html' name='formname'>"
+ "<label>User Name:</label>"
+ "<input type='text' id='text1' name='name' maxlength='30'"
......@@ -832,9 +836,8 @@ public class AwAutofillTest {
+ "<input type='image' id='image1'>"
+ "</form></body></html>";
final int totalControls = 4; // text1, checkbox1, select1, textarea1
try {
int cnt = 0;
final String url = webServer.setResponse(FILE, data, null);
final String url = mWebServer.setResponse(FILE, data, null);
loadUrlSync(url);
executeJavaScriptAndWaitForResult("document.getElementById('text1').select();");
dispatchDownAndUpKeyEvents(KeyEvent.KEYCODE_A);
......@@ -847,15 +850,13 @@ public class AwAutofillTest {
// Verify form filled correctly in ViewStructure.
URL pageURL = new URL(url);
String webDomain =
new URL(pageURL.getProtocol(), pageURL.getHost(), pageURL.getPort(), "/")
String webDomain = new URL(pageURL.getProtocol(), pageURL.getHost(), pageURL.getPort(), "/")
.toString();
assertEquals(webDomain, viewStructure.getWebDomain());
// WebView shouldn't set class name.
assertNull(viewStructure.getClassName());
Bundle extras = viewStructure.getExtras();
assertEquals(
"AwAutofillTest", extras.getCharSequence("VIRTUAL_STRUCTURE_PROVIDER_NAME"));
assertEquals("AwAutofillTest", extras.getCharSequence("VIRTUAL_STRUCTURE_PROVIDER_NAME"));
assertTrue(0 < extras.getCharSequence("VIRTUAL_STRUCTURE_PROVIDER_VERSION").length());
TestViewStructure.AwHtmlInfo htmlInfoForm = viewStructure.getHtmlInfo();
assertEquals("form", htmlInfoForm.getTag());
......@@ -941,35 +942,30 @@ public class AwAutofillTest {
String value0 =
executeJavaScriptAndWaitForResult("document.getElementById('text1').value;");
assertEquals("\"example@example.com\"", value0);
String value1 = executeJavaScriptAndWaitForResult(
"document.getElementById('checkbox1').value;");
String value1 =
executeJavaScriptAndWaitForResult("document.getElementById('checkbox1').value;");
assertEquals("\"on\"", value1);
String value2 =
executeJavaScriptAndWaitForResult("document.getElementById('select1').value;");
assertEquals("\"2\"", value2);
String value3 = executeJavaScriptAndWaitForResult(
"document.getElementById('textarea1').value;");
String value3 =
executeJavaScriptAndWaitForResult("document.getElementById('textarea1').value;");
assertEquals("\"aaa\"", value3);
ArrayList<Pair<Integer, AutofillValue>> changedValues = getChangedValues();
assertEquals("example@example.com", changedValues.get(0).second.getTextValue());
assertTrue(changedValues.get(1).second.getToggleValue());
assertEquals(1, changedValues.get(2).second.getListValue());
} finally {
webServer.shutdown();
}
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
public void testNotifyVirtualValueChanged() throws Throwable {
TestWebServer webServer = TestWebServer.start();
final String data = "<html><head></head><body><form action='a.html' name='formname'>"
+ "<input type='text' id='text1' name='username'"
+ " placeholder='placeholder@placeholder.com' autocomplete='username name'>"
+ "</form></body></html>";
try {
final String url = webServer.setResponse(FILE, data, null);
final String url = mWebServer.setResponse(FILE, data, null);
loadUrlSync(url);
int cnt = 0;
executeJavaScriptAndWaitForResult("document.getElementById('text1').select();");
......@@ -992,22 +988,17 @@ public class AwAutofillTest {
assertEquals("a", values.get(0).second.getTextValue());
assertEquals("ab", values.get(1).second.getTextValue());
assertEquals(values.get(0).first, values.get(1).first);
} finally {
webServer.shutdown();
}
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
public void testJavascriptNotTriggerNotifyVirtualValueChanged() throws Throwable {
TestWebServer webServer = TestWebServer.start();
final String data = "<html><head></head><body><form action='a.html' name='formname'>"
+ "<input type='text' id='text1' name='username'"
+ " placeholder='placeholder@placeholder.com' autocomplete='username name'>"
+ "</form></body></html>";
try {
final String url = webServer.setResponse(FILE, data, null);
final String url = mWebServer.setResponse(FILE, data, null);
loadUrlSync(url);
int cnt = 0;
executeJavaScriptAndWaitForResult("document.getElementById('text1').select();");
......@@ -1034,16 +1025,12 @@ public class AwAutofillTest {
assertEquals("a", values.get(0).second.getTextValue());
assertEquals("cb", values.get(1).second.getTextValue());
assertEquals(values.get(0).first, values.get(1).first);
} finally {
webServer.shutdown();
}
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
public void testCommit() throws Throwable {
TestWebServer webServer = TestWebServer.start();
final String data =
"<html><head></head><body><form action='a.html' name='formname' id='formid'>"
+ "<input type='text' id='text1' name='username'"
......@@ -1051,8 +1038,7 @@ public class AwAutofillTest {
+ "<input type='password' id='passwordid' name='passwordname'"
+ "<input type='submit'>"
+ "</form></body></html>";
try {
final String url = webServer.setResponse(FILE, data, null);
final String url = mWebServer.setResponse(FILE, data, null);
loadUrlSync(url);
int cnt = 0;
executeJavaScriptAndWaitForResult("document.getElementById('text1').select();");
......@@ -1071,16 +1057,12 @@ public class AwAutofillTest {
// Submit form.
executeJavaScriptAndWaitForResult("document.getElementById('formid').submit();");
waitForCallbackAndVerifyTypes(cnt,
new Integer[] {
AUTOFILL_VALUE_CHANGED, AUTOFILL_VALUE_CHANGED, AUTOFILL_COMMIT});
new Integer[] {AUTOFILL_VALUE_CHANGED, AUTOFILL_VALUE_CHANGED, AUTOFILL_COMMIT});
ArrayList<Pair<Integer, AutofillValue>> values = getChangedValues();
assertEquals(2, values.size());
assertEquals("a", values.get(0).second.getTextValue());
assertEquals("b", values.get(1).second.getTextValue());
assertEquals(SubmissionSource.FORM_SUBMISSION, mSubmissionSource);
} finally {
webServer.shutdown();
}
}
@Test
......@@ -1100,7 +1082,6 @@ public class AwAutofillTest {
@SmallTest
@Feature({"AndroidWebView"})
public void testMovingToOtherForm() throws Throwable {
TestWebServer webServer = TestWebServer.start();
final String data =
"<html><head></head><body><form action='a.html' name='formname' id='formid'>"
+ "<input type='text' id='text1' name='username'"
......@@ -1111,9 +1092,8 @@ public class AwAutofillTest {
+ " placeholder='placeholder@placeholder.com' autocomplete='username name'>"
+ "<input type='submit'>"
+ "</form></body></html>";
try {
int cnt = 0;
final String url = webServer.setResponse(FILE, data, null);
final String url = mWebServer.setResponse(FILE, data, null);
loadUrlSync(url);
executeJavaScriptAndWaitForResult("document.getElementById('text1').select();");
dispatchDownAndUpKeyEvents(KeyEvent.KEYCODE_A);
......@@ -1125,9 +1105,6 @@ public class AwAutofillTest {
waitForCallbackAndVerifyTypes(cnt,
new Integer[] {AUTOFILL_CANCEL, AUTOFILL_VIEW_EXITED, AUTOFILL_VIEW_ENTERED,
AUTOFILL_VIEW_EXITED, AUTOFILL_VIEW_ENTERED, AUTOFILL_VALUE_CHANGED});
} finally {
webServer.shutdown();
}
}
/**
......@@ -1139,7 +1116,6 @@ public class AwAutofillTest {
public void testSwitchFromIFrame() throws Throwable {
// we intentionally load main frame and iframe from the same URL and make both have the
// similar form, so the new session is triggered by frame change
TestWebServer webServer = TestWebServer.start();
final String data = "<html><head></head><body><form name='formname' id='formid'>"
+ "<input type='text' id='text1' name='username'"
+ " placeholder='placeholder@placeholder.com' autocomplete='username name'>"
......@@ -1152,8 +1128,7 @@ public class AwAutofillTest {
+ " autofocus>"
+ "<input type='submit'></form>"
+ "</body></html>";
try {
final String url = webServer.setResponse(FILE, data, null);
final String url = mWebServer.setResponse(FILE, data, null);
mContentsClient.setShouldInterceptRequestImpl(
new AwAutofillTestClient.ShouldInterceptRequestImpl() {
private int mCallCount;
......@@ -1205,9 +1180,6 @@ public class AwAutofillTest {
assertEquals("false",
executeJavaScriptAndWaitForResult(
"document.getElementById('myframe').contentDocument.hasFocus()"));
} finally {
webServer.shutdown();
}
}
/**
......@@ -1218,26 +1190,20 @@ public class AwAutofillTest {
@Feature({"AndroidWebView"})
public void testTouchingPasswordFieldTriggerQuery() throws Throwable {
int cnt = 0;
TestWebServer webServer = TestWebServer.start();
final String data =
"<html><head></head><body><form action='a.html' name='formname' id='formid'>"
+ "<input type='password' id='passwordid' name='passwordname'"
+ "<input type='submit'>"
+ "</form></body></html>";
try {
final String url = webServer.setResponse(FILE, data, null);
final String url = mWebServer.setResponse(FILE, data, null);
loadUrlSync(url);
} finally {
webServer.shutdown();
DOMUtils.waitForNonZeroNodeBounds(mAwContents.getWebContents(), "passwordid");
// Note that we currently depend on keyboard app's behavior.
// TODO(changwan): mock out IME interaction.
Assert.assertTrue(
DOMUtils.clickNode(mTestContainerView.getWebContents(), "passwordid"));
Assert.assertTrue(DOMUtils.clickNode(mTestContainerView.getWebContents(), "passwordid"));
cnt += waitForCallbackAndVerifyTypes(
cnt, new Integer[] {AUTOFILL_CANCEL, AUTOFILL_VIEW_ENTERED});
}
}
/**
* This test is verifying the session is still alive after navigation.
......@@ -1247,7 +1213,6 @@ public class AwAutofillTest {
@Feature({"AndroidWebView"})
public void testSessionAliveAfterNavigation() throws Throwable {
int cnt = 0;
TestWebServer webServer = TestWebServer.start();
final String data = "<!DOCTYPE html>"
+ "<html>"
+ "<body>"
......@@ -1263,9 +1228,8 @@ public class AwAutofillTest {
+ "<body>"
+ "</body>"
+ "</html>";
try {
webServer.setResponse("/success.html", success, null);
final String url = webServer.setResponse(FILE, data, null);
mWebServer.setResponse("/success.html", success, null);
final String url = mWebServer.setResponse(FILE, data, null);
loadUrlSync(url);
executeJavaScriptAndWaitForResult("document.getElementById('text1').select();");
dispatchDownAndUpKeyEvents(KeyEvent.KEYCODE_A);
......@@ -1273,12 +1237,8 @@ public class AwAutofillTest {
new Integer[] {AUTOFILL_CANCEL, AUTOFILL_VIEW_ENTERED, AUTOFILL_VALUE_CHANGED});
executeJavaScriptAndWaitForResult("window.location.href = 'success.html'; ");
waitForCallbackAndVerifyTypes(cnt,
new Integer[] {
AUTOFILL_VALUE_CHANGED, AUTOFILL_VALUE_CHANGED, AUTOFILL_COMMIT});
new Integer[] {AUTOFILL_VALUE_CHANGED, AUTOFILL_VALUE_CHANGED, AUTOFILL_COMMIT});
assertEquals(SubmissionSource.PROBABLY_FORM_SUBMITTED, mSubmissionSource);
} finally {
webServer.shutdown();
}
}
/**
......@@ -1290,7 +1250,6 @@ public class AwAutofillTest {
@Feature({"AndroidWebView"})
public void testNoSubmissionWithoutFillingForm() throws Throwable {
int cnt = 0;
TestWebServer webServer = TestWebServer.start();
final String data = "<!DOCTYPE html>"
+ "<html>"
+ "<body>"
......@@ -1306,16 +1265,12 @@ public class AwAutofillTest {
+ "<body>"
+ "</body>"
+ "</html>";
try {
final String successUrl = webServer.setResponse("/success.html", success, null);
final String url = webServer.setResponse(FILE, data, null);
final String successUrl = mWebServer.setResponse("/success.html", success, null);
final String url = mWebServer.setResponse(FILE, data, null);
loadUrlSync(url);
executeJavaScriptAndWaitForResult("window.location.href = 'success.html'; ");
// There is no callback. AUTOFILL_CANCEL shouldn't be invoked.
assertEquals(0, getCallbackCount());
} finally {
webServer.shutdown();
}
}
@Test
......@@ -1326,7 +1281,6 @@ public class AwAutofillTest {
public void
testSelectControlChangeNotification() throws Throwable {
int cnt = 0;
TestWebServer webServer = TestWebServer.start();
final String data = "<!DOCTYPE html>"
+ "<html>"
+ "<body>"
......@@ -1337,8 +1291,7 @@ public class AwAutofillTest {
+ "</form>"
+ "</body>"
+ "</html>";
try {
final String url = webServer.setResponse(FILE, data, null);
final String url = mWebServer.setResponse(FILE, data, null);
loadUrlSync(url);
executeJavaScriptAndWaitForResult("document.getElementById('text1').select();");
dispatchDownAndUpKeyEvents(KeyEvent.KEYCODE_A);
......@@ -1356,9 +1309,6 @@ public class AwAutofillTest {
assertEquals(1, values.size());
assertTrue(values.get(0).second.isList());
assertEquals(1, values.get(0).second.getListValue());
} finally {
webServer.shutdown();
}
}
@Test
......@@ -1369,7 +1319,6 @@ public class AwAutofillTest {
public void
testSelectControlChangeStartAutofillSession() throws Throwable {
int cnt = 0;
TestWebServer webServer = TestWebServer.start();
final String data = "<!DOCTYPE html>"
+ "<html>"
+ "<body>"
......@@ -1380,8 +1329,7 @@ public class AwAutofillTest {
+ "</form>"
+ "</body>"
+ "</html>";
try {
final String url = webServer.setResponse(FILE, data, null);
final String url = mWebServer.setResponse(FILE, data, null);
loadUrlSync(url);
// Change select control first shall start autofill session.
dispatchDownAndUpKeyEvents(KeyEvent.KEYCODE_SPACE);
......@@ -1407,9 +1355,6 @@ public class AwAutofillTest {
// The field has no scroll, should always be zero.
assertEquals(0, viewStructure.getChild(1).getDimensScrollX());
assertEquals(0, viewStructure.getChild(1).getDimensScrollY());
} finally {
webServer.shutdown();
}
}
@Test
......@@ -1417,7 +1362,6 @@ public class AwAutofillTest {
@Feature({"AndroidWebView"})
public void testUserInitiatedJavascriptSelectControlChangeNotification() throws Throwable {
int cnt = 0;
TestWebServer webServer = TestWebServer.start();
final String data = "<!DOCTYPE html>"
+ "<html>"
+ "<body>"
......@@ -1433,8 +1377,7 @@ public class AwAutofillTest {
+ "</form>"
+ "</body>"
+ "</html>";
try {
final String url = webServer.setResponse(FILE, data, null);
final String url = mWebServer.setResponse(FILE, data, null);
loadUrlSync(url);
// Change select control first shall start autofill session.
dispatchDownAndUpKeyEvents(KeyEvent.KEYCODE_SPACE);
......@@ -1444,9 +1387,6 @@ public class AwAutofillTest {
assertEquals(1, values.size());
assertTrue(values.get(0).second.isList());
assertEquals(1, values.get(0).second.getListValue());
} finally {
webServer.shutdown();
}
}
@Test
......@@ -1454,7 +1394,6 @@ public class AwAutofillTest {
@Feature({"AndroidWebView"})
public void testJavascriptNotTriggerSelectControlChangeNotification() throws Throwable {
int cnt = 0;
TestWebServer webServer = TestWebServer.start();
final String data = "<!DOCTYPE html>"
+ "<html>"
+ "<body onload='myFunction();'>"
......@@ -1470,8 +1409,7 @@ public class AwAutofillTest {
+ "</form>"
+ "</body>"
+ "</html>";
try {
final String url = webServer.setResponse(FILE, data, null);
final String url = mWebServer.setResponse(FILE, data, null);
loadUrlSync(url);
// 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
......@@ -1485,16 +1423,12 @@ public class AwAutofillTest {
assertEquals(1, values.size());
assertTrue(values.get(0).second.isList());
assertEquals(1, values.get(0).second.getListValue());
} finally {
webServer.shutdown();
}
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
public void testUaAutofillHints() throws Throwable {
TestWebServer webServer = TestWebServer.start();
final String data = "<html><head></head><body><form action='a.html' name='formname'>"
+ "<label for=\"frmAddressB\">Address</label>"
+ "<input name=\"bill-address\" id=\"frmAddressB\">"
......@@ -1510,9 +1444,8 @@ public class AwAutofillTest {
+ "<input type='submit'>"
+ "</form></body></html>";
final int totalControls = 6;
try {
int cnt = 0;
final String url = webServer.setResponse(FILE, data, null);
final String url = mWebServer.setResponse(FILE, data, null);
loadUrlSync(url);
executeJavaScriptAndWaitForResult("document.getElementById('frmAddressB').select();");
dispatchDownAndUpKeyEvents(KeyEvent.KEYCODE_A);
......@@ -1546,18 +1479,13 @@ public class AwAutofillTest {
TestViewStructure child5 = viewStructure.getChild(5);
TestViewStructure.AwHtmlInfo htmlInfo5 = child5.getHtmlInfo();
assertEquals("ADDRESS_HOME_COUNTRY", htmlInfo5.getAttribute("ua-autofill-hints"));
} finally {
webServer.shutdown();
}
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
public void testUMAUserSelectSuggestionUserChangeFormFormSubmitted() throws Throwable {
TestWebServer webServer = TestWebServer.start();
try {
mUMATestHelper.triggerAutofill(webServer);
mUMATestHelper.triggerAutofill();
invokeOnProvideAutoFillVirtualStructure();
invokeOnInputUIShown();
mUMATestHelper.simulateUserSelectSuggestion();
......@@ -1567,87 +1495,65 @@ public class AwAutofillTest {
mUMATestHelper.getSessionValue());
assertEquals(
AutofillProviderUMA.FORM_SUBMISSION, mUMATestHelper.getSubmissionSourceValue());
} finally {
webServer.shutdown();
}
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
public void testUMAUserSelectSuggestionUserChangeFormNoFormSubmitted() throws Throwable {
TestWebServer webServer = TestWebServer.start();
try {
mUMATestHelper.triggerAutofill(webServer);
mUMATestHelper.triggerAutofill();
invokeOnProvideAutoFillVirtualStructure();
invokeOnInputUIShown();
mUMATestHelper.simulateUserSelectSuggestion();
mUMATestHelper.simulateUserChangeField();
mUMATestHelper.startNewSession();
assertEquals(
AutofillProviderUMA.USER_SELECT_SUGGESTION_USER_CHANGE_FORM_NO_FORM_SUBMITTED,
assertEquals(AutofillProviderUMA.USER_SELECT_SUGGESTION_USER_CHANGE_FORM_NO_FORM_SUBMITTED,
mUMATestHelper.getSessionValue());
assertEquals(AwAutofillSessionUMATestHelper.NO_FORM_SUBMISSION,
mUMATestHelper.getSubmissionSourceValue());
} finally {
webServer.shutdown();
}
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
public void testUMAUserSelectNotSuggestionUserChangeFormNoFormSubmitted() throws Throwable {
TestWebServer webServer = TestWebServer.start();
try {
int count = mUMATestHelper.getHistogramSampleCount(
AutofillProviderUMA.UMA_AUTOFILL_SUGGESTION_TIME);
mUMATestHelper.triggerAutofill(webServer);
mUMATestHelper.triggerAutofill();
invokeOnProvideAutoFillVirtualStructure();
invokeOnInputUIShown();
mUMATestHelper.simulateUserChangeField();
mUMATestHelper.startNewSession();
assertEquals(AutofillProviderUMA
.USER_NOT_SELECT_SUGGESTION_USER_CHANGE_FORM_NO_FORM_SUBMITTED,
assertEquals(
AutofillProviderUMA.USER_NOT_SELECT_SUGGESTION_USER_CHANGE_FORM_NO_FORM_SUBMITTED,
mUMATestHelper.getSessionValue());
assertEquals(AwAutofillSessionUMATestHelper.NO_FORM_SUBMISSION,
mUMATestHelper.getSubmissionSourceValue());
assertEquals(count + 1,
mUMATestHelper.getHistogramSampleCount(
AutofillProviderUMA.UMA_AUTOFILL_SUGGESTION_TIME));
} finally {
webServer.shutdown();
}
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
public void testUMAUserNotSelectSuggestionUserChangeFormFormSubmitted() throws Throwable {
TestWebServer webServer = TestWebServer.start();
try {
mUMATestHelper.triggerAutofill(webServer);
mUMATestHelper.triggerAutofill();
invokeOnProvideAutoFillVirtualStructure();
invokeOnInputUIShown();
mUMATestHelper.simulateUserChangeField();
mUMATestHelper.submitForm();
assertEquals(
AutofillProviderUMA.USER_NOT_SELECT_SUGGESTION_USER_CHANGE_FORM_FORM_SUBMITTED,
assertEquals(AutofillProviderUMA.USER_NOT_SELECT_SUGGESTION_USER_CHANGE_FORM_FORM_SUBMITTED,
mUMATestHelper.getSessionValue());
assertEquals(
AutofillProviderUMA.FORM_SUBMISSION, mUMATestHelper.getSubmissionSourceValue());
} finally {
webServer.shutdown();
}
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
public void testUMANoSuggestionUserChangeFormNoFormSubmitted() throws Throwable {
TestWebServer webServer = TestWebServer.start();
try {
mUMATestHelper.triggerAutofill(webServer);
mUMATestHelper.triggerAutofill();
invokeOnProvideAutoFillVirtualStructure();
mUMATestHelper.simulateUserChangeField();
mUMATestHelper.startNewSession();
......@@ -1656,18 +1562,13 @@ public class AwAutofillTest {
assertEquals(AwAutofillSessionUMATestHelper.NO_FORM_SUBMISSION,
mUMATestHelper.getSubmissionSourceValue());
mUMATestHelper.verifyUserChangedNonAutofilledField();
} finally {
webServer.shutdown();
}
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
public void testUMANoSuggestionUserChangeFormFormSubmitted() throws Throwable {
TestWebServer webServer = TestWebServer.start();
try {
mUMATestHelper.triggerAutofill(webServer);
mUMATestHelper.triggerAutofill();
invokeOnProvideAutoFillVirtualStructure();
mUMATestHelper.simulateUserChangeField();
mUMATestHelper.submitForm();
......@@ -1676,62 +1577,46 @@ public class AwAutofillTest {
assertEquals(
AutofillProviderUMA.FORM_SUBMISSION, mUMATestHelper.getSubmissionSourceValue());
mUMATestHelper.verifyUserChangedNonAutofilledField();
} finally {
webServer.shutdown();
}
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
public void testUMAUserSelectSuggestionUserNotChangeFormFormSubmitted() throws Throwable {
TestWebServer webServer = TestWebServer.start();
try {
mUMATestHelper.triggerAutofill(webServer);
mUMATestHelper.triggerAutofill();
invokeOnProvideAutoFillVirtualStructure();
invokeOnInputUIShown();
mUMATestHelper.simulateUserSelectSuggestion();
mUMATestHelper.submitForm();
assertEquals(
AutofillProviderUMA.USER_SELECT_SUGGESTION_USER_NOT_CHANGE_FORM_FORM_SUBMITTED,
assertEquals(AutofillProviderUMA.USER_SELECT_SUGGESTION_USER_NOT_CHANGE_FORM_FORM_SUBMITTED,
mUMATestHelper.getSessionValue());
assertEquals(
AutofillProviderUMA.FORM_SUBMISSION, mUMATestHelper.getSubmissionSourceValue());
mUMATestHelper.verifyUserDidntChangeForm();
} finally {
webServer.shutdown();
}
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
public void testUMAUserSelectSuggestionUserNotChangeFormNoFormSubmitted() throws Throwable {
TestWebServer webServer = TestWebServer.start();
try {
mUMATestHelper.triggerAutofill(webServer);
mUMATestHelper.triggerAutofill();
invokeOnProvideAutoFillVirtualStructure();
invokeOnInputUIShown();
mUMATestHelper.simulateUserSelectSuggestion();
mUMATestHelper.startNewSession();
assertEquals(AutofillProviderUMA
.USER_SELECT_SUGGESTION_USER_NOT_CHANGE_FORM_NO_FORM_SUBMITTED,
assertEquals(
AutofillProviderUMA.USER_SELECT_SUGGESTION_USER_NOT_CHANGE_FORM_NO_FORM_SUBMITTED,
mUMATestHelper.getSessionValue());
assertEquals(AwAutofillSessionUMATestHelper.NO_FORM_SUBMISSION,
mUMATestHelper.getSubmissionSourceValue());
mUMATestHelper.verifyUserDidntChangeForm();
} finally {
webServer.shutdown();
}
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
public void testUMAUserSelectNotSuggestionUserNotChangeFormNoFormSubmitted() throws Throwable {
TestWebServer webServer = TestWebServer.start();
try {
mUMATestHelper.triggerAutofill(webServer);
mUMATestHelper.triggerAutofill();
invokeOnProvideAutoFillVirtualStructure();
invokeOnInputUIShown();
mUMATestHelper.startNewSession();
......@@ -1741,39 +1626,29 @@ public class AwAutofillTest {
assertEquals(AwAutofillSessionUMATestHelper.NO_FORM_SUBMISSION,
mUMATestHelper.getSubmissionSourceValue());
mUMATestHelper.verifyUserDidntChangeForm();
} finally {
webServer.shutdown();
}
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
public void testUMAUserNotSelectSuggestionUserNotChangeFormFormSubmitted() throws Throwable {
TestWebServer webServer = TestWebServer.start();
try {
mUMATestHelper.triggerAutofill(webServer);
mUMATestHelper.triggerAutofill();
invokeOnProvideAutoFillVirtualStructure();
invokeOnInputUIShown();
mUMATestHelper.submitForm();
assertEquals(AutofillProviderUMA
.USER_NOT_SELECT_SUGGESTION_USER_NOT_CHANGE_FORM_FORM_SUBMITTED,
assertEquals(
AutofillProviderUMA.USER_NOT_SELECT_SUGGESTION_USER_NOT_CHANGE_FORM_FORM_SUBMITTED,
mUMATestHelper.getSessionValue());
assertEquals(
AutofillProviderUMA.FORM_SUBMISSION, mUMATestHelper.getSubmissionSourceValue());
mUMATestHelper.verifyUserDidntChangeForm();
} finally {
webServer.shutdown();
}
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
public void testUMANoSuggestionUserNotChangeFormNoFormSubmitted() throws Throwable {
TestWebServer webServer = TestWebServer.start();
try {
mUMATestHelper.triggerAutofill(webServer);
mUMATestHelper.triggerAutofill();
invokeOnProvideAutoFillVirtualStructure();
mUMATestHelper.startNewSession();
assertEquals(AutofillProviderUMA.NO_SUGGESTION_USER_NOT_CHANGE_FORM_NO_FORM_SUBMITTED,
......@@ -1781,18 +1656,13 @@ public class AwAutofillTest {
assertEquals(AwAutofillSessionUMATestHelper.NO_FORM_SUBMISSION,
mUMATestHelper.getSubmissionSourceValue());
mUMATestHelper.verifyUserDidntChangeForm();
} finally {
webServer.shutdown();
}
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
public void testUMANoSuggestionUserNotChangeFormFormSubmitted() throws Throwable {
TestWebServer webServer = TestWebServer.start();
try {
mUMATestHelper.triggerAutofill(webServer);
mUMATestHelper.triggerAutofill();
invokeOnProvideAutoFillVirtualStructure();
mUMATestHelper.submitForm();
assertEquals(AutofillProviderUMA.NO_SUGGESTION_USER_NOT_CHANGE_FORM_FORM_SUBMITTED,
......@@ -1800,26 +1670,18 @@ public class AwAutofillTest {
assertEquals(
AutofillProviderUMA.FORM_SUBMISSION, mUMATestHelper.getSubmissionSourceValue());
mUMATestHelper.verifyUserDidntChangeForm();
} finally {
webServer.shutdown();
}
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
public void testUMANoCallbackFromFramework() throws Throwable {
TestWebServer webServer = TestWebServer.start();
try {
mUMATestHelper.triggerAutofill(webServer);
mUMATestHelper.triggerAutofill();
mUMATestHelper.startNewSession();
assertEquals(AutofillProviderUMA.NO_CALLBACK_FORM_FRAMEWORK,
mUMATestHelper.getSessionValue());
assertEquals(
AutofillProviderUMA.NO_CALLBACK_FORM_FRAMEWORK, mUMATestHelper.getSessionValue());
assertEquals(AwAutofillSessionUMATestHelper.NO_FORM_SUBMISSION,
mUMATestHelper.getSubmissionSourceValue());
} finally {
webServer.shutdown();
}
}
@Test
......@@ -1827,39 +1689,27 @@ public class AwAutofillTest {
@Feature({"AndroidWebView"})
public void testUMAAutofillDisabled() throws Throwable {
mTestAutofillManagerWrapper.setDisabled();
TestWebServer webServer = TestWebServer.start();
try {
mUMATestHelper.triggerAutofill(webServer);
mUMATestHelper.triggerAutofill();
mUMATestHelper.verifyAutofillDisabled();
assertEquals(AwAutofillSessionUMATestHelper.NO_FORM_SUBMISSION,
mUMATestHelper.getSubmissionSourceValue());
} finally {
webServer.shutdown();
}
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
public void testUMAAutofillEnabled() throws Throwable {
TestWebServer webServer = TestWebServer.start();
try {
mUMATestHelper.triggerAutofill(webServer);
mUMATestHelper.triggerAutofill();
mUMATestHelper.verifyAutofillEnabled();
assertEquals(AwAutofillSessionUMATestHelper.NO_FORM_SUBMISSION,
mUMATestHelper.getSubmissionSourceValue());
} finally {
webServer.shutdown();
}
}
@Test
@SmallTest
@Feature({"AndroidWebView"})
public void testUMAUserChangeAutofilledField() throws Throwable {
TestWebServer webServer = TestWebServer.start();
try {
mUMATestHelper.triggerAutofill(webServer);
mUMATestHelper.triggerAutofill();
invokeOnProvideAutoFillVirtualStructure();
invokeOnInputUIShown();
mUMATestHelper.simulateUserSelectSuggestion();
......@@ -1870,9 +1720,6 @@ public class AwAutofillTest {
assertEquals(
AutofillProviderUMA.FORM_SUBMISSION, mUMATestHelper.getSubmissionSourceValue());
mUMATestHelper.verifyUserChangedAutofilledField();
} finally {
webServer.shutdown();
}
}
@Test
......@@ -1887,13 +1734,11 @@ public class AwAutofillTest {
@Feature({"AndroidWebView"})
@FlakyTest(message = "crbug.com/1033179")
public void testPageScrollTriggerViewExitAndEnter() throws Throwable {
TestWebServer webServer = TestWebServer.start();
final String data = "<html><head></head><body><form action='a.html' name='formname'>"
+ "<input type='text' id='text1' name='username'"
+ " placeholder='placeholder@placeholder.com' autocomplete='username name'>"
+ "</form><p style='height: 100vh'>Hello</p></body></html>";
try {
final String url = webServer.setResponse(FILE, data, null);
final String url = mWebServer.setResponse(FILE, data, null);
loadUrlSync(url);
int cnt = 0;
executeJavaScriptAndWaitForResult("document.getElementById('text1').select();");
......@@ -1915,12 +1760,9 @@ public class AwAutofillTest {
}
// Check if NotifyVirtualValueChanged() called again and with extra AUTOFILL_VIEW_EXITED
// and AUTOFILL_VIEW_ENTERED
expectedValues.addAll(Arrays.asList(
AUTOFILL_VIEW_EXITED, AUTOFILL_VIEW_ENTERED, AUTOFILL_VALUE_CHANGED));
expectedValues.addAll(
Arrays.asList(AUTOFILL_VIEW_EXITED, AUTOFILL_VIEW_ENTERED, AUTOFILL_VALUE_CHANGED));
waitForCallbackAndVerifyTypes(cnt, expectedValues.toArray(new Integer[0]));
} finally {
webServer.shutdown();
}
}
private void scrollToBottom() {
......
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