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

Unified Diff: tests/OnceTest.cpp

Issue 302083003: Clean up SkOnce: (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: unused 1 == Created 6 years, 7 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/utils/win/SkDWrite.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 3a99c39d5396f82fc1d2b770425cc032ee6ca064..389d257b73fdb3a8aa25be023f6f48750cd2bb2f 100644
--- a/tests/OnceTest.cpp
+++ b/tests/OnceTest.cpp
@@ -27,20 +27,6 @@ DEF_TEST(SkOnce_Singlethreaded, r) {
REPORTER_ASSERT(r, 5 == x);
}
-struct AddFour { void operator()(int* x) { *x += 4; } };
-
-DEF_TEST(SkOnce_MiscFeatures, r) {
- // Tests that we support functors and explicit SkOnceFlags.
- int x = 0;
-
- SkOnceFlag once = SK_ONCE_INIT;
- SkOnce(&once, AddFour(), &x);
- SkOnce(&once, AddFour(), &x);
- SkOnce(&once, AddFour(), &x);
-
- REPORTER_ASSERT(r, 4 == x);
-}
-
static void add_six(int* x) {
*x += 6;
}
@@ -78,14 +64,13 @@ DEF_TEST(SkOnce_Multithreaded, r) {
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); }
+static int gX = 0;
+static void inc_gX() { gX++; }
-DEF_TEST(SkOnce_atExit, r) {
- atexit(checkDecremented);
+DEF_TEST(SkOnce_NoArg, r) {
SK_DECLARE_STATIC_ONCE(once);
- SkOnce(&once, noop, 0, decrement);
+ SkOnce(&once, inc_gX);
+ SkOnce(&once, inc_gX);
+ SkOnce(&once, inc_gX);
+ REPORTER_ASSERT(r, 1 == gX);
}
« no previous file with comments | « src/utils/win/SkDWrite.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698