diff options
author | Sam Judd <judds@google.com> | 2014-11-02 13:35:43 -0800 |
---|---|---|
committer | Sam Judd <judds@google.com> | 2014-11-02 17:48:13 -0800 |
commit | f4d511ebf70c55d9224b57e6ff390373c0e2b12e (patch) | |
tree | 0f6043ca791cfb306ab166079c9733310d399732 /library/src/androidTest/java/com/bumptech/glide/load/model/ModelCacheTest.java | |
parent | dfd29c7799559aa6215d36189e7ba1870256849b (diff) | |
download | glide-f4d511ebf70c55d9224b57e6ff390373c0e2b12e.tar.gz |
Fix some holes exposed by coverage report.
Diffstat (limited to 'library/src/androidTest/java/com/bumptech/glide/load/model/ModelCacheTest.java')
-rw-r--r-- | library/src/androidTest/java/com/bumptech/glide/load/model/ModelCacheTest.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/library/src/androidTest/java/com/bumptech/glide/load/model/ModelCacheTest.java b/library/src/androidTest/java/com/bumptech/glide/load/model/ModelCacheTest.java new file mode 100644 index 00000000..c62fe920 --- /dev/null +++ b/library/src/androidTest/java/com/bumptech/glide/load/model/ModelCacheTest.java @@ -0,0 +1,55 @@ +package com.bumptech.glide.load.model; + +import com.google.common.testing.EqualsTester; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import static org.junit.Assert.assertEquals; + +@RunWith(JUnit4.class) +public class ModelCacheTest { + + private ModelCache<Object, Object> cache; + + @Before + public void setUp() { + cache = new ModelCache<Object, Object>(10); + } + + @Test + public void testModelKeyEquivalence() { + new EqualsTester() + .addEqualityGroup(ModelCache.ModelKey.get(14f, 100, 200), ModelCache.ModelKey.get(14f, 100, 200)) + .addEqualityGroup(ModelCache.ModelKey.get(13f, 100, 200)) + .addEqualityGroup(ModelCache.ModelKey.get(14f, 200, 200)) + .addEqualityGroup(ModelCache.ModelKey.get(14f, 100, 300)) + .testEquals(); + } + + @Test + public void testCanSetAndGetModel() { + Object model = new Object(); + int width = 10; + int height = 20; + Object result = new Object(); + cache.put(model, width, height, result); + assertEquals(result, cache.get(model, width, height)); + } + + @Test + public void testCanSetAndGetMultipleResultsWithDifferentDimensionsForSameObject() { + Object model = new Object(); + int firstWidth = 10, firstHeight = 20; + Object firstResult = new Object(); + int secondWidth = 30, secondHeight = 40; + Object secondResult = new Object(); + + cache.put(model, firstWidth, firstHeight, firstResult); + cache.put(model, secondWidth, secondHeight, secondResult); + + assertEquals(firstResult, cache.get(model, firstWidth, firstHeight)); + assertEquals(secondResult, cache.get(model, secondWidth, secondHeight)); + } +}
\ No newline at end of file |