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

Unified Diff: tests/SkResourceCacheTest.cpp

Issue 1350143002: remove racy tests, as they assume the cache can't be purged behind their back (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/SkResourceCacheTest.cpp
diff --git a/tests/SkResourceCacheTest.cpp b/tests/SkResourceCacheTest.cpp
index 9df15192d86670b2dfd8cf11263b70d6e0f4a26c..4432b87d3b3b7af15fe5c5334b7808013ac811c6 100644
--- a/tests/SkResourceCacheTest.cpp
+++ b/tests/SkResourceCacheTest.cpp
@@ -13,72 +13,6 @@
#include "SkResourceCache.h"
#include "SkSurface.h"
-static const int kCanvasSize = 1;
-static const int kBitmapSize = 16;
-static const int kScale = 8;
-
-static bool is_in_scaled_image_cache(const SkBitmap& orig,
- SkScalar xScale,
- SkScalar yScale) {
- SkBitmap scaled;
- int width = SkScalarRoundToInt(orig.width() * xScale);
- int height = SkScalarRoundToInt(orig.height() * yScale);
- return SkBitmapCache::FindWH(SkBitmapCacheDesc::Make(orig, width, height), &scaled);
-}
-
-// Draw a scaled bitmap, then return true if it has been cached.
-static bool test_scaled_image_cache_usage() {
- SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(kCanvasSize, kCanvasSize));
- SkCanvas* canvas = surface->getCanvas();
- SkBitmap bitmap;
- bitmap.allocN32Pixels(kBitmapSize, kBitmapSize);
- bitmap.eraseColor(0xFFFFFFFF);
- SkScalar xScale = SkIntToScalar(kScale);
- SkScalar yScale = xScale / 2;
- SkScalar xScaledSize = SkIntToScalar(kBitmapSize) * xScale;
- SkScalar yScaledSize = SkIntToScalar(kBitmapSize) * yScale;
- canvas->clipRect(SkRect::MakeLTRB(0, 0, xScaledSize, yScaledSize));
- SkPaint paint;
- paint.setFilterQuality(kHigh_SkFilterQuality);
-
- canvas->drawBitmapRect(bitmap,
- SkRect::MakeLTRB(0, 0, xScaledSize, yScaledSize),
- &paint);
-
- return is_in_scaled_image_cache(bitmap, xScale, yScale);
-}
-
-// http://crbug.com/389439
-DEF_TEST(ResourceCache_SingleAllocationByteLimit, reporter) {
- size_t originalByteLimit = SkGraphics::GetResourceCacheTotalByteLimit();
- size_t originalAllocationLimit =
- SkGraphics::GetResourceCacheSingleAllocationByteLimit();
-
- size_t size = kBitmapSize * kScale * kBitmapSize * kScale
- * SkColorTypeBytesPerPixel(kN32_SkColorType);
-
- SkGraphics::SetResourceCacheTotalByteLimit(0); // clear cache
- SkGraphics::SetResourceCacheTotalByteLimit(2 * size);
- SkGraphics::SetResourceCacheSingleAllocationByteLimit(0); // No limit
-
- REPORTER_ASSERT(reporter, test_scaled_image_cache_usage());
-
- SkGraphics::SetResourceCacheTotalByteLimit(0); // clear cache
- SkGraphics::SetResourceCacheTotalByteLimit(2 * size);
- SkGraphics::SetResourceCacheSingleAllocationByteLimit(size * 2); // big enough
-
- REPORTER_ASSERT(reporter, test_scaled_image_cache_usage());
-
- SkGraphics::SetResourceCacheTotalByteLimit(0); // clear cache
- SkGraphics::SetResourceCacheTotalByteLimit(2 * size);
- SkGraphics::SetResourceCacheSingleAllocationByteLimit(size / 2); // too small
-
- REPORTER_ASSERT(reporter, !test_scaled_image_cache_usage());
-
- SkGraphics::SetResourceCacheSingleAllocationByteLimit(originalAllocationLimit);
- SkGraphics::SetResourceCacheTotalByteLimit(originalByteLimit);
-}
-
////////////////////////////////////////////////////////////////////////////////////////
static void make_bitmap(SkBitmap* bitmap, const SkImageInfo& info, SkBitmap::Allocator* allocator) {
@@ -268,7 +202,6 @@ DEF_TEST(BitmapCache_discarded_bitmap, reporter) {
if (factory) {
REPORTER_ASSERT(reporter, SkGetGlobalDiscardableMemoryPool()->getRAMUsed() > 0);
SkGetGlobalDiscardableMemoryPool()->dumpPool();
- REPORTER_ASSERT(reporter, SkGetGlobalDiscardableMemoryPool()->getRAMUsed() == 0);
// The bitmap is not in the cache since it has been dropped.
REPORTER_ASSERT(reporter, !SkBitmapCache::Find(cachedBitmap.getGenerationID(), rect, &bm, cache));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698