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

Side by Side 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, 9 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
OLDNEW
(Empty)
1 // Copyright 2016 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.input;
6
7 import android.os.Handler;
8 import android.os.Looper;
9
10 import java.util.concurrent.Callable;
11 import java.util.concurrent.FutureTask;
12 import java.util.concurrent.TimeUnit;
13
14 /**
15 * Utilities for testing IME (input method editor).
16 */
17 public class ImeTestUtils {
18 private static final long MAX_WAIT_TIME_MILLIS = 5000;
19
20 public static <T> T runBlockingOnHandlerNoException(Handler handler, Callabl e<T> callable) {
21 try {
22 return runBlockingOnHandler(handler, callable, MAX_WAIT_TIME_MILLIS) ;
23 } catch (Exception e) {
24 throw new RuntimeException("Error occured waiting for callable", e);
25 }
26 }
27
28 public static <T> T runBlockingOnHandler(Handler handler, Callable<T> callab le)
29 throws Exception {
30 return runBlockingOnHandler(handler, callable, MAX_WAIT_TIME_MILLIS);
31 }
32
33 public static <T> T runBlockingOnHandler(
34 Handler handler, Callable<T> callable, long waitTimeMillis) throws E xception {
35 if (handler.getLooper() == Looper.myLooper()) {
36 return callable.call();
37 } else {
38 FutureTask<T> task = new FutureTask<T>(callable);
39 handler.post(task);
40 return task.get(waitTimeMillis, TimeUnit.MILLISECONDS);
41 }
42 }
43 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698