aboutsummaryrefslogtreecommitdiff
path: root/tests/CachedDecodingPixelRefTest.cpp
diff options
context:
space:
mode:
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-24 18:33:07 +0000
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-24 18:33:07 +0000
commit227c24673196f5f06bee85e7e9aa067be90e1359 (patch)
tree0c9cb5e49e880dfff5936bb3b3be5509c26e1a33 /tests/CachedDecodingPixelRefTest.cpp
parentdd10e0ec4c9aeeadcd922d3ad0bf01496d920978 (diff)
Resolve a few memory leaks in tests.
Purge the global scaled image cache after use in tests. The cache was right to hold on to the pixels indefinitely, but this change makes it easier to run down actual memory leaks. Add SK_DECLARE_INST_COUNT to several classes. BUG=skia: R=reed@google.com Author: halcanary@google.com Review URL: https://codereview.chromium.org/145443004 git-svn-id: http://skia.googlecode.com/svn/trunk@13171 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/CachedDecodingPixelRefTest.cpp')
-rw-r--r--tests/CachedDecodingPixelRefTest.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/CachedDecodingPixelRefTest.cpp b/tests/CachedDecodingPixelRefTest.cpp
index 9ac5f81392..d725ff5fc9 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,