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