Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillPopupWithKeyboardTest.java

Issue 715733002: [Android] Show autofill popup after animation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: UI thread where needed. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/thread_proxy.cc ('k') | chrome/renderer/autofill/page_click_tracker_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..496be9a98b0c7718f882412a17625b7f745be2e2
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/autofill/AutofillPopupWithKeyboardTest.java
@@ -0,0 +1,224 @@
+// 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.ThreadUtils;
+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.ChromeShellActivity;
+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.Callable;
+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",
+ "John Smith", "Acme Inc", "1 Main\nApt A", "CA", "San Francisco", "", "94102", "",
+ "US", "(415) 888-9999", "john@acme.inc", "en"));
+ class Info {
newt (away) 2015/01/20 21:28:09 Another option would be to use AtomicReferences in
please use gerrit instead 2015/01/21 01:31:44 Done, that saves 2 lines :-).
+ public final ContentViewCore viewCore;
+ public final WebContents webContents;
+ public final ViewGroup view;
+ public Info(ChromeShellActivity activity) {
+ viewCore = activity.getActiveContentViewCore();
+ webContents = viewCore.getWebContents();
+ view = viewCore.getContainerView();
+ }
+ }
+ final Info info = ThreadUtils.runOnUiThreadBlocking(new Callable<Info>() {
+ @Override
+ public Info call() {
+ return new Info(getActivity());
+ }
+ });
+ assertTrue(DOMUtils.waitForNonZeroNodeBounds(info.webContents, "fn"));
+
+ // Click on the unfocused input element the first time to focus on it. This brings up the
+ // keyboard, but does not show the autofill popup.
+ DOMUtils.clickNode(this, info.viewCore, "fn");
+ waitForKeyboardShownOnUiThreadBlocking();
+ notifyViewHeightReducedOnUiThreadBlocking();
+
+ // Hide the keyboard while still keeping the focus on the input field.
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ UiUtils.hideKeyboard(info.view);
+ }
+ });
+ assertTrue("Keyboard was never hidden", CriteriaHelper.pollForCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ try {
+ return !isKeyboardShowingOnUiThreadBlocking();
+ } catch (InterruptedException e1) {
+ return false;
+ } catch (ExecutionException e2) {
+ return false;
+ }
+ }
+ }));
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ info.viewCore.onSizeChanged(info.viewCore.getViewportWidthPix(),
+ info.viewCore.getViewportHeightPix() + 100,
+ info.viewCore.getViewportWidthPix(), info.viewCore.getViewportHeightPix());
+ }
+ });
+
+ // Click on the focused input element the second time. This brings up the autofill popup and
+ // shows the keyboard at the same time. Showing the keyboard should not hide the autofill
+ // popup.
+ DOMUtils.clickNode(this, info.viewCore, "fn");
+ waitForKeyboardShownOnUiThreadBlocking();
+ notifyViewHeightReducedOnUiThreadBlocking();
+
+ // Verify that the autofill popup is showing.
+ assertTrue("Autofill Popup anchor view was never added.",
+ CriteriaHelper.pollForCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ try {
+ return findAchorViewOnUiThreadBlocking(info.view) != null;
+ } catch (InterruptedException e1) {
+ return false;
+ } catch (ExecutionException e2) {
+ return false;
+ }
+ }
+ }));
+ final View anchorView = findAchorViewOnUiThreadBlocking(info.view);
+ Object popupObject = ThreadUtils.runOnUiThreadBlocking(new Callable<Object>() {
+ @Override
+ public Object call() {
+ return anchorView.getTag();
+ }
+ });
+ assertTrue(popupObject instanceof AutofillPopup);
+ final AutofillPopup popup = (AutofillPopup) popupObject;
+ assertTrue(
+ "Autofill Popup was never shown.", CriteriaHelper.pollForCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ try {
+ return isPopupShowingOnUiThreadBlocking(popup);
+ } catch (InterruptedException e1) {
+ return false;
+ } catch (ExecutionException e2) {
+ return false;
+ }
+ }
+ }));
+ }
+
+ // Wait until the keyboard is showing on the UI thread.
+ private void waitForKeyboardShownOnUiThreadBlocking() throws InterruptedException {
newt (away) 2015/01/20 21:28:10 you could add a "visible" parameter to this method
please use gerrit instead 2015/01/21 01:31:44 Done.
+ assertTrue("Keyboard was never shown", CriteriaHelper.pollForCriteria(new Criteria() {
newt (away) 2015/01/20 21:28:09 use pollForUIThreadCriteria() here, then you can s
please use gerrit instead 2015/01/21 01:31:44 Done.
+ @Override
+ public boolean isSatisfied() {
+ try {
+ return isKeyboardShowingOnUiThreadBlocking();
+ } catch (InterruptedException e1) {
+ return false;
+ } catch (ExecutionException e2) {
+ return false;
+ }
+ }
+ }));
+ }
+
+ // Notify the ContentViewCore that its height was reduced on the UI thread.
+ private void notifyViewHeightReducedOnUiThreadBlocking() {
newt (away) 2015/01/20 21:28:09 I'd remove "OnUiThreadBlocking" from these methods
please use gerrit instead 2015/01/21 01:31:44 Done.
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ ContentViewCore viewCore = getActivity().getActiveContentViewCore();
+ viewCore.onSizeChanged(viewCore.getViewportWidthPix(),
+ viewCore.getViewportHeightPix() - 100, viewCore.getViewportWidthPix(),
+ viewCore.getViewportHeightPix());
+ }
+ });
+ }
+
+ // Check whether the keyboard is showing on the UI thread.
+ private Boolean isKeyboardShowingOnUiThreadBlocking()
newt (away) 2015/01/20 21:28:09 This should return "boolean" (not Boolean). Same b
please use gerrit instead 2015/01/21 01:31:44 No longer relevant, as this method got inlined.
+ throws InterruptedException, ExecutionException {
+ return ThreadUtils.runOnUiThreadBlocking(new Callable<Boolean>() {
+ @Override
+ public Boolean call() {
+ return UiUtils.isKeyboardShowing(
+ getActivity(), getActivity().getActiveContentViewCore().getContainerView());
+ }
+ });
+ }
+
+ // Find the autofill popup view on the UI thread.
+ private View findAchorViewOnUiThreadBlocking(final ViewGroup view)
+ throws InterruptedException, ExecutionException {
+ return ThreadUtils.runOnUiThreadBlocking(new Callable<View>() {
newt (away) 2015/01/20 21:28:09 I'd use runOnUiThreadBlockingNoException(). Then y
please use gerrit instead 2015/01/21 01:31:44 No longer necessary, as this got inlined.
+ @Override
+ public View call() {
+ return view.findViewById(R.id.dropdown_popup_window);
+ }
+ });
+ }
+
+ // Check whether the autofill popup is showing on the UI thread.
+ private Boolean isPopupShowingOnUiThreadBlocking(final AutofillPopup popup)
+ throws InterruptedException, ExecutionException {
+ return ThreadUtils.runOnUiThreadBlocking(new Callable<Boolean>() {
+ @Override
+ public Boolean call() {
+ return popup.isShowing();
+ }
+ });
+ }
+}
« no previous file with comments | « cc/trees/thread_proxy.cc ('k') | chrome/renderer/autofill/page_click_tracker_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698