@Test public void performSubmitWithShutdownServiceIgnoresRequest() { when(service.isShutdown()).thenReturn(true); Action action = mockAction(URI_KEY_1, URI_1); dispatcher.performSubmit(action); assertThat(dispatcher.hunterMap).isEmpty(); verify(service, never()).submit(any(BitmapHunter.class)); }
@Test public void performRetrySkipIfServiceShutdown() { when(service.isShutdown()).thenReturn(true); BitmapHunter hunter = mockHunter(URI_KEY_1, bitmap1, false); dispatcher.performRetry(hunter); verify(service, never()).submit(hunter); assertThat(dispatcher.hunterMap).isEmpty(); assertThat(dispatcher.failedActions).isEmpty(); }
void performNetworkStateChange(NetworkInfo info) { if (service instanceof PicassoExecutorService) { ((PicassoExecutorService) service).adjustThreadCount(info); } // Intentionally check only if isConnected() here before we flush out failed actions. if (info != null && info.isConnected()) { flushFailedActions(); } }
@Test public void performSubmitWithShutdownAttachesRequest() { BitmapHunter hunter = mockHunter(URI_KEY_1, bitmap1, false); dispatcher.hunterMap.put(URI_KEY_1, hunter); when(service.isShutdown()).thenReturn(true); Action action = mockAction(URI_KEY_1, URI_1); dispatcher.performSubmit(action); assertThat(dispatcher.hunterMap).hasSize(1); verify(hunter).attach(action); verify(service, never()).submit(any(BitmapHunter.class)); }