summaryrefslogtreecommitdiffstats
path: root/chrome/test/ui
diff options
context:
space:
mode:
authorukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-13 10:25:53 +0000
committerukai@chromium.org <ukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-13 10:25:53 +0000
commita6fb1417e1c35469835a6066f5fadaeadd6bfb69 (patch)
tree700131027585983d6574b81bca69bd8c700be2c3 /chrome/test/ui
parentc2034d9a454ee55e048d601ff2f172d24b1a28c7 (diff)
downloadchromium_src-a6fb1417e1c35469835a6066f5fadaeadd6bfb69.zip
chromium_src-a6fb1417e1c35469835a6066f5fadaeadd6bfb69.tar.gz
chromium_src-a6fb1417e1c35469835a6066f5fadaeadd6bfb69.tar.bz2
Add LayoutTests/websocket/tests/worker support.
BUG=27618 TEST=none Review URL: http://codereview.chromium.org/460106 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36114 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/ui')
-rw-r--r--chrome/test/ui/ui_layout_test.cc12
-rw-r--r--chrome/test/ui/ui_layout_test.h7
-rw-r--r--chrome/test/ui/ui_test.cc39
-rw-r--r--chrome/test/ui/ui_test.h6
4 files changed, 56 insertions, 8 deletions
diff --git a/chrome/test/ui/ui_layout_test.cc b/chrome/test/ui/ui_layout_test.cc
index a4be6e2..b9184f8 100644
--- a/chrome/test/ui/ui_layout_test.cc
+++ b/chrome/test/ui/ui_layout_test.cc
@@ -42,7 +42,7 @@ UILayoutTest::~UILayoutTest() {
void UILayoutTest::InitializeForLayoutTest(const FilePath& test_parent_dir,
const FilePath& test_case_dir,
- bool is_http_test) {
+ int port) {
FilePath src_dir;
PathService::Get(base::DIR_SOURCE_ROOT, &src_dir);
@@ -92,7 +92,7 @@ void UILayoutTest::InitializeForLayoutTest(const FilePath& test_parent_dir,
// dealing with location property, like worker-location.html, could fail.
new_layout_test_dir_ = temp_test_dir_;
new_layout_test_dir_ = new_layout_test_dir_.Append(test_parent_dir);
- if (is_http_test) {
+ if (port == kHttpPort) {
new_http_root_dir_ = new_layout_test_dir_;
test_case_dir_ = test_case_dir;
}
@@ -111,7 +111,7 @@ void UILayoutTest::InitializeForLayoutTest(const FilePath& test_parent_dir,
// Copies the parent resource subdirectory. This is needed in order to run
// http layout tests.
- if (is_http_test) {
+ if (port == kHttpPort) {
FilePath parent_resource_path(layout_test_dir_.DirName());
parent_resource_path = parent_resource_path.AppendASCII("resources");
FilePath new_parent_resource_path(new_layout_test_dir_.DirName());
@@ -149,7 +149,7 @@ void UILayoutTest::AddResourceForLayoutTest(const FilePath& parent_dir,
}
void UILayoutTest::RunLayoutTest(const std::string& test_case_file_name,
- bool is_http_test) {
+ int port) {
SCOPED_TRACE(test_case_file_name.c_str());
ASSERT_TRUE(!layout_test_controller_.empty());
@@ -179,9 +179,9 @@ void UILayoutTest::RunLayoutTest(const std::string& test_case_file_name,
static_cast<int>(test_html.size())));
scoped_ptr<GURL> new_test_url;
- if (is_http_test)
+ if (port != kNoHttpPort)
new_test_url.reset(new GURL(
- std::string("http://localhost:8080/") +
+ StringPrintf("http://localhost:%d/", port) +
WideToUTF8(test_case_dir_.ToWStringHack()) +
"/" +
test_case_file_name));
diff --git a/chrome/test/ui/ui_layout_test.h b/chrome/test/ui/ui_layout_test.h
index 3770478..522d287 100644
--- a/chrome/test/ui/ui_layout_test.h
+++ b/chrome/test/ui/ui_layout_test.h
@@ -15,11 +15,11 @@ class UILayoutTest : public UITest {
void InitializeForLayoutTest(const FilePath& test_parent_dir,
const FilePath& test_case_dir,
- bool is_http_test);
+ int port);
void AddResourceForLayoutTest(const FilePath& parent_dir,
const FilePath& resource_dir);
void RunLayoutTest(const std::string& test_case_file_name,
- bool is_http_test);
+ int port);
bool ReadExpectedResult(const FilePath& result_dir_path,
const std::string test_case_file_name,
@@ -38,6 +38,9 @@ class UILayoutTest : public UITest {
static const int kTestIntervalMs = 250;
static const int kTestWaitTimeoutMs = 60 * 1000;
+ static const int kNoHttpPort = -1;
+ static const int kHttpPort = 8080;
+ static const int kWebSocketPort = 8880;
};
#endif // CHROME_TEST_UI_UI_LAYOUT_TEST_H_
diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc
index 1cf62c7..4c2f887 100644
--- a/chrome/test/ui/ui_test.cc
+++ b/chrome/test/ui/ui_test.cc
@@ -280,6 +280,23 @@ static CommandLine* CreateHttpServerCommandLine() {
return cmd_line;
}
+static CommandLine* 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("layout_package");
+ script_path = script_path.AppendASCII("websocket_server.py");
+
+ CommandLine* cmd_line = CreatePythonCommandLine();
+ cmd_line->AppendLooseValue(script_path.ToWStringHack());
+ return cmd_line;
+}
+
static void RunCommand(const CommandLine& cmd_line) {
#if defined(OS_WIN)
// For Win32, use this 'version' of base::LaunchApp() with bInheritHandles
@@ -339,6 +356,28 @@ void UITest::StopHttpServer() {
RunCommand(*cmd_line.get());
}
+void UITest::StartWebSocketServer(const FilePath& root_directory) {
+ scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine());
+ ASSERT_TRUE(cmd_line.get());
+ cmd_line->AppendSwitchWithValue("server", "start");
+ cmd_line->AppendSwitch("register_cygwin");
+ cmd_line->AppendSwitchWithValue("root", root_directory.ToWStringHack());
+
+ websocket_pid_file_ = user_data_dir_.AppendASCII("websocket.pid");
+ cmd_line->AppendSwitchWithValue("pidfile",
+ websocket_pid_file_.ToWStringHack());
+ RunCommand(*cmd_line.get());
+}
+
+void UITest::StopWebSocketServer() {
+ scoped_ptr<CommandLine> cmd_line(CreateWebSocketServerCommandLine());
+ ASSERT_TRUE(cmd_line.get());
+ cmd_line->AppendSwitchWithValue("server", "stop");
+ cmd_line->AppendSwitchWithValue("pidfile",
+ websocket_pid_file_.ToWStringHack());
+ RunCommand(*cmd_line.get());
+}
+
void UITest::LaunchBrowser(const CommandLine& arguments, bool clear_profile) {
#if defined(OS_POSIX)
const char* alternative_userdir = getenv("CHROME_UI_TESTS_USER_DATA_DIR");
diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h
index d47a5d0..64677bc 100644
--- a/chrome/test/ui/ui_test.h
+++ b/chrome/test/ui/ui_test.h
@@ -452,6 +452,11 @@ class UITest : public PlatformTest {
const std::wstring& port);
void StopHttpServer();
+ // Synchronously launches local websocket server used to run LayoutTests.
+ void StartWebSocketServer(const FilePath& root_directory);
+
+ void StopWebSocketServer();
+
// Prints IO performance data for use by perf graphs.
void PrintIOPerfInfo(const char* test_name, FilePath data_dir);
@@ -538,6 +543,7 @@ class UITest : public PlatformTest {
bool enable_file_cookies_; // Enable file cookies, default is true.
ProfileType profile_type_; // Are we using a profile with a
// complex theme?
+ FilePath websocket_pid_file_; // PID file for websocket server.
private:
bool LaunchBrowserHelper(const CommandLine& arguments,