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