diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-19 20:32:58 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-19 20:32:58 +0000 |
commit | 2e028a0889a45e034177aedca54fc01b9f9166b0 (patch) | |
tree | 10852c98cc87363680f26ddcbf22127849843f31 /chrome | |
parent | 081f1cec17b1fd8054b532ac2b82b13b739c9949 (diff) | |
download | chromium_src-2e028a0889a45e034177aedca54fc01b9f9166b0.zip chromium_src-2e028a0889a45e034177aedca54fc01b9f9166b0.tar.gz chromium_src-2e028a0889a45e034177aedca54fc01b9f9166b0.tar.bz2 |
Add automation call to wait for multiple navigations.
Convert one ErrorPage UI test to use it.
The rest of the tests will require more work.
TEST=Covered by ui_tests.
http://crbug.com/19361, http://crbug.com/19395
Review URL: http://codereview.chromium.org/174015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23729 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 49 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider.h | 16 | ||||
-rw-r--r-- | chrome/browser/errorpage_uitest.cc | 5 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc | 12 | ||||
-rw-r--r-- | chrome/test/automated_ui_tests/automated_ui_test_base.cc | 1 | ||||
-rw-r--r-- | chrome/test/automated_ui_tests/automated_ui_tests.cc | 3 | ||||
-rw-r--r-- | chrome/test/automation/automation_messages_internal.h | 11 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy_uitest.cc | 8 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.cc | 27 | ||||
-rw-r--r-- | chrome/test/automation/tab_proxy.h | 18 | ||||
-rw-r--r-- | chrome/test/memory_test/memory_test.cc | 2 | ||||
-rw-r--r-- | chrome/test/reliability/page_load_test.cc | 2 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.cc | 8 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.h | 7 |
14 files changed, 117 insertions, 52 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 1784eeac..855b678 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -226,11 +226,14 @@ class NavigationNotificationObserver : public NotificationObserver { public: NavigationNotificationObserver(NavigationController* controller, AutomationProvider* automation, - IPC::Message* reply_message) + IPC::Message* reply_message, + int number_of_navigations) : automation_(automation), reply_message_(reply_message), controller_(controller), + navigations_remaining_(number_of_navigations), navigation_started_(false) { + DCHECK_LT(0, navigations_remaining_); Source<NavigationController> source(controller_); registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, source); registrar_.Add(this, NotificationType::LOAD_START, source); @@ -280,7 +283,8 @@ class NavigationNotificationObserver : public NotificationObserver { } else if (type == NotificationType::LOAD_STOP) { if (navigation_started_) { navigation_started_ = false; - ConditionMet(AUTOMATION_MSG_NAVIGATION_SUCCESS); + if (--navigations_remaining_ == 0) + ConditionMet(AUTOMATION_MSG_NAVIGATION_SUCCESS); } } else if (type == NotificationType::AUTH_SUPPLIED) { // The LoginHandler for this tab is no longer valid. @@ -317,6 +321,7 @@ class NavigationNotificationObserver : public NotificationObserver { AutomationProvider* automation_; IPC::Message* reply_message_; NavigationController* controller_; + int navigations_remaining_; bool navigation_started_; }; @@ -372,7 +377,7 @@ class TabAppendedNotificationObserver : public TabStripNotificationObserver { return; } - automation_->AddNavigationStatusListener(controller, reply_message_); + automation_->AddNavigationStatusListener(controller, reply_message_, 1); } protected: @@ -546,7 +551,7 @@ class ExecuteBrowserCommandObserver : public NotificationObserver { case IDC_RELOAD: { automation->AddNavigationStatusListener( &browser->GetSelectedTabContents()->controller(), - reply_message); + reply_message, 1); break; } default: { @@ -834,9 +839,11 @@ void AutomationProvider::SetExpectedTabCount(size_t expected_tabs) { } NotificationObserver* AutomationProvider::AddNavigationStatusListener( - NavigationController* tab, IPC::Message* reply_message) { + NavigationController* tab, IPC::Message* reply_message, + int number_of_navigations) { NotificationObserver* observer = - new NavigationNotificationObserver(tab, this, reply_message); + new NavigationNotificationObserver(tab, this, reply_message, + number_of_navigations); notification_observer_list_.AddObserver(observer); return observer; @@ -919,6 +926,9 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(AutomationMsg_GetCookies, GetCookies) IPC_MESSAGE_HANDLER(AutomationMsg_SetCookie, SetCookie) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_NavigateToURL, NavigateToURL) + IPC_MESSAGE_HANDLER_DELAY_REPLY( + AutomationMsg_NavigateToURLBlockUntilNavigationsComplete, + NavigateToURLBlockUntilNavigationsComplete) IPC_MESSAGE_HANDLER(AutomationMsg_NavigationAsync, NavigationAsync) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_GoBack, GoBack) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_GoForward, GoForward) @@ -1115,6 +1125,12 @@ void AutomationProvider::AppendTab(int handle, const GURL& url, void AutomationProvider::NavigateToURL(int handle, const GURL& url, IPC::Message* reply_message) { + NavigateToURLBlockUntilNavigationsComplete(handle, url, 1, reply_message); +} + +void AutomationProvider::NavigateToURLBlockUntilNavigationsComplete( + int handle, const GURL& url, int number_of_navigations, + IPC::Message* reply_message) { if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); @@ -1123,7 +1139,7 @@ void AutomationProvider::NavigateToURL(int handle, const GURL& url, Browser* browser = FindAndActivateTab(tab); if (browser) { - AddNavigationStatusListener(tab, reply_message); + AddNavigationStatusListener(tab, reply_message, number_of_navigations); // TODO(darin): avoid conversion to GURL browser->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::TYPED); @@ -1135,7 +1151,6 @@ void AutomationProvider::NavigateToURL(int handle, const GURL& url, reply_message, AUTOMATION_MSG_NAVIGATION_ERROR); Send(reply_message); } - void AutomationProvider::NavigationAsync(int handle, const GURL& url, bool* status) { *status = false; @@ -1161,7 +1176,7 @@ void AutomationProvider::GoBack(int handle, IPC::Message* reply_message) { NavigationController* tab = tab_tracker_->GetResource(handle); Browser* browser = FindAndActivateTab(tab); if (browser && browser->command_updater()->IsCommandEnabled(IDC_BACK)) { - AddNavigationStatusListener(tab, reply_message); + AddNavigationStatusListener(tab, reply_message, 1); browser->GoBack(CURRENT_TAB); return; } @@ -1177,7 +1192,7 @@ void AutomationProvider::GoForward(int handle, IPC::Message* reply_message) { NavigationController* tab = tab_tracker_->GetResource(handle); Browser* browser = FindAndActivateTab(tab); if (browser && browser->command_updater()->IsCommandEnabled(IDC_FORWARD)) { - AddNavigationStatusListener(tab, reply_message); + AddNavigationStatusListener(tab, reply_message, 1); browser->GoForward(CURRENT_TAB); return; } @@ -1193,7 +1208,7 @@ void AutomationProvider::Reload(int handle, IPC::Message* reply_message) { NavigationController* tab = tab_tracker_->GetResource(handle); Browser* browser = FindAndActivateTab(tab); if (browser && browser->command_updater()->IsCommandEnabled(IDC_RELOAD)) { - AddNavigationStatusListener(tab, reply_message); + AddNavigationStatusListener(tab, reply_message, 1); browser->Reload(); return; } @@ -1217,7 +1232,7 @@ void AutomationProvider::SetAuth(int tab_handle, // not strictly correct, because a navigation can require both proxy and // server auth, but it should be OK for now. LoginHandler* handler = iter->second; - AddNavigationStatusListener(tab, reply_message); + AddNavigationStatusListener(tab, reply_message, 1); handler->SetAuth(username, password); return; } @@ -1237,7 +1252,7 @@ void AutomationProvider::CancelAuth(int tab_handle, if (iter != login_handler_map_.end()) { // If auth is needed again after this, something is screwy. LoginHandler* handler = iter->second; - AddNavigationStatusListener(tab, reply_message); + AddNavigationStatusListener(tab, reply_message, 1); handler->CancelAuth(); return; } @@ -2274,7 +2289,7 @@ void AutomationProvider::ShowInterstitialPage(int tab_handle, NavigationController* controller = tab_tracker_->GetResource(tab_handle); TabContents* tab_contents = controller->tab_contents(); - AddNavigationStatusListener(controller, reply_message); + AddNavigationStatusListener(controller, reply_message, 1); AutomationInterstitialPage* interstitial = new AutomationInterstitialPage(tab_contents, GURL("about:interstitial"), @@ -2472,7 +2487,7 @@ void AutomationProvider::ActionOnSSLBlockingPage(int handle, bool proceed, InterstitialPage::GetInterstitialPage(tab_contents); if (ssl_blocking_page) { if (proceed) { - AddNavigationStatusListener(tab, reply_message); + AddNavigationStatusListener(tab, reply_message, 1); ssl_blocking_page->Proceed(); return; } @@ -2777,7 +2792,7 @@ void AutomationProvider::ClickSSLInfoBarLink(int handle, int count = nav_controller->tab_contents()->infobar_delegate_count(); if (info_bar_index >= 0 && info_bar_index < count) { if (wait_for_navigation) { - AddNavigationStatusListener(nav_controller, reply_message); + AddNavigationStatusListener(nav_controller, reply_message, 1); } InfoBarDelegate* delegate = nav_controller->tab_contents()->GetInfoBarDelegateAt( @@ -2814,7 +2829,7 @@ void AutomationProvider::WaitForNavigation(int handle, return; } - AddNavigationStatusListener(controller, reply_message); + AddNavigationStatusListener(controller, reply_message, 1); } void AutomationProvider::SetIntPreference(int handle, diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 0997653..da47f06 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -69,14 +69,15 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, void SetExpectedTabCount(size_t expected_tabs); // Add a listener for navigation status notification. Currently only - // navigation completion is observed; when the navigation completes, the - // completed_response object is sent; if the server requires authentication, - // we instead send the auth_needed_response object. A pointer to the added - // navigation observer is returned. This object should NOT be deleted and - // should be released by calling the corresponding + // navigation completion is observed; when the |number_of_navigations| + // complete, the completed_response object is sent; if the server requires + // authentication, we instead send the auth_needed_response object. A pointer + // to the added navigation observer is returned. This object should NOT be + // deleted and should be released by calling the corresponding // RemoveNavigationStatusListener method. NotificationObserver* AddNavigationStatusListener( - NavigationController* tab, IPC::Message* reply_message); + NavigationController* tab, IPC::Message* reply_message, + int number_of_navigations); void RemoveNavigationStatusListener(NotificationObserver* obs); @@ -198,6 +199,9 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, void GetTabURL(int handle, bool* success, GURL* url); void HandleUnused(const IPC::Message& message, int handle); void NavigateToURL(int handle, const GURL& url, IPC::Message* reply_message); + void NavigateToURLBlockUntilNavigationsComplete(int handle, const GURL& url, + int number_of_navigations, + IPC::Message* reply_message); void NavigationAsync(int handle, const GURL& url, bool* status); void GoBack(int handle, IPC::Message* reply_message); void GoForward(int handle, IPC::Message* reply_message); diff --git a/chrome/browser/errorpage_uitest.cc b/chrome/browser/errorpage_uitest.cc index fda144d..8a4c3a0 100644 --- a/chrome/browser/errorpage_uitest.cc +++ b/chrome/browser/errorpage_uitest.cc @@ -30,11 +30,10 @@ class ErrorPageTest : public UITest { } }; -// Flaky, see http://crbug.com/19361 and http://crbug.com/19395. -TEST_F(ErrorPageTest, DISABLED_DNSError_Basic) { +TEST_F(ErrorPageTest, DNSError_Basic) { GURL test_url(URLRequestFailedDnsJob::kTestUrl); - NavigateToURL(test_url); + NavigateToURLBlockUntilNavigationsComplete(test_url, 2); EXPECT_TRUE(WaitForTitleContaining(test_url.host())); } diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc index d8654fd..5d0f07c 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc @@ -148,11 +148,7 @@ TEST_F(ResourceDispatcherTest, SyncXMLHttpRequest_DuringUnload) { // Navigate to a new page, to dispatch unload event and trigger xhr. // (the bug would make this step hang the renderer). - bool timed_out = false; - tab->NavigateToURLWithTimeout(server->TestServerPageW(L"files/title2.html"), - action_max_timeout_ms(), - &timed_out); - EXPECT_FALSE(timed_out); + tab->NavigateToURL(server->TestServerPageW(L"files/title2.html")); // Check that the new page got loaded, and that no download was triggered. EXPECT_TRUE(tab->GetTabTitle(&tab_title)); @@ -248,11 +244,7 @@ TEST_F(ResourceDispatcherTest, CrossSiteNavigationNonBuffered) { // Make sure that the page loads and displays a title, and doesn't get stuck. FilePath test_file(test_data_directory_); test_file = test_file.AppendASCII("title2.html"); - bool timed_out = false; - tab->NavigateToURLWithTimeout(net::FilePathToFileURL(test_file), - action_max_timeout_ms(), - &timed_out); - EXPECT_FALSE(timed_out); + tab->NavigateToURL(net::FilePathToFileURL(test_file)); EXPECT_EQ(L"Title Of Awesomeness", GetActiveTabTitle()); } diff --git a/chrome/test/automated_ui_tests/automated_ui_test_base.cc b/chrome/test/automated_ui_tests/automated_ui_test_base.cc index 981965d..bf39831 100644 --- a/chrome/test/automated_ui_tests/automated_ui_test_base.cc +++ b/chrome/test/automated_ui_tests/automated_ui_test_base.cc @@ -292,6 +292,7 @@ bool AutomatedUITestBase::Navigate(const GURL& url) { } bool did_timeout = false; tab->NavigateToURLWithTimeout(url, + 1, command_execution_timeout_ms(), &did_timeout); diff --git a/chrome/test/automated_ui_tests/automated_ui_tests.cc b/chrome/test/automated_ui_tests/automated_ui_tests.cc index a2b6611..4b94cbf 100644 --- a/chrome/test/automated_ui_tests/automated_ui_tests.cc +++ b/chrome/test/automated_ui_tests/automated_ui_tests.cc @@ -623,7 +623,8 @@ bool AutomatedUITest::ForceCrash() { scoped_refptr<TabProxy> tab(GetActiveTab()); GURL test_url("about:crash"); bool did_timeout; - tab->NavigateToURLWithTimeout(test_url, kDebuggingTimeoutMsec, &did_timeout); + tab->NavigateToURLWithTimeout(test_url, 1, kDebuggingTimeoutMsec, + &did_timeout); if (!did_timeout) { AddInfoAttribute("expected_crash"); return false; diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index 5ebaca0..5309298 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -82,6 +82,7 @@ IPC_BEGIN_MESSAGES(Automation) // the tab resource. The second parameter is the target url. The return // value contains a status code which is nonnegative on success. // See AutomationMsg_NavigationResponseValues for the return value. + // TODO(phajdan.jr): Remove when the reference build gets updated. IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_NavigateToURL, int, GURL, AutomationMsg_NavigationResponseValues) @@ -1008,4 +1009,14 @@ IPC_BEGIN_MESSAGES(Automation) IPC_MESSAGE_ROUTED3(AutomationMsg_WindowClick, int, gfx::Point, int) #endif + // This message notifies the AutomationProvider to navigate to a specified + // url in the tab with given handle. The first parameter is the handle to + // the tab resource. The second parameter is the target url. The third + // parameter is the number of navigations that are required for a successful + // return value. See AutomationMsg_NavigationResponseValues for the return + // value. + IPC_SYNC_MESSAGE_ROUTED3_1( + AutomationMsg_NavigateToURLBlockUntilNavigationsComplete, int, GURL, int, + AutomationMsg_NavigationResponseValues) + IPC_END_MESSAGES(Automation) diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index c67c1f7..a709629 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -282,7 +282,7 @@ TEST_F(AutomationProxyTest, NavigateToURLWithTimeout1) { bool is_timeout; tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename), - 5000, &is_timeout); + 1, 5000, &is_timeout); ASSERT_FALSE(is_timeout); std::wstring title; @@ -294,7 +294,7 @@ TEST_F(AutomationProxyTest, NavigateToURLWithTimeout1) { ASSERT_GE(URLRequestSlowHTTPJob::kDelayMs, kLowTimeoutMs); tab->NavigateToURLWithTimeout( URLRequestSlowHTTPJob::GetMockUrl(filename.ToWStringHack()), - kLowTimeoutMs, &is_timeout); + 1, kLowTimeoutMs, &is_timeout); ASSERT_TRUE(is_timeout); } @@ -314,13 +314,13 @@ TEST_F(AutomationProxyTest, NavigateToURLWithTimeout2) { ASSERT_GE(URLRequestSlowHTTPJob::kDelayMs, kLowTimeoutMs); tab->NavigateToURLWithTimeout( URLRequestSlowHTTPJob::GetMockUrl(filename1.ToWStringHack()), - kLowTimeoutMs, &is_timeout); + 1, kLowTimeoutMs, &is_timeout); ASSERT_TRUE(is_timeout); FilePath filename2(test_data_directory_); filename2 = filename2.AppendASCII("title1.html"); tab->NavigateToURLWithTimeout(net::FilePathToFileURL(filename2), - 5000, &is_timeout); + 1, 5000, &is_timeout); ASSERT_FALSE(is_timeout); } diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc index 6ee36a2..3d21d8f 100644 --- a/chrome/test/automation/tab_proxy.cc +++ b/chrome/test/automation/tab_proxy.cc @@ -71,19 +71,38 @@ int TabProxy::FindInPage(const std::wstring& search_string, AutomationMsg_NavigationResponseValues TabProxy::NavigateToURL( const GURL& url) { - return NavigateToURLWithTimeout(url, base::kNoTimeout, NULL); + return NavigateToURLBlockUntilNavigationsComplete(url, 1); +} + +AutomationMsg_NavigationResponseValues + TabProxy::NavigateToURLBlockUntilNavigationsComplete( + const GURL& url, int number_of_navigations) { + return NavigateToURLWithTimeout(url, number_of_navigations, base::kNoTimeout, + NULL); } AutomationMsg_NavigationResponseValues TabProxy::NavigateToURLWithTimeout( - const GURL& url, uint32 timeout_ms, bool* is_timeout) { + const GURL& url, int number_of_navigations, uint32 timeout_ms, + bool* is_timeout) { if (!is_valid()) return AUTOMATION_MSG_NAVIGATION_ERROR; AutomationMsg_NavigationResponseValues navigate_response = AUTOMATION_MSG_NAVIGATION_ERROR; - sender_->SendWithTimeout(new AutomationMsg_NavigateToURL( - 0, handle_, url, &navigate_response), timeout_ms, is_timeout); + if (number_of_navigations == 1) { + // TODO(phajdan.jr): Remove when the reference build gets updated. + // This is only for backwards compatibility. + sender_->SendWithTimeout( + new AutomationMsg_NavigateToURL( + 0, handle_, url, &navigate_response), + timeout_ms, is_timeout); + } else { + sender_->SendWithTimeout( + new AutomationMsg_NavigateToURLBlockUntilNavigationsComplete( + 0, handle_, url, number_of_navigations, &navigate_response), + timeout_ms, is_timeout); + } return navigate_response; } diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h index 5e83227..2c19bea 100644 --- a/chrome/test/automation/tab_proxy.h +++ b/chrome/test/automation/tab_proxy.h @@ -77,13 +77,23 @@ class TabProxy : public AutomationResourceProxy { // Navigates to a url. This method accepts the same kinds of URL input that // can be passed to Chrome on the command line. This is a synchronous call and // hence blocks until the navigation completes. - AutomationMsg_NavigationResponseValues NavigateToURL(const GURL& url); + AutomationMsg_NavigationResponseValues NavigateToURL( + const GURL& url); + + // Navigates to a url. This method accepts the same kinds of URL input that + // can be passed to Chrome on the command line. This is a synchronous call and + // hence blocks until the |number_of_navigations| navigations complete. + AutomationMsg_NavigationResponseValues + NavigateToURLBlockUntilNavigationsComplete(const GURL& url, + int number_of_navigations); // Navigates to a url. This is same as NavigateToURL with a timeout option. - // The function returns until the navigation completes or timeout (in - // milliseconds) occurs. If return after timeout, is_timeout is set to true. + // The function blocks until the |number_of_navigations| navigations + // completes or timeout (in milliseconds) occurs. If return after timeout, + // is_timeout is set to true. AutomationMsg_NavigationResponseValues NavigateToURLWithTimeout( - const GURL& url, uint32 timeout_ms, bool* is_timeout); + const GURL& url, int number_of_navigations, uint32 timeout_ms, + bool* is_timeout); // Navigates to a url in an externally hosted tab. // This method accepts the same kinds of URL input that diff --git a/chrome/test/memory_test/memory_test.cc b/chrome/test/memory_test/memory_test.cc index 47ac960..2bd8d1b 100644 --- a/chrome/test/memory_test/memory_test.cc +++ b/chrome/test/memory_test/memory_test.cc @@ -249,7 +249,7 @@ class MemoryTest : public UITest { const int kMaxWaitTime = 5000; bool timed_out = false; - tab->NavigateToURLWithTimeout(GURL(urls[counter]), kMaxWaitTime, + tab->NavigateToURLWithTimeout(GURL(urls[counter]), 1, kMaxWaitTime, &timed_out); if (timed_out) printf("warning: %s timed out!\n", urls[counter].c_str()); diff --git a/chrome/test/reliability/page_load_test.cc b/chrome/test/reliability/page_load_test.cc index b3fbeb6..9d158ab5 100644 --- a/chrome/test/reliability/page_load_test.cc +++ b/chrome/test/reliability/page_load_test.cc @@ -193,7 +193,7 @@ class PageLoadTest : public UITest { // TabProxy should be released before Browser is closed. scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); if (tab_proxy.get()) { - result = tab_proxy->NavigateToURLWithTimeout(url, g_timeout_ms, + result = tab_proxy->NavigateToURLWithTimeout(url, 1, g_timeout_ms, &is_timeout); } diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index ec08b65..97d22fa 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -576,6 +576,11 @@ void UITest::NavigateToURLAsync(const GURL& url) { } void UITest::NavigateToURL(const GURL& url) { + NavigateToURLBlockUntilNavigationsComplete(url, 1); +} + +void UITest::NavigateToURLBlockUntilNavigationsComplete( + const GURL& url, int number_of_navigations) { scoped_refptr<TabProxy> tab_proxy(GetActiveTab()); ASSERT_TRUE(tab_proxy.get()); if (!tab_proxy.get()) @@ -583,7 +588,8 @@ void UITest::NavigateToURL(const GURL& url) { bool is_timeout = true; ASSERT_TRUE(tab_proxy->NavigateToURLWithTimeout( - url, command_execution_timeout_ms(), &is_timeout)) << url.spec(); + url, number_of_navigations, command_execution_timeout_ms(), + &is_timeout)) << url.spec(); ASSERT_FALSE(is_timeout) << url.spec(); } diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h index 50afc27..8568822 100644 --- a/chrome/test/ui/ui_test.h +++ b/chrome/test/ui/ui_test.h @@ -89,6 +89,13 @@ class UITest : public testing::Test { // This method doesn't return until the navigation is complete. void NavigateToURL(const GURL& url); + // Tells the browser to navigate to the given URL in the active tab + // of the first app window. + // This method doesn't return until the |number_of_navigations| navigations + // complete. + void NavigateToURLBlockUntilNavigationsComplete(const GURL& url, + int number_of_navigations); + // Returns the URL of the currently active tab. Only looks in the first // window, for backward compatibility. If there is no active tab, or some // other error, the returned URL will be empty. |