OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 std::string newpath(oldpath); | 792 std::string newpath(oldpath); |
793 newpath.append(":"); | 793 newpath.append(":"); |
794 newpath.append(dir.value()); | 794 newpath.append(dir.value()); |
795 setenv(kPythonPath, newpath.c_str(), 1); | 795 setenv(kPythonPath, newpath.c_str(), 1); |
796 } | 796 } |
797 #endif | 797 #endif |
798 } | 798 } |
799 | 799 |
800 } // anonymous namespace | 800 } // anonymous namespace |
801 | 801 |
802 TestWebSocketServer::TestWebSocketServer(const FilePath& root_directory) { | 802 TestWebSocketServer::TestWebSocketServer() : started_(false) { |
| 803 } |
| 804 |
| 805 bool TestWebSocketServer::Start(const FilePath& root_directory) { |
| 806 if (started_) |
| 807 return true; |
803 scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine()); | 808 scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine()); |
804 cmd_line->AppendSwitchASCII("server", "start"); | 809 cmd_line->AppendSwitchASCII("server", "start"); |
805 cmd_line->AppendSwitch("chromium"); | 810 cmd_line->AppendSwitch("chromium"); |
806 cmd_line->AppendSwitch("register_cygwin"); | 811 cmd_line->AppendSwitch("register_cygwin"); |
807 cmd_line->AppendSwitchPath("root", root_directory); | 812 cmd_line->AppendSwitchPath("root", root_directory); |
808 temp_dir_.CreateUniqueTempDir(); | 813 if (!temp_dir_.CreateUniqueTempDir()) { |
| 814 LOG(ERROR) << "Unable to create a temporary directory."; |
| 815 return false; |
| 816 } |
809 websocket_pid_file_ = temp_dir_.path().AppendASCII("websocket.pid"); | 817 websocket_pid_file_ = temp_dir_.path().AppendASCII("websocket.pid"); |
810 cmd_line->AppendSwitchPath("pidfile", websocket_pid_file_); | 818 cmd_line->AppendSwitchPath("pidfile", websocket_pid_file_); |
811 SetPythonPath(); | 819 SetPythonPath(); |
812 base::LaunchApp(*cmd_line.get(), true, false, NULL); | 820 if (!base::LaunchApp(*cmd_line.get(), true, false, NULL)) { |
| 821 LOG(ERROR) << "Unable to launch websocket server."; |
| 822 return false; |
| 823 } |
| 824 started_ = true; |
| 825 return true; |
813 } | 826 } |
814 | 827 |
815 CommandLine* TestWebSocketServer::CreatePythonCommandLine() { | 828 CommandLine* TestWebSocketServer::CreatePythonCommandLine() { |
816 return new CommandLine(FilePath(FILE_PATH_LITERAL("python"))); | 829 return new CommandLine(FilePath(FILE_PATH_LITERAL("python"))); |
817 } | 830 } |
818 | 831 |
819 void TestWebSocketServer::SetPythonPath() { | 832 void TestWebSocketServer::SetPythonPath() { |
820 FilePath scripts_path; | 833 FilePath scripts_path; |
821 PathService::Get(base::DIR_SOURCE_ROOT, &scripts_path); | 834 PathService::Get(base::DIR_SOURCE_ROOT, &scripts_path); |
822 | 835 |
(...skipping 16 matching lines...) Expand all Loading... |
839 script_path = script_path.AppendASCII("Tools"); | 852 script_path = script_path.AppendASCII("Tools"); |
840 script_path = script_path.AppendASCII("Scripts"); | 853 script_path = script_path.AppendASCII("Scripts"); |
841 script_path = script_path.AppendASCII("new-run-webkit-websocketserver"); | 854 script_path = script_path.AppendASCII("new-run-webkit-websocketserver"); |
842 | 855 |
843 CommandLine* cmd_line = CreatePythonCommandLine(); | 856 CommandLine* cmd_line = CreatePythonCommandLine(); |
844 cmd_line->AppendArgPath(script_path); | 857 cmd_line->AppendArgPath(script_path); |
845 return cmd_line; | 858 return cmd_line; |
846 } | 859 } |
847 | 860 |
848 TestWebSocketServer::~TestWebSocketServer() { | 861 TestWebSocketServer::~TestWebSocketServer() { |
| 862 if (!started_) |
| 863 return; |
849 scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine()); | 864 scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine()); |
850 cmd_line->AppendSwitchASCII("server", "stop"); | 865 cmd_line->AppendSwitchASCII("server", "stop"); |
851 cmd_line->AppendSwitch("chromium"); | 866 cmd_line->AppendSwitch("chromium"); |
852 cmd_line->AppendSwitchPath("pidfile", websocket_pid_file_); | 867 cmd_line->AppendSwitchPath("pidfile", websocket_pid_file_); |
853 base::LaunchApp(*cmd_line.get(), true, false, NULL); | 868 base::LaunchApp(*cmd_line.get(), true, false, NULL); |
854 } | 869 } |
855 | 870 |
856 WindowedNotificationObserver::WindowedNotificationObserver( | 871 WindowedNotificationObserver::WindowedNotificationObserver( |
857 NotificationType notification_type, | 872 NotificationType notification_type, |
858 const NotificationSource& source) | 873 const NotificationSource& source) |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); | 1019 return taker.TakeRenderWidgetSnapshot(rwh, page_size, page_size, bitmap); |
1005 } | 1020 } |
1006 | 1021 |
1007 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { | 1022 bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) { |
1008 DCHECK(bitmap); | 1023 DCHECK(bitmap); |
1009 SnapshotTaker taker; | 1024 SnapshotTaker taker; |
1010 return taker.TakeEntirePageSnapshot(rvh, bitmap); | 1025 return taker.TakeEntirePageSnapshot(rvh, bitmap); |
1011 } | 1026 } |
1012 | 1027 |
1013 } // namespace ui_test_utils | 1028 } // namespace ui_test_utils |
OLD | NEW |