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

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/input/ImeTestUtils.java

Issue 1278593004: Introduce ThreadedInputConnection behind a switch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed ImeTest#testDoesNotHang_rendererCrashes which does not test anything Created 4 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
Index: content/public/android/javatests/src/org/chromium/content/browser/input/ImeTestUtils.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTestUtils.java b/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTestUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..5759d50657079887a01a0588099353580b7ed648
--- /dev/null
+++ b/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTestUtils.java
@@ -0,0 +1,43 @@
+// Copyright 2016 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.input;
+
+import android.os.Handler;
+import android.os.Looper;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.FutureTask;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Utilities for testing IME (input method editor).
+ */
+public class ImeTestUtils {
+ private static final long MAX_WAIT_TIME_MILLIS = 5000;
+
+ public static <T> T runBlockingOnHandlerNoException(Handler handler, Callable<T> callable) {
+ try {
+ return runBlockingOnHandler(handler, callable, MAX_WAIT_TIME_MILLIS);
+ } catch (Exception e) {
+ throw new RuntimeException("Error occured waiting for callable", e);
+ }
+ }
+
+ public static <T> T runBlockingOnHandler(Handler handler, Callable<T> callable)
+ throws Exception {
+ return runBlockingOnHandler(handler, callable, MAX_WAIT_TIME_MILLIS);
+ }
+
+ public static <T> T runBlockingOnHandler(
+ Handler handler, Callable<T> callable, long waitTimeMillis) throws Exception {
+ if (handler.getLooper() == Looper.myLooper()) {
+ return callable.call();
+ } else {
+ FutureTask<T> task = new FutureTask<T>(callable);
+ handler.post(task);
+ return task.get(waitTimeMillis, TimeUnit.MILLISECONDS);
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698