diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-01-24 22:38:39 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-01-24 22:38:39 +0000 |
commit | 709ca75f032d7c60eb53c5840524a875a3a6cdb1 (patch) | |
tree | 0e9d511e02bdcf5e1ef443b7fac4c8e8694092a4 /tests/OnceTest.cpp | |
parent | 3a9ade7f37a819c3290f5a668bb11c5e61bfa93f (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/OnceTest.cpp')
-rw-r--r-- | tests/OnceTest.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
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); +} |