summaryrefslogtreecommitdiffstats
path: root/chrome/worker
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-31 08:56:47 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-31 08:56:47 +0000
commit5a145436666621448c8eafab5006413986137934 (patch)
tree76f165cabc2d6e4b3fa396598b435fceabae621d /chrome/worker
parentdf0a0bfe0ea219ede803adfd600d95584d6e8c0d (diff)
downloadchromium_src-5a145436666621448c8eafab5006413986137934.zip
chromium_src-5a145436666621448c8eafab5006413986137934.tar.gz
chromium_src-5a145436666621448c8eafab5006413986137934.tar.bz2
Merge UiTest::GetTest* and ui_test_utils::GetTest*. Convert these utility functions to use FilePaths.
BUG=none TEST=none Review URL: http://codereview.chromium.org/1567009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43190 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/worker')
-rw-r--r--chrome/worker/worker_uitest.cc85
1 files changed, 58 insertions, 27 deletions
diff --git a/chrome/worker/worker_uitest.cc b/chrome/worker/worker_uitest.cc
index a356e96..00c7f85 100644
--- a/chrome/worker/worker_uitest.cc
+++ b/chrome/worker/worker_uitest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/file_path.h"
#include "base/string_util.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/worker_host/worker_service.h"
@@ -12,18 +13,36 @@
#include "chrome/test/ui_test_utils.h"
#include "net/url_request/url_request_unittest.h"
-static const char kTestCompleteCookie[] = "status";
-static const char kTestCompleteSuccess[] = "OK";
+namespace {
+
+const char kTestCompleteCookie[] = "status";
+const char kTestCompleteSuccess[] = "OK";
+const FilePath::CharType* kTestDir =
+ FILE_PATH_LITERAL("workers");
+const FilePath::CharType* kManySharedWorkersFile =
+ FILE_PATH_LITERAL("many_shared_workers.html");
+const FilePath::CharType* kManyWorkersFile =
+ FILE_PATH_LITERAL("many_workers.html");
+const FilePath::CharType* kQuerySharedWorkerShutdownFile =
+ FILE_PATH_LITERAL("queued_shared_worker_shutdown.html");
+const FilePath::CharType* kShutdownSharedWorkerFile =
+ FILE_PATH_LITERAL("shutdown_shared_worker.html");
+const FilePath::CharType* kSingleSharedWorkersFile =
+ FILE_PATH_LITERAL("single_shared_worker.html");
+const FilePath::CharType* kWorkerClose =
+ FILE_PATH_LITERAL("worker_close.html");
+
+} // anonymous namespace
class WorkerTest : public UILayoutTest {
protected:
virtual ~WorkerTest() { }
- void RunTest(const std::wstring& test_case) {
+ void RunTest(const FilePath& test_case) {
scoped_refptr<TabProxy> tab(GetActiveTab());
ASSERT_TRUE(tab.get());
- GURL url = GetTestUrl(L"workers", test_case);
+ GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), test_case);
ASSERT_TRUE(tab->NavigateToURL(url));
std::string value = WaitUntilCookieNonEmpty(tab.get(), url,
@@ -31,7 +50,7 @@ class WorkerTest : public UILayoutTest {
ASSERT_STREQ(kTestCompleteSuccess, value.c_str());
}
- void RunIncognitoTest(const std::wstring& test_case) {
+ void RunIncognitoTest(const FilePath& test_case) {
scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
ASSERT_TRUE(browser.get());
@@ -46,7 +65,7 @@ class WorkerTest : public UILayoutTest {
scoped_refptr<TabProxy> tab(incognito->GetTab(0));
ASSERT_TRUE(tab.get());
- GURL url = GetTestUrl(L"workers", test_case);
+ GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), test_case);
ASSERT_TRUE(tab->NavigateToURL(url));
std::string value = WaitUntilCookieNonEmpty(tab.get(), url,
@@ -97,7 +116,7 @@ class WorkerTest : public UILayoutTest {
resource_dir = resource_dir.AppendASCII("resources");
AddResourceForLayoutTest(js_dir, resource_dir);
- printf ("Test: %s\n", test_case_file_name.c_str());
+ printf("Test: %s\n", test_case_file_name.c_str());
RunLayoutTest(test_case_file_name, kNoHttpPort);
// Navigate to a blank page so that any workers are cleaned up.
@@ -118,7 +137,7 @@ class WorkerTest : public UILayoutTest {
TEST_F(WorkerTest, SingleWorker) {
- RunTest(L"single_worker.html");
+ RunTest(FilePath(FILE_PATH_LITERAL("single_worker.html")));
}
#if defined(OS_LINUX)
@@ -128,15 +147,15 @@ TEST_F(WorkerTest, SingleWorker) {
#endif
TEST_F(WorkerTest, MultipleWorkers) {
- RunTest(L"multi_worker.html");
+ RunTest(FilePath(FILE_PATH_LITERAL("multi_worker.html")));
}
TEST_F(WorkerTest, SingleSharedWorker) {
- RunTest(L"single_worker.html?shared=true");
+ RunTest(FilePath(FILE_PATH_LITERAL("single_worker.html?shared=true")));
}
TEST_F(WorkerTest, MultipleSharedWorkers) {
- RunTest(L"multi_worker.html?shared=true");
+ RunTest(FilePath(FILE_PATH_LITERAL("multi_worker.html?shared=true")));
}
#if defined(OS_LINUX)
@@ -146,9 +165,9 @@ TEST_F(WorkerTest, MultipleSharedWorkers) {
// Incognito windows should not share workers with non-incognito windows
TEST_F(WorkerTest, IncognitoSharedWorkers) {
// Load a non-incognito tab and have it create a shared worker
- RunTest(L"incognito_worker.html");
+ RunTest(FilePath(FILE_PATH_LITERAL("incognito_worker.html")));
// Incognito worker should not share with non-incognito
- RunIncognitoTest(L"incognito_worker.html");
+ RunIncognitoTest(FilePath(FILE_PATH_LITERAL("incognito_worker.html")));
}
const wchar_t kDocRoot[] = L"chrome/test/data/workers";
@@ -424,14 +443,14 @@ TEST_F(WorkerTest, DISABLED_WorkerXhrHttpLayoutTests) {
#endif
// These tests (and the shared-worker versions below) are disabled due to
// limitations in lighttpd (doesn't handle all of the HTTP methods).
- //"methods-async.html",
- //"methods.html",
+ // "methods-async.html",
+ // "methods.html",
"shared-worker-close.html",
// Disabled due to limitations in lighttpd (does not handle methods other
// than GET/PUT/POST).
- //"shared-worker-methods-async.html",
- //"shared-worker-methods.html",
+ // "shared-worker-methods-async.html",
+ // "shared-worker-methods.html",
"shared-worker-xhr-file-not-found.html",
"xmlhttprequest-file-not-found.html"
@@ -469,7 +488,7 @@ TEST_F(WorkerTest, FLAKY_MessagePorts) {
"message-port-multi.html",
"message-port-no-wrapper.html",
// Only works with run-webkit-tests --leaks.
- //"message-channel-listener-circular-ownership.html",
+ // "message-channel-listener-circular-ownership.html",
};
FilePath fast_test_dir;
@@ -495,7 +514,8 @@ TEST_F(WorkerTest, FLAKY_MessagePorts) {
// http://crbug.com/36630. Termination issues, disabled on all platforms.
TEST_F(WorkerTest, DISABLED_LimitPerPage) {
int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate;
- GURL url = GetTestUrl(L"workers", L"many_workers.html");
+ GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir),
+ FilePath(kManyWorkersFile));
url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab + 1));
NavigateToURL(url);
@@ -511,7 +531,8 @@ TEST_F(WorkerTest, DISABLED_LimitTotal) {
int total_workers = WorkerService::kMaxWorkersWhenSeparate;
int tab_count = (total_workers / max_workers_per_tab) + 1;
- GURL url = GetTestUrl(L"workers", L"many_workers.html");
+ GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir),
+ FilePath(kManyWorkersFile));
url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab));
scoped_refptr<TabProxy> tab(GetActiveTab());
@@ -526,8 +547,11 @@ TEST_F(WorkerTest, DISABLED_LimitTotal) {
ASSERT_TRUE(WaitForProcessCountToBe(tab_count, total_workers));
// Now close a page and check that the queued workers were started.
+ const FilePath::CharType* kGoogleDir = FILE_PATH_LITERAL("google");
+ const FilePath::CharType* kGoogleFile = FILE_PATH_LITERAL("google.html");
ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS,
- tab->NavigateToURL(GetTestUrl(L"google", L"google.html")));
+ tab->NavigateToURL(ui_test_utils::GetTestUrl(FilePath(kGoogleDir),
+ FilePath(kGoogleFile))));
ASSERT_TRUE(WaitForProcessCountToBe(tab_count, total_workers));
#endif
@@ -537,7 +561,8 @@ TEST_F(WorkerTest, DISABLED_LimitTotal) {
TEST_F(WorkerTest, DISABLED_WorkerClose) {
scoped_refptr<TabProxy> tab(GetActiveTab());
ASSERT_TRUE(tab.get());
- GURL url = GetTestUrl(L"workers", L"worker_close.html");
+ GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir),
+ FilePath(kWorkerClose));
ASSERT_TRUE(tab->NavigateToURL(url));
std::string value = WaitUntilCookieNonEmpty(tab.get(), url,
kTestCompleteCookie, action_max_timeout_ms());
@@ -549,7 +574,8 @@ TEST_F(WorkerTest, QueuedSharedWorkerShutdown) {
// Tests to make sure that queued shared workers are started up when
// shared workers shut down.
int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate;
- GURL url = GetTestUrl(L"workers", L"queued_shared_worker_shutdown.html");
+ GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir),
+ FilePath(kQuerySharedWorkerShutdownFile));
url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab));
scoped_refptr<TabProxy> tab(GetActiveTab());
@@ -565,7 +591,8 @@ TEST_F(WorkerTest, MultipleTabsQueuedSharedWorker) {
// Tests to make sure that only one instance of queued shared workers are
// started up even when those instances are on multiple tabs.
int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate;
- GURL url = GetTestUrl(L"workers", L"many_shared_workers.html");
+ GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir),
+ FilePath(kManySharedWorkersFile));
url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab+1));
scoped_refptr<TabProxy> tab(GetActiveTab());
@@ -582,7 +609,9 @@ TEST_F(WorkerTest, MultipleTabsQueuedSharedWorker) {
// Now shutdown one of the shared workers - this will fire both queued
// workers, but only one instance should be started
- GURL url2 = GetTestUrl(L"workers", L"shutdown_shared_worker.html?id=0");
+ GURL url2 = ui_test_utils::GetTestUrl(FilePath(kTestDir),
+ FilePath(kShutdownSharedWorkerFile));
+ url2 = GURL(url2.spec() + "?id=0");
ASSERT_TRUE(window->AppendTab(url2));
std::string value = WaitUntilCookieNonEmpty(tab.get(), url,
@@ -596,7 +625,8 @@ TEST_F(WorkerTest, DISABLED_QueuedSharedWorkerStartedFromOtherTab) {
// Tests to make sure that queued shared workers are started up when
// an instance is launched from another tab.
int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate;
- GURL url = GetTestUrl(L"workers", L"many_shared_workers.html");
+ GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir),
+ FilePath(kManySharedWorkersFile));
url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab+1));
scoped_refptr<TabProxy> tab(GetActiveTab());
@@ -608,7 +638,8 @@ TEST_F(WorkerTest, DISABLED_QueuedSharedWorkerStartedFromOtherTab) {
// connected to the first window too.
scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
ASSERT_TRUE(window.get());
- GURL url2 = GetTestUrl(L"workers", L"single_shared_worker.html");
+ GURL url2 = ui_test_utils::GetTestUrl(FilePath(kTestDir),
+ FilePath(kSingleSharedWorkersFile));
url2 = GURL(url2.spec() + StringPrintf("?id=%d", max_workers_per_tab));
ASSERT_TRUE(window->AppendTab(url2));