Commit 25117a7b authored by Friedrich Horschig's avatar Friedrich Horschig Committed by Commit Bot

[Android Mfill] Reenable integration tests

This CL reenables all Autofill and Manual Filling Integration tests that
previously flaked due to keyboard timing, unstable UI or were disabled
because autofill chips were not yet available.

Minor fix: Rescroll the chips when switching the focused field.

Bug: 838922, 836027, 847959, 894428, 911056, 919988
Change-Id: I2fcfdc4016da5952cddf79f2d5c33180d89b7e1f
Reviewed-on: https://chromium-review.googlesource.com/c/1459552Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Commit-Queue: Friedrich [CET] <fhorschig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630704}
parent 6c34bd1a
...@@ -744,6 +744,7 @@ android_library("chrome_test_java") { ...@@ -744,6 +744,7 @@ android_library("chrome_test_java") {
data = [ data = [
"//chrome/test/data/android/", "//chrome/test/data/android/",
"//chrome/test/data/autofill/",
"//chrome/test/data/banners/", "//chrome/test/data/banners/",
"//chrome/test/data/browsing_data/", "//chrome/test/data/browsing_data/",
"//chrome/test/data/encoding_tests/auto_detect/Big5_with_no_encoding_specified.html", "//chrome/test/data/encoding_tests/auto_detect/Big5_with_no_encoding_specified.html",
......
...@@ -90,6 +90,7 @@ class KeyboardAccessoryView extends LinearLayout { ...@@ -90,6 +90,7 @@ class KeyboardAccessoryView extends LinearLayout {
} }
void setVisible(boolean visible) { void setVisible(boolean visible) {
if (!visible || getVisibility() != VISIBLE) mBarItemsView.scrollToPosition(0);
if (visible) { if (visible) {
show(); show();
} else { } else {
......
...@@ -37,7 +37,6 @@ import org.junit.runner.RunWith; ...@@ -37,7 +37,6 @@ import org.junit.runner.RunWith;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.CommandLineFlags; import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.Restriction; import org.chromium.base.test.util.Restriction;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeFeatureList; import org.chromium.chrome.browser.ChromeFeatureList;
...@@ -68,9 +67,7 @@ import java.util.concurrent.atomic.AtomicReference; ...@@ -68,9 +67,7 @@ import java.util.concurrent.atomic.AtomicReference;
*/ */
@RunWith(ChromeJUnit4ClassRunner.class) @RunWith(ChromeJUnit4ClassRunner.class)
@EnableFeatures({ChromeFeatureList.PASSWORDS_KEYBOARD_ACCESSORY, @EnableFeatures({ChromeFeatureList.PASSWORDS_KEYBOARD_ACCESSORY,
ChromeFeatureList.AUTOFILL_KEYBOARD_ACCESSORY, ChromeFeatureList.AUTOFILL_KEYBOARD_ACCESSORY})
// TODO(crbug.com/894428): Remove and use the embedded test server instead of data urls.
ChromeFeatureList.AUTOFILL_ALLOW_NON_HTTP_ACTIVATION})
@CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE}) @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
public class ManualFillingIntegrationTest { public class ManualFillingIntegrationTest {
@Rule @Rule
...@@ -263,7 +260,6 @@ public class ManualFillingIntegrationTest { ...@@ -263,7 +260,6 @@ public class ManualFillingIntegrationTest {
@Test @Test
@SmallTest @SmallTest
@DisabledTest(message = "https://crbug.com/919988")
@Restriction(UiRestriction.RESTRICTION_TYPE_PHONE) @Restriction(UiRestriction.RESTRICTION_TYPE_PHONE)
public void testInvokingTabSwitcherHidesAccessory() public void testInvokingTabSwitcherHidesAccessory()
throws InterruptedException, TimeoutException { throws InterruptedException, TimeoutException {
......
...@@ -39,6 +39,8 @@ import org.chromium.base.ThreadUtils; ...@@ -39,6 +39,8 @@ import org.chromium.base.ThreadUtils;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.ChromeTabbedActivity; import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.ChromeWindow; import org.chromium.chrome.browser.ChromeWindow;
import org.chromium.chrome.browser.autofill.AutofillTestHelper;
import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
import org.chromium.chrome.browser.autofill.keyboard_accessory.KeyboardAccessoryData.AccessorySheetData; import org.chromium.chrome.browser.autofill.keyboard_accessory.KeyboardAccessoryData.AccessorySheetData;
import org.chromium.chrome.browser.autofill.keyboard_accessory.KeyboardAccessoryData.Provider; import org.chromium.chrome.browser.autofill.keyboard_accessory.KeyboardAccessoryData.Provider;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule; import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
...@@ -54,6 +56,7 @@ import org.chromium.net.test.EmbeddedTestServer; ...@@ -54,6 +56,7 @@ import org.chromium.net.test.EmbeddedTestServer;
import org.chromium.ui.DropdownItem; import org.chromium.ui.DropdownItem;
import org.chromium.ui.DropdownPopupWindowInterface; import org.chromium.ui.DropdownPopupWindowInterface;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
...@@ -77,7 +80,7 @@ public class ManualFillingTestHelper { ...@@ -77,7 +80,7 @@ public class ManualFillingTestHelper {
return (FakeKeyboard) mActivityTestRule.getKeyboardDelegate(); return (FakeKeyboard) mActivityTestRule.getKeyboardDelegate();
} }
ManualFillingTestHelper(ChromeTabbedActivityTestRule activityTestRule) { public ManualFillingTestHelper(ChromeTabbedActivityTestRule activityTestRule) {
mActivityTestRule = activityTestRule; mActivityTestRule = activityTestRule;
} }
...@@ -86,6 +89,11 @@ public class ManualFillingTestHelper { ...@@ -86,6 +89,11 @@ public class ManualFillingTestHelper {
} }
public void loadTestPage(String url, boolean isRtl) throws InterruptedException { public void loadTestPage(String url, boolean isRtl) throws InterruptedException {
loadTestPage(url, isRtl, false);
}
public void loadTestPage(String url, boolean isRtl, boolean waitForNode)
throws InterruptedException {
mEmbeddedTestServer = EmbeddedTestServer.createAndStartServer( mEmbeddedTestServer = EmbeddedTestServer.createAndStartServer(
InstrumentationRegistry.getInstrumentation().getContext()); InstrumentationRegistry.getInstrumentation().getContext());
ChromeWindow.setKeyboardVisibilityDelegateFactory(FakeKeyboard::new); ChromeWindow.setKeyboardVisibilityDelegateFactory(FakeKeyboard::new);
...@@ -108,7 +116,7 @@ public class ManualFillingTestHelper { ...@@ -108,7 +116,7 @@ public class ManualFillingTestHelper {
activity.getManualFillingController().registerPasswordProvider( activity.getManualFillingController().registerPasswordProvider(
mSheetSuggestionsProvider); mSheetSuggestionsProvider);
}); });
DOMUtils.waitForNonZeroNodeBounds(mWebContentsRef.get(), PASSWORD_NODE_ID); if (waitForNode) DOMUtils.waitForNonZeroNodeBounds(mWebContentsRef.get(), PASSWORD_NODE_ID);
cacheCredentials(new String[0], new String[0]); // This caches the empty state. cacheCredentials(new String[0], new String[0]); // This caches the empty state.
} }
...@@ -121,6 +129,10 @@ public class ManualFillingTestHelper { ...@@ -121,6 +129,10 @@ public class ManualFillingTestHelper {
// Helpers interacting with the web page. // Helpers interacting with the web page.
// -------------------------------------- // --------------------------------------
public WebContents getWebContents() {
return mWebContentsRef.get();
}
public void focusPasswordField() throws TimeoutException, InterruptedException { public void focusPasswordField() throws TimeoutException, InterruptedException {
DOMUtils.focusNode(mActivityTestRule.getWebContents(), PASSWORD_NODE_ID); DOMUtils.focusNode(mActivityTestRule.getWebContents(), PASSWORD_NODE_ID);
ThreadUtils.runOnUiThreadBlocking( ThreadUtils.runOnUiThreadBlocking(
...@@ -143,7 +155,13 @@ public class ManualFillingTestHelper { ...@@ -143,7 +155,13 @@ public class ManualFillingTestHelper {
.getMediatorForTesting() .getMediatorForTesting()
.showWhenKeyboardIsVisible(); .showWhenKeyboardIsVisible();
}); });
}; }
getKeyboard().showKeyboard(mActivityTestRule.getActivity().getCurrentFocus());
}
public void clickNodeAndShowKeyboard(String node)
throws TimeoutException, InterruptedException {
DOMUtils.clickNode(mWebContentsRef.get(), node);
getKeyboard().showKeyboard(mActivityTestRule.getActivity().getCurrentFocus()); getKeyboard().showKeyboard(mActivityTestRule.getActivity().getCurrentFocus());
} }
...@@ -262,6 +280,19 @@ public class ManualFillingTestHelper { ...@@ -262,6 +280,19 @@ public class ManualFillingTestHelper {
}); });
} }
public static void createAutofillTestProfiles()
throws InterruptedException, ExecutionException, TimeoutException {
new AutofillTestHelper().setProfile(new AutofillProfile("", "https://www.example.com",
"Johnathan Smithonian-Jackson", "Acme Inc", "1 Main\nApt A", "CA", "San Francisco",
"", "94102", "", "US", "(415) 888-9999", "john.sj@acme-mail.inc", "en"));
new AutofillTestHelper().setProfile(new AutofillProfile("", "https://www.example.com",
"Jane Erika Donovanova", "Acme Inc", "1 Main\nApt A", "CA", "San Francisco", "",
"94102", "", "US", "(415) 999-0000", "donovanova.j@acme-mail.inc", "en"));
new AutofillTestHelper().setProfile(new AutofillProfile("", "https://www.example.com",
"Marcus McSpartangregor", "Acme Inc", "1 Main\nApt A", "CA", "San Francisco", "",
"94102", "", "US", "(415) 999-0000", "marc@acme-mail.inc", "en"));
}
// -------------------------------------------------- // --------------------------------------------------
// Generic helpers to match, check or wait for views. // Generic helpers to match, check or wait for views.
// TODO(fhorschig): Consider Moving to ViewUtils. // TODO(fhorschig): Consider Moving to ViewUtils.
......
...@@ -37,6 +37,7 @@ import org.chromium.chrome.test.util.browser.Features.DisableFeatures; ...@@ -37,6 +37,7 @@ import org.chromium.chrome.test.util.browser.Features.DisableFeatures;
import org.chromium.chrome.test.util.browser.Features.EnableFeatures; import org.chromium.chrome.test.util.browser.Features.EnableFeatures;
import org.chromium.chrome.test.util.browser.RecyclerViewTestUtils; import org.chromium.chrome.test.util.browser.RecyclerViewTestUtils;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
/** /**
...@@ -124,13 +125,13 @@ public class ManualFillingUiCaptureTest { ...@@ -124,13 +125,13 @@ public class ManualFillingUiCaptureTest {
@EnableFeatures(ChromeFeatureList.AUTOFILL_KEYBOARD_ACCESSORY) @EnableFeatures(ChromeFeatureList.AUTOFILL_KEYBOARD_ACCESSORY)
@Feature({"KeyboardAccessoryModern", "LTR", "UiCatalogue"}) @Feature({"KeyboardAccessoryModern", "LTR", "UiCatalogue"})
public void testCaptureKeyboardAccessoryV2WithPasswords() public void testCaptureKeyboardAccessoryV2WithPasswords()
throws InterruptedException, TimeoutException { throws InterruptedException, TimeoutException, ExecutionException {
mHelper.loadTestPage(false); mHelper.loadTestPage(false);
ManualFillingTestHelper.createAutofillTestProfiles();
mHelper.cacheTestCredentials(); mHelper.cacheTestCredentials();
mHelper.focusPasswordField(); mHelper.focusPasswordField();
mHelper.waitForKeyboardAccessoryToBeShown(); mHelper.waitForKeyboardAccessoryToBeShown();
mHelper.addGenerationButton(); mHelper.addGenerationButton();
mHelper.addAutofillChips();
waitForActionsInAccessory(); waitForActionsInAccessory();
waitForUnrelatedChromeUi(); waitForUnrelatedChromeUi();
...@@ -156,13 +157,13 @@ public class ManualFillingUiCaptureTest { ...@@ -156,13 +157,13 @@ public class ManualFillingUiCaptureTest {
@EnableFeatures(ChromeFeatureList.AUTOFILL_KEYBOARD_ACCESSORY) @EnableFeatures(ChromeFeatureList.AUTOFILL_KEYBOARD_ACCESSORY)
@Feature({"KeyboardAccessoryModern", "RTL", "UiCatalogue"}) @Feature({"KeyboardAccessoryModern", "RTL", "UiCatalogue"})
public void testCaptureKeyboardAccessoryV2WithPasswordsRTL() public void testCaptureKeyboardAccessoryV2WithPasswordsRTL()
throws InterruptedException, TimeoutException { throws InterruptedException, TimeoutException, ExecutionException {
mHelper.loadTestPage(true); mHelper.loadTestPage(true);
ManualFillingTestHelper.createAutofillTestProfiles();
mHelper.cacheTestCredentials(); mHelper.cacheTestCredentials();
mHelper.focusPasswordField(); mHelper.focusPasswordField();
mHelper.waitForKeyboardAccessoryToBeShown(); mHelper.waitForKeyboardAccessoryToBeShown();
mHelper.addGenerationButton(); mHelper.addGenerationButton();
mHelper.addAutofillChips();
waitForActionsInAccessory(); waitForActionsInAccessory();
waitForUnrelatedChromeUi(); waitForUnrelatedChromeUi();
......
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