Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5330)

Unified Diff: chrome/worker/worker_uitest.cc

Issue 147125: Support running http layout tests for workers in UI test framework. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « DEPS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/worker/worker_uitest.cc
===================================================================
--- chrome/worker/worker_uitest.cc (revision 19210)
+++ chrome/worker/worker_uitest.cc (working copy)
@@ -37,11 +37,12 @@
void RunTest(const std::wstring& test_case);
- void InitializeForLayoutTest(const FilePath& test_case_dir);
- void RunLayoutTest(const std::string& test_case_file_name);
- void RunHttpTest(const std::string& test_case_name);
+ void InitializeForLayoutTest(const FilePath& test_parent_dir,
+ const FilePath& test_case_dir,
+ bool for_http);
Dmitry Titov 2009/06/25 18:09:13 bool vars are usually named using "is_foo" pattern
+ void RunLayoutTest(const std::string& test_case_file_name, bool for_http);
- private:
+ protected:
bool ReadExpectedResult(const FilePath& result_dir_path,
const std::string test_case_file_name,
std::string* expected_result_value);
@@ -50,6 +51,8 @@
int test_count_;
FilePath temp_test_dir_;
FilePath layout_test_dir_;
+ FilePath test_case_dir_;
+ FilePath new_http_root_dir_;
FilePath new_layout_test_dir_;
FilePath rebase_result_dir_;
std::string layout_test_controller_;
@@ -76,20 +79,9 @@
ASSERT_STREQ(kTestCompleteSuccess, value.c_str());
}
-void WorkerTest::RunHttpTest(const std::string& test_case_name) {
- scoped_refptr<TabProxy> tab(GetActiveTab());
-
- std::string test_url_string(std::string("http://localhost:8080/") +
- test_case_name);
- GURL url(test_url_string);
- ASSERT_TRUE(tab->NavigateToURL(url));
-
- std::string value = WaitUntilCookieNonEmpty(tab.get(), url,
- kTestCompleteCookie, kTestIntervalMs, kTestWaitTimeoutMs);
- ASSERT_STREQ(kTestCompleteSuccess, value.c_str());
-}
-
-void WorkerTest::InitializeForLayoutTest(const FilePath& test_case_dir) {
+void WorkerTest::InitializeForLayoutTest(const FilePath& test_parent_dir,
+ const FilePath& test_case_dir,
+ bool for_http) {
FilePath src_dir;
PathService::Get(base::DIR_SOURCE_ROOT, &src_dir);
@@ -101,8 +93,21 @@
layout_test_dir_ = layout_test_dir_.AppendASCII("test");
layout_test_dir_ = layout_test_dir_.AppendASCII("data");
layout_test_dir_ = layout_test_dir_.AppendASCII("workers");
+ layout_test_dir_ = layout_test_dir_.Append(test_parent_dir);
layout_test_dir_ = layout_test_dir_.Append(test_case_dir);
+ // If not found, try to use the original copy of WebKit layout tests for
+ // workers. For testing only in local machine only.
+ // webkit/data/layout_tests/LayoutTests/.../workers
+ if (!file_util::DirectoryExists(layout_test_dir_)) {
+ layout_test_dir_ = src_dir.AppendASCII("webkit");
+ layout_test_dir_ = layout_test_dir_.AppendASCII("data");
+ layout_test_dir_ = layout_test_dir_.AppendASCII("layout_tests");
+ layout_test_dir_ = layout_test_dir_.Append(test_parent_dir);
+ layout_test_dir_ = layout_test_dir_.Append(test_case_dir);
+ ASSERT_TRUE(file_util::DirectoryExists(layout_test_dir_));
+ }
+
// Gets the file path to rebased expected result directory for workers.
// webkit/data/layout_tests/platform/chromium_***/LayoutTests/.../workers
rebase_result_dir_ = src_dir.AppendASCII("webkit");
@@ -110,6 +115,7 @@
rebase_result_dir_ = rebase_result_dir_.AppendASCII("layout_tests");
rebase_result_dir_ = rebase_result_dir_.AppendASCII("platform");
rebase_result_dir_ = rebase_result_dir_.AppendASCII(kPlatformName);
+ rebase_result_dir_ = rebase_result_dir_.Append(test_parent_dir);
rebase_result_dir_ = rebase_result_dir_.Append(test_case_dir);
// Creates the temporary directory.
@@ -121,6 +127,11 @@
// like .../LayoutTests/fast/workers/.... Otherwise those layout tests
// 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 (for_http) {
+ new_http_root_dir_ = new_layout_test_dir_;
+ test_case_dir_ = test_case_dir;
+ }
new_layout_test_dir_ = new_layout_test_dir_.Append(test_case_dir);
ASSERT_TRUE(file_util::CreateDirectory(new_layout_test_dir_));
@@ -131,10 +142,21 @@
FilePath new_layout_test_resource_path(new_layout_test_dir_);
new_layout_test_resource_path =
new_layout_test_resource_path.AppendASCII("resources");
- ASSERT_TRUE(file_util::DirectoryExists(layout_test_resource_path));
ASSERT_TRUE(file_util::CopyDirectory(
layout_test_resource_path, new_layout_test_resource_path, true));
+ // Copies the parent resource subdirectory. This is needed in order to run
+ // http layout tests.
+ if (for_http) {
+ 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());
+ new_parent_resource_path =
+ new_parent_resource_path.AppendASCII("resources");
+ ASSERT_TRUE(file_util::CopyDirectory(
+ parent_resource_path, new_parent_resource_path, true));
+ }
+
// Reads the layout test controller simulation script.
FilePath path;
PathService::Get(chrome::DIR_TEST_DATA, &path);
@@ -143,7 +165,8 @@
ASSERT_TRUE(file_util::ReadFileToString(path, &layout_test_controller_));
}
-void WorkerTest::RunLayoutTest(const std::string& test_case_file_name) {
+void WorkerTest::RunLayoutTest(const std::string& test_case_file_name,
+ bool for_http) {
SCOPED_TRACE(test_case_file_name.c_str());
ASSERT_TRUE(!layout_test_controller_.empty());
@@ -171,13 +194,22 @@
ASSERT_TRUE(file_util::WriteFile(new_test_file_path,
&test_html.at(0),
static_cast<int>(test_html.size())));
- GURL new_test_file_url = net::FilePathToFileURL(new_test_file_path);
+ scoped_ptr<GURL> new_test_url;
+ if (for_http)
+ new_test_url.reset(new GURL(
+ std::string("http://localhost:8080/") +
+ UTF16ToUTF8(test_case_dir_.ToWStringHack()) +
+ "/" +
+ test_case_file_name));
+ else
+ new_test_url.reset(new GURL(net::FilePathToFileURL(new_test_file_path)));
+
// Runs the new layout test.
scoped_refptr<TabProxy> tab(GetActiveTab());
- ASSERT_TRUE(tab->NavigateToURL(new_test_file_url));
+ ASSERT_TRUE(tab->NavigateToURL(*new_test_url.get()));
std::string escaped_value =
- WaitUntilCookieNonEmpty(tab.get(), new_test_file_url,
+ WaitUntilCookieNonEmpty(tab.get(), *new_test_url.get(),
status_cookie.c_str(), kTestIntervalMs, kTestWaitTimeoutMs);
// Unescapes and normalizes the actual result.
@@ -246,13 +278,61 @@
FilePath fast_test_dir;
fast_test_dir = fast_test_dir.AppendASCII("LayoutTests");
fast_test_dir = fast_test_dir.AppendASCII("fast");
- fast_test_dir = fast_test_dir.AppendASCII("workers");
- InitializeForLayoutTest(fast_test_dir);
+ FilePath worker_test_dir;
+ worker_test_dir = worker_test_dir.AppendASCII("workers");
+ InitializeForLayoutTest(fast_test_dir, worker_test_dir, false);
+
for (int i = 0; i < arraysize(kLayoutTestFiles); ++i)
- RunLayoutTest(kLayoutTestFiles[i]);
+ RunLayoutTest(kLayoutTestFiles[i], false);
}
+TEST_F(WorkerTest, WorkerHttpLayoutTests) {
+ static const char* kLayoutTestFiles[] = {
+ //"text-encoding.html",
+ "worker-importScripts.html",
+ "worker-redirect.html",
+ };
+
+ FilePath http_test_dir;
+ http_test_dir = http_test_dir.AppendASCII("LayoutTests");
+ http_test_dir = http_test_dir.AppendASCII("http");
+ http_test_dir = http_test_dir.AppendASCII("tests");
+
+ FilePath worker_test_dir;
+ worker_test_dir = worker_test_dir.AppendASCII("workers");
+ InitializeForLayoutTest(http_test_dir, worker_test_dir, true);
+
+ StartHttpServer(new_http_root_dir_);
+ for (int i = 0; i < arraysize(kLayoutTestFiles); ++i)
+ RunLayoutTest(kLayoutTestFiles[i], true);
+ StopHttpServer();
+}
+
+TEST_F(WorkerTest, WorkerXhrHttpLayoutTests) {
+ static const char* kLayoutTestFiles[] = {
+ "abort-exception-assert.html",
+ //"methods-async.html",
+ //"methods.html",
+ "xmlhttprequest-file-not-found.html"
+ };
+
+ FilePath http_test_dir;
+ http_test_dir = http_test_dir.AppendASCII("LayoutTests");
+ http_test_dir = http_test_dir.AppendASCII("http");
+ http_test_dir = http_test_dir.AppendASCII("tests");
+
+ 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);
+
+ StartHttpServer(new_http_root_dir_);
+ for (int i = 0; i < arraysize(kLayoutTestFiles); ++i)
+ RunLayoutTest(kLayoutTestFiles[i], true);
+ StopHttpServer();
+}
+
TEST_F(WorkerTest, LimitPerPage) {
int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate;
GURL url = GetTestUrl(L"workers", L"many_workers.html");
@@ -290,12 +370,3 @@
EXPECT_EQ(total_workers + 1 + (UITest::in_process_renderer() ? 0 : tab_count),
UITest::GetBrowserProcessCount());
}
-
-TEST_F(WorkerTest, TestHttpServer) {
Dmitry Titov 2009/06/25 18:09:13 either leave this test (as a test for StartHttpSer
- FilePath path;
- PathService::Get(chrome::DIR_TEST_DATA, &path);
- path = path.AppendASCII("workers");
- StartHttpServer(path);
- RunHttpTest("test_http_server_up.html");
- StopHttpServer();
-}
« no previous file with comments | « DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698