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

Side by Side Diff: content/worker/test/worker_uitest.cc

Issue 9052007: Create an API around WorkerService that chrome consumes. Rename the existing WorkerService to Wor... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/public/browser/worker_service_observer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/file_path.h" 5 #include "base/file_path.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "base/test/test_timeouts.h" 7 #include "base/test/test_timeouts.h"
8 #include "base/threading/platform_thread.h" 8 #include "base/threading/platform_thread.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/test/automation/automation_proxy.h" 10 #include "chrome/test/automation/automation_proxy.h"
11 #include "chrome/test/automation/browser_proxy.h" 11 #include "chrome/test/automation/browser_proxy.h"
12 #include "chrome/test/automation/tab_proxy.h" 12 #include "chrome/test/automation/tab_proxy.h"
13 #include "chrome/test/base/layout_test_http_server.h" 13 #include "chrome/test/base/layout_test_http_server.h"
14 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
15 #include "chrome/test/ui/ui_layout_test.h" 15 #include "chrome/test/ui/ui_layout_test.h"
16 #include "content/browser/worker_host/worker_service.h" 16 #include "content/browser/worker_host/worker_service_impl.h"
17 #include "content/public/common/url_constants.h" 17 #include "content/public/common/url_constants.h"
18 #include "net/test/test_server.h" 18 #include "net/test/test_server.h"
19 19
20 using content::WorkerServiceImpl;
21
20 namespace { 22 namespace {
21 23
22 const char kTestCompleteCookie[] = "status"; 24 const char kTestCompleteCookie[] = "status";
23 const char kTestCompleteSuccess[] = "OK"; 25 const char kTestCompleteSuccess[] = "OK";
24 const FilePath::CharType* kTestDir = 26 const FilePath::CharType* kTestDir =
25 FILE_PATH_LITERAL("workers"); 27 FILE_PATH_LITERAL("workers");
26 const FilePath::CharType* kManySharedWorkersFile = 28 const FilePath::CharType* kManySharedWorkersFile =
27 FILE_PATH_LITERAL("many_shared_workers.html"); 29 FILE_PATH_LITERAL("many_shared_workers.html");
28 const FilePath::CharType* kManyWorkersFile = 30 const FilePath::CharType* kManyWorkersFile =
29 FILE_PATH_LITERAL("many_workers.html"); 31 FILE_PATH_LITERAL("many_workers.html");
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 } 581 }
580 582
581 #if defined(OS_MACOSX) 583 #if defined(OS_MACOSX)
582 // See http://crbug.com/48664 584 // See http://crbug.com/48664
583 #define MAYBE_LimitPerPage DISABLED_LimitPerPage 585 #define MAYBE_LimitPerPage DISABLED_LimitPerPage
584 #else 586 #else
585 // See http://crbug.com/36800 for Windows/Linux 587 // See http://crbug.com/36800 for Windows/Linux
586 #define MAYBE_LimitPerPage FLAKY_LimitPerPage 588 #define MAYBE_LimitPerPage FLAKY_LimitPerPage
587 #endif 589 #endif
588 TEST_F(WorkerTest, MAYBE_LimitPerPage) { 590 TEST_F(WorkerTest, MAYBE_LimitPerPage) {
589 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; 591 int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerTabWhenSeparate;
590 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), 592 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir),
591 FilePath(kManyWorkersFile)); 593 FilePath(kManyWorkersFile));
592 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab + 1)); 594 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab + 1));
593 595
594 NavigateToURL(url); 596 NavigateToURL(url);
595 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab)); 597 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab));
596 } 598 }
597 599
598 // Doesn't crash, but on all platforms, it sometimes fails. 600 // Doesn't crash, but on all platforms, it sometimes fails.
599 // Flaky on all platforms: http://crbug.com/28445 601 // Flaky on all platforms: http://crbug.com/28445
600 // Hangs on Linux: http://crbug.com/30332 602 // Hangs on Linux: http://crbug.com/30332
601 // Possibly causing ui_tests to hang on Mac: http://crbug.com/88958 603 // Possibly causing ui_tests to hang on Mac: http://crbug.com/88958
602 // Times out consistently on all platforms. 604 // Times out consistently on all platforms.
603 TEST_F(WorkerTest, DISABLED_LimitTotal) { 605 TEST_F(WorkerTest, DISABLED_LimitTotal) {
604 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; 606 int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerTabWhenSeparate;
605 int total_workers = WorkerService::kMaxWorkersWhenSeparate; 607 int total_workers = WorkerServiceImpl::kMaxWorkersWhenSeparate;
606 608
607 int tab_count = (total_workers / max_workers_per_tab) + 1; 609 int tab_count = (total_workers / max_workers_per_tab) + 1;
608 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), 610 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir),
609 FilePath(kManyWorkersFile)); 611 FilePath(kManyWorkersFile));
610 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab)); 612 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab));
611 613
612 scoped_refptr<TabProxy> tab(GetActiveTab()); 614 scoped_refptr<TabProxy> tab(GetActiveTab());
613 ASSERT_TRUE(tab.get()); 615 ASSERT_TRUE(tab.get());
614 ASSERT_TRUE(tab->NavigateToURL(url)); 616 ASSERT_TRUE(tab->NavigateToURL(url));
615 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); 617 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
(...skipping 24 matching lines...) Expand all
640 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, 642 std::string value = WaitUntilCookieNonEmpty(tab.get(), url,
641 kTestCompleteCookie, TestTimeouts::action_max_timeout_ms()); 643 kTestCompleteCookie, TestTimeouts::action_max_timeout_ms());
642 ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); 644 ASSERT_STREQ(kTestCompleteSuccess, value.c_str());
643 ASSERT_TRUE(WaitForProcessCountToBe(1, 0)); 645 ASSERT_TRUE(WaitForProcessCountToBe(1, 0));
644 } 646 }
645 647
646 // Flaky, http://crbug.com/70861. 648 // Flaky, http://crbug.com/70861.
647 TEST_F(WorkerTest, FLAKY_QueuedSharedWorkerShutdown) { 649 TEST_F(WorkerTest, FLAKY_QueuedSharedWorkerShutdown) {
648 // Tests to make sure that queued shared workers are started up when 650 // Tests to make sure that queued shared workers are started up when
649 // shared workers shut down. 651 // shared workers shut down.
650 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; 652 int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerTabWhenSeparate;
651 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), 653 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir),
652 FilePath(kQuerySharedWorkerShutdownFile)); 654 FilePath(kQuerySharedWorkerShutdownFile));
653 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab)); 655 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab));
654 656
655 scoped_refptr<TabProxy> tab(GetActiveTab()); 657 scoped_refptr<TabProxy> tab(GetActiveTab());
656 ASSERT_TRUE(tab.get()); 658 ASSERT_TRUE(tab.get());
657 ASSERT_TRUE(tab->NavigateToURL(url)); 659 ASSERT_TRUE(tab->NavigateToURL(url));
658 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, 660 std::string value = WaitUntilCookieNonEmpty(tab.get(), url,
659 kTestCompleteCookie, TestTimeouts::action_max_timeout_ms()); 661 kTestCompleteCookie, TestTimeouts::action_max_timeout_ms());
660 ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); 662 ASSERT_STREQ(kTestCompleteSuccess, value.c_str());
661 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab)); 663 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab));
662 } 664 }
663 665
664 // Flaky, http://crbug.com/69881. 666 // Flaky, http://crbug.com/69881.
665 TEST_F(WorkerTest, FLAKY_MultipleTabsQueuedSharedWorker) { 667 TEST_F(WorkerTest, FLAKY_MultipleTabsQueuedSharedWorker) {
666 // Tests to make sure that only one instance of queued shared workers are 668 // Tests to make sure that only one instance of queued shared workers are
667 // started up even when those instances are on multiple tabs. 669 // started up even when those instances are on multiple tabs.
668 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; 670 int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerTabWhenSeparate;
669 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), 671 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir),
670 FilePath(kManySharedWorkersFile)); 672 FilePath(kManySharedWorkersFile));
671 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab+1)); 673 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab+1));
672 674
673 scoped_refptr<TabProxy> tab(GetActiveTab()); 675 scoped_refptr<TabProxy> tab(GetActiveTab());
674 ASSERT_TRUE(tab.get()); 676 ASSERT_TRUE(tab.get());
675 ASSERT_TRUE(tab->NavigateToURL(url)); 677 ASSERT_TRUE(tab->NavigateToURL(url));
676 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab)); 678 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab));
677 679
678 // Create same set of workers in new tab (leaves one worker queued from this 680 // Create same set of workers in new tab (leaves one worker queued from this
(...skipping 13 matching lines...) Expand all
692 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, 694 std::string value = WaitUntilCookieNonEmpty(tab.get(), url,
693 kTestCompleteCookie, TestTimeouts::action_max_timeout_ms()); 695 kTestCompleteCookie, TestTimeouts::action_max_timeout_ms());
694 ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); 696 ASSERT_STREQ(kTestCompleteSuccess, value.c_str());
695 ASSERT_TRUE(WaitForProcessCountToBe(3, max_workers_per_tab)); 697 ASSERT_TRUE(WaitForProcessCountToBe(3, max_workers_per_tab));
696 } 698 }
697 699
698 // Flaky: http://crbug.com/48148 700 // Flaky: http://crbug.com/48148
699 TEST_F(WorkerTest, FLAKY_QueuedSharedWorkerStartedFromOtherTab) { 701 TEST_F(WorkerTest, FLAKY_QueuedSharedWorkerStartedFromOtherTab) {
700 // Tests to make sure that queued shared workers are started up when 702 // Tests to make sure that queued shared workers are started up when
701 // an instance is launched from another tab. 703 // an instance is launched from another tab.
702 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; 704 int max_workers_per_tab = WorkerServiceImpl::kMaxWorkersPerTabWhenSeparate;
703 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), 705 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir),
704 FilePath(kManySharedWorkersFile)); 706 FilePath(kManySharedWorkersFile));
705 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab+1)); 707 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab+1));
706 708
707 scoped_refptr<TabProxy> tab(GetActiveTab()); 709 scoped_refptr<TabProxy> tab(GetActiveTab());
708 ASSERT_TRUE(tab.get()); 710 ASSERT_TRUE(tab.get());
709 ASSERT_TRUE(tab->NavigateToURL(url)); 711 ASSERT_TRUE(tab->NavigateToURL(url));
710 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab)); 712 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab));
711 // First window has hit its limit. Now launch second window which creates 713 // First window has hit its limit. Now launch second window which creates
712 // the same worker that was queued in the first window, to ensure it gets 714 // the same worker that was queued in the first window, to ensure it gets
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 } 885 }
884 886
885 #if defined(OS_LINUX) 887 #if defined(OS_LINUX)
886 // Fails on Linux due to an assert in WebKit's RNG. 888 // Fails on Linux due to an assert in WebKit's RNG.
887 // See http://webkit.org/b/55728. 889 // See http://webkit.org/b/55728.
888 #define FileWriterSyncWriteOverlapped DISABLED_FileWriterSyncWriteOverlapped 890 #define FileWriterSyncWriteOverlapped DISABLED_FileWriterSyncWriteOverlapped
889 #endif 891 #endif
890 TEST_F(WorkerFileSystemTest, FileWriterSyncWriteOverlapped) { 892 TEST_F(WorkerFileSystemTest, FileWriterSyncWriteOverlapped) {
891 RunWorkerFileSystemLayoutTest("file-writer-sync-write-overlapped.html"); 893 RunWorkerFileSystemLayoutTest("file-writer-sync-write-overlapped.html");
892 } 894 }
OLDNEW
« no previous file with comments | « content/public/browser/worker_service_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698