aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-24 22:38:39 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-01-24 22:38:39 +0000
commit709ca75f032d7c60eb53c5840524a875a3a6cdb1 (patch)
tree0e9d511e02bdcf5e1ef443b7fac4c8e8694092a4 /tests
parent3a9ade7f37a819c3290f5a668bb11c5e61bfa93f (diff)
SkOnce: add option to call another cleanup function once at exit.
Use this to clean up empty SkData and SkPathRef. Current leaks: Leaked SkRefCntBase: 40 Leaked SkFlattenable: 32 Leaked SkPixelRef: 32 Leaked SkMallocPixelRef: 32 Leaked SkFontConfigInterface: 1 Leaked SkWeakRefCnt: 1 Leaked SkTypeface: 1 Leaked SkFontMgr: 1 Leaked SkDataTable: 3 Leaked SkImage: 1 Leaked ???: 1 Leaked ???: 1 BUG=skia: R=halcanary@google.com, reed@google.com Author: mtklein@google.com Review URL: https://codereview.chromium.org/132803005 git-svn-id: http://skia.googlecode.com/svn/trunk@13180 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r--tests/CachedDecodingPixelRefTest.cpp9
-rw-r--r--tests/OnceTest.cpp12
2 files changed, 12 insertions, 9 deletions
diff --git a/tests/CachedDecodingPixelRefTest.cpp b/tests/CachedDecodingPixelRefTest.cpp
index a04ebe637d..f984123958 100644
--- a/tests/CachedDecodingPixelRefTest.cpp
+++ b/tests/CachedDecodingPixelRefTest.cpp
@@ -142,12 +142,6 @@ 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(
@@ -169,7 +163,6 @@ 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);
}
@@ -302,8 +295,6 @@ 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,
diff --git a/tests/OnceTest.cpp b/tests/OnceTest.cpp
index f9ab427c16..3a99c39d53 100644
--- a/tests/OnceTest.cpp
+++ b/tests/OnceTest.cpp
@@ -77,3 +77,15 @@ DEF_TEST(SkOnce_Multithreaded, r) {
// Only one should have done the +=.
REPORTER_ASSERT(r, 6 == x);
}
+
+// Test that the atExit option works.
+static int gToDecrement = 1;
+static void noop(int) {}
+static void decrement() { gToDecrement--; }
+static void checkDecremented() { SkASSERT(gToDecrement == 0); }
+
+DEF_TEST(SkOnce_atExit, r) {
+ atexit(checkDecremented);
+ SK_DECLARE_STATIC_ONCE(once);
+ SkOnce(&once, noop, 0, decrement);
+}