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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 CommandLine old_command_line_; | 65 CommandLine old_command_line_; |
66 | 66 |
67 DISALLOW_COPY_AND_ASSIGN(TestClientInitializer); | 67 DISALLOW_COPY_AND_ASSIGN(TestClientInitializer); |
68 }; | 68 }; |
69 | 69 |
70 } // namespace | 70 } // namespace |
71 | 71 |
72 const char TestSuite::kStrictFailureHandling[] = "strict_failure_handling"; | 72 const char TestSuite::kStrictFailureHandling[] = "strict_failure_handling"; |
73 | 73 |
74 TestSuite::TestSuite(int argc, char** argv) { | 74 TestSuite::TestSuite(int argc, char** argv) { |
75 PreInitialize(argc, argv, true); | |
76 } | |
77 | |
78 TestSuite::TestSuite(int argc, char** argv, bool create_at_exit_manager) { | |
79 PreInitialize(argc, argv, create_at_exit_manager); | |
80 } | |
81 | |
82 TestSuite::~TestSuite() { | |
83 CommandLine::Reset(); | |
84 } | |
85 | |
86 void TestSuite::PreInitialize(int argc, char** argv, | |
87 bool create_at_exit_manager) { | |
75 #if defined(OS_WIN) | 88 #if defined(OS_WIN) |
76 testing::GTEST_FLAG(catch_exceptions) = false; | 89 testing::GTEST_FLAG(catch_exceptions) = false; |
77 #endif | 90 #endif |
78 base::EnableTerminationOnHeapCorruption(); | 91 base::EnableTerminationOnHeapCorruption(); |
79 CommandLine::Init(argc, argv); | 92 CommandLine::Init(argc, argv); |
80 testing::InitGoogleTest(&argc, argv); | 93 testing::InitGoogleTest(&argc, argv); |
81 #if defined(OS_LINUX) && defined(USE_AURA) | 94 #if defined(OS_LINUX) && defined(USE_AURA) |
82 // When calling native char conversion functions (e.g wrctomb) we need to | 95 // When calling native char conversion functions (e.g wrctomb) we need to |
83 // have the locale set. In the absence of such a call the "C" locale is the | 96 // have the locale set. In the absence of such a call the "C" locale is the |
84 // default. In the gtk code (below) gtk_init() implicitly sets a locale. | 97 // default. In the gtk code (below) gtk_init() implicitly sets a locale. |
85 setlocale(LC_ALL, ""); | 98 setlocale(LC_ALL, ""); |
86 #elif defined(TOOLKIT_USES_GTK) | 99 #elif defined(TOOLKIT_USES_GTK) |
87 gtk_init_check(&argc, &argv); | 100 gtk_init_check(&argc, &argv); |
88 #endif // defined(TOOLKIT_USES_GTK) | 101 #endif // defined(TOOLKIT_USES_GTK) |
89 // Don't add additional code to this constructor. Instead add it to | 102 if (create_at_exit_manager) { |
brettw
2011/12/15 00:00:15
No {} to match surrounding code.
ananta
2011/12/15 00:14:55
Done.
| |
103 at_exit_manager_.reset(new base::AtExitManager); | |
104 } | |
105 // Don't add additional code to this function. Instead add it to | |
90 // Initialize(). See bug 6436. | 106 // Initialize(). See bug 6436. |
91 } | 107 } |
92 | 108 |
93 TestSuite::~TestSuite() { | |
94 CommandLine::Reset(); | |
95 } | |
96 | 109 |
97 // static | 110 // static |
98 bool TestSuite::IsMarkedFlaky(const testing::TestInfo& test) { | 111 bool TestSuite::IsMarkedFlaky(const testing::TestInfo& test) { |
99 return strncmp(test.name(), "FLAKY_", 6) == 0; | 112 return strncmp(test.name(), "FLAKY_", 6) == 0; |
100 } | 113 } |
101 | 114 |
102 // static | 115 // static |
103 bool TestSuite::IsMarkedFailing(const testing::TestInfo& test) { | 116 bool TestSuite::IsMarkedFailing(const testing::TestInfo& test) { |
104 return strncmp(test.name(), "FAILS_", 6) == 0; | 117 return strncmp(test.name(), "FAILS_", 6) == 0; |
105 } | 118 } |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 #endif | 273 #endif |
261 | 274 |
262 CatchMaybeTests(); | 275 CatchMaybeTests(); |
263 ResetCommandLine(); | 276 ResetCommandLine(); |
264 | 277 |
265 TestTimeouts::Initialize(); | 278 TestTimeouts::Initialize(); |
266 } | 279 } |
267 | 280 |
268 void TestSuite::Shutdown() { | 281 void TestSuite::Shutdown() { |
269 } | 282 } |
OLD | NEW |