OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/test/test_suite.h" | 5 #include "base/test/test_suite.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/base_paths.h" | 8 #include "base/base_paths.h" |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 29 matching lines...) Expand all Loading... | |
40 class MaybeTestDisabler : public testing::EmptyTestEventListener { | 40 class MaybeTestDisabler : public testing::EmptyTestEventListener { |
41 public: | 41 public: |
42 virtual void OnTestStart(const testing::TestInfo& test_info) { | 42 virtual void OnTestStart(const testing::TestInfo& test_info) { |
43 ASSERT_FALSE(TestSuite::IsMarkedMaybe(test_info)) | 43 ASSERT_FALSE(TestSuite::IsMarkedMaybe(test_info)) |
44 << "Probably the OS #ifdefs don't include all of the necessary " | 44 << "Probably the OS #ifdefs don't include all of the necessary " |
45 "platforms.\nPlease ensure that no tests have the MAYBE_ prefix " | 45 "platforms.\nPlease ensure that no tests have the MAYBE_ prefix " |
46 "after the code is preprocessed."; | 46 "after the code is preprocessed."; |
47 } | 47 } |
48 }; | 48 }; |
49 | 49 |
50 class TestClientInitializer : public testing::EmptyTestEventListener { | |
51 public: | |
52 TestClientInitializer() | |
53 : old_command_line_(CommandLine::NO_PROGRAM) { | |
asargent_no_longer_on_chrome
2011/11/21 19:19:50
I guess it doesn't really matter since you set it
| |
54 } | |
55 | |
56 virtual void OnTestStart(const testing::TestInfo& test_info) OVERRIDE { | |
57 old_command_line_ = *CommandLine::ForCurrentProcess(); | |
58 } | |
59 | |
60 virtual void OnTestEnd(const testing::TestInfo& test_info) OVERRIDE { | |
61 *CommandLine::ForCurrentProcess() = old_command_line_; | |
62 } | |
63 | |
64 private: | |
65 CommandLine old_command_line_; | |
66 | |
67 DISALLOW_COPY_AND_ASSIGN(TestClientInitializer); | |
68 }; | |
69 | |
50 } // namespace | 70 } // namespace |
51 | 71 |
52 const char TestSuite::kStrictFailureHandling[] = "strict_failure_handling"; | 72 const char TestSuite::kStrictFailureHandling[] = "strict_failure_handling"; |
53 | 73 |
54 TestSuite::TestSuite(int argc, char** argv) { | 74 TestSuite::TestSuite(int argc, char** argv) { |
55 #if defined(OS_WIN) | 75 #if defined(OS_WIN) |
56 testing::GTEST_FLAG(catch_exceptions) = false; | 76 testing::GTEST_FLAG(catch_exceptions) = false; |
57 #endif | 77 #endif |
58 base::EnableTerminationOnHeapCorruption(); | 78 base::EnableTerminationOnHeapCorruption(); |
59 CommandLine::Init(argc, argv); | 79 CommandLine::Init(argc, argv); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 } | 243 } |
224 | 244 |
225 #if !defined(OS_ANDROID) | 245 #if !defined(OS_ANDROID) |
226 // TODO(michaelbai): The icu can not be compiled in Android now, this should | 246 // TODO(michaelbai): The icu can not be compiled in Android now, this should |
227 // be enabled once icu is ready. http://b/5406077. | 247 // be enabled once icu is ready. http://b/5406077. |
228 icu_util::Initialize(); | 248 icu_util::Initialize(); |
229 #endif | 249 #endif |
230 | 250 |
231 CatchMaybeTests(); | 251 CatchMaybeTests(); |
232 | 252 |
253 testing::TestEventListeners& listeners = | |
Paweł Hajdan Jr.
2011/11/21 19:59:32
nit: It's slightly inconsistent to add the MAYBE t
| |
254 testing::UnitTest::GetInstance()->listeners(); | |
255 listeners.Append(new TestClientInitializer); | |
256 | |
233 TestTimeouts::Initialize(); | 257 TestTimeouts::Initialize(); |
234 } | 258 } |
235 | 259 |
236 void TestSuite::Shutdown() { | 260 void TestSuite::Shutdown() { |
237 } | 261 } |
OLD | NEW |