Chromium Code Reviews| Index: chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillPopupWithKeyboardTest.java |
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillPopupWithKeyboardTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillPopupWithKeyboardTest.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1de3de7e930dad49d17ac8652cd7bc066736a143 |
| --- /dev/null |
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillPopupWithKeyboardTest.java |
| @@ -0,0 +1,127 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.chrome.browser.autofill; |
| + |
| +import android.test.suitebuilder.annotation.MediumTest; |
| +import android.view.View; |
| +import android.view.ViewGroup; |
| + |
| +import org.chromium.base.test.util.Feature; |
| +import org.chromium.base.test.util.UrlUtils; |
| +import org.chromium.chrome.R; |
| +import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile; |
| +import org.chromium.chrome.shell.ChromeShellTestBase; |
| +import org.chromium.content.browser.ContentViewCore; |
| +import org.chromium.content.browser.test.util.Criteria; |
| +import org.chromium.content.browser.test.util.CriteriaHelper; |
| +import org.chromium.content.browser.test.util.DOMUtils; |
| +import org.chromium.content_public.browser.WebContents; |
| +import org.chromium.ui.UiUtils; |
| +import org.chromium.ui.autofill.AutofillPopup; |
| + |
| +import java.util.concurrent.ExecutionException; |
| +import java.util.concurrent.TimeoutException; |
| + |
| +/** |
| + * Integration tests for interaction of the AutofillPopup and a keyboard. |
| + */ |
| +public class AutofillPopupWithKeyboardTest extends ChromeShellTestBase { |
| + /** |
| + * Test that showing autofill popup and keyboard will not hide the autofill popup. |
| + */ |
| + @MediumTest |
| + @Feature({"autofill-keyboard"}) |
| + public void testShowAutofillPopupAndKeyboardimultaneously() |
| + throws InterruptedException, ExecutionException, TimeoutException { |
| + launchChromeShellWithUrl(UrlUtils.encodeHtmlDataUri("<html><head>" |
| + + "<meta name=\"viewport\"" |
| + + "content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0\" /></head>" |
| + + "<body><form method=\"POST\">" |
| + + "<input type=\"text\" id=\"fn\" autocomplete=\"given-name\" /><br>" |
| + + "<input type=\"text\" id=\"ln\" autocomplete=\"family-name\" /><br>" |
| + + "<textarea id=\"sa\" autocomplete=\"street-address\"></textarea><br>" |
| + + "<input type=\"text\" id=\"a1\" autocomplete=\"address-line1\" /><br>" |
| + + "<input type=\"text\" id=\"a2\" autocomplete=\"address-line2\" /><br>" |
| + + "<input type=\"text\" id=\"ct\" autocomplete=\"locality\" /><br>" |
| + + "<input type=\"text\" id=\"zc\" autocomplete=\"postal-code\" /><br>" |
| + + "<input type=\"text\" id=\"em\" autocomplete=\"email\" /><br>" |
| + + "<input type=\"text\" id=\"ph\" autocomplete=\"tel\" /><br>" |
| + + "<input type=\"text\" id=\"fx\" autocomplete=\"fax\" /><br>" |
| + + "<select id=\"co\" autocomplete=\"country\"><br>" |
| + + "<option value=\"BR\">Brazil</option>" |
| + + "<option value=\"US\">United States</option>" |
| + + "</select>" |
| + + "<input type=\"submit\" />" |
| + + "</form></body></html>")); |
| + assertTrue(waitForActiveShellToBeDoneLoading()); |
| + |
| + new AutofillTestHelper().setProfile(new AutofillProfile("", "https://www.example.com", |
|
newt (away)
2015/01/15 17:36:45
These objects all live on the UI thread. You shoul
please use gerrit instead
2015/01/20 19:38:02
AutofillTestHelper.setProfile() handles threading
|
| + "John Smith", "Acme Inc", "1 Main\nApt A", "CA", "San Francisco", "", "94102", "", |
| + "US", "(415) 888-9999", "john@acme.inc", "en")); |
| + ContentViewCore viewCore = getActivity().getActiveContentViewCore(); |
| + WebContents webContents = viewCore.getWebContents(); |
| + assertTrue(DOMUtils.waitForNonZeroNodeBounds(webContents, "fn")); |
| + |
| + DOMUtils.clickNode(this, viewCore, "fn"); |
| + waitForKeyboardShown(); |
| + |
| + final ViewGroup view = viewCore.getContainerView(); |
| + UiUtils.hideKeyboard(view); |
| + waitForKeyboardHidden(); |
| + |
| + DOMUtils.clickNode(this, viewCore, "fn"); |
| + waitForKeyboardShown(); |
| + |
| + assertTrue("Autofill Popup anchor view was never added.", |
| + CriteriaHelper.pollForCriteria(new Criteria() { |
| + @Override |
| + public boolean isSatisfied() { |
|
newt (away)
2015/01/15 17:36:45
This should run on the UI thread, too. Also, lines
please use gerrit instead
2015/01/20 19:38:02
Done.
|
| + return view.findViewById(R.id.dropdown_popup_window) != null; |
| + } |
| + })); |
| + |
| + View anchorView = view.findViewById(R.id.dropdown_popup_window); |
| + assertTrue(anchorView.getTag() instanceof AutofillPopup); |
| + |
| + final AutofillPopup popup = (AutofillPopup) anchorView.getTag(); |
| + assertTrue("Autofill Popup anchor view was never added.", |
|
newt (away)
2015/01/15 17:36:45
this message doesn't seem quite right
please use gerrit instead
2015/01/20 19:38:02
Done.
|
| + CriteriaHelper.pollForCriteria(new Criteria() { |
| + @Override |
| + public boolean isSatisfied() { |
| + return popup.isShowing(); |
| + } |
| + })); |
| + } |
| + |
| + private void waitForKeyboardShown() throws InterruptedException { |
| + final ContentViewCore viewCore = getActivity().getActiveContentViewCore(); |
| + assertTrue("Keyboard was never shown", |
| + CriteriaHelper.pollForCriteria(new Criteria() { |
| + @Override |
| + public boolean isSatisfied() { |
| + return UiUtils.isKeyboardShowing(getActivity(), |
| + viewCore.getContainerView()); |
| + } |
| + })); |
| + viewCore.onSizeChanged(viewCore.getViewportWidthPix(), |
|
newt (away)
2015/01/15 17:36:45
UI thread, etc. You get the point :)
please use gerrit instead
2015/01/20 19:38:03
Done.
|
| + viewCore.getViewportHeightPix() - 100, viewCore.getViewportWidthPix(), |
| + viewCore.getViewportHeightPix()); |
| + } |
| + |
| + private void waitForKeyboardHidden() throws InterruptedException { |
| + final ContentViewCore viewCore = getActivity().getActiveContentViewCore(); |
| + assertTrue("Keyboard was never hidden", |
| + CriteriaHelper.pollForCriteria(new Criteria() { |
| + @Override |
| + public boolean isSatisfied() { |
| + return !UiUtils.isKeyboardShowing(getActivity(), |
| + viewCore.getContainerView()); |
| + } |
| + })); |
| + viewCore.onSizeChanged(viewCore.getViewportWidthPix(), |
| + viewCore.getViewportHeightPix() + 100, viewCore.getViewportWidthPix(), |
| + viewCore.getViewportHeightPix()); |
| + } |
| +} |