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 "content/public/test/test_launcher.h" | 5 #include "content/public/test/test_launcher.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 169 |
170 DISALLOW_COPY_AND_ASSIGN(WrapperTestLauncherDelegate); | 170 DISALLOW_COPY_AND_ASSIGN(WrapperTestLauncherDelegate); |
171 }; | 171 }; |
172 | 172 |
173 bool WrapperTestLauncherDelegate::ShouldRunTest( | 173 bool WrapperTestLauncherDelegate::ShouldRunTest( |
174 const std::string& test_case_name, | 174 const std::string& test_case_name, |
175 const std::string& test_name) { | 175 const std::string& test_name) { |
176 all_test_names_.insert(test_case_name + "." + test_name); | 176 all_test_names_.insert(test_case_name + "." + test_name); |
177 | 177 |
178 if (StartsWithASCII(test_name, kManualTestPrefix, true) && | 178 if (StartsWithASCII(test_name, kManualTestPrefix, true) && |
179 !CommandLine::ForCurrentProcess()->HasSwitch(kRunManualTestsFlag)) { | 179 !base::CommandLine::ForCurrentProcess()->HasSwitch(kRunManualTestsFlag)) { |
180 return false; | 180 return false; |
181 } | 181 } |
182 | 182 |
183 if (StartsWithASCII(test_name, kPreTestPrefix, true)) { | 183 if (StartsWithASCII(test_name, kPreTestPrefix, true)) { |
184 // We will actually run PRE_ tests, but to ensure they run on the same shard | 184 // We will actually run PRE_ tests, but to ensure they run on the same shard |
185 // as dependent tests, handle all these details internally. | 185 // as dependent tests, handle all these details internally. |
186 return false; | 186 return false; |
187 } | 187 } |
188 | 188 |
189 return true; | 189 return true; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 for (size_t i = 0; i < tests_to_run_now.size(); i++) | 308 for (size_t i = 0; i < tests_to_run_now.size(); i++) |
309 DoRunTest(test_launcher, tests_to_run_now[i]); | 309 DoRunTest(test_launcher, tests_to_run_now[i]); |
310 | 310 |
311 return test_names_set.size(); | 311 return test_names_set.size(); |
312 } | 312 } |
313 | 313 |
314 void WrapperTestLauncherDelegate::DoRunTest(base::TestLauncher* test_launcher, | 314 void WrapperTestLauncherDelegate::DoRunTest(base::TestLauncher* test_launcher, |
315 const std::string& test_name) { | 315 const std::string& test_name) { |
316 std::string test_name_no_pre(RemoveAnyPrePrefixes(test_name)); | 316 std::string test_name_no_pre(RemoveAnyPrePrefixes(test_name)); |
317 | 317 |
318 CommandLine cmd_line(*CommandLine::ForCurrentProcess()); | 318 base::CommandLine cmd_line(*base::CommandLine::ForCurrentProcess()); |
319 CHECK(launcher_delegate_->AdjustChildProcessCommandLine( | 319 CHECK(launcher_delegate_->AdjustChildProcessCommandLine( |
320 &cmd_line, user_data_dir_map_[test_name_no_pre])); | 320 &cmd_line, user_data_dir_map_[test_name_no_pre])); |
321 | 321 |
322 CommandLine new_cmd_line(cmd_line.GetProgram()); | 322 base::CommandLine new_cmd_line(cmd_line.GetProgram()); |
323 CommandLine::SwitchMap switches = cmd_line.GetSwitches(); | 323 base::CommandLine::SwitchMap switches = cmd_line.GetSwitches(); |
324 | 324 |
325 // Strip out gtest_output flag because otherwise we would overwrite results | 325 // Strip out gtest_output flag because otherwise we would overwrite results |
326 // of the other tests. | 326 // of the other tests. |
327 switches.erase(base::kGTestOutputFlag); | 327 switches.erase(base::kGTestOutputFlag); |
328 | 328 |
329 for (CommandLine::SwitchMap::const_iterator iter = switches.begin(); | 329 for (base::CommandLine::SwitchMap::const_iterator iter = switches.begin(); |
330 iter != switches.end(); ++iter) { | 330 iter != switches.end(); ++iter) { |
331 new_cmd_line.AppendSwitchNative(iter->first, iter->second); | 331 new_cmd_line.AppendSwitchNative(iter->first, iter->second); |
332 } | 332 } |
333 | 333 |
334 // Always enable disabled tests. This method is not called with disabled | 334 // Always enable disabled tests. This method is not called with disabled |
335 // tests unless this flag was specified to the browser test executable. | 335 // tests unless this flag was specified to the browser test executable. |
336 new_cmd_line.AppendSwitch("gtest_also_run_disabled_tests"); | 336 new_cmd_line.AppendSwitch("gtest_also_run_disabled_tests"); |
337 new_cmd_line.AppendSwitchASCII("gtest_filter", test_name); | 337 new_cmd_line.AppendSwitchASCII("gtest_filter", test_name); |
338 new_cmd_line.AppendSwitch(kSingleProcessTestsFlag); | 338 new_cmd_line.AppendSwitch(kSingleProcessTestsFlag); |
339 | 339 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 TestLauncherDelegate::~TestLauncherDelegate() { | 428 TestLauncherDelegate::~TestLauncherDelegate() { |
429 } | 429 } |
430 | 430 |
431 int LaunchTests(TestLauncherDelegate* launcher_delegate, | 431 int LaunchTests(TestLauncherDelegate* launcher_delegate, |
432 int default_jobs, | 432 int default_jobs, |
433 int argc, | 433 int argc, |
434 char** argv) { | 434 char** argv) { |
435 DCHECK(!g_launcher_delegate); | 435 DCHECK(!g_launcher_delegate); |
436 g_launcher_delegate = launcher_delegate; | 436 g_launcher_delegate = launcher_delegate; |
437 | 437 |
438 CommandLine::Init(argc, argv); | 438 base::CommandLine::Init(argc, argv); |
439 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 439 const base::CommandLine* command_line = |
| 440 base::CommandLine::ForCurrentProcess(); |
440 | 441 |
441 if (command_line->HasSwitch(kHelpFlag)) { | 442 if (command_line->HasSwitch(kHelpFlag)) { |
442 PrintUsage(); | 443 PrintUsage(); |
443 return 0; | 444 return 0; |
444 } | 445 } |
445 | 446 |
446 scoped_ptr<ContentMainDelegate> chrome_main_delegate( | 447 scoped_ptr<ContentMainDelegate> chrome_main_delegate( |
447 launcher_delegate->CreateContentMainDelegate()); | 448 launcher_delegate->CreateContentMainDelegate()); |
448 ContentMainParams params(chrome_main_delegate.get()); | 449 ContentMainParams params(chrome_main_delegate.get()); |
449 | 450 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 | 499 |
499 TestLauncherDelegate* GetCurrentTestLauncherDelegate() { | 500 TestLauncherDelegate* GetCurrentTestLauncherDelegate() { |
500 return g_launcher_delegate; | 501 return g_launcher_delegate; |
501 } | 502 } |
502 | 503 |
503 ContentMainParams* GetContentMainParams() { | 504 ContentMainParams* GetContentMainParams() { |
504 return g_params; | 505 return g_params; |
505 } | 506 } |
506 | 507 |
507 } // namespace content | 508 } // namespace content |
OLD | NEW |