use of com.bumptech.glide.load.engine.ActiveResources.ResourceWeakReference in project glide by bumptech.
the class ActiveResourcesTest method queueIdle_withQueuedReferenceRetrievedFromGetAndNotCacheable_doesNotNotifyListener.
@Test
public void queueIdle_withQueuedReferenceRetrievedFromGetAndNotCacheable_doesNotNotifyListener() {
EngineResource<Object> engineResource = new EngineResource<>(resource, /*isCacheable=*/
false, /*isRecyclable=*/
true);
resources.activate(key, engineResource);
ResourceWeakReference weakRef = resources.activeEngineResources.get(key);
CountDownLatch latch = getLatchForClearedRef();
weakRef.enqueue();
resources.get(key);
waitForLatch(latch);
verify(listener, never()).onResourceReleased(any(Key.class), any(EngineResource.class));
}
use of com.bumptech.glide.load.engine.ActiveResources.ResourceWeakReference in project glide by bumptech.
the class ActiveResourcesTest method queueIdle_withQueuedReferenceRetrievedFromGet_notifiesListener.
@Test
public void queueIdle_withQueuedReferenceRetrievedFromGet_notifiesListener() {
EngineResource<Object> engineResource = new EngineResource<>(resource, /*isCacheable=*/
true, /*isRecyclable=*/
true);
resources.activate(key, engineResource);
ResourceWeakReference weakRef = resources.activeEngineResources.get(key);
resources.get(key);
enqueueAndWaitForRef(weakRef);
ArgumentCaptor<EngineResource<?>> captor = getEngineResourceCaptor();
verify(listener).onResourceReleased(eq(key), captor.capture());
assertThat(captor.getValue().getResource()).isEqualTo(resource);
}
use of com.bumptech.glide.load.engine.ActiveResources.ResourceWeakReference in project glide by bumptech.
the class ActiveResourcesTest method queueIdle_afterResourceRemovedFromActive_doesNotCallListener.
@Test
public void queueIdle_afterResourceRemovedFromActive_doesNotCallListener() {
EngineResource<Object> engineResource = new EngineResource<>(resource, /*isCacheable=*/
true, /*isRecyclable=*/
true);
resources.activate(key, engineResource);
ResourceWeakReference weakRef = resources.activeEngineResources.get(key);
resources.deactivate(key);
enqueueAndWaitForRef(weakRef);
verify(listener, never()).onResourceReleased(any(Key.class), any(EngineResource.class));
}
use of com.bumptech.glide.load.engine.ActiveResources.ResourceWeakReference in project glide by bumptech.
the class ActiveResourcesTest method queueIdle_withNotCacheableResourceInActive_doesNotCallListener.
@Test
public void queueIdle_withNotCacheableResourceInActive_doesNotCallListener() {
EngineResource<Object> engineResource = new EngineResource<>(resource, /*isCacheable=*/
false, /*isRecyclable=*/
true);
resources.activate(key, engineResource);
ResourceWeakReference weakRef = resources.activeEngineResources.get(key);
weakRef.enqueue();
enqueueAndWaitForRef(weakRef);
verify(listener, never()).onResourceReleased(any(Key.class), any(EngineResource.class));
}
use of com.bumptech.glide.load.engine.ActiveResources.ResourceWeakReference in project glide by bumptech.
the class ActiveResourcesTest method queueIdle_withNotCacheableResourceInActive_removesResourceFromActive.
@Test
public void queueIdle_withNotCacheableResourceInActive_removesResourceFromActive() {
EngineResource<Object> engineResource = new EngineResource<>(resource, /*isCacheable=*/
false, /*isRecyclable=*/
true);
resources.activate(key, engineResource);
ResourceWeakReference weakRef = resources.activeEngineResources.get(key);
enqueueAndWaitForRef(weakRef);
assertThat(resources.get(key)).isNull();
}
Aggregations