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

Side by Side Diff: testing/android/junit/java/src/org/chromium/testing/local/BackgroundShadowAsyncTask.java

Issue 2239003002: Revert of [Android] Update all Robolectric tests to Robolectric 3.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.testing.local; 5 package org.chromium.testing.local;
6 6
7 import static org.junit.Assert.fail; 7 import static org.junit.Assert.fail;
8 8
9 import android.os.AsyncTask; 9 import android.os.AsyncTask;
10 10
11 import org.robolectric.Robolectric;
11 import org.robolectric.annotation.Implementation; 12 import org.robolectric.annotation.Implementation;
12 import org.robolectric.annotation.Implements; 13 import org.robolectric.annotation.Implements;
13 import org.robolectric.shadows.ShadowApplication;
14 import org.robolectric.shadows.ShadowAsyncTask; 14 import org.robolectric.shadows.ShadowAsyncTask;
15 15
16 import java.util.concurrent.Callable; 16 import java.util.concurrent.Callable;
17 import java.util.concurrent.ExecutorService; 17 import java.util.concurrent.ExecutorService;
18 import java.util.concurrent.Executors; 18 import java.util.concurrent.Executors;
19 19
20 /** 20 /**
21 * Executes async tasks on a background thread and waits on the result on the ma in thread. 21 * Executes async tasks on a background thread and waits on the result on the ma in thread.
22 * This is useful for users of AsyncTask on Roboelectric who check if the code i s actually being 22 * This is useful for users of AsyncTask on Roboelectric who check if the code i s actually being
23 * run on a background thread (i.e. through the use of {@link ThreadUtils#runnin gOnUiThread()}). 23 * run on a background thread (i.e. through the use of {@link ThreadUtils#runnin gOnUiThread()}).
(...skipping 20 matching lines...) Expand all
44 } catch (Exception ex) { 44 } catch (Exception ex) {
45 fail(ex.getMessage()); 45 fail(ex.getMessage());
46 return null; 46 return null;
47 } 47 }
48 } 48 }
49 49
50 public static void runBackgroundTasks() throws Exception { 50 public static void runBackgroundTasks() throws Exception {
51 sExecutorService.submit(new Runnable() { 51 sExecutorService.submit(new Runnable() {
52 @Override 52 @Override
53 public void run() { 53 public void run() {
54 ShadowApplication.runBackgroundTasks(); 54 Robolectric.runBackgroundTasks();
55 } 55 }
56 }).get(); 56 }).get();
57 } 57 }
58 } 58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698