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

Side by Side 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: Inline test functions. 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.autofill;
6
7 import android.test.suitebuilder.annotation.MediumTest;
8 import android.view.ViewGroup;
9
10 import org.chromium.base.ThreadUtils;
11 import org.chromium.base.test.util.Feature;
12 import org.chromium.base.test.util.UrlUtils;
13 import org.chromium.chrome.R;
14 import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
15 import org.chromium.chrome.shell.ChromeShellTestBase;
16 import org.chromium.content.browser.ContentViewCore;
17 import org.chromium.content.browser.test.util.Criteria;
18 import org.chromium.content.browser.test.util.CriteriaHelper;
19 import org.chromium.content.browser.test.util.DOMUtils;
20 import org.chromium.content_public.browser.WebContents;
21 import org.chromium.ui.UiUtils;
22 import org.chromium.ui.autofill.AutofillPopup;
23
24 import java.util.concurrent.Callable;
25 import java.util.concurrent.ExecutionException;
26 import java.util.concurrent.TimeoutException;
27 import java.util.concurrent.atomic.AtomicReference;
28
29 /**
30 * Integration tests for interaction of the AutofillPopup and a keyboard.
31 */
32 public class AutofillPopupWithKeyboardTest extends ChromeShellTestBase {
33 /**
34 * Test that showing autofill popup and keyboard will not hide the autofill popup.
35 */
36 @MediumTest
37 @Feature({"autofill-keyboard"})
38 public void testShowAutofillPopupAndKeyboardimultaneously()
39 throws InterruptedException, ExecutionException, TimeoutException {
40 launchChromeShellWithUrl(UrlUtils.encodeHtmlDataUri("<html><head>"
41 + "<meta name=\"viewport\""
42 + "content=\"width=device-width, initial-scale=1.0, maximum-scal e=1.0\" /></head>"
43 + "<body><form method=\"POST\">"
44 + "<input type=\"text\" id=\"fn\" autocomplete=\"given-name\" /> <br>"
45 + "<input type=\"text\" id=\"ln\" autocomplete=\"family-name\" / ><br>"
46 + "<textarea id=\"sa\" autocomplete=\"street-address\"></textare a><br>"
47 + "<input type=\"text\" id=\"a1\" autocomplete=\"address-line1\" /><br>"
48 + "<input type=\"text\" id=\"a2\" autocomplete=\"address-line2\" /><br>"
49 + "<input type=\"text\" id=\"ct\" autocomplete=\"locality\" /><b r>"
50 + "<input type=\"text\" id=\"zc\" autocomplete=\"postal-code\" / ><br>"
51 + "<input type=\"text\" id=\"em\" autocomplete=\"email\" /><br>"
52 + "<input type=\"text\" id=\"ph\" autocomplete=\"tel\" /><br>"
53 + "<input type=\"text\" id=\"fx\" autocomplete=\"fax\" /><br>"
54 + "<select id=\"co\" autocomplete=\"country\"><br>"
55 + "<option value=\"BR\">Brazil</option>"
56 + "<option value=\"US\">United States</option>"
57 + "</select>"
58 + "<input type=\"submit\" />"
59 + "</form></body></html>"));
60 assertTrue(waitForActiveShellToBeDoneLoading());
61 new AutofillTestHelper().setProfile(new AutofillProfile("", "https://www .example.com",
62 "John Smith", "Acme Inc", "1 Main\nApt A", "CA", "San Francisco" , "", "94102", "",
63 "US", "(415) 888-9999", "john@acme.inc", "en"));
64 final AtomicReference<ContentViewCore> viewCoreRef = new AtomicReference <ContentViewCore>();
65 final AtomicReference<WebContents> webContentsRef = new AtomicReference< WebContents>();
66 final AtomicReference<ViewGroup> viewRef = new AtomicReference<ViewGroup >();
67 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
68 @Override
69 public void run() {
70 viewCoreRef.set(getActivity().getActiveContentViewCore());
71 webContentsRef.set(viewCoreRef.get().getWebContents());
72 viewRef.set(viewCoreRef.get().getContainerView());
73 }
74 });
75 assertTrue(DOMUtils.waitForNonZeroNodeBounds(webContentsRef.get(), "fn") );
76
77 // Click on the unfocused input element for the first time to focus on i t. This brings up
78 // the keyboard, but does not show the autofill popup.
79 DOMUtils.clickNode(this, viewCoreRef.get(), "fn");
80 waitForKeyboardShown(true);
81
82 // Hide the keyboard while still keeping the focus on the input field.
83 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
84 @Override
85 public void run() {
86 UiUtils.hideKeyboard(viewRef.get());
87 }
88 });
89 waitForKeyboardShown(false);
90
91 // Click on the focused input element for the second time. This brings u p the autofill popup
92 // and shows the keyboard at the same time. Showing the keyboard should not hide the
93 // autofill popup.
94 DOMUtils.clickNode(this, viewCoreRef.get(), "fn");
95 waitForKeyboardShown(true);
96
97 // Verify that the autofill popup is showing.
98 assertTrue("Autofill Popup anchor view was never added.",
99 CriteriaHelper.pollForUIThreadCriteria(new Criteria() {
100 @Override
101 public boolean isSatisfied() {
102 return viewRef.get().findViewById(R.id.dropdown_popup_wi ndow) != null;
103 }
104 }));
105 Object popupObject = ThreadUtils.runOnUiThreadBlocking(new Callable<Obje ct>() {
106 @Override
107 public Object call() {
108 return viewRef.get().findViewById(R.id.dropdown_popup_window).ge tTag();
109 }
110 });
111 assertTrue(popupObject instanceof AutofillPopup);
112 final AutofillPopup popup = (AutofillPopup) popupObject;
113 assertTrue("Autofill Popup was never shown.",
114 CriteriaHelper.pollForUIThreadCriteria(new Criteria() {
115 @Override
116 public boolean isSatisfied() {
117 return popup.isShowing();
118 }
119 }));
120 }
121
122 // Wait until the keyboard is showing and notify the ContentViewCore that it s height was changed
newt (away) 2015/01/21 01:41:27 Nit: use javadoc style comment /** */
please use gerrit instead 2015/01/21 01:46:06 Done.
123 // on the UI thread.
124 private void waitForKeyboardShown(final boolean shown) throws InterruptedExc eption {
125 assertTrue((shown ? "Keyboard was never shown" : "Keyboard was never hid den"),
126 CriteriaHelper.pollForUIThreadCriteria(new Criteria() {
127 @Override
128 public boolean isSatisfied() {
129 return shown == UiUtils.isKeyboardShowing(
130 getActivity(),
131 getActivity().getActiveContentViewCore().getCont ainerView());
132 }
133 }));
134 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
135 @Override
136 public void run() {
137 ContentViewCore viewCore = getActivity().getActiveContentViewCor e();
138 viewCore.onSizeChanged(viewCore.getViewportWidthPix(),
139 viewCore.getViewportHeightPix() + (shown ? -100 : 100),
140 viewCore.getViewportWidthPix(), viewCore.getViewportHeig htPix());
141 }
142 });
143 }
144 }
OLDNEW
« 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