Search in sources :

Example 6 with ObjectKey

use of com.bumptech.glide.signature.ObjectKey in project glide by bumptech.

the class RequestOptionsTest method testEqualsHashCode.

@Test
public void testEqualsHashCode() {
    Drawable first = new ColorDrawable(Color.RED);
    Drawable second = new GradientDrawable();
    assertThat(first).isNotEqualTo(second);
    assertThat(Util.bothNullOrEqual(first, second)).isFalse();
    new EqualsTester().addEqualityGroup(new RequestOptions().sizeMultiplier(.7f), new RequestOptions().sizeMultiplier(.7f)).addEqualityGroup(new RequestOptions().sizeMultiplier(0.8f)).addEqualityGroup(new RequestOptions().error(1), new RequestOptions().error(1)).addEqualityGroup(new RequestOptions().error(2)).addEqualityGroup(new RequestOptions().error(first), new RequestOptions().error(first)).addEqualityGroup(new RequestOptions().error(second)).addEqualityGroup(new RequestOptions().placeholder(1), new RequestOptions().placeholder(1)).addEqualityGroup(new RequestOptions().placeholder(2)).addEqualityGroup(new RequestOptions().placeholder(first), new RequestOptions().placeholder(first)).addEqualityGroup(new RequestOptions().placeholder(second)).addEqualityGroup(new RequestOptions().fallback(1), new RequestOptions().fallback(1)).addEqualityGroup(new RequestOptions().fallback(2)).addEqualityGroup(new RequestOptions().fallback(first), new RequestOptions().fallback(first)).addEqualityGroup(new RequestOptions().fallback(second)).addEqualityGroup(new RequestOptions().skipMemoryCache(true), new RequestOptions().skipMemoryCache(true)).addEqualityGroup(new RequestOptions(), new RequestOptions().skipMemoryCache(false), new RequestOptions().theme(null), new RequestOptions().onlyRetrieveFromCache(false), new RequestOptions().useUnlimitedSourceGeneratorsPool(false)).addEqualityGroup(new RequestOptions().override(100), new RequestOptions().override(100, 100)).addEqualityGroup(new RequestOptions().override(200), new RequestOptions().override(200, 200)).addEqualityGroup(new RequestOptions().override(100, 200), new RequestOptions().override(100, 200)).addEqualityGroup(new RequestOptions().override(200, 100), new RequestOptions().override(200, 100)).addEqualityGroup(new RequestOptions().centerCrop(), new RequestOptions().centerCrop()).addEqualityGroup(new RequestOptions().optionalCenterCrop(), new RequestOptions().optionalCenterCrop()).addEqualityGroup(new RequestOptions().fitCenter()).addEqualityGroup(new RequestOptions().circleCrop()).addEqualityGroup(new RequestOptions().centerInside()).addEqualityGroup(new RequestOptions().useUnlimitedSourceGeneratorsPool(true), new RequestOptions().useUnlimitedSourceGeneratorsPool(true)).addEqualityGroup(new RequestOptions().onlyRetrieveFromCache(true), new RequestOptions().onlyRetrieveFromCache(true)).addEqualityGroup(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.ALL), new RequestOptions().diskCacheStrategy(DiskCacheStrategy.ALL)).addEqualityGroup(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE)).addEqualityGroup(new RequestOptions().priority(Priority.HIGH), new RequestOptions().priority(Priority.HIGH)).addEqualityGroup(new RequestOptions().priority(Priority.LOW)).addEqualityGroup(new RequestOptions().set(Option.memory("test"), true), new RequestOptions().set(Option.memory("test"), true)).addEqualityGroup(new RequestOptions().set(Option.memory("test"), false)).addEqualityGroup(new RequestOptions().set(Option.memory("test2"), true)).addEqualityGroup(new RequestOptions().decode(Integer.class), new RequestOptions().decode(Integer.class)).addEqualityGroup(new RequestOptions().decode(Float.class)).addEqualityGroup(new RequestOptions().signature(new ObjectKey("test")), new RequestOptions().signature(new ObjectKey("test"))).addEqualityGroup(new RequestOptions().signature(new ObjectKey("test2"))).addEqualityGroup(new RequestOptions().theme(app.getTheme()), new RequestOptions().theme(app.getTheme())).testEquals();
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) EqualsTester(com.google.common.testing.EqualsTester) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) GradientDrawable(android.graphics.drawable.GradientDrawable) ObjectKey(com.bumptech.glide.signature.ObjectKey) GradientDrawable(android.graphics.drawable.GradientDrawable) Test(org.junit.Test)

Aggregations

ObjectKey (com.bumptech.glide.signature.ObjectKey)6 Test (org.junit.Test)4 Options (com.bumptech.glide.load.Options)3 NonNull (android.support.annotation.NonNull)2 CacheKeyUpdater (com.bumptech.glide.load.Option.CacheKeyUpdater)2 EqualsTester (com.google.common.testing.EqualsTester)2 MessageDigest (java.security.MessageDigest)2 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 GradientDrawable (android.graphics.drawable.GradientDrawable)1 Transformation (com.bumptech.glide.load.Transformation)1 File (java.io.File)1 Before (org.junit.Before)1