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

Unified Diff: base/at_exit_unittest.cc

Issue 372057: Isolate tests by running AtExit callbacks between them. (Closed)
Patch Set: fix Linux hang Created 11 years, 1 month 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 | « base/at_exit.h ('k') | base/lazy_instance.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/at_exit_unittest.cc
diff --git a/base/at_exit_unittest.cc b/base/at_exit_unittest.cc
index 50dec04e17855a23084c51bea7117e29193b7782..2fbed25440bdda20ca66cb1e4050c7bdc34663fe 100644
--- a/base/at_exit_unittest.cc
+++ b/base/at_exit_unittest.cc
@@ -8,13 +8,6 @@
namespace {
-// Don't test the global AtExitManager, because asking it to process its
-// AtExit callbacks can ruin the global state that other tests may depend on.
-class ShadowingAtExitManager : public base::AtExitManager {
- public:
- ShadowingAtExitManager() : AtExitManager(true) {}
-};
-
int g_test_counter_1 = 0;
int g_test_counter_2 = 0;
@@ -45,9 +38,14 @@ void ExpectParamIsCounter(void* param) {
} // namespace
-TEST(AtExitTest, Basic) {
- ShadowingAtExitManager shadowing_at_exit_manager;
+class AtExitTest : public testing::Test {
+ private:
+ // Don't test the global AtExitManager, because asking it to process its
+ // AtExit callbacks can ruin the global state that other tests may depend on.
+ base::ShadowingAtExitManager exit_manager_;
+};
+TEST_F(AtExitTest, Basic) {
ZeroTestCounters();
base::AtExitManager::RegisterCallback(&IncrementTestCounter1, NULL);
base::AtExitManager::RegisterCallback(&IncrementTestCounter2, NULL);
@@ -60,9 +58,7 @@ TEST(AtExitTest, Basic) {
EXPECT_EQ(1, g_test_counter_2);
}
-TEST(AtExitTest, LIFOOrder) {
- ShadowingAtExitManager shadowing_at_exit_manager;
-
+TEST_F(AtExitTest, LIFOOrder) {
ZeroTestCounters();
base::AtExitManager::RegisterCallback(&IncrementTestCounter1, NULL);
base::AtExitManager::RegisterCallback(&ExpectCounter1IsZero, NULL);
@@ -75,9 +71,7 @@ TEST(AtExitTest, LIFOOrder) {
EXPECT_EQ(1, g_test_counter_2);
}
-TEST(AtExitTest, Param) {
- ShadowingAtExitManager shadowing_at_exit_manager;
-
+TEST_F(AtExitTest, Param) {
base::AtExitManager::RegisterCallback(&ExpectParamIsNull, NULL);
base::AtExitManager::RegisterCallback(&ExpectParamIsCounter,
&g_test_counter_1);
« no previous file with comments | « base/at_exit.h ('k') | base/lazy_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698