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

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

Powered by Google App Engine
This is Rietveld 408576698