diff options
author | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-11 19:45:18 +0000 |
---|---|---|
committer | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-11 19:45:18 +0000 |
commit | 6f9832e3f3c9f63a733e5564947b9957bee1a11d (patch) | |
tree | 03dfde7f10ce9ce1c21f14a652bc71589517b337 /chrome_frame | |
parent | 1de43d34522f088671d416317b778ad0ee2989a4 (diff) | |
download | chromium_src-6f9832e3f3c9f63a733e5564947b9957bee1a11d.zip chromium_src-6f9832e3f3c9f63a733e5564947b9957bee1a11d.tar.gz chromium_src-6f9832e3f3c9f63a733e5564947b9957bee1a11d.tar.bz2 |
Use TimeDelta for Chrome Frame test's TimedMsgLoop.
BUG=none
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10053004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131813 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/test/automation_client_mock.cc | 25 | ||||
-rw-r--r-- | chrome_frame/test/chrome_frame_test_utils.cc | 12 | ||||
-rw-r--r-- | chrome_frame/test/chrome_frame_test_utils.h | 20 | ||||
-rw-r--r-- | chrome_frame/test/delete_chrome_history_test.cc | 4 | ||||
-rw-r--r-- | chrome_frame/test/external_sites_test.cc | 5 | ||||
-rw-r--r-- | chrome_frame/test/infobar_unittests.cc | 7 | ||||
-rw-r--r-- | chrome_frame/test/mock_ie_event_sink_test.cc | 6 | ||||
-rw-r--r-- | chrome_frame/test/mock_ie_event_sink_test.h | 3 | ||||
-rw-r--r-- | chrome_frame/test/navigation_test.cc | 29 | ||||
-rw-r--r-- | chrome_frame/test/ready_mode_unittest.cc | 5 | ||||
-rw-r--r-- | chrome_frame/test/reliability/page_load_test.cc | 4 | ||||
-rw-r--r-- | chrome_frame/test/test_with_web_server.cc | 25 | ||||
-rw-r--r-- | chrome_frame/test/test_with_web_server.h | 3 | ||||
-rw-r--r-- | chrome_frame/test/ui_test.cc | 20 | ||||
-rw-r--r-- | chrome_frame/test/url_request_test.cc | 28 | ||||
-rw-r--r-- | chrome_frame/test/urlmon_moniker_integration_test.cc | 13 |
16 files changed, 104 insertions, 105 deletions
diff --git a/chrome_frame/test/automation_client_mock.cc b/chrome_frame/test/automation_client_mock.cc index e24d05b..0927ae2 100644 --- a/chrome_frame/test/automation_client_mock.cc +++ b/chrome_frame/test/automation_client_mock.cc @@ -23,9 +23,9 @@ using testing::Return; namespace { #ifndef NDEBUG -const int kChromeLaunchTimeout = 15; +const base::TimeDelta kChromeLaunchTimeout = base::TimeDelta::FromSeconds(15); #else -const int kChromeLaunchTimeout = 10; +const base::TimeDelta kChromeLaunchTimeout = base::TimeDelta::FromSeconds(10); #endif const int kSaneAutomationTimeoutMs = 10 * 1000; @@ -231,7 +231,7 @@ TEST_F(CFACWithChrome, NavigateFailed) { EXPECT_CALL(cfd_, OnNavigationFailed(_, GURL(url))) .Times(1) - .WillOnce(QUIT_LOOP_SOON(loop_, 2)); + .WillOnce(QUIT_LOOP_SOON(loop_, base::TimeDelta::FromSeconds(2))); EXPECT_TRUE(client_->Initialize(&cfd_, launch_params_)); @@ -270,7 +270,7 @@ TEST_F(CFACMockTest, MockedCreateTabOk) { clp->set_launch_timeout(timeout); clp->set_version_check(false); EXPECT_TRUE(client_->Initialize(&cfd_, clp)); - loop_.RunFor(10); + loop_.RunFor(base::TimeDelta::FromSeconds(10)); EXPECT_CALL(mock_proxy_, ReleaseTabProxy(testing::Eq(tab_handle_))).Times(1); client_->Uninitialize(); @@ -303,7 +303,7 @@ TEST_F(CFACMockTest, MockedCreateTabFailed) { clp->set_launch_timeout(timeout_); clp->set_version_check(false); EXPECT_TRUE(client_->Initialize(&cfd_, clp)); - loop_.RunFor(4); + loop_.RunFor(base::TimeDelta::FromSeconds(4)); client_->Uninitialize(); } @@ -334,6 +334,7 @@ TEST_F(CFACMockTest, OnChannelErrorEmpty) { } TEST_F(CFACMockTest, OnChannelError) { + const base::TimeDelta loop_duration = base::TimeDelta::FromSeconds(11); TestChromeFrameAutomationProxyImpl proxy; returned_proxy_ = &proxy; @@ -365,12 +366,12 @@ TEST_F(CFACMockTest, OnChannelError) { EXPECT_CALL(cfd1, OnAutomationServerReady()).WillOnce(QUIT_LOOP(loop_)); EXPECT_TRUE(client1->Initialize(&cfd1, clp)); // Wait for OnAutomationServerReady to be called in the UI thread. - loop_.RunFor(11); + loop_.RunFor(loop_duration); proxy.FakeChannelError(); EXPECT_CALL(cfd1, OnChannelError()).WillOnce(QUIT_LOOP(loop_)); // Wait for OnChannelError to be propagated to delegate from the UI thread. - loop_.RunFor(11); + loop_.RunFor(loop_duration); // Add a second tab using a different delegate. StrictMock<MockCFDelegate> cfd2; @@ -381,13 +382,13 @@ TEST_F(CFACMockTest, OnChannelError) { EXPECT_CALL(cfd2, OnAutomationServerReady()).WillOnce(QUIT_LOOP(loop_)); EXPECT_TRUE(client2->Initialize(&cfd2, clp)); // Wait for OnAutomationServerReady to be called in the UI thread. - loop_.RunFor(11); + loop_.RunFor(loop_duration); EXPECT_CALL(cfd1, OnChannelError()).Times(1); EXPECT_CALL(cfd2, OnChannelError()).WillOnce(QUIT_LOOP(loop_)); proxy.FakeChannelError(); // Wait for OnChannelError to be propagated to delegate from the UI thread. - loop_.RunFor(11); + loop_.RunFor(loop_duration); // And now a 3rd tab using the first delegate. scoped_refptr<ChromeFrameAutomationClient> client3; @@ -397,14 +398,14 @@ TEST_F(CFACMockTest, OnChannelError) { EXPECT_CALL(cfd1, OnAutomationServerReady()).WillOnce(QUIT_LOOP(loop_)); EXPECT_TRUE(client3->Initialize(&cfd1, clp)); // Wait for OnAutomationServerReady to be called in the UI thread. - loop_.RunFor(11); + loop_.RunFor(loop_duration); EXPECT_CALL(cfd2, OnChannelError()).Times(1); EXPECT_CALL(cfd1, OnChannelError()).Times(2).WillOnce(Return()) .WillOnce(QUIT_LOOP(loop_)); proxy.FakeChannelError(); // Wait for OnChannelError to be propagated to delegate from the UI thread. - loop_.RunFor(11); + loop_.RunFor(loop_duration); // Cleanup. client1->Uninitialize(); @@ -464,7 +465,7 @@ TEST_F(CFACMockTest, NavigateTwiceAfterInitToSameUrl) { launch_params->set_launch_timeout(timeout); launch_params->set_version_check(false); EXPECT_TRUE(client_->Initialize(&cfd_, launch_params)); - loop_.RunFor(10); + loop_.RunFor(base::TimeDelta::FromSeconds(10)); EXPECT_CALL(mock_proxy_, ReleaseTabProxy(testing::Eq(tab_handle_))).Times(1); client_->Uninitialize(); diff --git a/chrome_frame/test/chrome_frame_test_utils.cc b/chrome_frame/test/chrome_frame_test_utils.cc index 77f02fb..fa504b8 100644 --- a/chrome_frame/test/chrome_frame_test_utils.cc +++ b/chrome_frame/test/chrome_frame_test_utils.cc @@ -51,11 +51,15 @@ const wchar_t kIEProfileName[] = L"iexplore"; const wchar_t kChromeLauncher[] = L"chrome_launcher.exe"; #ifndef NDEBUG -const int kChromeFrameLongNavigationTimeoutInSeconds = 30; -const int kChromeFrameVeryLongNavigationTimeoutInSeconds = 90; +const base::TimeDelta kChromeFrameLongNavigationTimeout = + base::TimeDelta::FromSeconds(30); +const base::TimeDelta kChromeFrameVeryLongNavigationTimeout = + base::TimeDelta::FromSeconds(90); #else -const int kChromeFrameLongNavigationTimeoutInSeconds = 15; -const int kChromeFrameVeryLongNavigationTimeoutInSeconds = 45; +const base::TimeDelta kChromeFrameLongNavigationTimeout = + base::TimeDelta::FromSeconds(15); +const base::TimeDelta kChromeFrameVeryLongNavigationTimeout = + base::TimeDelta::FromSeconds(45); #endif // Callback function for EnumThreadWindows. diff --git a/chrome_frame/test/chrome_frame_test_utils.h b/chrome_frame/test/chrome_frame_test_utils.h index 8affbd5..8911188 100644 --- a/chrome_frame/test/chrome_frame_test_utils.h +++ b/chrome_frame/test/chrome_frame_test_utils.h @@ -17,6 +17,7 @@ #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" #include "base/process_util.h" +#include "base/time.h" #include "base/test/test_reg_util_win.h" #include "base/win/registry.h" #include "base/win/scoped_comptr.h" @@ -53,8 +54,8 @@ extern const wchar_t kIEImageName[]; extern const wchar_t kIEBrokerImageName[]; extern const char kChromeImageName[]; extern const wchar_t kChromeLauncher[]; -extern const int kChromeFrameLongNavigationTimeoutInSeconds; -extern const int kChromeFrameVeryLongNavigationTimeoutInSeconds; +extern const base::TimeDelta kChromeFrameLongNavigationTimeout; +extern const base::TimeDelta kChromeFrameVeryLongNavigationTimeout; // Temporarily impersonate the current thread to low integrity for the lifetime // of the object. Destructor will automatically revert integrity level. @@ -191,8 +192,8 @@ class TimedMsgLoop { TimedMsgLoop() : quit_loop_invoked_(false) { } - void RunFor(int seconds) { - QuitAfter(seconds); + void RunFor(base::TimeDelta duration) { + QuitAfter(duration); quit_loop_invoked_ = false; loop_.MessageLoop::Run(); } @@ -208,13 +209,12 @@ class TimedMsgLoop { } void Quit() { - QuitAfter(0); + QuitAfter(base::TimeDelta()); } - void QuitAfter(int seconds) { + void QuitAfter(base::TimeDelta delay) { quit_loop_invoked_ = true; - loop_.PostDelayedTask( - FROM_HERE, MessageLoop::QuitClosure(), 1000 * seconds); + loop_.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), delay); } bool WasTimedOut() const { @@ -232,9 +232,9 @@ class TimedMsgLoop { #define QUIT_LOOP(loop) testing::InvokeWithoutArgs(\ testing::CreateFunctor(&loop, &chrome_frame_test::TimedMsgLoop::Quit)) -#define QUIT_LOOP_SOON(loop, seconds) testing::InvokeWithoutArgs(\ +#define QUIT_LOOP_SOON(loop, delay) testing::InvokeWithoutArgs(\ testing::CreateFunctor(&loop, &chrome_frame_test::TimedMsgLoop::QuitAfter, \ - seconds)) + delay)) // Launches IE as a COM server and returns the corresponding IWebBrowser2 // interface pointer. diff --git a/chrome_frame/test/delete_chrome_history_test.cc b/chrome_frame/test/delete_chrome_history_test.cc index 4f8dd82..75fa48b 100644 --- a/chrome_frame/test/delete_chrome_history_test.cc +++ b/chrome_frame/test/delete_chrome_history_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -326,7 +326,7 @@ TEST_F(DeleteBrowsingHistoryTest, DISABLED_CFDeleteBrowsingHistory) { ie_mock_.event_sink()->LaunchIEAndNavigate(top_url, &ie_mock_)); // 3 navigations + 2 invocations of delete browser history == 5 - loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds * 5); + loop_.RunFor(kChromeFrameLongNavigationTimeout * 5); } } // namespace chrome_frame_test diff --git a/chrome_frame/test/external_sites_test.cc b/chrome_frame/test/external_sites_test.cc index c24b62ca..d92d52e 100644 --- a/chrome_frame/test/external_sites_test.cc +++ b/chrome_frame/test/external_sites_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -43,8 +43,7 @@ TEST_P(ChromeFrameSitesTest, LoadSite) { VerifyAddressBarUrl(&ie_mock_), CloseBrowserMock(&ie_mock_))); - LaunchIENavigateAndLoop(GetParam(), - kChromeFrameLongNavigationTimeoutInSeconds * 2); + LaunchIENavigateAndLoop(GetParam(), kChromeFrameLongNavigationTimeout * 2); } } // namespace chrome_frame_test diff --git a/chrome_frame/test/infobar_unittests.cc b/chrome_frame/test/infobar_unittests.cc index 6704e29..18f597a 100644 --- a/chrome_frame/test/infobar_unittests.cc +++ b/chrome_frame/test/infobar_unittests.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -536,7 +536,8 @@ TEST(InfobarsInfobarWindowTest, SlidingTest) { ASSERT_NO_FATAL_FAILURE(check.Call("returned from Show")); - ASSERT_NO_FATAL_FAILURE(message_loop.RunFor(10)); // seconds + ASSERT_NO_FATAL_FAILURE(message_loop.RunFor( + base::TimeDelta::FromSeconds(10))); window.DestroyWindow(); @@ -592,7 +593,7 @@ TEST(InfobarsInfobarManagerTest, BasicTest) { ASSERT_TRUE(manager->Show(content, TOP_INFOBAR)); - message_loop.RunFor(10); // seconds + message_loop.RunFor(base::TimeDelta::FromSeconds(10)); window.DestroyWindow(); diff --git a/chrome_frame/test/mock_ie_event_sink_test.cc b/chrome_frame/test/mock_ie_event_sink_test.cc index c858362..11a7dbd 100644 --- a/chrome_frame/test/mock_ie_event_sink_test.cc +++ b/chrome_frame/test/mock_ie_event_sink_test.cc @@ -192,15 +192,15 @@ MockIEEventSinkTest::MockIEEventSinkTest(int port, const std::wstring& address, } void MockIEEventSinkTest::LaunchIEAndNavigate(const std::wstring& url) { - LaunchIENavigateAndLoop(url, kChromeFrameLongNavigationTimeoutInSeconds); + LaunchIENavigateAndLoop(url, kChromeFrameLongNavigationTimeout); } void MockIEEventSinkTest::LaunchIENavigateAndLoop(const std::wstring& url, - int timeout) { + base::TimeDelta timeout) { if (GetInstalledIEVersion() >= IE_8) { chrome_frame_test::ClearIESessionHistory(); } - hung_call_detector_ = HungCOMCallDetector::Setup(timeout); + hung_call_detector_ = HungCOMCallDetector::Setup(ceil(timeout.InSecondsF())); EXPECT_TRUE(hung_call_detector_ != NULL); IEEventSink::SetAbnormalShutdown(false); diff --git a/chrome_frame/test/mock_ie_event_sink_test.h b/chrome_frame/test/mock_ie_event_sink_test.h index 721a157..8770775 100644 --- a/chrome_frame/test/mock_ie_event_sink_test.h +++ b/chrome_frame/test/mock_ie_event_sink_test.h @@ -292,7 +292,8 @@ class MockIEEventSinkTest { void LaunchIEAndNavigate(const std::wstring& url); // Same as above but allows the timeout to be specified. - void LaunchIENavigateAndLoop(const std::wstring& url, int timeout); + void LaunchIENavigateAndLoop(const std::wstring& url, + base::TimeDelta timeout); // Returns the url for the test file given. |relative_path| should be // relative to the test data directory. diff --git a/chrome_frame/test/navigation_test.cc b/chrome_frame/test/navigation_test.cc index b977d10..b87cf9d 100644 --- a/chrome_frame/test/navigation_test.cc +++ b/chrome_frame/test/navigation_test.cc @@ -186,8 +186,7 @@ TEST_P(FullTabNavigationTest, DISABLED_MultipleBackForward) { VerifyAddressBarUrl(&ie_mock_), CloseBrowserMock(&ie_mock_))); - LaunchIENavigateAndLoop(page1, - kChromeFrameLongNavigationTimeoutInSeconds * 2); + LaunchIENavigateAndLoop(page1, kChromeFrameLongNavigationTimeout * 2); } // Test multiple back and forward operations among urls with anchors. @@ -363,8 +362,7 @@ TEST_P(FullTabNavigationTest, DISABLED_JavascriptWindowOpenDifferentDomain) { .WillOnce(CloseBrowserMock(&ie_mock_)); // OnNavigateError can take a long time to fire. - LaunchIENavigateAndLoop(parent_url, - kChromeFrameLongNavigationTimeoutInSeconds * 4); + LaunchIENavigateAndLoop(parent_url, kChromeFrameLongNavigationTimeout * 4); ASSERT_TRUE(new_window_mock.event_sink()->web_browser2() != NULL); } @@ -403,8 +401,7 @@ TEST_P(FullTabNavigationTest, JavascriptWindowOpenCanClose) { EXPECT_CALL(new_window_mock, OnQuit()) .WillOnce(CloseBrowserMock(&ie_mock_)); - LaunchIENavigateAndLoop(parent_url, - kChromeFrameLongNavigationTimeoutInSeconds * 2); + LaunchIENavigateAndLoop(parent_url, kChromeFrameLongNavigationTimeout * 2); } // Parameter for tests using the NavigationTransitionTest fixture. Includes two @@ -506,8 +503,7 @@ TEST_P(NavigationTransitionTest, JavascriptWindowOpen) { EXPECT_CALL(new_window_mock, OnQuit()) .WillOnce(CloseBrowserMock(&ie_mock_)); - LaunchIENavigateAndLoop(parent_url, - kChromeFrameLongNavigationTimeoutInSeconds * 2); + LaunchIENavigateAndLoop(parent_url, kChromeFrameLongNavigationTimeout * 2); } // Test redirection with window.location in Javascript. @@ -863,8 +859,7 @@ TEST_F(FullTabDownloadTest, CF_DownloadFileFromPost) { testing::InvokeWithoutArgs( testing::CreateFunctor(CloseWindow, &owner_window)), CloseBrowserMock(&ie_mock_))); - LaunchIENavigateAndLoop(src_url, - kChromeFrameVeryLongNavigationTimeoutInSeconds); + LaunchIENavigateAndLoop(src_url, kChromeFrameVeryLongNavigationTimeout); std::string data; EXPECT_TRUE(file_util::ReadFileToString(temp_file_path, &data)); @@ -970,8 +965,7 @@ TEST_P(FullTabNavigationTest, RefreshContents) { .WillOnce(DelayRefresh(&ie_mock_, &loop_, 50)) .WillOnce(CloseBrowserMock(&ie_mock_)); - LaunchIENavigateAndLoop(src_url, - kChromeFrameVeryLongNavigationTimeoutInSeconds); + LaunchIENavigateAndLoop(src_url, kChromeFrameVeryLongNavigationTimeout); } class FullTabSeleniumTest @@ -1042,7 +1036,7 @@ TEST_F(FullTabSeleniumTest, DISABLED_Core) { CloseBrowserMock(&ie_mock_))); // Selenium tests take longer to finish, lets give it 2 mins. - const int kSeleniumTestTimeout = 120; + const base::TimeDelta kSeleniumTestTimeout = base::TimeDelta::FromMinutes(2); LaunchIENavigateAndLoop(url, kSeleniumTestTimeout); } @@ -1120,8 +1114,7 @@ TEST_F(FullTabDownloadTest, TopLevelPostReissueFromChromeFramePage) { StrEq(tgt_url)))) .Times(2); - LaunchIENavigateAndLoop(src_url, - kChromeFrameVeryLongNavigationTimeoutInSeconds); + LaunchIENavigateAndLoop(src_url, kChromeFrameVeryLongNavigationTimeout); } MATCHER_P(UserAgentHeaderMatcher, ua_string, "") { @@ -1204,8 +1197,7 @@ TEST_P(FullTabNavigationTest, RefreshContentsUATest) { .WillOnce(DelayRefresh(&ie_mock_, &loop_, 50)); } - LaunchIENavigateAndLoop(src_url, - kChromeFrameVeryLongNavigationTimeoutInSeconds); + LaunchIENavigateAndLoop(src_url, kChromeFrameVeryLongNavigationTimeout); } // Link navigations in the same domain specified with the noreferrer flag @@ -1287,8 +1279,7 @@ TEST_F(FullTabNavigationTest, JavascriptWindowOpenNoReferrerOpensInHost) { EXPECT_CALL(no_referrer_target_opener_window_mock, OnQuit()) .WillOnce(CloseBrowserMock(&ie_mock_)); - LaunchIENavigateAndLoop(initial_url, - kChromeFrameVeryLongNavigationTimeoutInSeconds); + LaunchIENavigateAndLoop(initial_url, kChromeFrameVeryLongNavigationTimeout); } } // namespace chrome_frame_test diff --git a/chrome_frame/test/ready_mode_unittest.cc b/chrome_frame/test/ready_mode_unittest.cc index 6022d26..6a508a2 100644 --- a/chrome_frame/test/ready_mode_unittest.cc +++ b/chrome_frame/test/ready_mode_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -213,7 +213,8 @@ class ReadyPromptWindowButtonTest : public ReadyPromptWindowTest { void RunUntilCloseInfobar() { EXPECT_CALL(frame_, CloseInfobar()).WillOnce(QUIT_LOOP(message_loop_)); - ASSERT_NO_FATAL_FAILURE(message_loop_.RunFor(5)); // seconds + ASSERT_NO_FATAL_FAILURE(message_loop_.RunFor( + base::TimeDelta::FromSeconds(5))); } chrome_frame_test::TimedMsgLoop message_loop_; diff --git a/chrome_frame/test/reliability/page_load_test.cc b/chrome_frame/test/reliability/page_load_test.cc index 7dd88e6..99b44de 100644 --- a/chrome_frame/test/reliability/page_load_test.cc +++ b/chrome_frame/test/reliability/page_load_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -219,7 +219,7 @@ class PageLoadTest : public testing::Test { ie_event_sink.Attach(web_browser2); hr = ie_event_sink.Navigate(UTF8ToWide(url.spec())); if (SUCCEEDED(hr)) { - message_loop.RunFor(g_timeout_seconds); + message_loop.RunFor(base::TimeDelta::FromSeconds(g_timeout_seconds)); if (!message_loop.WasTimedOut()) metrics.result = NAVIGATION_SUCCESS; } diff --git a/chrome_frame/test/test_with_web_server.cc b/chrome_frame/test/test_with_web_server.cc index e01733e..1c87f7b 100644 --- a/chrome_frame/test/test_with_web_server.cc +++ b/chrome_frame/test/test_with_web_server.cc @@ -24,8 +24,8 @@ #include "net/base/mime_util.h" #include "net/http/http_util.h" -using chrome_frame_test::kChromeFrameLongNavigationTimeoutInSeconds; -using chrome_frame_test::kChromeFrameVeryLongNavigationTimeoutInSeconds; +using chrome_frame_test::kChromeFrameLongNavigationTimeout; +using chrome_frame_test::kChromeFrameVeryLongNavigationTimeout; using testing::_; using testing::StrCaseEq; @@ -201,8 +201,9 @@ bool ChromeFrameTestWithWebServer::BringBrowserToTop() { GetProcessId(browser_handle_)); } -bool ChromeFrameTestWithWebServer::WaitForTestToComplete(int milliseconds) { - loop_.RunFor(milliseconds/1000); +bool ChromeFrameTestWithWebServer::WaitForTestToComplete( + base::TimeDelta duration) { + loop_.RunFor(duration); return true; } @@ -217,7 +218,7 @@ void ChromeFrameTestWithWebServer::SimpleBrowserTestExpectedResult( server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), kPostedResultSubstring); ASSERT_TRUE(LaunchBrowser(browser, page)); - WaitForTestToComplete(TestTimeouts::action_max_timeout_ms()); + WaitForTestToComplete(TestTimeouts::action_max_timeout()); ASSERT_EQ(result, server_mock_.posted_result()); } @@ -264,7 +265,7 @@ void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser, server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), kPostedResultSubstring); EXPECT_TRUE(LaunchBrowser(browser, page)); - WaitForTestToComplete(TestTimeouts::action_max_timeout_ms()); + WaitForTestToComplete(TestTimeouts::action_max_timeout()); ASSERT_EQ(version, UTF8ToWide(server_mock_.posted_result())); } @@ -669,7 +670,7 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_InstallFlowTest) { ASSERT_TRUE(LaunchBrowser(IE, kInstallFlowTestUrl)); - loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); + loop_.RunFor(kChromeFrameLongNavigationTimeout); ScopedChromeFrameRegistrar::RegisterAtPath( GetChromeFrameBuildPath().value(), @@ -677,7 +678,7 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_InstallFlowTest) { server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), kPostedResultSubstring); - loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); + loop_.RunFor(kChromeFrameLongNavigationTimeout); chrome_frame_test::CloseAllIEWindows(); ASSERT_EQ("OK", server_mock_.posted_result()); @@ -728,7 +729,7 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_TestPostReissue) { ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); - loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); + loop_.RunFor(kChromeFrameLongNavigationTimeout); const test_server::Request* request = NULL; server.FindRequest("/quit?OK", &request); @@ -760,7 +761,7 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_TestMultipleGet) { ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); - loop_.RunFor(kChromeFrameVeryLongNavigationTimeoutInSeconds); + loop_.RunFor(kChromeFrameVeryLongNavigationTimeout); const test_server::Request* request = NULL; server.FindRequest("/quit?OK", &request); @@ -878,7 +879,7 @@ TEST_F(ChromeFrameTestWithWebServer, FAILS_FullTabModeIE_RefreshMshtmlTest) { ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); - loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); + loop_.RunFor(kChromeFrameLongNavigationTimeout); test_server::SimpleWebServer* ws = server.web_server(); const test_server::ConnectionList& connections = ws->connections(); @@ -1019,7 +1020,7 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_TestDownloadFromForm) { std::wstring url(server.FormatHttpPath(L"form.html")); ASSERT_TRUE(LaunchBrowser(IE, url.c_str())); - loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); + loop_.RunFor(kChromeFrameLongNavigationTimeout); EXPECT_EQ(1, response->get_request_count()); EXPECT_EQ(1, response->post_request_count()); diff --git a/chrome_frame/test/test_with_web_server.h b/chrome_frame/test/test_with_web_server.h index 7202ca2..78c3166 100644 --- a/chrome_frame/test/test_with_web_server.h +++ b/chrome_frame/test/test_with_web_server.h @@ -152,7 +152,8 @@ class ChromeFrameTestWithWebServer : public testing::Test { enum BrowserKind { INVALID, IE, CHROME }; bool LaunchBrowser(BrowserKind browser, const wchar_t* url); - bool WaitForTestToComplete(int milliseconds); + bool WaitForTestToComplete(base::TimeDelta duration); + // Waits for the page to notify us of the window.onload event firing. // Note that the milliseconds value is only approximate. bool WaitForOnLoad(int milliseconds); diff --git a/chrome_frame/test/ui_test.cc b/chrome_frame/test/ui_test.cc index dbe7d94..52fc342 100644 --- a/chrome_frame/test/ui_test.cc +++ b/chrome_frame/test/ui_test.cc @@ -103,8 +103,7 @@ TEST_P(FullTabUITest, DISABLED_KeyboardBackForward) { EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(page2))) .WillOnce(CloseBrowserMock(&ie_mock_)); - LaunchIENavigateAndLoop(page1, - kChromeFrameVeryLongNavigationTimeoutInSeconds); + LaunchIENavigateAndLoop(page1, kChromeFrameVeryLongNavigationTimeout); } // Tests new window behavior with ctrl+N. @@ -142,7 +141,7 @@ TEST_P(FullTabUITest, CtrlN) { .Times(testing::AtMost(2)); LaunchIENavigateAndLoop(GetSimplePageUrl(), - kChromeFrameVeryLongNavigationTimeoutInSeconds); + kChromeFrameVeryLongNavigationTimeout); } // Test that Ctrl+F opens the Find dialog. @@ -172,7 +171,7 @@ TEST_P(FullTabUITest, CtrlF) { .WillOnce(CloseBrowserMock(&ie_mock_)); LaunchIENavigateAndLoop(GetSimplePageUrl(), - kChromeFrameVeryLongNavigationTimeoutInSeconds); + kChromeFrameVeryLongNavigationTimeout); } // Test that ctrl+r does cause a refresh. @@ -196,7 +195,7 @@ TEST_P(FullTabUITest, CtrlR) { .WillRepeatedly(testing::Return()); LaunchIENavigateAndLoop(GetSimplePageUrl(), - kChromeFrameVeryLongNavigationTimeoutInSeconds); + kChromeFrameVeryLongNavigationTimeout); } // Test window close with ctrl+w. @@ -213,7 +212,7 @@ TEST_P(FullTabUITest, CtrlW) { DelaySendChar(&loop_, 1000, 'w', simulate_input::CONTROL))); LaunchIENavigateAndLoop(GetSimplePageUrl(), - kChromeFrameVeryLongNavigationTimeoutInSeconds); + kChromeFrameVeryLongNavigationTimeout); } // Test address bar navigation with Alt+d and URL. @@ -234,7 +233,7 @@ TEST_P(FullTabUITest, AltD) { .WillOnce(CloseBrowserMock(&ie_mock_)); LaunchIENavigateAndLoop(GetSimplePageUrl(), - kChromeFrameVeryLongNavigationTimeoutInSeconds); + kChromeFrameVeryLongNavigationTimeout); } // Tests that the renderer has focus after navigation. @@ -459,7 +458,7 @@ class ContextMenuTest : public MockIEEventSinkTest, public testing::Test { .WillOnce(CloseWhenFileSaved(&ie_mock_, temp_file_path, 8000)); LaunchIENavigateAndLoop(GetTestUrl(L"save_as_context_menu.html"), - kChromeFrameVeryLongNavigationTimeoutInSeconds); + kChromeFrameVeryLongNavigationTimeout); ASSERT_TRUE(file_util::DieFileDie(temp_file_path, false)); } @@ -585,7 +584,7 @@ TEST_F(ContextMenuTest, CFInspector) { .WillOnce(CloseBrowserMock(&ie_mock_)); LaunchIENavigateAndLoop(GetSimplePageUrl(), - kChromeFrameVeryLongNavigationTimeoutInSeconds); + kChromeFrameVeryLongNavigationTimeout); } // http://code.google.com/p/chromium/issues/detail?id=83114 @@ -1030,8 +1029,7 @@ TEST_F(ContextMenuTest, FLAKY_CFBackForward) { EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(page3))) .WillOnce(CloseBrowserMock(&ie_mock_)); - LaunchIENavigateAndLoop(page1, - kChromeFrameVeryLongNavigationTimeoutInSeconds); + LaunchIENavigateAndLoop(page1, kChromeFrameVeryLongNavigationTimeout); } } // namespace chrome_frame_test diff --git a/chrome_frame/test/url_request_test.cc b/chrome_frame/test/url_request_test.cc index 9274cce..15037d8 100644 --- a/chrome_frame/test/url_request_test.cc +++ b/chrome_frame/test/url_request_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -20,7 +20,7 @@ using testing::CreateFunctor; -const int kChromeFrameLongNavigationTimeoutInSeconds = 10; +using chrome_frame_test::kChromeFrameLongNavigationTimeout; static void AppendToStream(IStream* s, void* buffer, ULONG cb) { ULONG bytes_written; @@ -106,10 +106,10 @@ TEST(UrlmonUrlRequestTest, Simple1) { EXPECT_CALL(mock, OnResponseEnd(1, testing::_)) .Times(1) - .WillOnce(QUIT_LOOP_SOON(loop, 2)); + .WillOnce(QUIT_LOOP_SOON(loop, base::TimeDelta::FromSeconds(2))); request.Start(); - loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); + loop.RunFor(kChromeFrameLongNavigationTimeout); request.Release(); } @@ -151,10 +151,10 @@ TEST(UrlmonUrlRequestTest, Head) { EXPECT_CALL(mock, OnResponseEnd(1, testing::_)) .Times(1) - .WillOnce(QUIT_LOOP_SOON(loop, 2)); + .WillOnce(QUIT_LOOP_SOON(loop, base::TimeDelta::FromSeconds(2))); request.Start(); - loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); + loop.RunFor(kChromeFrameLongNavigationTimeout); request.Release(); } @@ -187,7 +187,7 @@ TEST(UrlmonUrlRequestTest, UnreachableUrl) { testing::_, testing::_, testing::_, testing::_, testing::_)) .Times(1) - .WillOnce(QUIT_LOOP_SOON(loop, 2)); + .WillOnce(QUIT_LOOP_SOON(loop, base::TimeDelta::FromSeconds(2))); EXPECT_CALL(mock, OnResponseEnd(1, testing::Property( &net::URLRequestStatus::error, @@ -195,7 +195,7 @@ TEST(UrlmonUrlRequestTest, UnreachableUrl) { .Times(testing::AtMost(1)); request.Start(); - loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); + loop.RunFor(kChromeFrameLongNavigationTimeout); request.Release(); } @@ -228,12 +228,12 @@ TEST(UrlmonUrlRequestTest, ZeroLengthResponse) { .WillOnce(QUIT_LOOP(loop)); request.Start(); - loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); + loop.RunFor(kChromeFrameLongNavigationTimeout); EXPECT_FALSE(loop.WasTimedOut()); // Should stay quiet, since we do not ask for anything for awhile. EXPECT_CALL(mock, OnResponseEnd(1, testing::_)).Times(0); - loop.RunFor(3); + loop.RunFor(base::TimeDelta::FromSeconds(3)); // Invoke read. Only now the response end ("server closed the connection") // is supposed to be delivered. @@ -283,10 +283,10 @@ TEST(UrlmonUrlRequestManagerTest, Simple1) { EXPECT_CALL(mock, OnResponseEnd(1, testing::_)) .Times(1) - .WillOnce(QUIT_LOOP_SOON(loop, 2)); + .WillOnce(QUIT_LOOP_SOON(loop, base::TimeDelta::FromSeconds(2))); mgr->StartUrlRequest(1, r1); - loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); + loop.RunFor(kChromeFrameLongNavigationTimeout); mgr.reset(); } @@ -311,7 +311,7 @@ TEST(UrlmonUrlRequestManagerTest, Abort1) { .Times(1) .WillOnce(testing::DoAll( ManagerEndRequest(&loop, mgr.get(), 1), - QUIT_LOOP_SOON(loop, 3))); + QUIT_LOOP_SOON(loop, base::TimeDelta::FromSeconds(3)))); EXPECT_CALL(mock, OnReadComplete(1, testing::_)) .Times(0); @@ -320,6 +320,6 @@ TEST(UrlmonUrlRequestManagerTest, Abort1) { .Times(0); mgr->StartUrlRequest(1, r1); - loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); + loop.RunFor(kChromeFrameLongNavigationTimeout); mgr.reset(); } diff --git a/chrome_frame/test/urlmon_moniker_integration_test.cc b/chrome_frame/test/urlmon_moniker_integration_test.cc index 7c656a8..2937df4 100644 --- a/chrome_frame/test/urlmon_moniker_integration_test.cc +++ b/chrome_frame/test/urlmon_moniker_integration_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -31,7 +31,8 @@ using testing::DoAll; using testing::WithArgs; -static int kUrlmonMonikerTimeoutSec = 5; +static const base::TimeDelta kUrlmonMonikerTimeout = + base::TimeDelta::FromSeconds(5); namespace { const char kTestContent[] = "<html><head>" @@ -81,7 +82,7 @@ class RunTestServer : public base::Thread { } bool wait_until_ready() { - return ::WaitForSingleObject(ready_, kUrlmonMonikerTimeoutSec * 1000) + return ::WaitForSingleObject(ready_, kUrlmonMonikerTimeout.InMilliseconds()) == WAIT_OBJECT_0; } @@ -250,7 +251,7 @@ TEST_F(UrlmonMonikerTest, BindToStorageAsynchronous) { HRESULT hr = callback.CreateUrlMonikerAndBindToStorage(test_url, bind_ctx.Receive()); EXPECT_EQ(MK_S_ASYNCHRONOUS, hr); - test.loop().RunFor(kUrlmonMonikerTimeoutSec); + test.loop().RunFor(kUrlmonMonikerTimeout); IBindCtx* release = bind_ctx.Detach(); EXPECT_EQ(0, release->Release()); @@ -288,7 +289,7 @@ TEST_F(UrlmonMonikerTest, BindToStorageSwitchContent) { HRESULT hr = callback.CreateUrlMonikerAndBindToStorage(test_url, NULL); EXPECT_EQ(MK_S_ASYNCHRONOUS, hr); - test.loop().RunFor(kUrlmonMonikerTimeoutSec); + test.loop().RunFor(kUrlmonMonikerTimeout); scoped_refptr<RequestData> request_data( test.nav_manager().GetActiveRequestData(test_url)); @@ -332,7 +333,7 @@ TEST_F(UrlmonMonikerTest, BindToStorageCachedContent) { HRESULT hr = callback.CreateUrlMonikerAndBindToStorage(test_url, NULL); EXPECT_EQ(MK_S_ASYNCHRONOUS, hr); - test.loop().RunFor(kUrlmonMonikerTimeoutSec); + test.loop().RunFor(kUrlmonMonikerTimeout); scoped_refptr<RequestData> request_data( test.nav_manager().GetActiveRequestData(test_url)); |