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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 } | 327 } |
328 | 328 |
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->AppendSwitchASCII("server", "start"); |
338 cmd_line->AppendSwitch("register_cygwin"); | 338 cmd_line->AppendSwitch("register_cygwin"); |
339 cmd_line->AppendSwitchPath("root", root_directory); | 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()) { |
350 cmd_line->AppendSwitchWithValue("port", port); | 350 cmd_line->AppendSwitchWithValue("port", port); |
351 } | 351 } |
352 RunCommand(*cmd_line.get()); | 352 RunCommand(*cmd_line.get()); |
353 } | 353 } |
354 | 354 |
355 void UITestBase::StopHttpServer() { | 355 void UITestBase::StopHttpServer() { |
356 scoped_ptr<CommandLine> cmd_line(CreateHttpServerCommandLine()); | 356 scoped_ptr<CommandLine> cmd_line(CreateHttpServerCommandLine()); |
357 ASSERT_TRUE(cmd_line.get()); | 357 ASSERT_TRUE(cmd_line.get()); |
358 cmd_line->AppendSwitchWithValue("server", "stop"); | 358 cmd_line->AppendSwitchASCII("server", "stop"); |
359 RunCommand(*cmd_line.get()); | 359 RunCommand(*cmd_line.get()); |
360 } | 360 } |
361 | 361 |
362 void UITestBase::LaunchBrowser(const CommandLine& arguments, | 362 void UITestBase::LaunchBrowser(const CommandLine& arguments, |
363 bool clear_profile) { | 363 bool clear_profile) { |
364 if (clear_profile || !temp_profile_dir_->IsValid()) { | 364 if (clear_profile || !temp_profile_dir_->IsValid()) { |
365 temp_profile_dir_.reset(new ScopedTempDir()); | 365 temp_profile_dir_.reset(new ScopedTempDir()); |
366 ASSERT_TRUE(temp_profile_dir_->CreateUniqueTempDir()); | 366 ASSERT_TRUE(temp_profile_dir_->CreateUniqueTempDir()); |
367 | 367 |
368 // Update the information about user data directory location on the ui_test | 368 // Update the information about user data directory location on the ui_test |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, kUITestType); | 1121 command_line.AppendSwitchASCII(switches::kTestType, kUITestType); |
1122 | 1122 |
1123 // 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. |
1124 command_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir()); | 1124 command_line.AppendSwitchPath(switches::kUserDataDir, user_data_dir()); |
1125 | 1125 |
1126 // We need cookies on file:// for things like the page cycler. | 1126 // We need cookies on file:// for things like the page cycler. |
1127 if (enable_file_cookies_) | 1127 if (enable_file_cookies_) |
1128 command_line.AppendSwitch(switches::kEnableFileCookies); | 1128 command_line.AppendSwitch(switches::kEnableFileCookies); |
1129 | 1129 |
1130 if (dom_automation_enabled_) | 1130 if (dom_automation_enabled_) |
1131 command_line.AppendSwitch(switches::kDomAutomationController); | 1131 command_line.AppendSwitch(switches::kDomAutomationController); |
1132 | 1132 |
1133 if (include_testing_id_) { | 1133 if (include_testing_id_) { |
1134 command_line.AppendSwitchWithValue(switches::kTestingChannelID, | 1134 command_line.AppendSwitchASCII(switches::kTestingChannelID, |
1135 server_->channel_id()); | 1135 server_->channel_id()); |
1136 } | 1136 } |
1137 | 1137 |
1138 if (!show_error_dialogs_ && | 1138 if (!show_error_dialogs_ && |
1139 !CommandLine::ForCurrentProcess()->HasSwitch(kEnableErrorDialogs)) { | 1139 !CommandLine::ForCurrentProcess()->HasSwitch(kEnableErrorDialogs)) { |
1140 command_line.AppendSwitch(switches::kNoErrorDialogs); | 1140 command_line.AppendSwitch(switches::kNoErrorDialogs); |
1141 } | 1141 } |
1142 if (in_process_renderer_) | 1142 if (in_process_renderer_) |
1143 command_line.AppendSwitch(switches::kSingleProcess); | 1143 command_line.AppendSwitch(switches::kSingleProcess); |
1144 if (no_sandbox_) | 1144 if (no_sandbox_) |
1145 command_line.AppendSwitch(switches::kNoSandbox); | 1145 command_line.AppendSwitch(switches::kNoSandbox); |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 set_ui_test_name(ASCIIToWide(test_name)); | 1517 set_ui_test_name(ASCIIToWide(test_name)); |
1518 } | 1518 } |
1519 UITestBase::SetUp(); | 1519 UITestBase::SetUp(); |
1520 PlatformTest::SetUp(); | 1520 PlatformTest::SetUp(); |
1521 } | 1521 } |
1522 | 1522 |
1523 void UITest::TearDown() { | 1523 void UITest::TearDown() { |
1524 UITestBase::TearDown(); | 1524 UITestBase::TearDown(); |
1525 PlatformTest::TearDown(); | 1525 PlatformTest::TearDown(); |
1526 } | 1526 } |
OLD | NEW |