use of com.bumptech.glide.load.engine.ActiveResources.ResourceWeakReference in project glide by bumptech.
the class ActiveResourcesTest method queueIdle_withQueuedReferenceRetrievedFromGet_retentionDisabled_doesNotNotify.
@Test
public void queueIdle_withQueuedReferenceRetrievedFromGet_retentionDisabled_doesNotNotify() {
resources = new ActiveResources(/*isActiveResourceRetentionAllowed=*/
false);
EngineResource<Object> engineResource = new EngineResource<>(resource, /*isCacheable=*/
true, /*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 get_withQueuedReference_returnsResource.
@Test
public void get_withQueuedReference_returnsResource() {
EngineResource<Object> engineResource = new EngineResource<>(resource, /*isCacheable=*/
true, /*isRecyclable=*/
true);
resources.activate(key, engineResource);
ResourceWeakReference weakRef = resources.activeEngineResources.get(key);
weakRef.enqueue();
assertThat(resources.get(key)).isEqualTo(engineResource);
}
use of com.bumptech.glide.load.engine.ActiveResources.ResourceWeakReference in project glide by bumptech.
the class ActiveResourcesTest method queueIdle_withQueuedReferenceDeactivated_doesNotNotifyListener.
@Test
public void queueIdle_withQueuedReferenceDeactivated_doesNotNotifyListener() {
EngineResource<Object> engineResource = new EngineResource<>(resource, /*isCacheable=*/
true, /*isRecyclable=*/
true);
resources.activate(key, engineResource);
ResourceWeakReference weakRef = resources.activeEngineResources.get(key);
CountDownLatch latch = getLatchForClearedRef();
weakRef.enqueue();
resources.deactivate(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_afterReferenceQueuedThenReactivated_doesNotNotifyListener.
@Test
public void queueIdle_afterReferenceQueuedThenReactivated_doesNotNotifyListener() {
EngineResource<Object> first = new EngineResource<>(resource, /*isCacheable=*/
true, /*isRecyclable=*/
true);
resources.activate(key, first);
ResourceWeakReference weakRef = resources.activeEngineResources.get(key);
CountDownLatch latch = getLatchForClearedRef();
weakRef.enqueue();
EngineResource<Object> second = new EngineResource<>(resource, /*isCacheable=*/
true, /*isRecyclable=*/
true);
resources.activate(key, second);
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_withCacheableResourceInActive_callListener.
@Test
public void queueIdle_withCacheableResourceInActive_callListener() {
EngineResource<Object> engineResource = new EngineResource<>(resource, /*isCacheable=*/
true, /*isRecyclable=*/
true);
resources.activate(key, engineResource);
ResourceWeakReference weakRef = resources.activeEngineResources.get(key);
enqueueAndWaitForRef(weakRef);
ArgumentCaptor<EngineResource<?>> captor = getEngineResourceCaptor();
verify(listener).onResourceReleased(eq(key), captor.capture());
EngineResource<?> released = captor.getValue();
assertThat(released.getResource()).isEqualTo(resource);
assertThat(released.isCacheable()).isTrue();
released.recycle();
verify(resource, never()).recycle();
}
Aggregations