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: 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: 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
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 TEST_F(WorkerTest, MultipleTabsQueuedSharedWorker) { 632 TEST_F(WorkerTest, MultipleTabsQueuedSharedWorker) {
633 // Tests to make sure that only one instance of queued shared workers are 633 // Tests to make sure that only one instance of queued shared workers are
634 // started up even when those instances are on multiple tabs. 634 // started up even when those instances are on multiple tabs.
635 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; 635 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate;
636 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), 636 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir),
637 FilePath(kManySharedWorkersFile)); 637 FilePath(kManySharedWorkersFile));
(...skipping 12 matching lines...) Expand all
650 ASSERT_TRUE(WaitForProcessCountToBe(2, max_workers_per_tab)); 650 ASSERT_TRUE(WaitForProcessCountToBe(2, max_workers_per_tab));
651 651
652 // Now shutdown one of the shared workers - this will fire both queued 652 // Now shutdown one of the shared workers - this will fire both queued
653 // workers, but only one instance should be started 653 // workers, but only one instance should be started
654 GURL url2 = ui_test_utils::GetTestUrl(FilePath(kTestDir), 654 GURL url2 = ui_test_utils::GetTestUrl(FilePath(kTestDir),
655 FilePath(kShutdownSharedWorkerFile)); 655 FilePath(kShutdownSharedWorkerFile));
656 url2 = GURL(url2.spec() + "?id=0"); 656 url2 = GURL(url2.spec() + "?id=0");
657 ASSERT_TRUE(window->AppendTab(url2)); 657 ASSERT_TRUE(window->AppendTab(url2));
658 658
659 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, 659 std::string value = WaitUntilCookieNonEmpty(tab.get(), url,
660 kTestCompleteCookie, action_max_timeout_ms()); 660 kTestCompleteCookie, TestTimeouts::action_max_timeout_ms());
661 ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); 661 ASSERT_STREQ(kTestCompleteSuccess, value.c_str());
662 ASSERT_TRUE(WaitForProcessCountToBe(3, max_workers_per_tab)); 662 ASSERT_TRUE(WaitForProcessCountToBe(3, max_workers_per_tab));
663 } 663 }
664 664
665 // Flaky: http://crbug.com/48148 665 // Flaky: http://crbug.com/48148
666 TEST_F(WorkerTest, FLAKY_QueuedSharedWorkerStartedFromOtherTab) { 666 TEST_F(WorkerTest, FLAKY_QueuedSharedWorkerStartedFromOtherTab) {
667 // Tests to make sure that queued shared workers are started up when 667 // Tests to make sure that queued shared workers are started up when
668 // an instance is launched from another tab. 668 // an instance is launched from another tab.
669 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; 669 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate;
670 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir), 670 GURL url = ui_test_utils::GetTestUrl(FilePath(kTestDir),
671 FilePath(kManySharedWorkersFile)); 671 FilePath(kManySharedWorkersFile));
672 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab+1)); 672 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab+1));
673 673
674 scoped_refptr<TabProxy> tab(GetActiveTab()); 674 scoped_refptr<TabProxy> tab(GetActiveTab());
675 ASSERT_TRUE(tab.get()); 675 ASSERT_TRUE(tab.get());
676 ASSERT_TRUE(tab->NavigateToURL(url)); 676 ASSERT_TRUE(tab->NavigateToURL(url));
677 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab)); 677 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab));
678 // First window has hit its limit. Now launch second window which creates 678 // First window has hit its limit. Now launch second window which creates
679 // the same worker that was queued in the first window, to ensure it gets 679 // the same worker that was queued in the first window, to ensure it gets
680 // connected to the first window too. 680 // connected to the first window too.
681 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); 681 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
682 ASSERT_TRUE(window.get()); 682 ASSERT_TRUE(window.get());
683 GURL url2 = ui_test_utils::GetTestUrl(FilePath(kTestDir), 683 GURL url2 = ui_test_utils::GetTestUrl(FilePath(kTestDir),
684 FilePath(kSingleSharedWorkersFile)); 684 FilePath(kSingleSharedWorkersFile));
685 url2 = GURL(url2.spec() + StringPrintf("?id=%d", max_workers_per_tab)); 685 url2 = GURL(url2.spec() + StringPrintf("?id=%d", max_workers_per_tab));
686 ASSERT_TRUE(window->AppendTab(url2)); 686 ASSERT_TRUE(window->AppendTab(url2));
687 687
688 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, 688 std::string value = WaitUntilCookieNonEmpty(tab.get(), url,
689 kTestCompleteCookie, action_max_timeout_ms()); 689 kTestCompleteCookie, TestTimeouts::action_max_timeout_ms());
690 ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); 690 ASSERT_STREQ(kTestCompleteSuccess, value.c_str());
691 ASSERT_TRUE(WaitForProcessCountToBe(2, max_workers_per_tab+1)); 691 ASSERT_TRUE(WaitForProcessCountToBe(2, max_workers_per_tab+1));
692 } 692 }
693 693
694 // FileSystem worker tests. 694 // FileSystem worker tests.
695 // They are disabled for now as the feature is not enabled by default. 695 // They are disabled for now as the feature is not enabled by default.
696 // http://crbug.com/32277 696 // http://crbug.com/32277
697 TEST_F(WorkerTest, DISABLED_WorkerFileSystemTemporaryTest) { 697 TEST_F(WorkerTest, DISABLED_WorkerFileSystemTemporaryTest) {
698 RunWorkerFileSystemLayoutTest("simple-temporary.html"); 698 RunWorkerFileSystemLayoutTest("simple-temporary.html");
699 } 699 }
(...skipping 10 matching lines...) Expand all
710 RunWorkerFileSystemLayoutTest("simple-persistent-sync.html"); 710 RunWorkerFileSystemLayoutTest("simple-persistent-sync.html");
711 } 711 }
712 712
713 TEST_F(WorkerTest, DISABLED_WorkerFileSystemAsyncOperationsTest) { 713 TEST_F(WorkerTest, DISABLED_WorkerFileSystemAsyncOperationsTest) {
714 RunWorkerFileSystemLayoutTest("async-operations.html"); 714 RunWorkerFileSystemLayoutTest("async-operations.html");
715 } 715 }
716 716
717 TEST_F(WorkerTest, DISABLED_WorkerFileSystemSyncOperationsTest) { 717 TEST_F(WorkerTest, DISABLED_WorkerFileSystemSyncOperationsTest) {
718 RunWorkerFileSystemLayoutTest("sync-operations.html"); 718 RunWorkerFileSystemLayoutTest("sync-operations.html");
719 } 719 }
OLDNEW
« chrome/test/interactive_ui/mouseleave_interactive_uitest.cc ('K') | « chrome/test/ui/ui_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698