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

Unified Diff: base/test/unit_test.cc

Issue 10582012: For unit tests, track additions to AtExitManager and warn. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
Index: base/test/unit_test.cc
diff --git a/base/test/unit_test.cc b/base/test/unit_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0447432ce2b6a5db8b1825bf7865e6a70ef16612
--- /dev/null
+++ b/base/test/unit_test.cc
@@ -0,0 +1,36 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/test/unit_test.h"
+
+#include "base/at_exit.h"
+#include "base/logging.h"
+
+namespace base {
+
+UnitTest::UnitTest() {
+}
+
+UnitTest::~UnitTest() {
+}
+
+void UnitTest::SetUp() {
+ base::ShadowingAtExitManager at_exit_manager;
+ initial_top_manager_ = at_exit_manager.next_manager_;
+ at_exit_stack_size_ = initial_top_manager_->stack_.size();
+}
+
+void UnitTest::TearDown() {
+ base::ShadowingAtExitManager at_exit_manager;
+ base::AtExitManager* new_top_manager = at_exit_manager.next_manager_;
+ size_t new_stack_size = new_top_manager->stack_.size();
+
+ if (initial_top_manager_ != new_top_manager) {
+ LOG(WARNING) << "AtExitManager stack changed depth across test.";
+ } else if (new_stack_size != at_exit_stack_size_) {
+ LOG(WARNING) << "Test added items to the AtExitManager list.";
+ }
+}
+
+} // namespace base

Powered by Google App Engine
This is Rietveld 408576698