Search in sources :

Example 11 with ResourceCallback

use of com.bumptech.glide.request.ResourceCallback in project glide by bumptech.

the class EngineJobTest method testRemovingCallbackDuringOnExceptionPreventsCallbackFromBeingCalledIfNotYetCalled.

@Test
public void testRemovingCallbackDuringOnExceptionPreventsCallbackFromBeingCalledIfNotYetCalled() {
    harness = new EngineJobHarness();
    final EngineJob<Object> job = harness.getJob();
    final ResourceCallback called = mock(ResourceCallback.class);
    final ResourceCallback notYetCalled = mock(ResourceCallback.class);
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
            job.removeCallback(notYetCalled);
            return null;
        }
    }).when(called).onLoadFailed(any(GlideException.class));
    job.addCallback(called);
    job.addCallback(notYetCalled);
    job.start(harness.decodeJob);
    job.onLoadFailed(new GlideException("test"));
    verify(notYetCalled, never()).onResourceReady(anyResource(), isADataSource());
}
Also used : ResourceCallback(com.bumptech.glide.request.ResourceCallback) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Test(org.junit.Test)

Example 12 with ResourceCallback

use of com.bumptech.glide.request.ResourceCallback in project glide by bumptech.

the class EngineJobTest method testNotifiesAllCallbacksOnReady.

@Test
public void testNotifiesAllCallbacksOnReady() {
    MultiCbHarness harness = new MultiCbHarness();
    harness.job.start(harness.decodeJob);
    harness.job.onResourceReady(harness.resource, harness.dataSource);
    for (ResourceCallback cb : harness.cbs) {
        verify(cb).onResourceReady(eq(harness.engineResource), eq(harness.dataSource));
    }
}
Also used : ResourceCallback(com.bumptech.glide.request.ResourceCallback) Test(org.junit.Test)

Aggregations

ResourceCallback (com.bumptech.glide.request.ResourceCallback)12 Test (org.junit.Test)10 InvocationOnMock (org.mockito.invocation.InvocationOnMock)7 Synthetic (com.bumptech.glide.util.Synthetic)2