public void testOnlyElementNull() { assertThat(Stream.of((Object) null).collect(MoreCollectors.onlyElement())).isNull(); }
@Test public void testGetResourceFetcher_withEmptyString_returnsNull() { assertThat(loader.buildLoadData("", IMAGE_SIDE, IMAGE_SIDE, options)).isNull(); assertThat(loader.buildLoadData(" ", IMAGE_SIDE, IMAGE_SIDE, options)).isNull(); assertThat(loader.buildLoadData(" \n", IMAGE_SIDE, IMAGE_SIDE, options)).isNull(); } }
@Test public void testDoesNotThrowOnInvalidOrMissingId() { assertThat(loader.buildLoadData(1234, 0, 0, options)).isNull(); verify(uriLoader, never()).buildLoadData(any(Uri.class), anyInt(), anyInt(), any(Options.class)); } }
@Test public void obtain_withNullBitmapResource_returnsNull() { assertThat(LazyBitmapDrawableResource.obtain(resources, null)).isNull(); }
@Test public void get_withMissingKey_returnsNull() { assertThat(resources.get(key)).isNull(); }
@Test public void activate_withNonCacheableResource_doesNotSaveResource() { EngineResource<Object> engineResource = new EngineResource<>(resource, /*isCacheable=*/ false, /*isRecyclable=*/ true); resources.activate(key, engineResource); assertThat(resources.activeEngineResources.get(key).resource).isNull(); }
@Test public void testDoesNotPutResourceThatIsNotCacheableInActiveResourcesOnEngineComplete() { when(harness.resource.isCacheable()).thenReturn(false); harness.callOnEngineJobComplete(); assertThat(harness.activeResources.get(harness.cacheKey)).isNull(); }
@Test public void getError_afterSettingErrorId_returnsNull() { assertThat( options .error(new ColorDrawable(Color.RED)) .error(android.R.drawable.star_on) .getErrorPlaceholder()) .isNull(); }
@Test public void getPlaceholder_afterSettingPlaceholderId_returnsNul() { assertThat( options .placeholder(new ColorDrawable(Color.RED)) .placeholder(android.R.drawable.star_on) .getPlaceholderDrawable()) .isNull(); }
@Test public void getFallback_afterSettingFallbackId_returnsNull() { assertThat( options .fallback(new ColorDrawable(Color.RED)) .fallback(android.R.drawable.star_on) .getFallbackDrawable()) .isNull(); }
@Test public void clear_withSingleRequest_nullsOutDrawableInView() { concurrency.loadOnMainThread( GlideApp.with(context) .load(ResourceIds.raw.canonical), imageView); assertThat(imageView.getDrawable()).isNotNull(); concurrency.clearOnMainThread(imageView); assertThat(imageView.getDrawable()).isNull(); }
@Test public void testDoesNotPutNullResourceInActiveResourcesOnEngineComplete() { harness.getEngine().onEngineJobComplete(harness.job, harness.cacheKey, /*resource=*/ null); assertThat(harness.activeResources.get(harness.cacheKey)).isNull(); }
@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(); }
@Test public void queueIdle_withCacheableResourceInActive_removesResourceFromActive() { 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(); }
@Test public void get_withActiveAndClearedKey_returnsNull() { EngineResource<Object> engineResource = new EngineResource<>(resource, /*isCacheable=*/ true, /*isRecyclable=*/ true); resources.activate(key, engineResource); resources.activeEngineResources.get(key).clear(); assertThat(resources.get(key)).isNull(); }
@Test public void getFallback_afterApplyingOptionsWithFallbackId_returnsNull() { RequestOptions toApply = new RequestOptions().fallback(android.R.drawable.star_on); assertThat( options .fallback(new ColorDrawable(Color.RED)) .apply(toApply) .getFallbackDrawable()) .isNull(); }
@Test public void getPlaceholder_afterApplyingOptionsWithPlaceholderId_returnsNull() { RequestOptions toApply = new RequestOptions().placeholder(android.R.drawable.star_on); assertThat( options .placeholder(new ColorDrawable(Color.RED)) .apply(toApply) .getPlaceholderDrawable()) .isNull(); }
@Test public void getError_afterApplyingOptionsWithErrorId_returnsNull() { RequestOptions toApply = new RequestOptions().error(android.R.drawable.star_on); assertThat( options .error(new ColorDrawable(Color.RED)) .apply(toApply) .getErrorPlaceholder()) .isNull(); }
@Test public void get_withDeactivatedKey_returnsNull() { EngineResource<Object> engineResource = new EngineResource<>(resource, /*isCacheable=*/ true, /*isRecyclable=*/ true); resources.activate(key, engineResource); resources.deactivate(key); assertThat(resources.get(key)).isNull(); }
@Test public void testResourceIsRemovedFromActiveResourcesWhenReleased() { harness.activeResources.activate(harness.cacheKey, harness.resource); harness.getEngine().onResourceReleased(harness.cacheKey, harness.resource); assertThat(harness.activeResources.get(harness.cacheKey)).isNull(); }