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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/environment.h" | 11 #include "base/environment.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/hash_tables.h" | 13 #include "base/hash_tables.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/memory/linked_ptr.h" | 15 #include "base/memory/linked_ptr.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/process_util.h" | 17 #include "base/process_util.h" |
18 #include "base/scoped_temp_dir.h" | 18 #include "base/scoped_temp_dir.h" |
19 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
21 #include "base/test/test_suite.h" | 21 #include "base/test/test_suite.h" |
| 22 #include "base/test/test_switches.h" |
22 #include "base/test/test_timeouts.h" | 23 #include "base/test/test_timeouts.h" |
23 #include "base/time.h" | 24 #include "base/time.h" |
24 #include "base/utf_string_conversions.h" | 25 #include "base/utf_string_conversions.h" |
25 #include "content/public/app/startup_helper_win.h" | 26 #include "content/public/app/startup_helper_win.h" |
26 #include "content/public/common/sandbox_init.h" | 27 #include "content/public/common/sandbox_init.h" |
27 #include "content/public/test/browser_test.h" | 28 #include "content/public/test/browser_test.h" |
28 #include "net/base/escape.h" | 29 #include "net/base/escape.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
30 | 31 |
31 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 | 336 |
336 for (CommandLine::SwitchMap::const_iterator iter = switches.begin(); | 337 for (CommandLine::SwitchMap::const_iterator iter = switches.begin(); |
337 iter != switches.end(); ++iter) { | 338 iter != switches.end(); ++iter) { |
338 new_cmd_line.AppendSwitchNative((*iter).first, (*iter).second); | 339 new_cmd_line.AppendSwitchNative((*iter).first, (*iter).second); |
339 } | 340 } |
340 | 341 |
341 // Always enable disabled tests. This method is not called with disabled | 342 // Always enable disabled tests. This method is not called with disabled |
342 // tests unless this flag was specified to the browser test executable. | 343 // tests unless this flag was specified to the browser test executable. |
343 new_cmd_line.AppendSwitch("gtest_also_run_disabled_tests"); | 344 new_cmd_line.AppendSwitch("gtest_also_run_disabled_tests"); |
344 new_cmd_line.AppendSwitchASCII("gtest_filter", test_name); | 345 new_cmd_line.AppendSwitchASCII("gtest_filter", test_name); |
345 new_cmd_line.AppendSwitch(kSingleProcessTestsFlag); | 346 new_cmd_line.AppendSwitch(switches::kSingleProcessTestsFlag); |
346 | 347 |
347 // Do not let the child ignore failures. We need to propagate the | 348 // Do not let the child ignore failures. We need to propagate the |
348 // failure status back to the parent. | 349 // failure status back to the parent. |
349 new_cmd_line.AppendSwitch(base::TestSuite::kStrictFailureHandling); | 350 new_cmd_line.AppendSwitch(base::TestSuite::kStrictFailureHandling); |
350 | 351 |
351 if (!launcher_delegate->AdjustChildProcessCommandLine(&new_cmd_line)) | 352 if (!launcher_delegate->AdjustChildProcessCommandLine(&new_cmd_line)) |
352 return -1; | 353 return -1; |
353 | 354 |
354 const char* browser_wrapper = getenv("BROWSER_WRAPPER"); | 355 const char* browser_wrapper = getenv("BROWSER_WRAPPER"); |
355 if (browser_wrapper) { | 356 if (browser_wrapper) { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 | 560 |
560 } // namespace | 561 } // namespace |
561 | 562 |
562 const char kGTestFilterFlag[] = "gtest_filter"; | 563 const char kGTestFilterFlag[] = "gtest_filter"; |
563 const char kGTestHelpFlag[] = "gtest_help"; | 564 const char kGTestHelpFlag[] = "gtest_help"; |
564 const char kGTestListTestsFlag[] = "gtest_list_tests"; | 565 const char kGTestListTestsFlag[] = "gtest_list_tests"; |
565 const char kGTestRepeatFlag[] = "gtest_repeat"; | 566 const char kGTestRepeatFlag[] = "gtest_repeat"; |
566 const char kGTestRunDisabledTestsFlag[] = "gtest_also_run_disabled_tests"; | 567 const char kGTestRunDisabledTestsFlag[] = "gtest_also_run_disabled_tests"; |
567 const char kGTestOutputFlag[] = "gtest_output"; | 568 const char kGTestOutputFlag[] = "gtest_output"; |
568 | 569 |
569 const char kSingleProcessTestsFlag[] = "single_process"; | |
570 const char kSingleProcessTestsAndChromeFlag[] = "single-process"; | |
571 // The following is kept for historical reasons (so people that are used to | 570 // The following is kept for historical reasons (so people that are used to |
572 // using it don't get surprised). | 571 // using it don't get surprised). |
573 const char kChildProcessFlag[] = "child"; | 572 const char kChildProcessFlag[] = "child"; |
574 | 573 |
575 const char kHelpFlag[] = "help"; | 574 const char kHelpFlag[] = "help"; |
576 | 575 |
577 TestLauncherDelegate::~TestLauncherDelegate() { | 576 TestLauncherDelegate::~TestLauncherDelegate() { |
578 } | 577 } |
579 | 578 |
580 int LaunchTests(TestLauncherDelegate* launcher_delegate, | 579 int LaunchTests(TestLauncherDelegate* launcher_delegate, |
581 int argc, | 580 int argc, |
582 char** argv) { | 581 char** argv) { |
583 launcher_delegate->EarlyInitialize(); | 582 launcher_delegate->EarlyInitialize(); |
584 | 583 |
585 CommandLine::Init(argc, argv); | 584 CommandLine::Init(argc, argv); |
586 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 585 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
587 | 586 |
588 if (command_line->HasSwitch(kHelpFlag)) { | 587 if (command_line->HasSwitch(kHelpFlag)) { |
589 PrintUsage(); | 588 PrintUsage(); |
590 return 0; | 589 return 0; |
591 } | 590 } |
592 | 591 |
593 // TODO(pkasting): This "single_process vs. single-process" design is | 592 // TODO(pkasting): This "single_process vs. single-process" design is |
594 // terrible UI. Instead, there should be some sort of signal flag on the | 593 // terrible UI. Instead, there should be some sort of signal flag on the |
595 // command line, with all subsequent arguments passed through to the | 594 // command line, with all subsequent arguments passed through to the |
596 // underlying browser. | 595 // underlying browser. |
597 if (command_line->HasSwitch(kSingleProcessTestsFlag) || | 596 if (command_line->HasSwitch(switches::kSingleProcessTestsFlag) || |
598 command_line->HasSwitch(kSingleProcessTestsAndChromeFlag) || | 597 command_line->HasSwitch(switches::kSingleProcessChromeFlag) || |
599 command_line->HasSwitch(kGTestListTestsFlag) || | 598 command_line->HasSwitch(kGTestListTestsFlag) || |
600 command_line->HasSwitch(kGTestHelpFlag)) { | 599 command_line->HasSwitch(kGTestHelpFlag)) { |
601 #if defined(OS_WIN) | 600 #if defined(OS_WIN) |
602 if (command_line->HasSwitch(kSingleProcessTestsFlag)) { | 601 if (command_line->HasSwitch(switches::kSingleProcessTestsFlag)) { |
603 sandbox::SandboxInterfaceInfo sandbox_info; | 602 sandbox::SandboxInterfaceInfo sandbox_info; |
604 content::InitializeSandboxInfo(&sandbox_info); | 603 content::InitializeSandboxInfo(&sandbox_info); |
605 content::InitializeSandbox(&sandbox_info); | 604 content::InitializeSandbox(&sandbox_info); |
606 } | 605 } |
607 #endif | 606 #endif |
608 return launcher_delegate->RunTestSuite(argc, argv); | 607 return launcher_delegate->RunTestSuite(argc, argv); |
609 } | 608 } |
610 | 609 |
611 int return_code = 0; | 610 int return_code = 0; |
612 if (launcher_delegate->Run(argc, argv, &return_code)) | 611 if (launcher_delegate->Run(argc, argv, &return_code)) |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 } | 662 } |
664 | 663 |
665 // Special value "-1" means "repeat indefinitely". | 664 // Special value "-1" means "repeat indefinitely". |
666 if (cycles != -1) | 665 if (cycles != -1) |
667 cycles--; | 666 cycles--; |
668 } | 667 } |
669 return exit_code; | 668 return exit_code; |
670 } | 669 } |
671 | 670 |
672 } // namespace test_launcher | 671 } // namespace test_launcher |
OLD | NEW |