diff options
author | miket@chromium.org <miket@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-22 00:44:38 +0000 |
---|---|---|
committer | miket@chromium.org <miket@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-22 00:44:38 +0000 |
commit | 972ecf66c5d52090a813ee943015b2081c9df40d (patch) | |
tree | e5bfc113a294492046b53856976486cabb52473c /base/test | |
parent | 0e3571f32c5c81656b6ae1a6613ac700b061af64 (diff) | |
download | chromium_src-972ecf66c5d52090a813ee943015b2081c9df40d.zip chromium_src-972ecf66c5d52090a813ee943015b2081c9df40d.tar.gz chromium_src-972ecf66c5d52090a813ee943015b2081c9df40d.tar.bz2 |
Replace ScopedCommandLineOverride with TestSuite listener.
This was split out of http://codereview.chromium.org/8588067/.
BUG=none
TEST=none, but this does make testing easier.
Review URL: http://codereview.chromium.org/8561031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111057 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/test')
-rw-r--r-- | base/test/test_suite.cc | 27 | ||||
-rw-r--r-- | base/test/test_suite.h | 4 |
2 files changed, 30 insertions, 1 deletions
diff --git a/base/test/test_suite.cc b/base/test/test_suite.cc index c257b14..e67be8d 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(); } diff --git a/base/test/test_suite.h b/base/test/test_suite.h index 2d4352b..2572756 100644 --- a/base/test/test_suite.h +++ b/base/test/test_suite.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. @@ -50,6 +50,8 @@ class TestSuite { void CatchMaybeTests(); + void ResetCommandLine(); + int Run(); // A command-line flag that makes a test failure always result in a non-zero |