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

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

Issue 161933002: Show IME when DPAD_CENTER is pressed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add a test for dpad center event Created 6 years, 10 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 | « content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java ('k') | no next file » | 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 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.test.suitebuilder.annotation.SmallTest;
9 import android.view.KeyEvent;
10
11 import org.chromium.content.browser.input.ImeAdapter;
12 import org.chromium.content_shell_apk.ContentShellTestBase;
13
14 /**
15 * Tests that ContentViewCore responds to DPAD key events correctly
16 */
17 public class ContentViewCoreDpadTest extends ContentShellTestBase {
18 TestContentViewCore mContentViewCore;
19 private static class TestImeAdapter extends ImeAdapter {
20 public TestImeAdapter() {
21 super(null, null);
22 }
23
24 @Override
25 public boolean dispatchKeyEvent(KeyEvent event) {
26 return true;
27 }
28 }
29
30 private static class TestContentViewCore extends ContentViewCore {
31 private boolean mIsShowImeIfNeededCalled = false;
32 public TestContentViewCore(Context context) {
33 super(context);
34 }
35
36 public boolean isShowImeIfNeededCalled() {
37 return mIsShowImeIfNeededCalled;
38 }
39
40 @Override
41 public void showImeIfNeeded() {
42 mIsShowImeIfNeededCalled = true;
43 }
44 }
45
46 public void setUp() throws Exception {
47 super.setUp();
48 mContentViewCore = new TestContentViewCore(getActivity());
49 mContentViewCore.setImeAdapterForTest(new TestImeAdapter());
50 }
51
52 @SmallTest
53 // Test KEYCODE_DPAD_CENTER keyevent will bring up the IME, if needed
54 public void testDpadCenterBringsUpIme() throws Exception {
55 KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPA D_CENTER);
56
57 mContentViewCore.dispatchKeyEvent(event);
58
59 // Just assert showImeIfNeeded is called. Software keyboard may not show if a QWERTY
60 // keyboard is connected or if the focused object is not editable.
61 assertTrue(mContentViewCore.isShowImeIfNeededCalled());
62 }
63 }
OLDNEW
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698