OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/base/ui_test_utils.h" | 5 #include "chrome/test/base/ui_test_utils.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 return base::Bind(&MessageLoopRunner::Quit, this); | 870 return base::Bind(&MessageLoopRunner::Quit, this); |
871 } | 871 } |
872 | 872 |
873 void MessageLoopRunner::Quit() { | 873 void MessageLoopRunner::Quit() { |
874 ui_test_utils::GetQuitTaskForRunLoop(&run_loop_).Run(); | 874 ui_test_utils::GetQuitTaskForRunLoop(&run_loop_).Run(); |
875 } | 875 } |
876 | 876 |
877 TestWebSocketServer::TestWebSocketServer() | 877 TestWebSocketServer::TestWebSocketServer() |
878 : started_(false), | 878 : started_(false), |
879 port_(kDefaultWsPort), | 879 port_(kDefaultWsPort), |
880 secure_(false), | 880 secure_(false) { |
881 client_authentication_(false) { | |
882 #if defined(OS_POSIX) | 881 #if defined(OS_POSIX) |
883 process_group_id_ = base::kNullProcessHandle; | 882 process_group_id_ = base::kNullProcessHandle; |
884 #endif | 883 #endif |
885 } | 884 } |
886 | 885 |
887 int TestWebSocketServer::UseRandomPort() { | 886 int TestWebSocketServer::UseRandomPort() { |
888 port_ = base::RandInt(1024, 65535); | 887 port_ = base::RandInt(1024, 65535); |
889 return port_; | 888 return port_; |
890 } | 889 } |
891 | 890 |
892 void TestWebSocketServer::UseTLS() { | 891 void TestWebSocketServer::UseTLS() { |
893 secure_ = true; | 892 secure_ = true; |
894 } | 893 } |
895 | 894 |
896 void TestWebSocketServer::UseClientAuthentication() { | |
897 client_authentication_ = true; | |
898 } | |
899 | |
900 bool TestWebSocketServer::Start(const FilePath& root_directory) { | 895 bool TestWebSocketServer::Start(const FilePath& root_directory) { |
901 if (started_) | 896 if (started_) |
902 return true; | 897 return true; |
903 // Append CommandLine arguments after the server script, switches won't work. | 898 // Append CommandLine arguments after the server script, switches won't work. |
904 scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine()); | 899 scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine()); |
905 cmd_line->AppendArg("--server=start"); | 900 cmd_line->AppendArg("--server=start"); |
906 cmd_line->AppendArg("--chromium"); | 901 cmd_line->AppendArg("--chromium"); |
907 cmd_line->AppendArg("--register_cygwin"); | 902 cmd_line->AppendArg("--register_cygwin"); |
908 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--root=") + | 903 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--root=") + |
909 root_directory.value()); | 904 root_directory.value()); |
910 cmd_line->AppendArg("--port=" + base::IntToString(port_)); | 905 cmd_line->AppendArg("--port=" + base::IntToString(port_)); |
911 if (secure_) | 906 if (secure_) |
912 cmd_line->AppendArg("--tls"); | 907 cmd_line->AppendArg("--tls"); |
913 if (!temp_dir_.CreateUniqueTempDir()) { | 908 if (!temp_dir_.CreateUniqueTempDir()) { |
914 LOG(ERROR) << "Unable to create a temporary directory."; | 909 LOG(ERROR) << "Unable to create a temporary directory."; |
915 return false; | 910 return false; |
916 } | 911 } |
917 if (client_authentication_) { | |
918 FilePath cacert_path(root_directory); | |
919 cmd_line->AppendArg("--ca-certificate"); | |
920 cacert_path = cacert_path.Append(FILE_PATH_LITERAL("ssl")); | |
921 cacert_path = cacert_path.Append(FILE_PATH_LITERAL("cacert.pem")); | |
922 cmd_line->AppendArgNative(cacert_path.value()); | |
923 } | |
924 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--output-dir=") + | 912 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--output-dir=") + |
925 temp_dir_.path().value()); | 913 temp_dir_.path().value()); |
926 websocket_pid_file_ = temp_dir_.path().AppendASCII("websocket.pid"); | 914 websocket_pid_file_ = temp_dir_.path().AppendASCII("websocket.pid"); |
927 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--pidfile=") + | 915 cmd_line->AppendArgNative(FILE_PATH_LITERAL("--pidfile=") + |
928 websocket_pid_file_.value()); | 916 websocket_pid_file_.value()); |
929 SetPythonPath(); | 917 SetPythonPath(); |
930 | 918 |
931 base::LaunchOptions options; | 919 base::LaunchOptions options; |
932 base::ProcessHandle process_handle; | 920 base::ProcessHandle process_handle; |
933 | 921 |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1301 int state, | 1289 int state, |
1302 const base::Closure& followup) { | 1290 const base::Closure& followup) { |
1303 if (!followup.is_null()) | 1291 if (!followup.is_null()) |
1304 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); | 1292 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); |
1305 else | 1293 else |
1306 ui_controls::SendMouseEvents(button, state); | 1294 ui_controls::SendMouseEvents(button, state); |
1307 } | 1295 } |
1308 | 1296 |
1309 } // namespace internal | 1297 } // namespace internal |
1310 } // namespace ui_test_utils | 1298 } // namespace ui_test_utils |
OLD | NEW |