| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 } | 542 } |
| 543 | 543 |
| 544 void UITest::StartHttpServer(const FilePath& root_directory) { | 544 void UITest::StartHttpServer(const FilePath& root_directory) { |
| 545 StartHttpServerWithPort(root_directory, 0); | 545 StartHttpServerWithPort(root_directory, 0); |
| 546 } | 546 } |
| 547 | 547 |
| 548 void UITest::StartHttpServerWithPort(const FilePath& root_directory, | 548 void UITest::StartHttpServerWithPort(const FilePath& root_directory, |
| 549 int port) { | 549 int port) { |
| 550 scoped_ptr<CommandLine> cmd_line(CreateHttpServerCommandLine()); | 550 scoped_ptr<CommandLine> cmd_line(CreateHttpServerCommandLine()); |
| 551 ASSERT_TRUE(cmd_line.get()); | 551 ASSERT_TRUE(cmd_line.get()); |
| 552 cmd_line->AppendSwitchASCII("server", "start"); | 552 cmd_line->AppendArg("--server=start"); |
| 553 cmd_line->AppendSwitch("register_cygwin"); | 553 cmd_line->AppendArg("--register_cygwin"); |
| 554 cmd_line->AppendSwitchPath("root", root_directory); | 554 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--root=") + |
| 555 root_directory.value()); |
| 555 | 556 |
| 556 FilePath layout_tests_dir; | 557 FilePath layout_tests_dir; |
| 557 PathService::Get(base::DIR_SOURCE_ROOT, &layout_tests_dir); | 558 PathService::Get(base::DIR_SOURCE_ROOT, &layout_tests_dir); |
| 558 layout_tests_dir = layout_tests_dir.AppendASCII("chrome") | 559 layout_tests_dir = layout_tests_dir.AppendASCII("chrome") |
| 559 .AppendASCII("test") | 560 .AppendASCII("test") |
| 560 .AppendASCII("data") | 561 .AppendASCII("data") |
| 561 .AppendASCII("layout_tests") | 562 .AppendASCII("layout_tests") |
| 562 .AppendASCII("LayoutTests"); | 563 .AppendASCII("LayoutTests"); |
| 563 cmd_line->AppendSwitchPath("layout_tests_dir", layout_tests_dir); | 564 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--layout_tests_dir=") + |
| 565 layout_tests_dir.value()); |
| 564 | 566 |
| 565 // For Windows 7, if we start the lighttpd server on the foreground mode, | 567 // For Windows 7, if we start the lighttpd server on the foreground mode, |
| 566 // it will mess up with the command window and cause conhost.exe to crash. To | 568 // it will mess up with the command window and cause conhost.exe to crash. To |
| 567 // work around this, we start the http server on the background mode. | 569 // work around this, we start the http server on the background mode. |
| 568 #if defined(OS_WIN) | 570 #if defined(OS_WIN) |
| 569 if (base::win::GetVersion() >= base::win::VERSION_WIN7) | 571 if (base::win::GetVersion() >= base::win::VERSION_WIN7) |
| 570 cmd_line->AppendSwitch("run_background"); | 572 cmd_line->AppendArg("--run_background"); |
| 571 #endif | 573 #endif |
| 572 | 574 |
| 573 if (port) | 575 if (port) |
| 574 cmd_line->AppendSwitchASCII("port", base::IntToString(port)); | 576 cmd_line->AppendArg("--port=" + base::IntToString(port)); |
| 575 | 577 |
| 576 #if defined(OS_WIN) | 578 #if defined(OS_WIN) |
| 577 // TODO(phajdan.jr): is this needed? | 579 // TODO(phajdan.jr): is this needed? |
| 578 base::LaunchAppWithHandleInheritance(cmd_line->command_line_string(), | 580 base::LaunchAppWithHandleInheritance(cmd_line->command_line_string(), |
| 579 true, | 581 true, |
| 580 false, | 582 false, |
| 581 NULL); | 583 NULL); |
| 582 #else | 584 #else |
| 583 base::LaunchApp(*cmd_line.get(), true, false, NULL); | 585 base::LaunchApp(*cmd_line.get(), true, false, NULL); |
| 584 #endif | 586 #endif |
| 585 } | 587 } |
| 586 | 588 |
| 587 void UITest::StopHttpServer() { | 589 void UITest::StopHttpServer() { |
| 588 scoped_ptr<CommandLine> cmd_line(CreateHttpServerCommandLine()); | 590 scoped_ptr<CommandLine> cmd_line(CreateHttpServerCommandLine()); |
| 589 ASSERT_TRUE(cmd_line.get()); | 591 ASSERT_TRUE(cmd_line.get()); |
| 590 cmd_line->AppendSwitchASCII("server", "stop"); | 592 cmd_line->AppendArg("--server=stop"); |
| 591 | 593 |
| 592 #if defined(OS_WIN) | 594 #if defined(OS_WIN) |
| 593 // TODO(phajdan.jr): is this needed? | 595 // TODO(phajdan.jr): is this needed? |
| 594 base::LaunchAppWithHandleInheritance(cmd_line->command_line_string(), | 596 base::LaunchAppWithHandleInheritance(cmd_line->command_line_string(), |
| 595 true, | 597 true, |
| 596 false, | 598 false, |
| 597 NULL); | 599 NULL); |
| 598 #else | 600 #else |
| 599 base::LaunchApp(*cmd_line.get(), true, false, NULL); | 601 base::LaunchApp(*cmd_line.get(), true, false, NULL); |
| 600 #endif | 602 #endif |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms() / kCycles); | 840 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms() / kCycles); |
| 839 } | 841 } |
| 840 | 842 |
| 841 LOG(INFO) << "Elapsed time: " << (base::Time::Now() - start).InSecondsF() | 843 LOG(INFO) << "Elapsed time: " << (base::Time::Now() - start).InSecondsF() |
| 842 << " seconds" | 844 << " seconds" |
| 843 << " call failed " << fail_count << " times" | 845 << " call failed " << fail_count << " times" |
| 844 << " state was incorrect " << incorrect_state_count << " times"; | 846 << " state was incorrect " << incorrect_state_count << " times"; |
| 845 ADD_FAILURE() << "Timeout reached in " << __FUNCTION__; | 847 ADD_FAILURE() << "Timeout reached in " << __FUNCTION__; |
| 846 return false; | 848 return false; |
| 847 } | 849 } |
| OLD | NEW |