| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/sys_info.h" | 11 #include "base/sys_info.h" |
| 12 #include "base/test/test_timeouts.h" | 12 #include "base/test/test_timeouts.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_tabstrip.h" | 15 #include "chrome/browser/ui/browser_tabstrip.h" |
| 16 #include "chrome/test/base/ui_test_utils.h" | 16 #include "chrome/test/base/ui_test_utils.h" |
| 17 #include "content/browser/worker_host/worker_process_host.h" | 17 #include "content/browser/worker_host/worker_process_host.h" |
| 18 #include "content/browser/worker_host/worker_service_impl.h" | 18 #include "content/browser/worker_host/worker_service_impl.h" |
| 19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/common/content_paths.h" | 20 #include "content/public/common/content_paths.h" |
| 21 #include "content/public/test/browser_test_utils.h" |
| 21 #include "content/test/layout_browsertest.h" | 22 #include "content/test/layout_browsertest.h" |
| 22 #include "googleurl/src/gurl.h" | 23 #include "googleurl/src/gurl.h" |
| 23 | 24 |
| 24 using content::BrowserThread; | 25 using content::BrowserThread; |
| 25 using content::WorkerServiceImpl; | 26 using content::WorkerServiceImpl; |
| 26 | 27 |
| 27 class WorkerLayoutTest : public InProcessBrowserLayoutTest { | 28 class WorkerLayoutTest : public InProcessBrowserLayoutTest { |
| 28 public: | 29 public: |
| 29 WorkerLayoutTest() : InProcessBrowserLayoutTest( | 30 WorkerLayoutTest() : InProcessBrowserLayoutTest( |
| 30 FilePath(), FilePath().AppendASCII("fast").AppendASCII("workers")) { | 31 FilePath(), FilePath().AppendASCII("fast").AppendASCII("workers")) { |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 FilePath(FILE_PATH_LITERAL("workers")), | 281 FilePath(FILE_PATH_LITERAL("workers")), |
| 281 FilePath().AppendASCII(test_case)); | 282 FilePath().AppendASCII(test_case)); |
| 282 return ui_test_utils::GetFileUrlWithQuery(test_file_path, query); | 283 return ui_test_utils::GetFileUrlWithQuery(test_file_path, query); |
| 283 } | 284 } |
| 284 | 285 |
| 285 void RunTest(Browser* browser, | 286 void RunTest(Browser* browser, |
| 286 const std::string& test_case, | 287 const std::string& test_case, |
| 287 const std::string& query) { | 288 const std::string& query) { |
| 288 GURL url = GetTestURL(test_case, query); | 289 GURL url = GetTestURL(test_case, query); |
| 289 const string16 expected_title = ASCIIToUTF16("OK"); | 290 const string16 expected_title = ASCIIToUTF16("OK"); |
| 290 ui_test_utils::TitleWatcher title_watcher( | 291 content::TitleWatcher title_watcher( |
| 291 chrome::GetActiveWebContents(browser), expected_title); | 292 chrome::GetActiveWebContents(browser), expected_title); |
| 292 ui_test_utils::NavigateToURL(browser, url); | 293 ui_test_utils::NavigateToURL(browser, url); |
| 293 string16 final_title = title_watcher.WaitAndGetTitle(); | 294 string16 final_title = title_watcher.WaitAndGetTitle(); |
| 294 EXPECT_EQ(expected_title, final_title); | 295 EXPECT_EQ(expected_title, final_title); |
| 295 } | 296 } |
| 296 | 297 |
| 297 void RunTest(const std::string& test_case, const std::string& query) { | 298 void RunTest(const std::string& test_case, const std::string& query) { |
| 298 RunTest(browser(), test_case, query); | 299 RunTest(browser(), test_case, query); |
| 299 } | 300 } |
| 300 | 301 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 // the same worker that was queued in the first window, to ensure it gets | 489 // the same worker that was queued in the first window, to ensure it gets |
| 489 // connected to the first window too. | 490 // connected to the first window too. |
| 490 query = StringPrintf("?id=%d", max_workers_per_tab); | 491 query = StringPrintf("?id=%d", max_workers_per_tab); |
| 491 url = GetTestURL("single_shared_worker.html", query); | 492 url = GetTestURL("single_shared_worker.html", query); |
| 492 ui_test_utils::NavigateToURLWithDisposition( | 493 ui_test_utils::NavigateToURLWithDisposition( |
| 493 browser(), url, NEW_FOREGROUND_TAB, | 494 browser(), url, NEW_FOREGROUND_TAB, |
| 494 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); | 495 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); |
| 495 | 496 |
| 496 ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab + 1)); | 497 ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab + 1)); |
| 497 } | 498 } |
| OLD | NEW |