Index: tests/SkResourceCacheTest.cpp |
diff --git a/tests/SkResourceCacheTest.cpp b/tests/SkResourceCacheTest.cpp |
index b71c7443e57ad6ad7c26a7f72c8078415a9cd9c4..7f2e16a088dc3b7c81f986f9917ba33e42eb4660 100644 |
--- a/tests/SkResourceCacheTest.cpp |
+++ b/tests/SkResourceCacheTest.cpp |
@@ -72,3 +72,24 @@ DEF_TEST(ResourceCache_SingleAllocationByteLimit, reporter) { |
SkGraphics::SetResourceCacheSingleAllocationByteLimit(originalAllocationLimit); |
SkGraphics::SetResourceCacheTotalByteLimit(originalByteLimit); |
} |
+ |
+// http://skbug.com/2894 |
+DEF_TEST(BitmapCache_add_rect, reporter) { |
+ SkBitmap bm; |
+ SkIRect rect = SkIRect::MakeWH(5, 5); |
+ |
+ SkBitmap cachedBitmap; |
+ cachedBitmap.setInfo(SkImageInfo::MakeN32Premul(5, 5)); |
+ SkBitmap::Allocator* allocator = SkBitmapCache::GetAllocator(); |
+ if (NULL != allocator) |
+ allocator->allocPixelRef(&cachedBitmap, 0); |
+ else |
+ cachedBitmap.allocPixels(); |
+ |
+ // Should not be in the cache |
+ REPORTER_ASSERT(reporter, !SkBitmapCache::Find(cachedBitmap.getGenerationID(), rect, &bm)); |
+ |
+ SkBitmapCache::Add(cachedBitmap.getGenerationID(), rect, cachedBitmap); |
+ // Should be in the cache, we just added it |
+ REPORTER_ASSERT(reporter, SkBitmapCache::Find(cachedBitmap.getGenerationID(), rect, &bm)); |
+} |