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

Side by Side Diff: chrome/test/ui_test_utils.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_test_utils.h" 5 #include "chrome/test/ui_test_utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 744
745 } // anonymous namespace 745 } // anonymous namespace
746 746
747 TestWebSocketServer::TestWebSocketServer() : started_(false) { 747 TestWebSocketServer::TestWebSocketServer() : started_(false) {
748 } 748 }
749 749
750 bool TestWebSocketServer::Start(const FilePath& root_directory) { 750 bool TestWebSocketServer::Start(const FilePath& root_directory) {
751 if (started_) 751 if (started_)
752 return true; 752 return true;
753 scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine()); 753 scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine());
754 cmd_line->AppendSwitchASCII("server", "start"); 754 cmd_line->AppendArg("--server=start");
755 cmd_line->AppendSwitch("chromium"); 755 cmd_line->AppendArg("--chromium");
756 cmd_line->AppendSwitch("register_cygwin"); 756 cmd_line->AppendArg("--register_cygwin");
757 cmd_line->AppendSwitchPath("root", root_directory); 757 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--root=") +
758 root_directory.value());
758 if (!temp_dir_.CreateUniqueTempDir()) { 759 if (!temp_dir_.CreateUniqueTempDir()) {
759 LOG(ERROR) << "Unable to create a temporary directory."; 760 LOG(ERROR) << "Unable to create a temporary directory.";
760 return false; 761 return false;
761 } 762 }
762 websocket_pid_file_ = temp_dir_.path().AppendASCII("websocket.pid"); 763 websocket_pid_file_ = temp_dir_.path().AppendASCII("websocket.pid");
763 cmd_line->AppendSwitchPath("pidfile", websocket_pid_file_); 764 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--pidfile=") +
765 websocket_pid_file_.value());
764 SetPythonPath(); 766 SetPythonPath();
765 if (!base::LaunchApp(*cmd_line.get(), true, false, NULL)) { 767 if (!base::LaunchApp(*cmd_line.get(), true, false, NULL)) {
766 LOG(ERROR) << "Unable to launch websocket server."; 768 LOG(ERROR) << "Unable to launch websocket server.";
767 return false; 769 return false;
768 } 770 }
769 started_ = true; 771 started_ = true;
770 return true; 772 return true;
771 } 773 }
772 774
773 CommandLine* TestWebSocketServer::CreatePythonCommandLine() { 775 CommandLine* TestWebSocketServer::CreatePythonCommandLine() {
(...skipping 26 matching lines...) Expand all
800 802
801 CommandLine* cmd_line = CreatePythonCommandLine(); 803 CommandLine* cmd_line = CreatePythonCommandLine();
802 cmd_line->AppendArgPath(script_path); 804 cmd_line->AppendArgPath(script_path);
803 return cmd_line; 805 return cmd_line;
804 } 806 }
805 807
806 TestWebSocketServer::~TestWebSocketServer() { 808 TestWebSocketServer::~TestWebSocketServer() {
807 if (!started_) 809 if (!started_)
808 return; 810 return;
809 scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine()); 811 scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine());
810 cmd_line->AppendSwitchASCII("server", "stop"); 812 cmd_line->AppendArg("--server=stop");
811 cmd_line->AppendSwitch("chromium"); 813 cmd_line->AppendArg("--chromium");
812 cmd_line->AppendSwitchPath("pidfile", websocket_pid_file_); 814 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--pidfile=") +
815 websocket_pid_file_.value());
813 base::LaunchApp(*cmd_line.get(), true, false, NULL); 816 base::LaunchApp(*cmd_line.get(), true, false, NULL);
814 } 817 }
815 818
816 TestNotificationObserver::TestNotificationObserver() 819 TestNotificationObserver::TestNotificationObserver()
817 : source_(NotificationService::AllSources()) { 820 : source_(NotificationService::AllSources()) {
818 } 821 }
819 822
820 TestNotificationObserver::~TestNotificationObserver() {} 823 TestNotificationObserver::~TestNotificationObserver() {}
821 824
822 void TestNotificationObserver::Observe(NotificationType type, 825 void TestNotificationObserver::Observe(NotificationType type,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); 983 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap);
981 } 984 }
982 985
983 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { 986 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) {
984 DCHECK(bitmap); 987 DCHECK(bitmap);
985 SnapshotTaker taker; 988 SnapshotTaker taker;
986 return taker.TakeEntirePageSnapshot(rvh, bitmap); 989 return taker.TakeEntirePageSnapshot(rvh, bitmap);
987 } 990 }
988 991
989 } // namespace ui_test_utils 992 } // namespace ui_test_utils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698