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

Side by Side Diff: content/public/android/javatests/src/org/chromium/content/browser/ContentViewCoreFocusTest.java

Issue 2290133002: Make WebView keep keyboard when losing focus (Closed)
Patch Set: rebase Created 4 years, 1 month 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
OLDNEW
(Empty)
1 // Copyright 2014 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.content.browser;
6
7 import android.content.Context;
8 import android.os.IBinder;
9 import android.os.ResultReceiver;
10 import android.test.UiThreadTest;
11 import android.test.suitebuilder.annotation.SmallTest;
12 import android.view.View;
13 import android.widget.EditText;
14
15 import org.chromium.content.browser.input.InputMethodManagerWrapper;
16 import org.chromium.content_shell.R;
17 import org.chromium.content_shell_apk.ContentShellTestBase;
18
19 /**
20 * Test that content view core responds to focus changes correctly.
21 */
22 public class ContentViewCoreFocusTest extends ContentShellTestBase {
23 private static class TestInputMethodManagerWrapper extends InputMethodManage rWrapper {
24 private boolean mHidden = false;
25 public TestInputMethodManagerWrapper(Context context) {
26 super(context);
27 }
28
29 @Override
30 public void showSoftInput(View view, int flags, ResultReceiver resultRec eiver) {
31 mHidden = false;
32 }
33
34 @Override
35 public boolean hideSoftInputFromWindow(IBinder windowToken, int flags,
36 ResultReceiver resultReceiver) {
37 mHidden = true;
38 return true;
39 }
40
41 @Override
42 public boolean isActive(View view) {
43 return true;
44 }
45
46 public boolean isHidden() {
47 return mHidden;
48 }
49 }
50
51 @UiThreadTest
52 @RerunWithUpdatedContainerView
53 @SmallTest
54 public void testHideImeOnLosingFocus() throws Throwable {
55 // Test the IME window is hidden from the content view when the content
56 // view loses its focus
57 final ContentViewCore contentViewCore = getContentViewCore();
58 final View view = contentViewCore.getContainerView();
59 assertTrue(view.requestFocus());
60
61 final TestInputMethodManagerWrapper immw = new TestInputMethodManagerWra pper(getActivity());
62 contentViewCore.getImeAdapterForTest().setInputMethodManagerWrapperForTe st(immw);
63
64 immw.showSoftInput(view, 0, null);
65 assertFalse(immw.isHidden());
66
67 final EditText urlBox = (EditText) getActivity().findViewById(R.id.url);
68
69 assertTrue(urlBox.requestFocus());
70
71 // Now another view has taken focus. The original view loses its focus
72 // and the input method window should be hidden
73 assertTrue(immw.isHidden());
74 }
75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698