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

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: Major refresh after r76339 and r76419. 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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 } 547 }
548 548
549 void UITest::StartHttpServer(const FilePath& root_directory) { 549 void UITest::StartHttpServer(const FilePath& root_directory) {
550 StartHttpServerWithPort(root_directory, 0); 550 StartHttpServerWithPort(root_directory, 0);
551 } 551 }
552 552
553 void UITest::StartHttpServerWithPort(const FilePath& root_directory, 553 void UITest::StartHttpServerWithPort(const FilePath& root_directory,
554 int port) { 554 int port) {
555 scoped_ptr<CommandLine> cmd_line(CreateHttpServerCommandLine()); 555 scoped_ptr<CommandLine> cmd_line(CreateHttpServerCommandLine());
556 ASSERT_TRUE(cmd_line.get()); 556 ASSERT_TRUE(cmd_line.get());
557 cmd_line->AppendSwitchASCII("server", "start"); 557 cmd_line->AppendArg("--server=start");
558 cmd_line->AppendSwitch("register_cygwin"); 558 cmd_line->AppendArg("--register_cygwin");
559 cmd_line->AppendSwitchPath("root", root_directory); 559 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--root=") +
560 root_directory.value());
Evan Martin 2011/05/10 23:48:32 Why not AppendSwitch?
msw 2011/05/11 02:28:12 Same reasoning as SafeBrowsingTestServer::Start().
560 561
561 FilePath layout_tests_dir; 562 FilePath layout_tests_dir;
562 PathService::Get(base::DIR_SOURCE_ROOT, &layout_tests_dir); 563 PathService::Get(base::DIR_SOURCE_ROOT, &layout_tests_dir);
563 layout_tests_dir = layout_tests_dir.AppendASCII("chrome") 564 layout_tests_dir = layout_tests_dir.AppendASCII("chrome")
564 .AppendASCII("test") 565 .AppendASCII("test")
565 .AppendASCII("data") 566 .AppendASCII("data")
566 .AppendASCII("layout_tests") 567 .AppendASCII("layout_tests")
567 .AppendASCII("LayoutTests"); 568 .AppendASCII("LayoutTests");
568 cmd_line->AppendSwitchPath("layout_tests_dir", layout_tests_dir); 569 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--layout_tests_dir=") +
570 layout_tests_dir.value());
569 571
570 // For Windows 7, if we start the lighttpd server on the foreground mode, 572 // For Windows 7, if we start the lighttpd server on the foreground mode,
571 // it will mess up with the command window and cause conhost.exe to crash. To 573 // it will mess up with the command window and cause conhost.exe to crash. To
572 // work around this, we start the http server on the background mode. 574 // work around this, we start the http server on the background mode.
573 #if defined(OS_WIN) 575 #if defined(OS_WIN)
574 if (base::win::GetVersion() >= base::win::VERSION_WIN7) 576 if (base::win::GetVersion() >= base::win::VERSION_WIN7)
575 cmd_line->AppendSwitch("run_background"); 577 cmd_line->AppendArg("--run_background");
576 #endif 578 #endif
577 579
578 if (port) 580 if (port)
579 cmd_line->AppendSwitchASCII("port", base::IntToString(port)); 581 cmd_line->AppendArg("--port=" + base::IntToString(port));
580 582
581 #if defined(OS_WIN) 583 #if defined(OS_WIN)
582 // TODO(phajdan.jr): is this needed? 584 // TODO(phajdan.jr): is this needed?
583 base::LaunchAppWithHandleInheritance(cmd_line->command_line_string(), 585 base::LaunchAppWithHandleInheritance(cmd_line->command_line_string(),
584 true, 586 true,
585 false, 587 false,
586 NULL); 588 NULL);
587 #else 589 #else
588 base::LaunchApp(*cmd_line.get(), true, false, NULL); 590 base::LaunchApp(*cmd_line.get(), true, false, NULL);
589 #endif 591 #endif
590 } 592 }
591 593
592 void UITest::StopHttpServer() { 594 void UITest::StopHttpServer() {
593 scoped_ptr<CommandLine> cmd_line(CreateHttpServerCommandLine()); 595 scoped_ptr<CommandLine> cmd_line(CreateHttpServerCommandLine());
594 ASSERT_TRUE(cmd_line.get()); 596 ASSERT_TRUE(cmd_line.get());
595 cmd_line->AppendSwitchASCII("server", "stop"); 597 cmd_line->AppendArg("--server=stop");
596 598
597 #if defined(OS_WIN) 599 #if defined(OS_WIN)
598 // TODO(phajdan.jr): is this needed? 600 // TODO(phajdan.jr): is this needed?
599 base::LaunchAppWithHandleInheritance(cmd_line->command_line_string(), 601 base::LaunchAppWithHandleInheritance(cmd_line->command_line_string(),
600 true, 602 true,
601 false, 603 false,
602 NULL); 604 NULL);
603 #else 605 #else
604 base::LaunchApp(*cmd_line.get(), true, false, NULL); 606 base::LaunchApp(*cmd_line.get(), true, false, NULL);
605 #endif 607 #endif
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms() / kCycles); 845 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms() / kCycles);
844 } 846 }
845 847
846 LOG(INFO) << "Elapsed time: " << (base::Time::Now() - start).InSecondsF() 848 LOG(INFO) << "Elapsed time: " << (base::Time::Now() - start).InSecondsF()
847 << " seconds" 849 << " seconds"
848 << " call failed " << fail_count << " times" 850 << " call failed " << fail_count << " times"
849 << " state was incorrect " << incorrect_state_count << " times"; 851 << " state was incorrect " << incorrect_state_count << " times";
850 ADD_FAILURE() << "Timeout reached in " << __FUNCTION__; 852 ADD_FAILURE() << "Timeout reached in " << __FUNCTION__;
851 return false; 853 return false;
852 } 854 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698