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

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

Issue 6526040: CommandLine refactoring and cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits, merge changes. Created 9 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/live_sync/live_sync_test.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) 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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 } 514 }
515 515
516 ProxyLauncher* UITest::CreateProxyLauncher() { 516 ProxyLauncher* UITest::CreateProxyLauncher() {
517 // Make the AutomationProxy disconnect the channel on the first error, 517 // Make the AutomationProxy disconnect the channel on the first error,
518 // so that we avoid spending a lot of time in timeouts. The browser is likely 518 // so that we avoid spending a lot of time in timeouts. The browser is likely
519 // hosed if we hit those errors. 519 // hosed if we hit those errors.
520 return new AnonymousProxyLauncher(true); 520 return new AnonymousProxyLauncher(true);
521 } 521 }
522 522
523 static CommandLine* CreatePythonCommandLine() { 523 static CommandLine* CreatePythonCommandLine() {
524 // Note: Python's first argument must be the script; do not append CommandLine
525 // switches, as they would precede the script path and break this CommandLine.
524 return new CommandLine(FilePath(FILE_PATH_LITERAL("python"))); 526 return new CommandLine(FilePath(FILE_PATH_LITERAL("python")));
525 } 527 }
526 528
527 static CommandLine* CreateHttpServerCommandLine() { 529 static CommandLine* CreateHttpServerCommandLine() {
528 FilePath src_path; 530 FilePath src_path;
529 // Get to 'src' dir. 531 // Get to 'src' dir.
530 PathService::Get(base::DIR_SOURCE_ROOT, &src_path); 532 PathService::Get(base::DIR_SOURCE_ROOT, &src_path);
531 533
532 FilePath script_path(src_path); 534 FilePath script_path(src_path);
533 script_path = script_path.AppendASCII("third_party"); 535 script_path = script_path.AppendASCII("third_party");
534 script_path = script_path.AppendASCII("WebKit"); 536 script_path = script_path.AppendASCII("WebKit");
535 script_path = script_path.AppendASCII("Tools"); 537 script_path = script_path.AppendASCII("Tools");
536 script_path = script_path.AppendASCII("Scripts"); 538 script_path = script_path.AppendASCII("Scripts");
537 script_path = script_path.AppendASCII("new-run-webkit-httpd"); 539 script_path = script_path.AppendASCII("new-run-webkit-httpd");
538 540
539 CommandLine* cmd_line = CreatePythonCommandLine(); 541 CommandLine* cmd_line = CreatePythonCommandLine();
540 cmd_line->AppendArgPath(script_path); 542 cmd_line->AppendArgPath(script_path);
541 return cmd_line; 543 return cmd_line;
542 } 544 }
543 545
544 void UITest::StartHttpServer(const FilePath& root_directory) { 546 void UITest::StartHttpServer(const FilePath& root_directory) {
545 StartHttpServerWithPort(root_directory, 0); 547 StartHttpServerWithPort(root_directory, 0);
546 } 548 }
547 549
548 void UITest::StartHttpServerWithPort(const FilePath& root_directory, 550 void UITest::StartHttpServerWithPort(const FilePath& root_directory,
549 int port) { 551 int port) {
552 // Append CommandLine arguments after the server script, switches won't work.
550 scoped_ptr<CommandLine> cmd_line(CreateHttpServerCommandLine()); 553 scoped_ptr<CommandLine> cmd_line(CreateHttpServerCommandLine());
551 ASSERT_TRUE(cmd_line.get()); 554 ASSERT_TRUE(cmd_line.get());
552 cmd_line->AppendSwitchASCII("server", "start"); 555 cmd_line->AppendArg("--server=start");
553 cmd_line->AppendSwitch("register_cygwin"); 556 cmd_line->AppendArg("--register_cygwin");
554 cmd_line->AppendSwitchPath("root", root_directory); 557 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--root=") +
558 root_directory.value());
555 559
556 FilePath layout_tests_dir; 560 FilePath layout_tests_dir;
557 PathService::Get(base::DIR_SOURCE_ROOT, &layout_tests_dir); 561 PathService::Get(base::DIR_SOURCE_ROOT, &layout_tests_dir);
558 layout_tests_dir = layout_tests_dir.AppendASCII("chrome") 562 layout_tests_dir = layout_tests_dir.AppendASCII("chrome")
559 .AppendASCII("test") 563 .AppendASCII("test")
560 .AppendASCII("data") 564 .AppendASCII("data")
561 .AppendASCII("layout_tests") 565 .AppendASCII("layout_tests")
562 .AppendASCII("LayoutTests"); 566 .AppendASCII("LayoutTests");
563 cmd_line->AppendSwitchPath("layout_tests_dir", layout_tests_dir); 567 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--layout_tests_dir=") +
568 layout_tests_dir.value());
564 569
565 // For Windows 7, if we start the lighttpd server on the foreground mode, 570 // 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 571 // 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. 572 // work around this, we start the http server on the background mode.
568 #if defined(OS_WIN) 573 #if defined(OS_WIN)
569 if (base::win::GetVersion() >= base::win::VERSION_WIN7) 574 if (base::win::GetVersion() >= base::win::VERSION_WIN7)
570 cmd_line->AppendSwitch("run_background"); 575 cmd_line->AppendArg("--run_background");
571 #endif 576 #endif
572 577
573 if (port) 578 if (port)
574 cmd_line->AppendSwitchASCII("port", base::IntToString(port)); 579 cmd_line->AppendArg("--port=" + base::IntToString(port));
575 580
576 #if defined(OS_WIN) 581 #if defined(OS_WIN)
577 // TODO(phajdan.jr): is this needed? 582 // TODO(phajdan.jr): is this needed?
578 base::LaunchAppWithHandleInheritance(cmd_line->command_line_string(), 583 base::LaunchAppWithHandleInheritance(cmd_line->command_line_string(),
579 true, 584 true,
580 false, 585 false,
581 NULL); 586 NULL);
582 #else 587 #else
583 base::LaunchApp(*cmd_line.get(), true, false, NULL); 588 base::LaunchApp(*cmd_line.get(), true, false, NULL);
584 #endif 589 #endif
585 } 590 }
586 591
587 void UITest::StopHttpServer() { 592 void UITest::StopHttpServer() {
593 // Append CommandLine arguments after the server script, switches won't work.
588 scoped_ptr<CommandLine> cmd_line(CreateHttpServerCommandLine()); 594 scoped_ptr<CommandLine> cmd_line(CreateHttpServerCommandLine());
589 ASSERT_TRUE(cmd_line.get()); 595 ASSERT_TRUE(cmd_line.get());
590 cmd_line->AppendSwitchASCII("server", "stop"); 596 cmd_line->AppendArg("--server=stop");
591 597
592 #if defined(OS_WIN) 598 #if defined(OS_WIN)
593 // TODO(phajdan.jr): is this needed? 599 // TODO(phajdan.jr): is this needed?
594 base::LaunchAppWithHandleInheritance(cmd_line->command_line_string(), 600 base::LaunchAppWithHandleInheritance(cmd_line->command_line_string(),
595 true, 601 true,
596 false, 602 false,
597 NULL); 603 NULL);
598 #else 604 #else
599 base::LaunchApp(*cmd_line.get(), true, false, NULL); 605 base::LaunchApp(*cmd_line.get(), true, false, NULL);
600 #endif 606 #endif
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms() / kCycles); 844 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms() / kCycles);
839 } 845 }
840 846
841 LOG(INFO) << "Elapsed time: " << (base::Time::Now() - start).InSecondsF() 847 LOG(INFO) << "Elapsed time: " << (base::Time::Now() - start).InSecondsF()
842 << " seconds" 848 << " seconds"
843 << " call failed " << fail_count << " times" 849 << " call failed " << fail_count << " times"
844 << " state was incorrect " << incorrect_state_count << " times"; 850 << " state was incorrect " << incorrect_state_count << " times";
845 ADD_FAILURE() << "Timeout reached in " << __FUNCTION__; 851 ADD_FAILURE() << "Timeout reached in " << __FUNCTION__;
846 return false; 852 return false;
847 } 853 }
OLDNEW
« no previous file with comments | « chrome/test/live_sync/live_sync_test.cc ('k') | chrome/test/ui_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698