Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: chrome/test/ui/ui_test.cc

Issue 3012021: CommandLine: add a CopySwitchesFrom() for copying from another CommandLine (Closed)
Patch Set: minor cleanups Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/test/ui/sandbox_uitests.cc ('k') | chrome/test/ui_test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 void UITestBase::StartHttpServer(const FilePath& root_directory) { 329 void UITestBase::StartHttpServer(const FilePath& root_directory) {
330 StartHttpServerWithPort(root_directory, L""); 330 StartHttpServerWithPort(root_directory, L"");
331 } 331 }
332 332
333 void UITestBase::StartHttpServerWithPort(const FilePath& root_directory, 333 void UITestBase::StartHttpServerWithPort(const FilePath& root_directory,
334 const std::wstring& port) { 334 const std::wstring& port) {
335 scoped_ptr<CommandLine> cmd_line(CreateHttpServerCommandLine()); 335 scoped_ptr<CommandLine> cmd_line(CreateHttpServerCommandLine());
336 ASSERT_TRUE(cmd_line.get()); 336 ASSERT_TRUE(cmd_line.get());
337 cmd_line->AppendSwitchWithValue("server", "start"); 337 cmd_line->AppendSwitchWithValue("server", "start");
338 cmd_line->AppendSwitch("register_cygwin"); 338 cmd_line->AppendSwitch("register_cygwin");
339 cmd_line->AppendSwitchWithValue("root", root_directory.ToWStringHack()); 339 cmd_line->AppendSwitchPath("root", root_directory);
340 340
341 // For Windows 7, if we start the lighttpd server on the foreground mode, 341 // For Windows 7, if we start the lighttpd server on the foreground mode,
342 // it will mess up with the command window and cause conhost.exe to crash. To 342 // it will mess up with the command window and cause conhost.exe to crash. To
343 // work around this, we start the http server on the background mode. 343 // work around this, we start the http server on the background mode.
344 #if defined(OS_WIN) 344 #if defined(OS_WIN)
345 if (win_util::GetWinVersion() >= win_util::WINVERSION_WIN7) 345 if (win_util::GetWinVersion() >= win_util::WINVERSION_WIN7)
346 cmd_line->AppendSwitch("run_background"); 346 cmd_line->AppendSwitch("run_background");
347 #endif 347 #endif
348 348
349 if (!port.empty()) { 349 if (!port.empty()) {
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 } 1111 }
1112 1112
1113 // No first-run dialogs, please. 1113 // No first-run dialogs, please.
1114 command_line.AppendSwitch(switches::kNoFirstRun); 1114 command_line.AppendSwitch(switches::kNoFirstRun);
1115 1115
1116 // No default browser check, it would create an info-bar (if we are not the 1116 // No default browser check, it would create an info-bar (if we are not the
1117 // default browser) that could conflicts with some tests expectations. 1117 // default browser) that could conflicts with some tests expectations.
1118 command_line.AppendSwitch(switches::kNoDefaultBrowserCheck); 1118 command_line.AppendSwitch(switches::kNoDefaultBrowserCheck);
1119 1119
1120 // This is a UI test. 1120 // This is a UI test.
1121 command_line.AppendSwitchWithValue(switches::kTestType, 1121 command_line.AppendSwitchWithValue(switches::kTestType, kUITestType);
1122 ASCIIToWide(kUITestType));
1123 1122
1124 // Tell the browser to use a temporary directory just for this test. 1123 // Tell the browser to use a temporary directory just for this test.
1125 command_line.AppendSwitchWithValue(switches::kUserDataDir, 1124 command_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir());
1126 user_data_dir().ToWStringHack());
1127 1125
1128 // We need cookies on file:// for things like the page cycler. 1126 // We need cookies on file:// for things like the page cycler.
1129 if (enable_file_cookies_) 1127 if (enable_file_cookies_)
1130 command_line.AppendSwitch(switches::kEnableFileCookies); 1128 command_line.AppendSwitch(switches::kEnableFileCookies);
1131 1129
1132 if (dom_automation_enabled_) 1130 if (dom_automation_enabled_)
1133 command_line.AppendSwitch(switches::kDomAutomationController); 1131 command_line.AppendSwitch(switches::kDomAutomationController);
1134 1132
1135 if (include_testing_id_) { 1133 if (include_testing_id_) {
1136 command_line.AppendSwitchWithValue(switches::kTestingChannelID, 1134 command_line.AppendSwitchWithValue(switches::kTestingChannelID,
1137 ASCIIToWide(server_->channel_id())); 1135 server_->channel_id());
1138 } 1136 }
1139 1137
1140 if (!show_error_dialogs_ && 1138 if (!show_error_dialogs_ &&
1141 !CommandLine::ForCurrentProcess()->HasSwitch(kEnableErrorDialogs)) { 1139 !CommandLine::ForCurrentProcess()->HasSwitch(kEnableErrorDialogs)) {
1142 command_line.AppendSwitch(switches::kNoErrorDialogs); 1140 command_line.AppendSwitch(switches::kNoErrorDialogs);
1143 } 1141 }
1144 if (in_process_renderer_) 1142 if (in_process_renderer_)
1145 command_line.AppendSwitch(switches::kSingleProcess); 1143 command_line.AppendSwitch(switches::kSingleProcess);
1146 if (no_sandbox_) 1144 if (no_sandbox_)
1147 command_line.AppendSwitch(switches::kNoSandbox); 1145 command_line.AppendSwitch(switches::kNoSandbox);
1148 if (full_memory_dump_) 1146 if (full_memory_dump_)
1149 command_line.AppendSwitch(switches::kFullMemoryCrashReport); 1147 command_line.AppendSwitch(switches::kFullMemoryCrashReport);
1150 if (safe_plugins_) 1148 if (safe_plugins_)
1151 command_line.AppendSwitch(switches::kSafePlugins); 1149 command_line.AppendSwitch(switches::kSafePlugins);
1152 if (enable_dcheck_) 1150 if (enable_dcheck_)
1153 command_line.AppendSwitch(switches::kEnableDCHECK); 1151 command_line.AppendSwitch(switches::kEnableDCHECK);
1154 if (silent_dump_on_dcheck_) 1152 if (silent_dump_on_dcheck_)
1155 command_line.AppendSwitch(switches::kSilentDumpOnDCHECK); 1153 command_line.AppendSwitch(switches::kSilentDumpOnDCHECK);
1156 if (disable_breakpad_) 1154 if (disable_breakpad_)
1157 command_line.AppendSwitch(switches::kDisableBreakpad); 1155 command_line.AppendSwitch(switches::kDisableBreakpad);
1158 if (!homepage_.empty()) 1156 if (!homepage_.empty())
1159 command_line.AppendSwitchWithValue(switches::kHomePage, 1157 command_line.AppendSwitchWithValue(switches::kHomePage, homepage_);
1160 homepage_);
1161 // Don't try to fetch web resources during UI testing. 1158 // Don't try to fetch web resources during UI testing.
1162 command_line.AppendSwitch(switches::kDisableWebResources); 1159 command_line.AppendSwitch(switches::kDisableWebResources);
1163 1160
1164 if (!js_flags_.empty()) 1161 if (!js_flags_.empty())
1165 command_line.AppendSwitchWithValue(switches::kJavaScriptFlags, 1162 command_line.AppendSwitchWithValue(switches::kJavaScriptFlags, js_flags_);
1166 js_flags_);
1167 if (!log_level_.empty()) 1163 if (!log_level_.empty())
1168 command_line.AppendSwitchWithValue(switches::kLoggingLevel, log_level_); 1164 command_line.AppendSwitchWithValue(switches::kLoggingLevel, log_level_);
1169 1165
1170 command_line.AppendSwitch(switches::kMetricsRecordingOnly); 1166 command_line.AppendSwitch(switches::kMetricsRecordingOnly);
1171 1167
1172 if (!CommandLine::ForCurrentProcess()->HasSwitch(kEnableErrorDialogs)) 1168 if (!CommandLine::ForCurrentProcess()->HasSwitch(kEnableErrorDialogs))
1173 command_line.AppendSwitch(switches::kEnableLogging); 1169 command_line.AppendSwitch(switches::kEnableLogging);
1174 1170
1175 if (dump_histograms_on_exit_) 1171 if (dump_histograms_on_exit_)
1176 command_line.AppendSwitch(switches::kDumpHistogramsOnExit); 1172 command_line.AppendSwitch(switches::kDumpHistogramsOnExit);
1177 1173
1178 #ifdef WAIT_FOR_DEBUGGER_ON_OPEN 1174 #ifdef WAIT_FOR_DEBUGGER_ON_OPEN
1179 command_line.AppendSwitch(switches::kDebugOnStart); 1175 command_line.AppendSwitch(switches::kDebugOnStart);
1180 #endif 1176 #endif
1181 1177
1182 if (!ui_test_name_.empty()) 1178 if (!ui_test_name_.empty())
1183 command_line.AppendSwitchWithValue(switches::kTestName, 1179 command_line.AppendSwitchWithValue(switches::kTestName, ui_test_name_);
1184 ui_test_name_);
1185 1180
1186 // The tests assume that file:// URIs can freely access other file:// URIs. 1181 // The tests assume that file:// URIs can freely access other file:// URIs.
1187 command_line.AppendSwitch(switches::kAllowFileAccessFromFiles); 1182 command_line.AppendSwitch(switches::kAllowFileAccessFromFiles);
1188 1183
1189 // Disable TabCloseableStateWatcher for tests. 1184 // Disable TabCloseableStateWatcher for tests.
1190 command_line.AppendSwitch(switches::kDisableTabCloseableStateWatcher); 1185 command_line.AppendSwitch(switches::kDisableTabCloseableStateWatcher);
1191 1186
1192 DebugFlags::ProcessDebugFlags( 1187 DebugFlags::ProcessDebugFlags(
1193 &command_line, ChildProcessInfo::UNKNOWN_PROCESS, false); 1188 &command_line, ChildProcessInfo::UNKNOWN_PROCESS, false);
1194 command_line.AppendArguments(arguments, false); 1189 command_line.AppendArguments(arguments, false);
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1522 set_ui_test_name(ASCIIToWide(test_name)); 1517 set_ui_test_name(ASCIIToWide(test_name));
1523 } 1518 }
1524 UITestBase::SetUp(); 1519 UITestBase::SetUp();
1525 PlatformTest::SetUp(); 1520 PlatformTest::SetUp();
1526 } 1521 }
1527 1522
1528 void UITest::TearDown() { 1523 void UITest::TearDown() {
1529 UITestBase::TearDown(); 1524 UITestBase::TearDown();
1530 PlatformTest::TearDown(); 1525 PlatformTest::TearDown();
1531 } 1526 }
OLDNEW
« no previous file with comments | « chrome/test/ui/sandbox_uitests.cc ('k') | chrome/test/ui_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698