summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--DEPS3
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_uitest.cc8
-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
-rw-r--r--chrome/worker/worker_uitest.cc43
-rw-r--r--chrome/worker/worker_webkitclient_impl.cc2
8 files changed, 97 insertions, 23 deletions
diff --git a/DEPS b/DEPS
index 3cbd8c9..04e6458 100644
--- a/DEPS
+++ b/DEPS
@@ -95,6 +95,9 @@ deps = {
"src/chrome/test/data/layout_tests/LayoutTests/storage/domstorage":
Var("webkit_trunk") + "/LayoutTests/storage/domstorage@" +
Var("webkit_revision"),
+ "src/chrome/test/data/layout_tests/LayoutTests/websocket/tests/workers":
+ Var("webkit_trunk") + "/LayoutTests/websocket/tests/workers@" +
+ Var("webkit_revision"),
}
diff --git a/chrome/browser/in_process_webkit/dom_storage_uitest.cc b/chrome/browser/in_process_webkit/dom_storage_uitest.cc
index 9406a26..903869d 100644
--- a/chrome/browser/in_process_webkit/dom_storage_uitest.cc
+++ b/chrome/browser/in_process_webkit/dom_storage_uitest.cc
@@ -93,7 +93,7 @@ class DOMStorageTest : public UILayoutTest {
void RunTests(const char** files) {
while (*files) {
ClearDOMStorage();
- RunLayoutTest(*files, false);
+ RunLayoutTest(*files, kNoHttpPort);
++files;
}
}
@@ -103,7 +103,7 @@ class DOMStorageTest : public UILayoutTest {
TEST_F(DOMStorageTest, DOMStorageLayoutTests) {
- InitializeForLayoutTest(test_dir_, FilePath(), false);
+ InitializeForLayoutTest(test_dir_, FilePath(), kNoHttpPort);
AddResources();
RunTests(kTopLevelFiles);
}
@@ -112,7 +112,7 @@ TEST_F(DOMStorageTest, DOMStorageLayoutTests) {
// http://crbug.com/27194
TEST_F(DOMStorageTest, FLAKY_LocalStorageLayoutTests) {
InitializeForLayoutTest(test_dir_, FilePath().AppendASCII("localstorage"),
- false);
+ kNoHttpPort);
AddResources();
RunTests(kNoEventsFiles);
RunTests(kEventsFiles);
@@ -121,7 +121,7 @@ TEST_F(DOMStorageTest, FLAKY_LocalStorageLayoutTests) {
TEST_F(DOMStorageTest, SessionStorageLayoutTests) {
InitializeForLayoutTest(test_dir_, FilePath().AppendASCII("sessionstorage"),
- false);
+ kNoHttpPort);
AddResources();
RunTests(kNoEventsFiles);
//RunTests(kEventsFiles);
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,
diff --git a/chrome/worker/worker_uitest.cc b/chrome/worker/worker_uitest.cc
index a9e8695..72f8af6 100644
--- a/chrome/worker/worker_uitest.cc
+++ b/chrome/worker/worker_uitest.cc
@@ -115,7 +115,7 @@ class WorkerTest : public UILayoutTest {
FilePath worker_test_dir;
worker_test_dir = worker_test_dir.AppendASCII("workers");
- InitializeForLayoutTest(fast_test_dir, worker_test_dir, false);
+ InitializeForLayoutTest(fast_test_dir, worker_test_dir, kNoHttpPort);
// Worker tests also rely on common files in js/resources.
FilePath js_dir = fast_test_dir.AppendASCII("js");
@@ -126,7 +126,7 @@ class WorkerTest : public UILayoutTest {
for (size_t i = 0; i < arraysize(kWorkerFastLayoutTestFiles); ++i) {
if ((i % kWorkerFastLayoutTestShards) == shard) {
printf ("Test: %s\n", kWorkerFastLayoutTestFiles[i]);
- RunLayoutTest(kWorkerFastLayoutTestFiles[i], false);
+ RunLayoutTest(kWorkerFastLayoutTestFiles[i], kNoHttpPort);
}
}
@@ -233,7 +233,7 @@ TEST_F(WorkerTest, SharedWorkerFastLayoutTests) {
FilePath worker_test_dir;
worker_test_dir = worker_test_dir.AppendASCII("workers");
- InitializeForLayoutTest(fast_test_dir, worker_test_dir, false);
+ InitializeForLayoutTest(fast_test_dir, worker_test_dir, kNoHttpPort);
// Worker tests also rely on common files in js/resources.
FilePath js_dir = fast_test_dir.AppendASCII("js");
@@ -242,7 +242,7 @@ TEST_F(WorkerTest, SharedWorkerFastLayoutTests) {
AddResourceForLayoutTest(js_dir, resource_dir);
for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i) {
- RunLayoutTest(kLayoutTestFiles[i], false);
+ RunLayoutTest(kLayoutTestFiles[i], kNoHttpPort);
// Shared workers will error out if we ever have more than one tab open.
int window_count = 0;
ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
@@ -271,14 +271,37 @@ TEST_F(WorkerTest, WorkerHttpLayoutTests) {
FilePath worker_test_dir;
worker_test_dir = worker_test_dir.AppendASCII("workers");
- InitializeForLayoutTest(http_test_dir, worker_test_dir, true);
+ InitializeForLayoutTest(http_test_dir, worker_test_dir, kHttpPort);
StartHttpServer(new_http_root_dir_);
for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i)
- RunLayoutTest(kLayoutTestFiles[i], true);
+ RunLayoutTest(kLayoutTestFiles[i], kHttpPort);
StopHttpServer();
}
+TEST_F(WorkerTest, WorkerWebSocketLayoutTests) {
+ static const char* kLayoutTestFiles[] = {
+ "worker-simple.html",
+ };
+
+ FilePath websocket_test_dir;
+ websocket_test_dir = websocket_test_dir.AppendASCII("LayoutTests");
+ websocket_test_dir = websocket_test_dir.AppendASCII("websocket");
+ websocket_test_dir = websocket_test_dir.AppendASCII("tests");
+
+ FilePath worker_test_dir;
+ worker_test_dir = worker_test_dir.AppendASCII("workers");
+ InitializeForLayoutTest(websocket_test_dir, worker_test_dir, kWebSocketPort);
+ test_case_dir_ = test_case_dir_.AppendASCII("websocket");
+ test_case_dir_ = test_case_dir_.AppendASCII("tests");
+ test_case_dir_ = test_case_dir_.AppendASCII("workers");
+
+ StartWebSocketServer(temp_test_dir_.AppendASCII("LayoutTests"));
+ for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i)
+ RunLayoutTest(kLayoutTestFiles[i], kWebSocketPort);
+ StopWebSocketServer();
+}
+
TEST_F(WorkerTest, WorkerXhrHttpLayoutTests) {
static const char* kLayoutTestFiles[] = {
"abort-exception-assert.html",
@@ -310,11 +333,11 @@ TEST_F(WorkerTest, WorkerXhrHttpLayoutTests) {
FilePath worker_test_dir;
worker_test_dir = worker_test_dir.AppendASCII("xmlhttprequest");
worker_test_dir = worker_test_dir.AppendASCII("workers");
- InitializeForLayoutTest(http_test_dir, worker_test_dir, true);
+ InitializeForLayoutTest(http_test_dir, worker_test_dir, kHttpPort);
StartHttpServer(new_http_root_dir_);
for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i)
- RunLayoutTest(kLayoutTestFiles[i], true);
+ RunLayoutTest(kLayoutTestFiles[i], kHttpPort);
StopHttpServer();
}
@@ -342,7 +365,7 @@ TEST_F(WorkerTest, MessagePorts) {
FilePath worker_test_dir;
worker_test_dir = worker_test_dir.AppendASCII("events");
- InitializeForLayoutTest(fast_test_dir, worker_test_dir, false);
+ InitializeForLayoutTest(fast_test_dir, worker_test_dir, kNoHttpPort);
// MessagePort tests also rely on common files in js/resources.
FilePath js_dir = fast_test_dir.AppendASCII("js");
@@ -351,7 +374,7 @@ TEST_F(WorkerTest, MessagePorts) {
AddResourceForLayoutTest(js_dir, resource_dir);
for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i)
- RunLayoutTest(kLayoutTestFiles[i], false);
+ RunLayoutTest(kLayoutTestFiles[i], kNoHttpPort);
}
#if defined(OS_LINUX)
diff --git a/chrome/worker/worker_webkitclient_impl.cc b/chrome/worker/worker_webkitclient_impl.cc
index bb8bb04..fbc6505 100644
--- a/chrome/worker/worker_webkitclient_impl.cc
+++ b/chrome/worker/worker_webkitclient_impl.cc
@@ -64,7 +64,7 @@ void WorkerWebKitClientImpl::setCookies(const WebURL& url,
WebString WorkerWebKitClientImpl::cookies(
const WebURL& url, const WebURL& first_party_for_cookies) {
- NOTREACHED();
+ // WebSocketHandshake may access cookies in worker process.
return WebString();
}