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.TextUtils; | 16 import android.text.TextUtils; |
17 import android.util.Pair; | 17 import android.util.Pair; |
18 import android.view.KeyEvent; | 18 import android.view.KeyEvent; |
19 import android.view.View; | 19 import android.view.View; |
20 import android.view.inputmethod.BaseInputConnection; | 20 import android.view.inputmethod.BaseInputConnection; |
21 import android.view.inputmethod.EditorInfo; | 21 import android.view.inputmethod.EditorInfo; |
22 import android.view.inputmethod.InputConnection; | 22 import android.view.inputmethod.InputConnection; |
23 | 23 |
24 import org.chromium.base.ThreadUtils; | 24 import org.chromium.base.ThreadUtils; |
25 import org.chromium.base.test.util.CommandLineFlags; | 25 import org.chromium.base.test.util.CommandLineFlags; |
26 import org.chromium.base.test.util.Feature; | 26 import org.chromium.base.test.util.Feature; |
| 27 import org.chromium.base.test.util.UrlUtils; |
27 import org.chromium.content.browser.ContentViewCore; | 28 import org.chromium.content.browser.ContentViewCore; |
28 import org.chromium.content.browser.test.util.Criteria; | 29 import org.chromium.content.browser.test.util.Criteria; |
29 import org.chromium.content.browser.test.util.CriteriaHelper; | 30 import org.chromium.content.browser.test.util.CriteriaHelper; |
30 import org.chromium.content.browser.test.util.DOMUtils; | 31 import org.chromium.content.browser.test.util.DOMUtils; |
31 import org.chromium.content.browser.test.util.JavaScriptUtils; | 32 import org.chromium.content.browser.test.util.JavaScriptUtils; |
32 import org.chromium.content.browser.test.util.TestCallbackHelperContainer; | 33 import org.chromium.content.browser.test.util.TestCallbackHelperContainer; |
33 import org.chromium.content.browser.test.util.TestInputMethodManagerWrapper; | 34 import org.chromium.content.browser.test.util.TestInputMethodManagerWrapper; |
34 import org.chromium.content_public.browser.WebContents; | 35 import org.chromium.content_public.browser.WebContents; |
35 import org.chromium.content_shell_apk.ContentShellTestBase; | 36 import org.chromium.content_shell_apk.ContentShellTestBase; |
36 import org.chromium.ui.base.ime.TextInputType; | 37 import org.chromium.ui.base.ime.TextInputType; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 assertEquals(0, mConnectionFactory.getOutAttrs().initialSelEnd); | 90 assertEquals(0, mConnectionFactory.getOutAttrs().initialSelEnd); |
90 | 91 |
91 waitForEventLogs("selectionchange"); | 92 waitForEventLogs("selectionchange"); |
92 clearEventLogs(); | 93 clearEventLogs(); |
93 | 94 |
94 resetAllStates(); | 95 resetAllStates(); |
95 } | 96 } |
96 | 97 |
97 @MediumTest | 98 @MediumTest |
98 @Feature({"TextInput", "Main"}) | 99 @Feature({"TextInput", "Main"}) |
| 100 public void testKeyboardDismissedWhenNavigating() throws Throwable { |
| 101 assertWaitForKeyboardStatus(true); |
| 102 |
| 103 // Should hide keyboard when loading a new Url. |
| 104 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 105 @Override |
| 106 public void run() { |
| 107 final String dataUrl = UrlUtils.encodeHtmlDataUri( |
| 108 "<html><body><input id=\"input_text\" type=\"text\"></bo
dy></html>"); |
| 109 getActivity().getActiveShell().loadUrl(dataUrl); |
| 110 } |
| 111 }); |
| 112 assertWaitForKeyboardStatus(false); |
| 113 |
| 114 DOMUtils.clickNode(this, mContentViewCore, "input_text"); |
| 115 assertWaitForKeyboardStatus(true); |
| 116 |
| 117 // Should hide keyboard when going back. |
| 118 final String code = "history.go(-1)"; |
| 119 JavaScriptUtils.executeJavaScriptAndWaitForResult( |
| 120 getContentViewCore().getWebContents(), code); |
| 121 assertWaitForKeyboardStatus(false); |
| 122 } |
| 123 |
| 124 @MediumTest |
| 125 @Feature({"TextInput", "Main"}) |
99 public void testKeyboardDismissedAfterClickingGo() throws Throwable { | 126 public void testKeyboardDismissedAfterClickingGo() throws Throwable { |
100 setComposingText("hello", 1); | 127 setComposingText("hello", 1); |
101 waitAndVerifyUpdateSelection(0, 5, 5, 0, 5); | 128 waitAndVerifyUpdateSelection(0, 5, 5, 0, 5); |
102 | 129 |
103 performGo(mCallbackContainer); | 130 performGo(mCallbackContainer); |
104 | 131 |
105 assertWaitForKeyboardStatus(false); | 132 assertWaitForKeyboardStatus(false); |
106 } | 133 } |
107 | 134 |
108 @MediumTest | 135 @MediumTest |
(...skipping 1624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1733 public void onViewAttachedToWindow() { | 1760 public void onViewAttachedToWindow() { |
1734 mFactory.onViewAttachedToWindow(); | 1761 mFactory.onViewAttachedToWindow(); |
1735 } | 1762 } |
1736 | 1763 |
1737 @Override | 1764 @Override |
1738 public void onViewDetachedFromWindow() { | 1765 public void onViewDetachedFromWindow() { |
1739 mFactory.onViewDetachedFromWindow(); | 1766 mFactory.onViewDetachedFromWindow(); |
1740 } | 1767 } |
1741 } | 1768 } |
1742 } | 1769 } |
OLD | NEW |