Search in sources :

Example 1 with PausedExecutorService

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");
}
Also used : PausedExecutorService(org.robolectric.android.util.concurrent.PausedExecutorService) Test(org.junit.Test)

Example 2 with PausedExecutorService

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;
}
Also used : PausedExecutorService(org.robolectric.android.util.concurrent.PausedExecutorService) PathBasedQueueDispatcher(com.iterable.iterableapi.unit.PathBasedQueueDispatcher) MockWebServer(okhttp3.mockwebserver.MockWebServer) Before(org.junit.Before)

Example 3 with PausedExecutorService

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);
}
Also used : PausedExecutorService(org.robolectric.android.util.concurrent.PausedExecutorService) Before(org.junit.Before)

Aggregations

PausedExecutorService (org.robolectric.android.util.concurrent.PausedExecutorService)3 Before (org.junit.Before)2 PathBasedQueueDispatcher (com.iterable.iterableapi.unit.PathBasedQueueDispatcher)1 MockWebServer (okhttp3.mockwebserver.MockWebServer)1 Test (org.junit.Test)1