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());
}
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));
}
}
Aggregations