| Index: chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillPopupTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillPopupTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillPopupTest.java
|
| index 6f193c5a38408915cc59a8c63d4e68627d8b1ef8..9c4540d69a186d823c33ccf6c1b81d55550e9370 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillPopupTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillPopupTest.java
|
| @@ -9,12 +9,21 @@ import android.text.TextUtils;
|
| import android.view.View;
|
| import android.view.ViewGroup;
|
|
|
| +import org.junit.Assert;
|
| +import org.junit.Before;
|
| +import org.junit.Rule;
|
| +import org.junit.Test;
|
| +import org.junit.runner.RunWith;
|
| +
|
| +import org.chromium.base.test.util.CommandLineFlags;
|
| import org.chromium.base.test.util.Feature;
|
| import org.chromium.base.test.util.RetryOnFailure;
|
| import org.chromium.base.test.util.UrlUtils;
|
| import org.chromium.chrome.browser.ChromeActivity;
|
| +import org.chromium.chrome.browser.ChromeSwitches;
|
| import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
|
| -import org.chromium.chrome.test.ChromeActivityTestCaseBase;
|
| +import org.chromium.chrome.test.ChromeActivityTestRule;
|
| +import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
|
| import org.chromium.components.autofill.AutofillPopup;
|
| import org.chromium.content.browser.ContentViewCore;
|
| import org.chromium.content.browser.input.ChromiumBaseInputConnection;
|
| @@ -35,8 +44,14 @@ import java.util.concurrent.TimeoutException;
|
| /**
|
| * Integration tests for the AutofillPopup.
|
| */
|
| +@RunWith(ChromeJUnit4ClassRunner.class)
|
| @RetryOnFailure
|
| -public class AutofillPopupTest extends ChromeActivityTestCaseBase<ChromeActivity> {
|
| +@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE,
|
| + ChromeActivityTestRule.DISABLE_NETWORK_PREDICTION_FLAG})
|
| +public class AutofillPopupTest {
|
| + @Rule
|
| + public ChromeActivityTestRule<ChromeActivity> mActivityTestRule =
|
| + new ChromeActivityTestRule<>(ChromeActivity.class);
|
|
|
| private static final String FIRST_NAME = "John";
|
| private static final String LAST_NAME = "Smith";
|
| @@ -122,18 +137,8 @@ public class AutofillPopupTest extends ChromeActivityTestCaseBase<ChromeActivity
|
| private AutofillTestHelper mHelper;
|
| private List<AutofillLogger.LogEntry> mAutofillLoggedEntries;
|
|
|
| - public AutofillPopupTest() {
|
| - super(ChromeActivity.class);
|
| - }
|
| -
|
| - @Override
|
| - public void startMainActivity() throws InterruptedException {
|
| - // Don't launch activity automatically.
|
| - }
|
| -
|
| - @Override
|
| + @Before
|
| public void setUp() throws Exception {
|
| - super.setUp();
|
| mAutofillLoggedEntries = new ArrayList<AutofillLogger.LogEntry>();
|
| AutofillLogger.setLoggerForTesting(
|
| new AutofillLogger.Logger() {
|
| @@ -148,12 +153,13 @@ public class AutofillPopupTest extends ChromeActivityTestCaseBase<ChromeActivity
|
| private void loadAndFillForm(
|
| final String formDataUrl, final String inputText)
|
| throws InterruptedException, ExecutionException, TimeoutException {
|
| - startMainActivityWithURL(formDataUrl);
|
| + mActivityTestRule.startMainActivityWithURL(formDataUrl);
|
| mHelper = new AutofillTestHelper();
|
|
|
| // The TestInputMethodManagerWrapper intercepts showSoftInput so that a keyboard is never
|
| // brought up.
|
| - final ContentViewCore viewCore = getActivity().getCurrentContentViewCore();
|
| + final ContentViewCore viewCore =
|
| + mActivityTestRule.getActivity().getCurrentContentViewCore();
|
| final WebContents webContents = viewCore.getWebContents();
|
| final ViewGroup view = viewCore.getContainerView();
|
| final TestInputMethodManagerWrapper immw =
|
| @@ -168,7 +174,7 @@ public class AutofillPopupTest extends ChromeActivityTestCaseBase<ChromeActivity
|
| ZIP_CODE, SORTING_CODE, COUNTRY, PHONE_NUMBER, EMAIL,
|
| LANGUAGE_CODE);
|
| mHelper.setProfile(profile);
|
| - assertEquals(1, mHelper.getNumberOfProfilesToSuggest());
|
| + Assert.assertEquals(1, mHelper.getNumberOfProfilesToSuggest());
|
|
|
| // Click the input field for the first name.
|
| DOMUtils.waitForNonZeroNodeBounds(webContents, "fn");
|
| @@ -188,7 +194,7 @@ public class AutofillPopupTest extends ChromeActivityTestCaseBase<ChromeActivity
|
| waitForAnchorViewAdd(view);
|
| View anchorView = view.findViewById(R.id.dropdown_popup_window);
|
|
|
| - assertTrue(anchorView.getTag() instanceof AutofillPopup);
|
| + Assert.assertTrue(anchorView.getTag() instanceof AutofillPopup);
|
| final AutofillPopup popup = (AutofillPopup) anchorView.getTag();
|
|
|
| waitForAutofillPopopShow(popup);
|
| @@ -202,39 +208,39 @@ public class AutofillPopupTest extends ChromeActivityTestCaseBase<ChromeActivity
|
| * Tests that bringing up an Autofill and clicking on the first entry fills out the expected
|
| * Autofill information.
|
| */
|
| + @Test
|
| @MediumTest
|
| @Feature({"autofill"})
|
| public void testClickAutofillPopupSuggestion()
|
| throws InterruptedException, ExecutionException, TimeoutException {
|
| loadAndFillForm(BASIC_PAGE_DATA, "J");
|
| - final ContentViewCore viewCore = getActivity().getCurrentContentViewCore();
|
| + final ContentViewCore viewCore =
|
| + mActivityTestRule.getActivity().getCurrentContentViewCore();
|
| final WebContents webContents = viewCore.getWebContents();
|
|
|
| - assertEquals("First name did not match",
|
| - FIRST_NAME, DOMUtils.getNodeValue(webContents, "fn"));
|
| - assertEquals("Last name did not match",
|
| - LAST_NAME, DOMUtils.getNodeValue(webContents, "ln"));
|
| - assertEquals("Street address (textarea) did not match",
|
| - STREET_ADDRESS_TEXTAREA, DOMUtils.getNodeValue(webContents, "sa"));
|
| - assertEquals("Address line 1 did not match",
|
| - ADDRESS_LINE1, DOMUtils.getNodeValue(webContents, "a1"));
|
| - assertEquals("Address line 2 did not match",
|
| - ADDRESS_LINE2, DOMUtils.getNodeValue(webContents, "a2"));
|
| - assertEquals("City did not match",
|
| - CITY, DOMUtils.getNodeValue(webContents, "ct"));
|
| - assertEquals("Zip code did not match",
|
| - ZIP_CODE, DOMUtils.getNodeValue(webContents, "zc"));
|
| - assertEquals("Country did not match",
|
| - COUNTRY, DOMUtils.getNodeValue(webContents, "co"));
|
| - assertEquals("Email did not match",
|
| - EMAIL, DOMUtils.getNodeValue(webContents, "em"));
|
| - assertEquals("Phone number did not match",
|
| - PHONE_NUMBER, DOMUtils.getNodeValue(webContents, "ph"));
|
| + Assert.assertEquals(
|
| + "First name did not match", FIRST_NAME, DOMUtils.getNodeValue(webContents, "fn"));
|
| + Assert.assertEquals(
|
| + "Last name did not match", LAST_NAME, DOMUtils.getNodeValue(webContents, "ln"));
|
| + Assert.assertEquals("Street address (textarea) did not match", STREET_ADDRESS_TEXTAREA,
|
| + DOMUtils.getNodeValue(webContents, "sa"));
|
| + Assert.assertEquals("Address line 1 did not match", ADDRESS_LINE1,
|
| + DOMUtils.getNodeValue(webContents, "a1"));
|
| + Assert.assertEquals("Address line 2 did not match", ADDRESS_LINE2,
|
| + DOMUtils.getNodeValue(webContents, "a2"));
|
| + Assert.assertEquals("City did not match", CITY, DOMUtils.getNodeValue(webContents, "ct"));
|
| + Assert.assertEquals(
|
| + "Zip code did not match", ZIP_CODE, DOMUtils.getNodeValue(webContents, "zc"));
|
| + Assert.assertEquals(
|
| + "Country did not match", COUNTRY, DOMUtils.getNodeValue(webContents, "co"));
|
| + Assert.assertEquals("Email did not match", EMAIL, DOMUtils.getNodeValue(webContents, "em"));
|
| + Assert.assertEquals("Phone number did not match", PHONE_NUMBER,
|
| + DOMUtils.getNodeValue(webContents, "ph"));
|
|
|
| final String profileFullName = FIRST_NAME + " " + LAST_NAME;
|
| final int loggedEntries = 10;
|
| - assertEquals("Mismatched number of logged entries",
|
| - loggedEntries, mAutofillLoggedEntries.size());
|
| + Assert.assertEquals("Mismatched number of logged entries", loggedEntries,
|
| + mAutofillLoggedEntries.size());
|
| assertLogged(FIRST_NAME, profileFullName);
|
| assertLogged(LAST_NAME, profileFullName);
|
| assertLogged(STREET_ADDRESS_TEXTAREA, profileFullName);
|
| @@ -251,6 +257,7 @@ public class AutofillPopupTest extends ChromeActivityTestCaseBase<ChromeActivity
|
| * Tests that bringing up an Autofill and clicking on the partially filled first
|
| * element will still fill the entire form (including the initiating element itself).
|
| */
|
| + @Test
|
| @MediumTest
|
| @Feature({"autofill"})
|
| public void testLoggingInitiatedElementFilled()
|
| @@ -258,8 +265,8 @@ public class AutofillPopupTest extends ChromeActivityTestCaseBase<ChromeActivity
|
| loadAndFillForm(INITIATING_ELEMENT_FILLED, "o");
|
| final String profileFullName = FIRST_NAME + " " + LAST_NAME;
|
| final int loggedEntries = 4;
|
| - assertEquals("Mismatched number of logged entries",
|
| - loggedEntries, mAutofillLoggedEntries.size());
|
| + Assert.assertEquals("Mismatched number of logged entries", loggedEntries,
|
| + mAutofillLoggedEntries.size());
|
| assertLogged(FIRST_NAME, profileFullName);
|
| assertLogged(LAST_NAME, profileFullName);
|
| assertLogged(EMAIL, profileFullName);
|
| @@ -270,6 +277,7 @@ public class AutofillPopupTest extends ChromeActivityTestCaseBase<ChromeActivity
|
| * Tests that bringing up an Autofill and clicking on the empty first element
|
| * will fill the all other elements except the previously filled email.
|
| */
|
| + @Test
|
| @MediumTest
|
| @Feature({"autofill"})
|
| public void testLoggingAnotherElementFilled()
|
| @@ -277,8 +285,8 @@ public class AutofillPopupTest extends ChromeActivityTestCaseBase<ChromeActivity
|
| loadAndFillForm(ANOTHER_ELEMENT_FILLED, "J");
|
| final String profileFullName = FIRST_NAME + " " + LAST_NAME;
|
| final int loggedEntries = 3;
|
| - assertEquals("Mismatched number of logged entries",
|
| - loggedEntries, mAutofillLoggedEntries.size());
|
| + Assert.assertEquals("Mismatched number of logged entries", loggedEntries,
|
| + mAutofillLoggedEntries.size());
|
| assertLogged(FIRST_NAME, profileFullName);
|
| assertLogged(LAST_NAME, profileFullName);
|
| assertLogged(COUNTRY, profileFullName);
|
| @@ -288,6 +296,7 @@ public class AutofillPopupTest extends ChromeActivityTestCaseBase<ChromeActivity
|
| /**
|
| * Tests that selecting a value not present in <option> will not be filled.
|
| */
|
| + @Test
|
| @MediumTest
|
| @Feature({"autofill"})
|
| public void testNotLoggingInvalidOption()
|
| @@ -295,8 +304,8 @@ public class AutofillPopupTest extends ChromeActivityTestCaseBase<ChromeActivity
|
| loadAndFillForm(INVALID_OPTION, "o");
|
| final String profileFullName = FIRST_NAME + " " + LAST_NAME;
|
| final int loggedEntries = 3;
|
| - assertEquals("Mismatched number of logged entries",
|
| - loggedEntries, mAutofillLoggedEntries.size());
|
| + Assert.assertEquals("Mismatched number of logged entries", loggedEntries,
|
| + mAutofillLoggedEntries.size());
|
| assertLogged(FIRST_NAME, profileFullName);
|
| assertLogged(LAST_NAME, profileFullName);
|
| assertLogged(EMAIL, profileFullName);
|
| @@ -362,6 +371,6 @@ public class AutofillPopupTest extends ChromeActivityTestCaseBase<ChromeActivity
|
| return;
|
| }
|
| }
|
| - fail("Logged entry not found [" + autofilledValue + "," + profileFullName + "]");
|
| + Assert.fail("Logged entry not found [" + autofilledValue + "," + profileFullName + "]");
|
| }
|
| }
|
|
|