use of org.robolectric.android.util.concurrent.PausedExecutorService in project robolectric by robolectric.
the class ShadowPausedAsyncTaskTest method overrideExecutor.
@Test
public void overrideExecutor() throws ExecutionException, InterruptedException {
PausedExecutorService pausedExecutor = new PausedExecutorService();
ShadowPausedAsyncTask.overrideExecutor(pausedExecutor);
AsyncTask<String, String, String> asyncTask = new RecordingAsyncTask();
asyncTask.execute("a", "b");
assertThat(transcript).containsExactly("onPreExecute");
transcript.clear();
pausedExecutor.runAll();
assertThat(transcript).containsExactly("doInBackground a, b");
assertThat(asyncTask.get()).isEqualTo("c");
transcript.clear();
shadowMainLooper().idle();
assertThat(transcript).containsExactly("onPostExecute c");
}
use of org.robolectric.android.util.concurrent.PausedExecutorService in project iterable-android-sdk by Iterable.
the class IterableInAppManagerTest method setUp.
@Before
public void setUp() throws IOException {
backgroundExecutor = new PausedExecutorService();
server = new MockWebServer();
dispatcher = new PathBasedQueueDispatcher();
server.setDispatcher(dispatcher);
inAppHandler = mock(IterableInAppHandler.class);
customActionHandler = mock(IterableCustomActionHandler.class);
urlHandler = mock(IterableUrlHandler.class);
IterableApi.overrideURLEndpointPath(server.url("").toString());
IterableApi.sharedInstance = new IterableApi();
IterableTestUtils.createIterableApiNew(new IterableTestUtils.ConfigBuilderExtender() {
@Override
public IterableConfig.Builder run(IterableConfig.Builder builder) {
return builder.setInAppHandler(inAppHandler).setCustomActionHandler(customActionHandler).setUrlHandler(urlHandler);
}
});
IterableInAppFragmentHTMLNotification.notification = null;
}
use of org.robolectric.android.util.concurrent.PausedExecutorService in project robolectric by robolectric.
the class ShadowPausedAsyncTaskLoaderTest method setUp.
@Before
public void setUp() {
pausedBackgroundExecutor = new PausedExecutorService();
testLoader = new TestLoader(42);
ShadowPausedAsyncTaskLoader<Integer> shadowLoader = Shadow.extract(testLoader);
shadowLoader.setExecutor(pausedBackgroundExecutor);
}
Aggregations