diff options
author | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-25 00:33:11 +0000 |
---|---|---|
committer | rafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-25 00:33:11 +0000 |
commit | ce61f226b76a8e31b16a865b691d2a578f02f9d6 (patch) | |
tree | 040ee9305b0570f7fcec8cef96a565183726c4e4 /chrome/test/ui_test_utils.cc | |
parent | 271ca3ebe9075d90aa4122aa2a86b341539edd69 (diff) | |
download | chromium_src-ce61f226b76a8e31b16a865b691d2a578f02f9d6.zip chromium_src-ce61f226b76a8e31b16a865b691d2a578f02f9d6.tar.gz chromium_src-ce61f226b76a8e31b16a865b691d2a578f02f9d6.tar.bz2 |
Add an WebSocket extension browsertest.
This adds a simple browsertest that sanity checks that WebSockets can be opened and used from extension processes.
BUG=NONE
TEST=NONE
Review URL: http://codereview.chromium.org/660011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39961 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/ui_test_utils.cc')
-rw-r--r-- | chrome/test/ui_test_utils.cc | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/chrome/test/ui_test_utils.cc b/chrome/test/ui_test_utils.cc index 6eac7fa..d1cd7d3 100644 --- a/chrome/test/ui_test_utils.cc +++ b/chrome/test/ui_test_utils.cc @@ -29,6 +29,7 @@ #endif #include "googleurl/src/gurl.h" #include "net/base/net_util.h" +#include "testing/gtest/include/gtest/gtest.h" namespace ui_test_utils { @@ -572,4 +573,59 @@ void TimedMessageLoopRunner::QuitAfter(int ms) { loop_->PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask, ms); } +TestWebSocketServer::TestWebSocketServer(const FilePath& root_directory) { + scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine()); + cmd_line->AppendSwitchWithValue("server", "start"); + cmd_line->AppendSwitch("register_cygwin"); + cmd_line->AppendSwitchWithValue("root", root_directory.ToWStringHack()); + temp_dir_.CreateUniqueTempDir(); + websocket_pid_file_ = temp_dir_.path().AppendASCII("websocket.pid"); + cmd_line->AppendSwitchWithValue("pidfile", + websocket_pid_file_.ToWStringHack()); + base::LaunchApp(*cmd_line.get(), true, false, NULL); +} + +CommandLine* TestWebSocketServer::CreatePythonCommandLine() { +#if defined(OS_WIN) + // Get path to python interpreter + FilePath python_runtime; + if (!PathService::Get(base::DIR_SOURCE_ROOT, &python_runtime)) + return NULL; + python_runtime = python_runtime + .Append(FILE_PATH_LITERAL("third_party")) + .Append(FILE_PATH_LITERAL("python_24")) + .Append(FILE_PATH_LITERAL("python.exe")); + return new CommandLine(python_runtime); +#elif defined(OS_POSIX) + return new CommandLine(FilePath("python")); +#endif +} + +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("webkit"); + script_path = script_path.AppendASCII("tools"); + script_path = script_path.AppendASCII("layout_tests"); + script_path = script_path.AppendASCII("webkitpy"); + script_path = script_path.AppendASCII("layout_tests"); + script_path = script_path.AppendASCII("layout_package"); + script_path = script_path.AppendASCII("websocket_server.py"); + + CommandLine* cmd_line = CreatePythonCommandLine(); + cmd_line->AppendLooseValue(script_path.ToWStringHack()); + return cmd_line; +} + +TestWebSocketServer::~TestWebSocketServer() { + scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine()); + cmd_line->AppendSwitchWithValue("server", "stop"); + cmd_line->AppendSwitchWithValue("pidfile", + websocket_pid_file_.ToWStringHack()); + base::LaunchApp(*cmd_line.get(), true, false, NULL); +} + } // namespace ui_test_utils |