OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/test/ui/ui_test.h" | 5 #include "chrome/test/ui/ui_test.h" |
6 | 6 |
7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
8 #include <signal.h> | 8 #include <signal.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #endif | 10 #endif |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 case UITestBase::CUSTOM_FRAME_NATIVE_THEME: | 652 case UITestBase::CUSTOM_FRAME_NATIVE_THEME: |
653 source_history_file = | 653 source_history_file = |
654 source_history_file.AppendASCII("custom_frame_gtk_theme"); | 654 source_history_file.AppendASCII("custom_frame_gtk_theme"); |
655 break; | 655 break; |
656 default: | 656 default: |
657 NOTREACHED(); | 657 NOTREACHED(); |
658 } | 658 } |
659 return source_history_file; | 659 return source_history_file; |
660 } | 660 } |
661 | 661 |
662 bool UITestBase::LaunchBrowserHelper(const CommandLine& arguments, | 662 void UITestBase::PrepareCommonUITestCommandline(CommandLine* command_line) { |
663 bool wait, | |
664 base::ProcessHandle* process) { | |
665 FilePath command = browser_directory_.Append( | |
666 FilePath::FromWStringHack(chrome::kBrowserProcessExecutablePath)); | |
667 CommandLine command_line(command); | |
668 | |
669 // Add any explicit command line flags passed to the process. | 663 // Add any explicit command line flags passed to the process. |
670 CommandLine::StringType extra_chrome_flags = | 664 CommandLine::StringType extra_chrome_flags = |
671 CommandLine::ForCurrentProcess()->GetSwitchValueNative( | 665 CommandLine::ForCurrentProcess()->GetSwitchValueNative( |
672 switches::kExtraChromeFlags); | 666 switches::kExtraChromeFlags); |
673 if (!extra_chrome_flags.empty()) { | 667 if (!extra_chrome_flags.empty()) { |
674 // Split by spaces and append to command line | 668 // Split by spaces and append to command line |
675 std::vector<CommandLine::StringType> flags; | 669 std::vector<CommandLine::StringType> flags; |
676 base::SplitString(extra_chrome_flags, ' ', &flags); | 670 base::SplitString(extra_chrome_flags, ' ', &flags); |
677 for (size_t i = 0; i < flags.size(); ++i) | 671 for (size_t i = 0; i < flags.size(); ++i) |
678 command_line.AppendArgNative(flags[i]); | 672 command_line->AppendArgNative(flags[i]); |
679 } | 673 } |
680 | 674 |
681 // No default browser check, it would create an info-bar (if we are not the | 675 // No default browser check, it would create an info-bar (if we are not the |
682 // default browser) that could conflicts with some tests expectations. | 676 // default browser) that could conflicts with some tests expectations. |
683 command_line.AppendSwitch(switches::kNoDefaultBrowserCheck); | 677 command_line->AppendSwitch(switches::kNoDefaultBrowserCheck); |
684 | 678 |
685 // This is a UI test. | 679 // This is a UI test. |
686 command_line.AppendSwitchASCII(switches::kTestType, kUITestType); | 680 command_line->AppendSwitchASCII(switches::kTestType, kUITestType); |
687 | 681 |
688 // Tell the browser to use a temporary directory just for this test. | 682 // Tell the browser to use a temporary directory just for this test. |
689 command_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir()); | 683 command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir()); |
690 | 684 |
691 // We need cookies on file:// for things like the page cycler. | 685 // We need cookies on file:// for things like the page cycler. |
692 if (enable_file_cookies_) | 686 if (enable_file_cookies_) |
693 command_line.AppendSwitch(switches::kEnableFileCookies); | 687 command_line->AppendSwitch(switches::kEnableFileCookies); |
694 | 688 |
695 if (dom_automation_enabled_) | 689 if (dom_automation_enabled_) |
696 command_line.AppendSwitch(switches::kDomAutomationController); | 690 command_line->AppendSwitch(switches::kDomAutomationController); |
697 | 691 |
698 if (include_testing_id_) { | 692 if (include_testing_id_) { |
699 command_line.AppendSwitchASCII(switches::kTestingChannelID, | 693 command_line->AppendSwitchASCII(switches::kTestingChannelID, |
700 server_->channel_id()); | 694 server_->channel_id()); |
701 } | 695 } |
702 | 696 |
703 if (!show_error_dialogs_ && | 697 if (!show_error_dialogs_ && |
704 !CommandLine::ForCurrentProcess()->HasSwitch( | 698 !CommandLine::ForCurrentProcess()->HasSwitch( |
705 switches::kEnableErrorDialogs)) { | 699 switches::kEnableErrorDialogs)) { |
706 command_line.AppendSwitch(switches::kNoErrorDialogs); | 700 command_line->AppendSwitch(switches::kNoErrorDialogs); |
707 } | 701 } |
708 if (in_process_renderer_) | 702 if (in_process_renderer_) |
709 command_line.AppendSwitch(switches::kSingleProcess); | 703 command_line->AppendSwitch(switches::kSingleProcess); |
710 if (no_sandbox_) | 704 if (no_sandbox_) |
711 command_line.AppendSwitch(switches::kNoSandbox); | 705 command_line->AppendSwitch(switches::kNoSandbox); |
712 if (full_memory_dump_) | 706 if (full_memory_dump_) |
713 command_line.AppendSwitch(switches::kFullMemoryCrashReport); | 707 command_line->AppendSwitch(switches::kFullMemoryCrashReport); |
714 if (safe_plugins_) | 708 if (safe_plugins_) |
715 command_line.AppendSwitch(switches::kSafePlugins); | 709 command_line->AppendSwitch(switches::kSafePlugins); |
716 if (enable_dcheck_) | 710 if (enable_dcheck_) |
717 command_line.AppendSwitch(switches::kEnableDCHECK); | 711 command_line->AppendSwitch(switches::kEnableDCHECK); |
718 if (silent_dump_on_dcheck_) | 712 if (silent_dump_on_dcheck_) |
719 command_line.AppendSwitch(switches::kSilentDumpOnDCHECK); | 713 command_line->AppendSwitch(switches::kSilentDumpOnDCHECK); |
720 if (disable_breakpad_) | 714 if (disable_breakpad_) |
721 command_line.AppendSwitch(switches::kDisableBreakpad); | 715 command_line->AppendSwitch(switches::kDisableBreakpad); |
722 if (!homepage_.empty()) | 716 if (!homepage_.empty()) |
723 command_line.AppendSwitchASCII(switches::kHomePage, homepage_); | 717 command_line->AppendSwitchASCII(switches::kHomePage, homepage_); |
724 | 718 |
725 if (!js_flags_.empty()) | 719 if (!js_flags_.empty()) |
726 command_line.AppendSwitchASCII(switches::kJavaScriptFlags, js_flags_); | 720 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, js_flags_); |
727 if (!log_level_.empty()) | 721 if (!log_level_.empty()) |
728 command_line.AppendSwitchASCII(switches::kLoggingLevel, log_level_); | 722 command_line->AppendSwitchASCII(switches::kLoggingLevel, log_level_); |
729 | 723 |
730 command_line.AppendSwitch(switches::kMetricsRecordingOnly); | 724 command_line->AppendSwitch(switches::kMetricsRecordingOnly); |
731 | 725 |
732 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 726 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
733 switches::kEnableErrorDialogs)) | 727 switches::kEnableErrorDialogs)) |
734 command_line.AppendSwitch(switches::kEnableLogging); | 728 command_line->AppendSwitch(switches::kEnableLogging); |
735 | 729 |
736 if (dump_histograms_on_exit_) | 730 if (dump_histograms_on_exit_) |
737 command_line.AppendSwitch(switches::kDumpHistogramsOnExit); | 731 command_line->AppendSwitch(switches::kDumpHistogramsOnExit); |
738 | 732 |
739 #ifdef WAIT_FOR_DEBUGGER_ON_OPEN | 733 #ifdef WAIT_FOR_DEBUGGER_ON_OPEN |
740 command_line.AppendSwitch(switches::kDebugOnStart); | 734 command_line->AppendSwitch(switches::kDebugOnStart); |
741 #endif | 735 #endif |
742 | 736 |
743 if (!ui_test_name_.empty()) | 737 if (!ui_test_name_.empty()) |
744 command_line.AppendSwitchASCII(switches::kTestName, ui_test_name_); | 738 command_line->AppendSwitchASCII(switches::kTestName, ui_test_name_); |
745 | 739 |
746 // The tests assume that file:// URIs can freely access other file:// URIs. | 740 // The tests assume that file:// URIs can freely access other file:// URIs. |
747 command_line.AppendSwitch(switches::kAllowFileAccessFromFiles); | 741 command_line->AppendSwitch(switches::kAllowFileAccessFromFiles); |
748 | 742 |
749 // Disable TabCloseableStateWatcher for tests. | 743 // Disable TabCloseableStateWatcher for tests. |
750 command_line.AppendSwitch(switches::kDisableTabCloseableStateWatcher); | 744 command_line->AppendSwitch(switches::kDisableTabCloseableStateWatcher); |
| 745 } |
751 | 746 |
| 747 bool UITestBase::LaunchBrowserHelper(const CommandLine& arguments, |
| 748 bool wait, |
| 749 base::ProcessHandle* process) { |
| 750 FilePath command = browser_directory_.Append( |
| 751 FilePath::FromWStringHack(chrome::kBrowserProcessExecutablePath)); |
| 752 CommandLine command_line(command); |
| 753 |
| 754 // Add browser command line arguments that should be applied to all tests. |
752 test_launcher_utils::PrepareBrowserCommandLineForTests(&command_line); | 755 test_launcher_utils::PrepareBrowserCommandLineForTests(&command_line); |
753 | 756 |
| 757 // Add command line arguments that should be applied to all UI tests. |
| 758 PrepareCommonUITestCommandline(&command_line); |
| 759 |
| 760 // Process debug flags. |
754 DebugFlags::ProcessDebugFlags( | 761 DebugFlags::ProcessDebugFlags( |
755 &command_line, ChildProcessInfo::UNKNOWN_PROCESS, false); | 762 &command_line, ChildProcessInfo::UNKNOWN_PROCESS, false); |
| 763 |
| 764 // Add arguments for this UI test. |
756 command_line.AppendArguments(arguments, false); | 765 command_line.AppendArguments(arguments, false); |
757 | 766 |
758 // TODO(phajdan.jr): Only run it for "main" browser launch. | 767 // TODO(phajdan.jr): Only run it for "main" browser launch. |
759 browser_launch_time_ = TimeTicks::Now(); | 768 browser_launch_time_ = TimeTicks::Now(); |
760 | 769 |
761 #if defined(OS_WIN) | 770 #if defined(OS_WIN) |
762 bool started = base::LaunchApp(command_line, | 771 bool started = base::LaunchApp(command_line, |
763 wait, | 772 wait, |
764 !show_window_, | 773 !show_window_, |
765 process); | 774 process); |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1168 incorrect_state_count++; | 1177 incorrect_state_count++; |
1169 } | 1178 } |
1170 | 1179 |
1171 LOG(INFO) << "Elapsed time: " << (base::Time::Now() - start).InSecondsF() | 1180 LOG(INFO) << "Elapsed time: " << (base::Time::Now() - start).InSecondsF() |
1172 << " seconds" | 1181 << " seconds" |
1173 << " call failed " << fail_count << " times" | 1182 << " call failed " << fail_count << " times" |
1174 << " state was incorrect " << incorrect_state_count << " times"; | 1183 << " state was incorrect " << incorrect_state_count << " times"; |
1175 ADD_FAILURE() << "Timeout reached in " << __FUNCTION__; | 1184 ADD_FAILURE() << "Timeout reached in " << __FUNCTION__; |
1176 return false; | 1185 return false; |
1177 } | 1186 } |
1178 | |
OLD | NEW |