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

Unified Diff: base/test/test_suite.cc

Issue 8561031: Replace ScopedCommandLineOverride with TestSuite listener. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Last nit from Pawel. Created 9 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
Index: base/test/test_suite.cc
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc
index c257b141819851ddfa0987e3ce84bc26bf04478b..e67be8d1d6f40a202d0d44511aafac047b8b97a0 100644
--- a/base/test/test_suite.cc
+++ b/base/test/test_suite.cc
@@ -47,6 +47,26 @@ class MaybeTestDisabler : public testing::EmptyTestEventListener {
}
};
+class TestClientInitializer : public testing::EmptyTestEventListener {
+ public:
+ TestClientInitializer()
+ : old_command_line_(CommandLine::NO_PROGRAM) {
+ }
+
+ virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE {
+ old_command_line_ = *CommandLine::ForCurrentProcess();
+ }
+
+ virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE {
+ *CommandLine::ForCurrentProcess() = old_command_line_;
+ }
+
+ private:
+ CommandLine old_command_line_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestClientInitializer);
+};
+
} // namespace
const char TestSuite::kStrictFailureHandling[] = "strict_failure_handling";
@@ -119,6 +139,12 @@ void TestSuite::CatchMaybeTests() {
listeners.Append(new MaybeTestDisabler);
}
+void TestSuite::ResetCommandLine() {
+ testing::TestEventListeners& listeners =
+ testing::UnitTest::GetInstance()->listeners();
+ listeners.Append(new TestClientInitializer);
+}
+
// Don't add additional code to this method. Instead add it to
// Initialize(). See bug 6436.
int TestSuite::Run() {
@@ -229,6 +255,7 @@ void TestSuite::Initialize() {
#endif
CatchMaybeTests();
+ ResetCommandLine();
TestTimeouts::Initialize();
}

Powered by Google App Engine
This is Rietveld 408576698