Search in sources :

Example 11 with ResourceWeakReference

use of com.bumptech.glide.load.engine.ActiveResources.ResourceWeakReference in project glide by bumptech.

the class ActiveResourcesTest method queueIdle_withCacheableResourceInActive_removesResourceFromActive.

@Test
public void queueIdle_withCacheableResourceInActive_removesResourceFromActive() throws InterruptedException {
    EngineResource<Object> engineResource = new EngineResource<>(resource, /*isCacheable=*/
    true, /*isRecyclable=*/
    true);
    resources.activate(key, engineResource);
    ResourceWeakReference weakRef = resources.activeEngineResources.get(key);
    enqueueAndWaitForRef(weakRef);
    assertThat(resources.get(key)).isNull();
}
Also used : ResourceWeakReference(com.bumptech.glide.load.engine.ActiveResources.ResourceWeakReference) Test(org.junit.Test)

Example 12 with ResourceWeakReference

use of com.bumptech.glide.load.engine.ActiveResources.ResourceWeakReference in project glide by bumptech.

the class ActiveResourcesTest method get_withQueuedReference_doesNotNotifyListener.

@Test
public void get_withQueuedReference_doesNotNotifyListener() {
    EngineResource<Object> engineResource = new EngineResource<>(resource, /*isCacheable=*/
    true, /*isRecyclable=*/
    true);
    resources.activate(key, engineResource);
    ResourceWeakReference weakRef = resources.activeEngineResources.get(key);
    weakRef.enqueue();
    verify(listener, never()).onResourceReleased(any(Key.class), any(EngineResource.class));
}
Also used : ResourceWeakReference(com.bumptech.glide.load.engine.ActiveResources.ResourceWeakReference) Key(com.bumptech.glide.load.Key) Test(org.junit.Test)

Example 13 with ResourceWeakReference

use of com.bumptech.glide.load.engine.ActiveResources.ResourceWeakReference in project glide by bumptech.

the class ActiveResourcesTest method get_withQueuedReference_retentionDisabled_returnsResource.

@Test
public void get_withQueuedReference_retentionDisabled_returnsResource() {
    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);
    weakRef.enqueue();
    assertThat(resources.get(key)).isEqualTo(engineResource);
}
Also used : ResourceWeakReference(com.bumptech.glide.load.engine.ActiveResources.ResourceWeakReference) Test(org.junit.Test)

Aggregations

ResourceWeakReference (com.bumptech.glide.load.engine.ActiveResources.ResourceWeakReference)13 Test (org.junit.Test)13 Key (com.bumptech.glide.load.Key)7 CountDownLatch (java.util.concurrent.CountDownLatch)4