aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ImageCacheTest.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-05 13:44:18 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-05 13:44:18 +0000
commit5e4112b33aeecbb773ed4c8e33994dec14becb84 (patch)
treebc75d9134042016d9d21d126ddc8561e2a1982cf /tests/ImageCacheTest.cpp
parent8ef51b975c2bdb8fa332f091863e5410c18576c7 (diff)
Replace scaled bitmap if entry already exist in cache.
BUG=skia:2251 R=reed@google.com Author: reveman@chromium.org Review URL: https://codereview.chromium.org/185263009 git-svn-id: http://skia.googlecode.com/svn/trunk@13667 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/ImageCacheTest.cpp')
-rw-r--r--tests/ImageCacheTest.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/tests/ImageCacheTest.cpp b/tests/ImageCacheTest.cpp
index 65c9068853..43a5e70f23 100644
--- a/tests/ImageCacheTest.cpp
+++ b/tests/ImageCacheTest.cpp
@@ -105,17 +105,27 @@ DEF_TEST(ImageCache, reporter) {
DEF_TEST(ImageCache_doubleAdd, r) {
// Adding the same key twice should be safe.
- SkScaledImageCache cache(1024);
+ SkScaledImageCache cache(4096);
SkBitmap original;
original.allocN32Pixels(40, 40);
- SkBitmap scaled;
- scaled.allocN32Pixels(20, 20);
+ SkBitmap scaled1;
+ scaled1.allocN32Pixels(20, 20);
- SkScaledImageCache::ID* id1 = cache.addAndLock(original, 0.5f, 0.5f, scaled);
- SkScaledImageCache::ID* id2 = cache.addAndLock(original, 0.5f, 0.5f, scaled);
+ SkBitmap scaled2;
+ scaled2.allocN32Pixels(20, 20);
+
+ SkScaledImageCache::ID* id1 = cache.addAndLock(original, 0.5f, 0.5f, scaled1);
+ SkScaledImageCache::ID* id2 = cache.addAndLock(original, 0.5f, 0.5f, scaled2);
// We don't really care if id1 == id2 as long as unlocking both works.
cache.unlock(id1);
cache.unlock(id2);
+
+ SkBitmap tmp;
+ // Lookup should return the value that was added last.
+ SkScaledImageCache::ID* id = cache.findAndLock(original, 0.5f, 0.5f, &tmp);
+ REPORTER_ASSERT(r, NULL != id);
+ REPORTER_ASSERT(r, tmp.getGenerationID() == scaled2.getGenerationID());
+ cache.unlock(id);
}