diff options
author | toyoshim@chromium.org <toyoshim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-25 04:46:11 +0000 |
---|---|---|
committer | toyoshim@chromium.org <toyoshim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-25 04:46:11 +0000 |
commit | d4a34cee3be898c5ef1e7281e0a3865e6539be9c (patch) | |
tree | 151c77a923980ae982c91ce159d40fd6afba6833 /content/public/test/browser_test_utils.cc | |
parent | 90a9427d0bc84b00f435c9f0afd2152b6591537a (diff) | |
download | chromium_src-d4a34cee3be898c5ef1e7281e0a3865e6539be9c.zip chromium_src-d4a34cee3be898c5ef1e7281e0a3865e6539be9c.tar.gz chromium_src-d4a34cee3be898c5ef1e7281e0a3865e6539be9c.tar.bz2 |
Remove unused content::TestWebSocketServer
Now, all unit tests which used content::TestWebSocketServer migrate to
net::TestServer. It's time to remove obsolete content::TestWebSocketServer.
BUG=137639
TEST=browser_tests; content_browsertests
Review URL: https://chromiumcodereview.appspot.com/11144015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164012 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/public/test/browser_test_utils.cc')
-rw-r--r-- | content/public/test/browser_test_utils.cc | 149 |
1 files changed, 0 insertions, 149 deletions
diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc index bf7e3db..6efa0a6 100644 --- a/content/public/test/browser_test_utils.cc +++ b/content/public/test/browser_test_utils.cc @@ -424,155 +424,6 @@ void TitleWatcher::Observe(int type, } } -TestWebSocketServer::TestWebSocketServer() - : started_(false), - port_(kDefaultWsPort), - secure_(false) { -#if defined(OS_POSIX) - process_group_id_ = base::kNullProcessHandle; -#endif -} - -int TestWebSocketServer::UseRandomPort() { - port_ = base::RandInt(1024, 65535); - return port_; -} - -void TestWebSocketServer::UseTLS() { - secure_ = true; -} - -bool TestWebSocketServer::Start(const FilePath& root_directory) { - if (started_) - return true; - // Append CommandLine arguments after the server script, switches won't work. - scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine()); - cmd_line->AppendArg("--server=start"); - cmd_line->AppendArg("--chromium"); - cmd_line->AppendArg("--register_cygwin"); - cmd_line->AppendArgNative(FILE_PATH_LITERAL("--root=") + - root_directory.value()); - cmd_line->AppendArg("--port=" + base::IntToString(port_)); - if (secure_) - cmd_line->AppendArg("--tls"); - if (!temp_dir_.CreateUniqueTempDir()) { - LOG(ERROR) << "Unable to create a temporary directory."; - return false; - } - cmd_line->AppendArgNative(FILE_PATH_LITERAL("--output-dir=") + - temp_dir_.path().value()); - websocket_pid_file_ = temp_dir_.path().AppendASCII("websocket.pid"); - cmd_line->AppendArgNative(FILE_PATH_LITERAL("--pidfile=") + - websocket_pid_file_.value()); - SetPythonPath(); - - base::LaunchOptions options; - base::ProcessHandle process_handle; - -#if defined(OS_POSIX) - options.new_process_group = true; -#elif defined(OS_WIN) - job_handle_.Set(CreateJobObject(NULL, NULL)); - if (!job_handle_.IsValid()) { - LOG(ERROR) << "Could not create JobObject."; - return false; - } - - if (!base::SetJobObjectAsKillOnJobClose(job_handle_.Get())) { - LOG(ERROR) << "Could not SetInformationJobObject."; - return false; - } - - options.inherit_handles = true; - options.job_handle = job_handle_.Get(); -#endif - - // Launch a new WebSocket server process. - if (!base::LaunchProcess(*cmd_line.get(), options, &process_handle)) { - LOG(ERROR) << "Unable to launch websocket server:\n" - << cmd_line.get()->GetCommandLineString(); - return false; - } -#if defined(OS_POSIX) - process_group_id_ = process_handle; -#endif - int exit_code; - bool wait_success = base::WaitForExitCodeWithTimeout( - process_handle, - &exit_code, - TestTimeouts::action_max_timeout()); - base::CloseProcessHandle(process_handle); - - if (!wait_success || exit_code != 0) { - LOG(ERROR) << "Failed to run new-run-webkit-websocketserver: " - << "wait_success = " << wait_success << ", " - << "exit_code = " << exit_code << ", " - << "command_line = " << cmd_line.get()->GetCommandLineString(); - return false; - } - - started_ = true; - return true; -} - -CommandLine* TestWebSocketServer::CreatePythonCommandLine() { - // Note: Python's first argument must be the script; do not append CommandLine - // switches, as they would precede the script path and break this CommandLine. - CommandLine* cmd_line = new CommandLine(CommandLine::NO_PROGRAM); - // TODO(phajdan.jr): Instead of CHECKing, return a boolean indicating success. - CHECK(GetPythonCommand(cmd_line)); - return cmd_line; -} - -void TestWebSocketServer::SetPythonPath() { - FilePath scripts_path; - PathService::Get(base::DIR_SOURCE_ROOT, &scripts_path); - - scripts_path = scripts_path - .Append(FILE_PATH_LITERAL("third_party")) - .Append(FILE_PATH_LITERAL("WebKit")) - .Append(FILE_PATH_LITERAL("Tools")) - .Append(FILE_PATH_LITERAL("Scripts")); - AppendToPythonPath(scripts_path); -} - -CommandLine* TestWebSocketServer::CreateWebSocketServerCommandLine() { - FilePath src_path; - // Get to 'src' dir. - PathService::Get(base::DIR_SOURCE_ROOT, &src_path); - - FilePath script_path(src_path); - script_path = script_path.AppendASCII("third_party"); - script_path = script_path.AppendASCII("WebKit"); - script_path = script_path.AppendASCII("Tools"); - script_path = script_path.AppendASCII("Scripts"); - script_path = script_path.AppendASCII("new-run-webkit-websocketserver"); - - CommandLine* cmd_line = CreatePythonCommandLine(); - cmd_line->AppendArgPath(script_path); - return cmd_line; -} - -TestWebSocketServer::~TestWebSocketServer() { - if (!started_) - return; - // Append CommandLine arguments after the server script, switches won't work. - scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine()); - cmd_line->AppendArg("--server=stop"); - cmd_line->AppendArg("--chromium"); - cmd_line->AppendArgNative(FILE_PATH_LITERAL("--pidfile=") + - websocket_pid_file_.value()); - base::LaunchOptions options; - options.wait = true; - base::LaunchProcess(*cmd_line.get(), options, NULL); - -#if defined(OS_POSIX) - // Just to make sure that the server process terminates certainly. - if (process_group_id_ != base::kNullProcessHandle) - base::KillProcessGroup(process_group_id_); -#endif -} - DOMMessageQueue::DOMMessageQueue() : waiting_for_message_(false) { registrar_.Add(this, NOTIFICATION_DOM_OPERATION_RESPONSE, NotificationService::AllSources()); |