| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 10 #include "base/bind.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 testing::UnitTest::GetInstance()->listeners(); | 164 testing::UnitTest::GetInstance()->listeners(); |
| 165 listeners.Append(new MaybeTestDisabler); | 165 listeners.Append(new MaybeTestDisabler); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void TestSuite::ResetCommandLine() { | 168 void TestSuite::ResetCommandLine() { |
| 169 testing::TestEventListeners& listeners = | 169 testing::TestEventListeners& listeners = |
| 170 testing::UnitTest::GetInstance()->listeners(); | 170 testing::UnitTest::GetInstance()->listeners(); |
| 171 listeners.Append(new TestClientInitializer); | 171 listeners.Append(new TestClientInitializer); |
| 172 } | 172 } |
| 173 | 173 |
| 174 #if !defined(OS_IOS) | |
| 175 void TestSuite::AddTestLauncherResultPrinter() { | 174 void TestSuite::AddTestLauncherResultPrinter() { |
| 176 // Only add the custom printer if requested. | 175 // Only add the custom printer if requested. |
| 177 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 176 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 178 switches::kTestLauncherOutput)) { | 177 switches::kTestLauncherOutput)) { |
| 179 return; | 178 return; |
| 180 } | 179 } |
| 181 | 180 |
| 182 FilePath output_path(base::CommandLine::ForCurrentProcess()-> | 181 FilePath output_path(base::CommandLine::ForCurrentProcess()-> |
| 183 GetSwitchValuePath(switches::kTestLauncherOutput)); | 182 GetSwitchValuePath(switches::kTestLauncherOutput)); |
| 184 | 183 |
| 185 // Do not add the result printer if output path already exists. It's an | 184 // Do not add the result printer if output path already exists. It's an |
| 186 // indicator there is a process printing to that file, and we're likely | 185 // indicator there is a process printing to that file, and we're likely |
| 187 // its child. Do not clobber the results in that case. | 186 // its child. Do not clobber the results in that case. |
| 188 if (PathExists(output_path)) { | 187 if (PathExists(output_path)) { |
| 189 LOG(WARNING) << "Test launcher output path " << output_path.AsUTF8Unsafe() | 188 LOG(WARNING) << "Test launcher output path " << output_path.AsUTF8Unsafe() |
| 190 << " exists. Not adding test launcher result printer."; | 189 << " exists. Not adding test launcher result printer."; |
| 191 return; | 190 return; |
| 192 } | 191 } |
| 193 | 192 |
| 194 XmlUnitTestResultPrinter* printer = new XmlUnitTestResultPrinter; | 193 XmlUnitTestResultPrinter* printer = new XmlUnitTestResultPrinter; |
| 195 CHECK(printer->Initialize(output_path)); | 194 CHECK(printer->Initialize(output_path)); |
| 196 testing::TestEventListeners& listeners = | 195 testing::TestEventListeners& listeners = |
| 197 testing::UnitTest::GetInstance()->listeners(); | 196 testing::UnitTest::GetInstance()->listeners(); |
| 198 listeners.Append(printer); | 197 listeners.Append(printer); |
| 199 } | 198 } |
| 200 #endif // !defined(OS_IOS) | |
| 201 | 199 |
| 202 // Don't add additional code to this method. Instead add it to | 200 // Don't add additional code to this method. Instead add it to |
| 203 // Initialize(). See bug 6436. | 201 // Initialize(). See bug 6436. |
| 204 int TestSuite::Run() { | 202 int TestSuite::Run() { |
| 205 #if defined(OS_IOS) | 203 #if defined(OS_IOS) |
| 206 RunTestsFromIOSApp(); | 204 RunTestsFromIOSApp(); |
| 207 #endif | 205 #endif |
| 208 | 206 |
| 209 #if defined(OS_MACOSX) | 207 #if defined(OS_MACOSX) |
| 210 base::mac::ScopedNSAutoreleasePool scoped_pool; | 208 base::mac::ScopedNSAutoreleasePool scoped_pool; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 "show-error-dialogs")) { | 317 "show-error-dialogs")) { |
| 320 SuppressErrorDialogs(); | 318 SuppressErrorDialogs(); |
| 321 base::debug::SetSuppressDebugUI(true); | 319 base::debug::SetSuppressDebugUI(true); |
| 322 logging::SetLogAssertHandler(UnitTestAssertHandler); | 320 logging::SetLogAssertHandler(UnitTestAssertHandler); |
| 323 } | 321 } |
| 324 | 322 |
| 325 base::i18n::InitializeICU(); | 323 base::i18n::InitializeICU(); |
| 326 | 324 |
| 327 CatchMaybeTests(); | 325 CatchMaybeTests(); |
| 328 ResetCommandLine(); | 326 ResetCommandLine(); |
| 329 #if !defined(OS_IOS) | |
| 330 AddTestLauncherResultPrinter(); | 327 AddTestLauncherResultPrinter(); |
| 331 #endif // !defined(OS_IOS) | |
| 332 | 328 |
| 333 TestTimeouts::Initialize(); | 329 TestTimeouts::Initialize(); |
| 334 | 330 |
| 335 trace_to_file_.BeginTracingFromCommandLineOptions(); | 331 trace_to_file_.BeginTracingFromCommandLineOptions(); |
| 336 } | 332 } |
| 337 | 333 |
| 338 void TestSuite::Shutdown() { | 334 void TestSuite::Shutdown() { |
| 339 } | 335 } |
| OLD | NEW |