@Test public void getPlaceholder_afterApplyingOptionsWithPlaceholderDrawable_returnsNewDrawable() { Drawable expected = new ColorDrawable(Color.GREEN); RequestOptions toApply = new RequestOptions().placeholder(expected); assertThat( options .placeholder(new ColorDrawable(Color.RED)) .apply(toApply) .getPlaceholderDrawable()) .isEqualTo(expected); }
@Test public void getError_afterApplyingOptionsWithErrorDrawable_returnsNewErrorDrawable() { Drawable expected = new ColorDrawable(Color.GREEN); RequestOptions toApply = new RequestOptions().error(expected); assertThat( options .error(new ColorDrawable(Color.RED)) .apply(toApply) .getErrorPlaceholder()) .isEqualTo(expected); }
@Test public void getPlaceholderId_afterApplyingOptionsWithPlaceholderDrawable_returnsZero() { RequestOptions toApply = new RequestOptions().placeholder(new ColorDrawable(Color.RED)); assertThat( options .placeholder(android.R.drawable.star_on) .apply(toApply) .getPlaceholderId()) .isEqualTo(0); }
@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 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 getFallback_afterApplyingOptionsWithFallbackDrawable_returnsNewDrawable() { RequestOptions toApply = new RequestOptions(); RequestOptions apply = options.fallback(new ColorDrawable(Color.RED)).apply(toApply); assertThat(((ColorDrawable) apply.getFallbackDrawable()).getColor()).isEqualTo(Color.RED); }
@Test public void getErrorId_afterApplyingOptionsWithErrorDrawable_returnsZero() { RequestOptions toApply = new RequestOptions().error(new ColorDrawable(Color.RED)); assertThat( options.error(android.R.drawable.star_on) .apply(toApply) .getErrorId()) .isEqualTo(0); }
@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 testIsTransformationSet_afterApplyingOptionsWithTransform_isTrue() { RequestOptions other = new RequestOptions(); other.transform(Bitmap.class, transformation); options.apply(other); assertThat(options.isTransformationSet()).isTrue(); }
@Test public void testApplyingDefaultOptions_withTransform_retrainsTransform() { options.transform(transformation); options.apply(new RequestOptions()); assertThat(options.isTransformationAllowed()).isTrue(); assertThat(options.isTransformationRequired()).isTrue(); assertThat(options.getTransformations()).containsEntry(Bitmap.class, transformation); }
@Test public void testApplyingDefaultOptions_withDontTransform_retainsDontTransform() { options.dontTransform(); options.apply(new RequestOptions()); assertThat(options.isTransformationAllowed()).isFalse(); assertThat(options.isTransformationRequired()).isFalse(); assertThat(options.getTransformations()).isEmpty(); }
@Test public void getFallbackId_afterApplyingOptionsWithFallbackId_returnsNewFallbackId() { RequestOptions toApply = new RequestOptions().fallback(android.R.drawable.star_off); assertThat( options .fallback(android.R.drawable.star_on) .apply(toApply) .getFallbackId()) .isEqualTo(android.R.drawable.star_off); }
@Test public void getErrorId_afterApplyingOptionsWithErrorId_returnsNewErrorId() { RequestOptions toApply = new RequestOptions().error(android.R.drawable.star_off); assertThat( options.error(android.R.drawable.star_on) .apply(toApply) .getErrorId()) .isEqualTo(android.R.drawable.star_off); }
@Test public void isScaleOnlyOrNoTransform_withDontTransformAndAppliedNonScaleTransform_isFalse() { options.fitCenter(); options.apply(new RequestOptions().circleCrop()); assertThat(options.isScaleOnlyOrNoTransform()).isFalse(); }
@Test public void isScaleOnlyOrNoTransform_withScaleOnlyAndAppliedWithoutTransform_isTrue() { options.fitCenter(); options.apply(new RequestOptions().dontAnimate()); assertThat(options.isScaleOnlyOrNoTransform()).isTrue(); }
@Test public void getPlaceholderId_afterApplyingOptionsWithId_returnsNewId() { int expectedId = android.R.drawable.star_off; RequestOptions toApply = new RequestOptions().placeholder(expectedId); assertThat( options .placeholder(android.R.drawable.star_on) .apply(toApply) .getPlaceholderId()) .isEqualTo(expectedId); }
@Test public void isScaleOnlyOrNoTransform_withNonScaleAndAppliedDontTransform_isTrue() { options.circleCrop(); options.apply(new RequestOptions().dontTransform()); assertThat(options.isScaleOnlyOrNoTransform()).isTrue(); }
@Test public void isScaleOnlyOrNoTransform_withNonScaleOnlyAndAppliedWithoutTransform_isFalse() { options.circleCrop(); options.apply(new RequestOptions().dontAnimate()); assertThat(options.isScaleOnlyOrNoTransform()).isFalse(); }
@Test public void isScaleOnlyOrNoTransform_withNonScaleOnly_andAppliedWithScaleOnly_isTrue() { options.circleCrop(); options.apply(new RequestOptions().fitCenter()); assertThat(options.isScaleOnlyOrNoTransform()).isTrue(); }
@Test public void testApplyingOptions_withTransformation_overridesDontTransform() { options.dontTransform(); RequestOptions other = new RequestOptions(); other.transform(transformation); options.apply(other); assertThat(options.isTransformationAllowed()).isTrue(); assertThat(options.isTransformationSet()).isTrue(); assertThat(options.isTransformationRequired()).isTrue(); assertThat(options.getTransformations()).containsEntry(Bitmap.class, transformation); }