OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.content.browser.input; | 5 package org.chromium.content.browser.input; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.content.ClipData; | 8 import android.content.ClipData; |
9 import android.content.ClipboardManager; | 9 import android.content.ClipboardManager; |
10 import android.content.Context; | 10 import android.content.Context; |
11 import android.content.res.Configuration; | 11 import android.content.res.Configuration; |
12 import android.os.Handler; | 12 import android.os.Handler; |
13 import android.os.Looper; | 13 import android.os.Looper; |
14 import android.test.suitebuilder.annotation.MediumTest; | 14 import android.test.suitebuilder.annotation.MediumTest; |
15 import android.test.suitebuilder.annotation.SmallTest; | 15 import android.test.suitebuilder.annotation.SmallTest; |
16 import android.text.InputType; | 16 import android.text.InputType; |
17 import android.text.TextUtils; | 17 import android.text.TextUtils; |
18 import android.util.Pair; | 18 import android.util.Pair; |
19 import android.view.KeyEvent; | 19 import android.view.KeyEvent; |
20 import android.view.View; | 20 import android.view.View; |
21 import android.view.inputmethod.BaseInputConnection; | 21 import android.view.inputmethod.BaseInputConnection; |
22 import android.view.inputmethod.EditorInfo; | 22 import android.view.inputmethod.EditorInfo; |
23 import android.view.inputmethod.InputConnection; | 23 import android.view.inputmethod.InputConnection; |
24 | 24 |
25 import org.chromium.base.ThreadUtils; | 25 import org.chromium.base.ThreadUtils; |
26 import org.chromium.base.test.util.CommandLineFlags; | 26 import org.chromium.base.test.util.CommandLineFlags; |
27 import org.chromium.base.test.util.DisabledTest; | 27 import org.chromium.base.test.util.DisabledTest; |
28 import org.chromium.base.test.util.Feature; | 28 import org.chromium.base.test.util.Feature; |
29 import org.chromium.base.test.util.RetryOnFailure; | 29 import org.chromium.base.test.util.RetryOnFailure; |
30 import org.chromium.base.test.util.UrlUtils; | |
30 import org.chromium.base.test.util.parameter.Parameter; | 31 import org.chromium.base.test.util.parameter.Parameter; |
31 import org.chromium.base.test.util.parameter.ParameterizedTest; | 32 import org.chromium.base.test.util.parameter.ParameterizedTest; |
32 import org.chromium.content.browser.ContentViewCore; | 33 import org.chromium.content.browser.ContentViewCore; |
33 import org.chromium.content.browser.test.util.Criteria; | 34 import org.chromium.content.browser.test.util.Criteria; |
34 import org.chromium.content.browser.test.util.CriteriaHelper; | 35 import org.chromium.content.browser.test.util.CriteriaHelper; |
35 import org.chromium.content.browser.test.util.DOMUtils; | 36 import org.chromium.content.browser.test.util.DOMUtils; |
36 import org.chromium.content.browser.test.util.JavaScriptUtils; | 37 import org.chromium.content.browser.test.util.JavaScriptUtils; |
37 import org.chromium.content.browser.test.util.TestCallbackHelperContainer; | 38 import org.chromium.content.browser.test.util.TestCallbackHelperContainer; |
38 import org.chromium.content.browser.test.util.TestInputMethodManagerWrapper; | 39 import org.chromium.content.browser.test.util.TestInputMethodManagerWrapper; |
39 import org.chromium.content_public.browser.WebContents; | 40 import org.chromium.content_public.browser.WebContents; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 waitForKeyboardStates(1, 0, 1, new Integer[] {TextInputType.TEXT}); | 111 waitForKeyboardStates(1, 0, 1, new Integer[] {TextInputType.TEXT}); |
111 assertEquals(0, mConnectionFactory.getOutAttrs().initialSelStart); | 112 assertEquals(0, mConnectionFactory.getOutAttrs().initialSelStart); |
112 assertEquals(0, mConnectionFactory.getOutAttrs().initialSelEnd); | 113 assertEquals(0, mConnectionFactory.getOutAttrs().initialSelEnd); |
113 | 114 |
114 waitForEventLogs("selectionchange"); | 115 waitForEventLogs("selectionchange"); |
115 clearEventLogs(); | 116 clearEventLogs(); |
116 | 117 |
117 resetAllStates(); | 118 resetAllStates(); |
118 } | 119 } |
119 | 120 |
121 private void fullyLoadNewUrl(final String url) throws Throwable { | |
122 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | |
123 @Override | |
124 public void run() { | |
125 getActivity().getActiveShell().loadUrl(url); | |
126 } | |
127 }); | |
128 waitForActiveShellToBeDoneLoading(); | |
129 } | |
130 | |
131 @MediumTest | |
132 @Feature({"TextInput", "Main"}) | |
133 @RetryOnFailure | |
134 public void testKeyboardDismissedWhenNavigating() throws Throwable { | |
135 assertWaitForKeyboardStatus(true); | |
136 | |
137 // Should hide keyboard when loading a new Url. | |
138 fullyLoadNewUrl(UrlUtils.getIsolatedTestFileUrl(INPUT_FORM_HTML)); | |
Changwan Ryu
2016/10/19 05:10:21
Isn't reloadPage() enough? If not, could you fix r
yabinh
2016/10/24 01:40:57
Done.
| |
139 assertWaitForKeyboardStatus(false); | |
140 | |
141 DOMUtils.clickNode(this, mContentViewCore, "input_text"); | |
142 assertWaitForKeyboardStatus(true); | |
143 | |
144 // Should hide keyboard when navigating. | |
145 final String code = "document.getElementById(\"link\").click()"; | |
146 JavaScriptUtils.executeJavaScriptAndWaitForResult( | |
147 getContentViewCore().getWebContents(), code); | |
148 assertWaitForKeyboardStatus(false); | |
149 } | |
150 | |
120 @MediumTest | 151 @MediumTest |
121 @Feature({"TextInput", "Main"}) | 152 @Feature({"TextInput", "Main"}) |
122 public void testKeyboardDismissedAfterClickingGo() throws Throwable { | 153 public void testKeyboardDismissedAfterClickingGo() throws Throwable { |
123 setComposingText("hello", 1); | 154 setComposingText("hello", 1); |
124 waitAndVerifyUpdateSelection(0, 5, 5, 0, 5); | 155 waitAndVerifyUpdateSelection(0, 5, 5, 0, 5); |
125 | 156 |
126 performGo(mCallbackContainer); | 157 performGo(mCallbackContainer); |
127 | 158 |
128 assertWaitForKeyboardStatus(false); | 159 assertWaitForKeyboardStatus(false); |
129 } | 160 } |
(...skipping 1838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1968 public void onViewAttachedToWindow() { | 1999 public void onViewAttachedToWindow() { |
1969 mFactory.onViewAttachedToWindow(); | 2000 mFactory.onViewAttachedToWindow(); |
1970 } | 2001 } |
1971 | 2002 |
1972 @Override | 2003 @Override |
1973 public void onViewDetachedFromWindow() { | 2004 public void onViewDetachedFromWindow() { |
1974 mFactory.onViewDetachedFromWindow(); | 2005 mFactory.onViewDetachedFromWindow(); |
1975 } | 2006 } |
1976 } | 2007 } |
1977 } | 2008 } |
OLD | NEW |