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

Unified Diff: tests/CachedDecodingPixelRefTest.cpp

Issue 145443004: Resolve a few memory leaks in tests. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 11 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/lazy/SkDiscardablePixelRef.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/CachedDecodingPixelRefTest.cpp
diff --git a/tests/CachedDecodingPixelRefTest.cpp b/tests/CachedDecodingPixelRefTest.cpp
index 9ac5f8139259f2261e5fb98a5d6be76ada9b6dab..d725ff5fc9c57b7390f0ced1ca77f4f80f17dd5c 100644
--- a/tests/CachedDecodingPixelRefTest.cpp
+++ b/tests/CachedDecodingPixelRefTest.cpp
@@ -142,6 +142,12 @@ static void test_three_encodings(skiatest::Reporter* reporter,
}
}
+static void purge_global_scaled_image_cache() {
+ size_t byteLimit = SkScaledImageCache::GetByteLimit();
+ SkScaledImageCache::SetByteLimit(0);
+ SkScaledImageCache::SetByteLimit(byteLimit);
+}
+
////////////////////////////////////////////////////////////////////////////////
static bool install_skCachingPixelRef(SkData* encoded, SkBitmap* dst) {
return SkCachingPixelRef::Install(
@@ -163,6 +169,7 @@ static bool install_skDiscardablePixelRef(SkData* encoded, SkBitmap* dst) {
*/
DEF_TEST(DecodingImageGenerator, reporter) {
test_three_encodings(reporter, install_skCachingPixelRef);
+ purge_global_scaled_image_cache();
test_three_encodings(reporter, install_skDiscardablePixelRef);
}
@@ -295,6 +302,8 @@ DEF_TEST(DiscardableAndCachingPixelRef, reporter) {
check_pixelref(TestImageGenerator::kSucceedGetPixels_TestType,
reporter, kSkCaching_PixelRefType, NULL);
+ purge_global_scaled_image_cache();
+
check_pixelref(TestImageGenerator::kFailGetInfo_TestType,
reporter, kSkDiscardable_PixelRefType, NULL);
check_pixelref(TestImageGenerator::kFailGetPixels_TestType,
« no previous file with comments | « src/lazy/SkDiscardablePixelRef.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698