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

Unified Diff: tests/OnceTest.cpp

Issue 132803005: SkOnce: add option to call another cleanup function once at exit. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add static 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 | « tests/CachedDecodingPixelRefTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/OnceTest.cpp
diff --git a/tests/OnceTest.cpp b/tests/OnceTest.cpp
index f9ab427c16439f95afe1561a554fac504ef02856..3a99c39d5396f82fc1d2b770425cc032ee6ca064 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);
+}
« no previous file with comments | « tests/CachedDecodingPixelRefTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698