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

Side by Side Diff: base/android/javatests/src/org/chromium/base/test/InstrumentationUtils.java

Issue 10974012: Move base Java utils to base/test/android/javatests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moved util packaged to test subpackage. addded OWNERS Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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.base.test;
6
7 import android.app.Instrumentation;
8
9 import java.util.concurrent.Callable;
10 import java.util.concurrent.ExecutionException;
11 import java.util.concurrent.FutureTask;
12
13 /**
14 * Utility methods built around the android.app.Instrumentation class.
15 */
16 public final class InstrumentationUtils {
17
18 private InstrumentationUtils() {
19 }
20
21 public static <R> R runOnMainSyncAndGetResult(Instrumentation instrumentatio n,
22 Callable<R> callable) throws Throwable {
23 FutureTask<R> task = new FutureTask<R>(callable);
24 instrumentation.runOnMainSync(task);
25 try {
26 return task.get();
27 } catch (ExecutionException e) {
28 // Unwrap the cause of the exception and re-throw it.
29 throw e.getCause();
30 }
31 }
32 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698