Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(549)

Unified Diff: tests/ImageCacheTest.cpp

Issue 185263009: Replace scaled bitmap if entry already exist in cache. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: unit test Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkScaledImageCache.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ImageCacheTest.cpp
diff --git a/tests/ImageCacheTest.cpp b/tests/ImageCacheTest.cpp
index 65c9068853d7e20711f792998946c107c7868416..43a5e70f23b605f47eef44404f81396615b69474 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);
}
« no previous file with comments | « src/core/SkScaledImageCache.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698