Search in sources :

Example 21 with Key

use of com.bumptech.glide.load.Key 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));
}
Also used : ResourceWeakReference(com.bumptech.glide.load.engine.ActiveResources.ResourceWeakReference) CountDownLatch(java.util.concurrent.CountDownLatch) Key(com.bumptech.glide.load.Key) Test(org.junit.Test)

Example 22 with Key

use of com.bumptech.glide.load.Key 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));
}
Also used : ResourceWeakReference(com.bumptech.glide.load.engine.ActiveResources.ResourceWeakReference) CountDownLatch(java.util.concurrent.CountDownLatch) Key(com.bumptech.glide.load.Key) Test(org.junit.Test)

Example 23 with Key

use of com.bumptech.glide.load.Key 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 24 with Key

use of com.bumptech.glide.load.Key in project glide by bumptech.

the class ApplicationVersionSignatureTest method testMissingPackageInfo.

@Test
public void testMissingPackageInfo() throws NameNotFoundException {
    Context context = mock(Context.class, Answers.RETURNS_DEEP_STUBS.get());
    String packageName = "my.package";
    when(context.getPackageName()).thenReturn(packageName);
    when(context.getPackageManager().getPackageInfo(packageName, 0)).thenReturn(null);
    Key key = ApplicationVersionSignature.obtain(context);
    assertNotNull(key);
}
Also used : Context(android.content.Context) Key(com.bumptech.glide.load.Key) Test(org.junit.Test)

Aggregations

Key (com.bumptech.glide.load.Key)24 Test (org.junit.Test)13 ResourceWeakReference (com.bumptech.glide.load.engine.ActiveResources.ResourceWeakReference)7 File (java.io.File)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 Context (android.content.Context)2 NonNull (android.support.annotation.NonNull)2 DataFetcher (com.bumptech.glide.load.data.DataFetcher)2 ArrayList (java.util.ArrayList)2 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)1 Bitmap (android.graphics.Bitmap)1 VisibleForTesting (android.support.annotation.VisibleForTesting)1 EncodeStrategy (com.bumptech.glide.load.EncodeStrategy)1 Resource (com.bumptech.glide.load.engine.Resource)1 ResourceRemovedListener (com.bumptech.glide.load.engine.cache.MemoryCache.ResourceRemovedListener)1 MediaStoreSignature (com.bumptech.glide.signature.MediaStoreSignature)1 Util.anyResource (com.bumptech.glide.tests.Util.anyResource)1 Util.mockResource (com.bumptech.glide.tests.Util.mockResource)1 LruCache (com.bumptech.glide.util.LruCache)1 Synthetic (com.bumptech.glide.util.Synthetic)1