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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/javatests/src/org/chromium/content/browser/ContentViewCoreDpadTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/ContentViewCoreDpadTest.java b/content/public/android/javatests/src/org/chromium/content/browser/ContentViewCoreDpadTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..0db99aa9c5e9d79c239189889a25eafeb15f0a9b
--- /dev/null
+++ b/content/public/android/javatests/src/org/chromium/content/browser/ContentViewCoreDpadTest.java
@@ -0,0 +1,63 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+package org.chromium.content.browser;
+
+import android.content.Context;
+import android.test.suitebuilder.annotation.SmallTest;
+import android.view.KeyEvent;
+
+import org.chromium.content.browser.input.ImeAdapter;
+import org.chromium.content_shell_apk.ContentShellTestBase;
+
+/**
+ * Tests that ContentViewCore responds to DPAD key events correctly
+ */
+public class ContentViewCoreDpadTest extends ContentShellTestBase {
+ TestContentViewCore mContentViewCore;
+ private static class TestImeAdapter extends ImeAdapter {
+ public TestImeAdapter() {
+ super(null, null);
+ }
+
+ @Override
+ public boolean dispatchKeyEvent(KeyEvent event) {
+ return true;
+ }
+ }
+
+ private static class TestContentViewCore extends ContentViewCore {
+ private boolean mIsShowImeIfNeededCalled = false;
+ public TestContentViewCore(Context context) {
+ super(context);
+ }
+
+ public boolean isShowImeIfNeededCalled() {
+ return mIsShowImeIfNeededCalled;
+ }
+
+ @Override
+ public void showImeIfNeeded() {
+ mIsShowImeIfNeededCalled = true;
+ }
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ mContentViewCore = new TestContentViewCore(getActivity());
+ mContentViewCore.setImeAdapterForTest(new TestImeAdapter());
+ }
+
+ @SmallTest
+ // Test KEYCODE_DPAD_CENTER keyevent will bring up the IME, if needed
+ public void testDpadCenterBringsUpIme() throws Exception {
+ KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_CENTER);
+
+ mContentViewCore.dispatchKeyEvent(event);
+
+ // Just assert showImeIfNeeded is called. Software keyboard may not show if a QWERTY
+ // keyboard is connected or if the focused object is not editable.
+ assertTrue(mContentViewCore.isShowImeIfNeededCalled());
+ }
+}
« 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