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

Side by Side Diff: chrome/worker/worker_uitest.cc

Issue 6354005: Remove action_max_timeout_ms and fix all the callers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 9 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 | « chrome/test/ui/ui_test.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/browser/worker_host/worker_service.h" 10 #include "chrome/browser/worker_host/worker_service.h"
(...skipping 30 matching lines...) Expand all
41 virtual ~WorkerTest() { } 41 virtual ~WorkerTest() { }
42 42
43 void RunTest(const FilePath& test_case) { 43 void RunTest(const FilePath& test_case) {
44 scoped_refptr<TabProxy> tab(GetActiveTab()); 44 scoped_refptr<TabProxy> tab(GetActiveTab());
45 ASSERT_TRUE(tab.get()); 45 ASSERT_TRUE(tab.get());
46 46
47 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), test_case); 47 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), test_case);
48 ASSERT_TRUE(tab->NavigateToURL(url)); 48 ASSERT_TRUE(tab->NavigateToURL(url));
49 49
50 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, 50 std::string value = WaitUntilCookieNonEmpty(tab.get(), url,
51 kTestCompleteCookie, action_max_timeout_ms()); 51 kTestCompleteCookie, TestTimeouts::action_max_timeout_ms());
52 ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); 52 ASSERT_STREQ(kTestCompleteSuccess, value.c_str());
53 } 53 }
54 54
55 void RunIncognitoTest(const FilePath& test_case) { 55 void RunIncognitoTest(const FilePath& test_case) {
56 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); 56 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
57 ASSERT_TRUE(browser.get()); 57 ASSERT_TRUE(browser.get());
58 58
59 // Open an Incognito window. 59 // Open an Incognito window.
60 ASSERT_TRUE(browser->RunCommand(IDC_NEW_INCOGNITO_WINDOW)); 60 ASSERT_TRUE(browser->RunCommand(IDC_NEW_INCOGNITO_WINDOW));
61 scoped_refptr<BrowserProxy> incognito(automation()->GetBrowserWindow(1)); 61 scoped_refptr<BrowserProxy> incognito(automation()->GetBrowserWindow(1));
62 ASSERT_TRUE(incognito.get()); 62 ASSERT_TRUE(incognito.get());
63 int window_count; 63 int window_count;
64 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); 64 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
65 ASSERT_EQ(2, window_count); 65 ASSERT_EQ(2, window_count);
66 66
67 scoped_refptr<TabProxy> tab(incognito->GetTab(0)); 67 scoped_refptr<TabProxy> tab(incognito->GetTab(0));
68 ASSERT_TRUE(tab.get()); 68 ASSERT_TRUE(tab.get());
69 69
70 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), test_case); 70 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), test_case);
71 ASSERT_TRUE(tab->NavigateToURL(url)); 71 ASSERT_TRUE(tab->NavigateToURL(url));
72 72
73 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, 73 std::string value = WaitUntilCookieNonEmpty(tab.get(), url,
74 kTestCompleteCookie, action_max_timeout_ms()); 74 kTestCompleteCookie, TestTimeouts::action_max_timeout_ms());
75 75
76 // Close the incognito window 76 // Close the incognito window
77 ASSERT_TRUE(incognito->RunCommand(IDC_CLOSE_WINDOW)); 77 ASSERT_TRUE(incognito->RunCommand(IDC_CLOSE_WINDOW));
78 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); 78 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count));
79 ASSERT_EQ(1, window_count); 79 ASSERT_EQ(1, window_count);
80 80
81 ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); 81 ASSERT_STREQ(kTestCompleteSuccess, value.c_str());
82 } 82 }
83 83
84 bool WaitForProcessCountToBe(int tabs, int workers) { 84 bool WaitForProcessCountToBe(int tabs, int workers) {
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 } 600 }
601 601
602 // Flaky, http://crbug.com/59786. 602 // Flaky, http://crbug.com/59786.
603 TEST_F(WorkerTest, FLAKY_WorkerClose) { 603 TEST_F(WorkerTest, FLAKY_WorkerClose) {
604 scoped_refptr<TabProxy> tab(GetActiveTab()); 604 scoped_refptr<TabProxy> tab(GetActiveTab());
605 ASSERT_TRUE(tab.get()); 605 ASSERT_TRUE(tab.get());
606 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), 606 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir),
607 FilePath(kWorkerClose)); 607 FilePath(kWorkerClose));
608 ASSERT_TRUE(tab->NavigateToURL(url)); 608 ASSERT_TRUE(tab->NavigateToURL(url));
609 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, 609 std::string value = WaitUntilCookieNonEmpty(tab.get(), url,
610 kTestCompleteCookie, action_max_timeout_ms()); 610 kTestCompleteCookie, TestTimeouts::action_max_timeout_ms());
611 ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); 611 ASSERT_STREQ(kTestCompleteSuccess, value.c_str());
612 ASSERT_TRUE(WaitForProcessCountToBe(1, 0)); 612 ASSERT_TRUE(WaitForProcessCountToBe(1, 0));
613 } 613 }
614 614
615 TEST_F(WorkerTest, QueuedSharedWorkerShutdown) { 615 TEST_F(WorkerTest, QueuedSharedWorkerShutdown) {
616 // Tests to make sure that queued shared workers are started up when 616 // Tests to make sure that queued shared workers are started up when
617 // shared workers shut down. 617 // shared workers shut down.
618 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; 618 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate;
619 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), 619 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir),
620 FilePath(kQuerySharedWorkerShutdownFile)); 620 FilePath(kQuerySharedWorkerShutdownFile));
621 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab)); 621 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab));
622 622
623 scoped_refptr<TabProxy> tab(GetActiveTab()); 623 scoped_refptr<TabProxy> tab(GetActiveTab());
624 ASSERT_TRUE(tab.get()); 624 ASSERT_TRUE(tab.get());
625 ASSERT_TRUE(tab->NavigateToURL(url)); 625 ASSERT_TRUE(tab->NavigateToURL(url));
626 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, 626 std::string value = WaitUntilCookieNonEmpty(tab.get(), url,
627 kTestCompleteCookie, action_max_timeout_ms()); 627 kTestCompleteCookie, TestTimeouts::action_max_timeout_ms());
628 ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); 628 ASSERT_STREQ(kTestCompleteSuccess, value.c_str());
629 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab)); 629 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab));
630 } 630 }
631 631
632 // Flaky, http://crbug.com/69881. 632 // Flaky, http://crbug.com/69881.
633 TEST_F(WorkerTest, FLAKY_MultipleTabsQueuedSharedWorker) { 633 TEST_F(WorkerTest, FLAKY_MultipleTabsQueuedSharedWorker) {
634 // Tests to make sure that only one instance of queued shared workers are 634 // Tests to make sure that only one instance of queued shared workers are
635 // started up even when those instances are on multiple tabs. 635 // started up even when those instances are on multiple tabs.
636 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; 636 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate;
637 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), 637 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir),
(...skipping 13 matching lines...) Expand all
651 ASSERT_TRUE(WaitForProcessCountToBe(2, max_workers_per_tab)); 651 ASSERT_TRUE(WaitForProcessCountToBe(2, max_workers_per_tab));
652 652
653 // Now shutdown one of the shared workers - this will fire both queued 653 // Now shutdown one of the shared workers - this will fire both queued
654 // workers, but only one instance should be started 654 // workers, but only one instance should be started
655 GURL url2 = ui_test_utils::GetTestUrl(FilePath(kTestDir), 655 GURL url2 = ui_test_utils::GetTestUrl(FilePath(kTestDir),
656 FilePath(kShutdownSharedWorkerFile)); 656 FilePath(kShutdownSharedWorkerFile));
657 url2 = GURL(url2.spec() + "?id=0"); 657 url2 = GURL(url2.spec() + "?id=0");
658 ASSERT_TRUE(window->AppendTab(url2)); 658 ASSERT_TRUE(window->AppendTab(url2));
659 659
660 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, 660 std::string value = WaitUntilCookieNonEmpty(tab.get(), url,
661 kTestCompleteCookie, action_max_timeout_ms()); 661 kTestCompleteCookie, TestTimeouts::action_max_timeout_ms());
662 ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); 662 ASSERT_STREQ(kTestCompleteSuccess, value.c_str());
663 ASSERT_TRUE(WaitForProcessCountToBe(3, max_workers_per_tab)); 663 ASSERT_TRUE(WaitForProcessCountToBe(3, max_workers_per_tab));
664 } 664 }
665 665
666 // Flaky: http://crbug.com/48148 666 // Flaky: http://crbug.com/48148
667 TEST_F(WorkerTest, FLAKY_QueuedSharedWorkerStartedFromOtherTab) { 667 TEST_F(WorkerTest, FLAKY_QueuedSharedWorkerStartedFromOtherTab) {
668 // Tests to make sure that queued shared workers are started up when 668 // Tests to make sure that queued shared workers are started up when
669 // an instance is launched from another tab. 669 // an instance is launched from another tab.
670 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; 670 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate;
671 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), 671 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir),
672 FilePath(kManySharedWorkersFile)); 672 FilePath(kManySharedWorkersFile));
673 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));
674 674
675 scoped_refptr<TabProxy> tab(GetActiveTab()); 675 scoped_refptr<TabProxy> tab(GetActiveTab());
676 ASSERT_TRUE(tab.get()); 676 ASSERT_TRUE(tab.get());
677 ASSERT_TRUE(tab->NavigateToURL(url)); 677 ASSERT_TRUE(tab->NavigateToURL(url));
678 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab)); 678 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab));
679 // First window has hit its limit. Now launch second window which creates 679 // First window has hit its limit. Now launch second window which creates
680 // the same worker that was queued in the first window, to ensure it gets 680 // the same worker that was queued in the first window, to ensure it gets
681 // connected to the first window too. 681 // connected to the first window too.
682 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); 682 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
683 ASSERT_TRUE(window.get()); 683 ASSERT_TRUE(window.get());
684 GURL url2 = ui_test_utils::GetTestUrl(FilePath(kTestDir), 684 GURL url2 = ui_test_utils::GetTestUrl(FilePath(kTestDir),
685 FilePath(kSingleSharedWorkersFile)); 685 FilePath(kSingleSharedWorkersFile));
686 url2 = GURL(url2.spec() + StringPrintf("?id=%d", max_workers_per_tab)); 686 url2 = GURL(url2.spec() + StringPrintf("?id=%d", max_workers_per_tab));
687 ASSERT_TRUE(window->AppendTab(url2)); 687 ASSERT_TRUE(window->AppendTab(url2));
688 688
689 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, 689 std::string value = WaitUntilCookieNonEmpty(tab.get(), url,
690 kTestCompleteCookie, action_max_timeout_ms()); 690 kTestCompleteCookie, TestTimeouts::action_max_timeout_ms());
691 ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); 691 ASSERT_STREQ(kTestCompleteSuccess, value.c_str());
692 ASSERT_TRUE(WaitForProcessCountToBe(2, max_workers_per_tab+1)); 692 ASSERT_TRUE(WaitForProcessCountToBe(2, max_workers_per_tab+1));
693 } 693 }
694 694
695 // FileSystem worker tests. 695 // FileSystem worker tests.
696 // They are disabled for now as the feature is not enabled by default. 696 // They are disabled for now as the feature is not enabled by default.
697 // http://crbug.com/32277 697 // http://crbug.com/32277
698 TEST_F(WorkerTest, DISABLED_WorkerFileSystemTemporaryTest) { 698 TEST_F(WorkerTest, DISABLED_WorkerFileSystemTemporaryTest) {
699 RunWorkerFileSystemLayoutTest("simple-temporary.html"); 699 RunWorkerFileSystemLayoutTest("simple-temporary.html");
700 } 700 }
(...skipping 10 matching lines...) Expand all
711 RunWorkerFileSystemLayoutTest("simple-persistent-sync.html"); 711 RunWorkerFileSystemLayoutTest("simple-persistent-sync.html");
712 } 712 }
713 713
714 TEST_F(WorkerTest, DISABLED_WorkerFileSystemAsyncOperationsTest) { 714 TEST_F(WorkerTest, DISABLED_WorkerFileSystemAsyncOperationsTest) {
715 RunWorkerFileSystemLayoutTest("async-operations.html"); 715 RunWorkerFileSystemLayoutTest("async-operations.html");
716 } 716 }
717 717
718 TEST_F(WorkerTest, DISABLED_WorkerFileSystemSyncOperationsTest) { 718 TEST_F(WorkerTest, DISABLED_WorkerFileSystemSyncOperationsTest) {
719 RunWorkerFileSystemLayoutTest("sync-operations.html"); 719 RunWorkerFileSystemLayoutTest("sync-operations.html");
720 } 720 }
OLDNEW
« no previous file with comments | « chrome/test/ui/ui_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698