summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-26 01:15:35 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-26 01:15:35 +0000
commit6ddc6e3f2a1a23c888b13f97c0a9ada270158549 (patch)
tree31b6370c21a5752b384f2b2f4d83e480619f8195
parentdef55e02c79cd340a6a8a778e422da16bf94ae28 (diff)
downloadchromium_src-6ddc6e3f2a1a23c888b13f97c0a9ada270158549.zip
chromium_src-6ddc6e3f2a1a23c888b13f97c0a9ada270158549.tar.gz
chromium_src-6ddc6e3f2a1a23c888b13f97c0a9ada270158549.tar.bz2
Move WaitForLoadStop from ui_test_utils to browser_test_utils so that it can be reused in content_browsertests.
BUG=90448 TBR=viettrungluu Review URL: https://chromiumcodereview.appspot.com/10823029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@148463 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autofill/autofill_browsertest.cc2
-rw-r--r--chrome/browser/browser_focus_uitest.cc8
-rw-r--r--chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc7
-rw-r--r--chrome/browser/extensions/api/web_request/web_request_apitest.cc3
-rw-r--r--chrome/browser/referrer_policy_browsertest.cc2
-rw-r--r--chrome/browser/ssl/ssl_browser_tests.cc2
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu_browsertest.cc3
-rw-r--r--chrome/browser/ui/browser_close_browsertest.cc4
-rw-r--r--chrome/browser/ui/pdf/pdf_browsertest.cc2
-rw-r--r--chrome/browser/ui/views/ssl_client_certificate_selector_browsertest.cc7
-rw-r--r--chrome/test/base/in_process_browser_test.cc3
-rw-r--r--chrome/test/base/ui_test_utils.cc13
-rw-r--r--chrome/test/base/ui_test_utils.h4
-rw-r--r--chrome/test/perf/rendering/throughput_tests.cc3
-rw-r--r--content/browser/renderer_host/render_view_host_manager_browsertest.cc24
-rw-r--r--content/public/test/browser_test_utils.h4
-rw-r--r--content/test/browser_test_utils.cc12
17 files changed, 55 insertions, 48 deletions
diff --git a/chrome/browser/autofill/autofill_browsertest.cc b/chrome/browser/autofill/autofill_browsertest.cc
index 0fc2212..4e0b43d 100644
--- a/chrome/browser/autofill/autofill_browsertest.cc
+++ b/chrome/browser/autofill/autofill_browsertest.cc
@@ -624,7 +624,7 @@ IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_AutofillAfterReload) {
LOG(WARNING) << "Reloading the page.";
WebContents* tab = chrome::GetActiveWebContents(browser());
tab->GetController().Reload(false);
- ui_test_utils::WaitForLoadStop(tab);
+ content::WaitForLoadStop(tab);
// Invoke Autofill.
LOG(WARNING) << "Trying to fill the form.";
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc
index a876a5a..4bcaca6 100644
--- a/chrome/browser/browser_focus_uitest.cc
+++ b/chrome/browser/browser_focus_uitest.cc
@@ -841,26 +841,26 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_TabInitialFocus) {
// Open the history tab, focus should be on the tab contents.
chrome::ShowHistory(browser());
- ASSERT_NO_FATAL_FAILURE(ui_test_utils::WaitForLoadStop(
+ ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop(
chrome::GetActiveWebContents(browser())));
EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
// Open the new tab, focus should be on the location bar.
chrome::NewTab(browser());
- ASSERT_NO_FATAL_FAILURE(ui_test_utils::WaitForLoadStop(
+ ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop(
chrome::GetActiveWebContents(browser())));
EXPECT_TRUE(IsViewFocused(location_bar_focus_view_id_));
// Open the download tab, focus should be on the tab contents.
chrome::ShowDownloads(browser());
- ASSERT_NO_FATAL_FAILURE(ui_test_utils::WaitForLoadStop(
+ ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop(
chrome::GetActiveWebContents(browser())));
EXPECT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
// Open about:blank, focus should be on the location bar.
chrome::AddSelectedTabWithURL(browser(), GURL(chrome::kAboutBlankURL),
content::PAGE_TRANSITION_LINK);
- ASSERT_NO_FATAL_FAILURE(ui_test_utils::WaitForLoadStop(
+ ASSERT_NO_FATAL_FAILURE(content::WaitForLoadStop(
chrome::GetActiveWebContents(browser())));
EXPECT_TRUE(IsViewFocused(location_bar_focus_view_id_));
}
diff --git a/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc b/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc
index ef0b652..1b4cfb7 100644
--- a/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc
+++ b/chrome/browser/extensions/api/web_navigation/web_navigation_apitest.cc
@@ -15,6 +15,7 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/context_menu_params.h"
+#include "content/public/test/browser_test_utils.h"
#include "net/base/mock_host_resolver.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
@@ -172,7 +173,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationUserAction) {
RunExtensionSubtest("webnavigation", "test_userAction.html")) << message_;
WebContents* tab = chrome::GetActiveWebContents(browser());
- ui_test_utils::WaitForLoadStop(tab);
+ content::WaitForLoadStop(tab);
ResultCatcher catcher;
@@ -210,7 +211,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationRequestOpenTab) {
<< message_;
WebContents* tab = chrome::GetActiveWebContents(browser());
- ui_test_utils::WaitForLoadStop(tab);
+ content::WaitForLoadStop(tab);
ResultCatcher catcher;
@@ -247,7 +248,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationTargetBlank) {
<< message_;
WebContents* tab = chrome::GetActiveWebContents(browser());
- ui_test_utils::WaitForLoadStop(tab);
+ content::WaitForLoadStop(tab);
ResultCatcher catcher;
diff --git a/chrome/browser/extensions/api/web_request/web_request_apitest.cc b/chrome/browser/extensions/api/web_request/web_request_apitest.cc
index 3203e23..0ad09f0 100644
--- a/chrome/browser/extensions/api/web_request/web_request_apitest.cc
+++ b/chrome/browser/extensions/api/web_request/web_request_apitest.cc
@@ -17,6 +17,7 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/test/browser_test_utils.h"
#include "net/base/mock_host_resolver.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
@@ -101,7 +102,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestNewTab) {
<< message_;
WebContents* tab = chrome::GetActiveWebContents(browser());
- ui_test_utils::WaitForLoadStop(tab);
+ content::WaitForLoadStop(tab);
ResultCatcher catcher;
diff --git a/chrome/browser/referrer_policy_browsertest.cc b/chrome/browser/referrer_policy_browsertest.cc
index 6f129cb..6a40e67 100644
--- a/chrome/browser/referrer_policy_browsertest.cc
+++ b/chrome/browser/referrer_policy_browsertest.cc
@@ -164,7 +164,7 @@ class ReferrerPolicyTest : public InProcessBrowserTest {
tab_added_observer.Wait();
tab = tab_added_observer.GetTab();
EXPECT_TRUE(tab);
- ui_test_utils::WaitForLoadStop(tab);
+ content::WaitForLoadStop(tab);
EXPECT_EQ(expected_title, tab->GetTitle());
} else {
EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
diff --git a/chrome/browser/ssl/ssl_browser_tests.cc b/chrome/browser/ssl/ssl_browser_tests.cc
index 39610f4..be44461 100644
--- a/chrome/browser/ssl/ssl_browser_tests.cc
+++ b/chrome/browser/ssl/ssl_browser_tests.cc
@@ -616,7 +616,7 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, MAYBE_TestHTTPSErrorWithNoNavEntry) {
GURL url = https_server_expired_.GetURL("files/ssl/google.htm");
TabContents* tab2 = chrome::AddSelectedTabWithURL(
browser(), url, content::PAGE_TRANSITION_TYPED);
- ui_test_utils::WaitForLoadStop(tab2->web_contents());
+ content::WaitForLoadStop(tab2->web_contents());
// Verify our assumption that there was no prior navigation.
EXPECT_FALSE(chrome::CanGoBack(browser()));
diff --git a/chrome/browser/tab_contents/render_view_context_menu_browsertest.cc b/chrome/browser/tab_contents/render_view_context_menu_browsertest.cc
index 7f60468..be64a42 100644
--- a/chrome/browser/tab_contents/render_view_context_menu_browsertest.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu_browsertest.cc
@@ -21,6 +21,7 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
+#include "content/public/test/browser_test_utils.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
@@ -130,7 +131,7 @@ IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest,
// be added.
tab_observer.Wait();
tab = tab_observer.GetTab();
- ui_test_utils::WaitForLoadStop(tab);
+ content::WaitForLoadStop(tab);
// Verify that it's the correct tab.
EXPECT_EQ(GURL("about:blank"), tab->GetURL());
diff --git a/chrome/browser/ui/browser_close_browsertest.cc b/chrome/browser/ui/browser_close_browsertest.cc
index c8baf02..2c32118 100644
--- a/chrome/browser/ui/browser_close_browsertest.cc
+++ b/chrome/browser/ui/browser_close_browsertest.cc
@@ -25,6 +25,7 @@
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/download_item.h"
#include "content/public/common/page_transition_types.h"
+#include "content/public/test/browser_test_utils.h"
#include "content/test/net/url_request_slow_download_job.h"
using content::BrowserContext;
@@ -174,8 +175,7 @@ class BrowserCloseTest : public InProcessBrowserTest {
Browser* new_browser = new Browser(Browser::CreateParams(profile));
chrome::AddSelectedTabWithURL(new_browser, GURL(chrome::kAboutBlankURL),
content::PAGE_TRANSITION_START_PAGE);
- ui_test_utils::WaitForLoadStop(
- chrome::GetActiveWebContents(new_browser));
+ content::WaitForLoadStop(chrome::GetActiveWebContents(new_browser));
new_browser->window()->Show();
return new_browser;
}
diff --git a/chrome/browser/ui/pdf/pdf_browsertest.cc b/chrome/browser/ui/pdf/pdf_browsertest.cc
index a06bfd6..503a63b 100644
--- a/chrome/browser/ui/pdf/pdf_browsertest.cc
+++ b/chrome/browser/ui/pdf/pdf_browsertest.cc
@@ -334,7 +334,7 @@ IN_PROC_BROWSER_TEST_F(PDFBrowserTest, SLOW_Loading) {
// nested message loop for the JS call.
if (last_count != load_stop_notification_count())
continue;
- ui_test_utils::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
+ content::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
}
}
}
diff --git a/chrome/browser/ui/views/ssl_client_certificate_selector_browsertest.cc b/chrome/browser/ui/views/ssl_client_certificate_selector_browsertest.cc
index b8a4d63..566f41e 100644
--- a/chrome/browser/ui/views/ssl_client_certificate_selector_browsertest.cc
+++ b/chrome/browser/ui/views/ssl_client_certificate_selector_browsertest.cc
@@ -13,6 +13,7 @@
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/test/browser_test_utils.h"
#include "net/base/cert_test_util.h"
#include "net/base/ssl_cert_request_info.h"
#include "net/base/x509_certificate.h"
@@ -61,7 +62,7 @@ class SSLClientCertificateSelectorTest : public InProcessBrowserTest {
io_loop_finished_event_.Wait();
- ui_test_utils::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
+ content::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
selector_ = new SSLClientCertificateSelector(
chrome::GetActiveTabContents(browser()),
auth_requestor_->http_network_session_,
@@ -150,8 +151,8 @@ class SSLClientCertificateSelectorMultiTabTest
ASSERT_TRUE(NULL != chrome::GetWebContentsAt(browser(), 0));
ASSERT_TRUE(NULL != chrome::GetWebContentsAt(browser(), 1));
ASSERT_TRUE(NULL != chrome::GetWebContentsAt(browser(), 2));
- ui_test_utils::WaitForLoadStop(chrome::GetWebContentsAt(browser(), 1));
- ui_test_utils::WaitForLoadStop(chrome::GetWebContentsAt(browser(), 2));
+ content::WaitForLoadStop(chrome::GetWebContentsAt(browser(), 1));
+ content::WaitForLoadStop(chrome::GetWebContentsAt(browser(), 2));
selector_1_ = new SSLClientCertificateSelector(
chrome::GetTabContentsAt(browser(), 1),
diff --git a/chrome/test/base/in_process_browser_test.cc b/chrome/test/base/in_process_browser_test.cc
index 3de2aa9..7897f61 100644
--- a/chrome/test/base/in_process_browser_test.cc
+++ b/chrome/test/base/in_process_browser_test.cc
@@ -37,6 +37,7 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"
+#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_browser_thread.h"
#include "content/public/test/test_launcher.h"
#include "net/base/mock_host_resolver.h"
@@ -334,7 +335,7 @@ void InProcessBrowserTest::RunTestOnMainThreadLoop() {
if (!BrowserList::empty()) {
browser_ = *BrowserList::begin();
- ui_test_utils::WaitForLoadStop(chrome::GetActiveWebContents(browser_));
+ content::WaitForLoadStop(chrome::GetActiveWebContents(browser_));
}
// Pump any pending events that were created as a result of creating a
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc
index 77c3148..e5527ec 100644
--- a/chrome/test/base/ui_test_utils.cc
+++ b/chrome/test/base/ui_test_utils.cc
@@ -212,17 +212,6 @@ void WaitForNewTab(Browser* browser) {
observer.Wait();
}
-void WaitForLoadStop(WebContents* tab) {
- content::WindowedNotificationObserver load_stop_observer(
- content::NOTIFICATION_LOAD_STOP,
- content::Source<NavigationController>(&tab->GetController()));
- // In many cases, the load may have finished before we get here. Only wait if
- // the tab still has a pending navigation.
- if (!tab->IsLoading())
- return;
- load_stop_observer.Wait();
-}
-
Browser* WaitForBrowserNotInSet(std::set<Browser*> excluded_browsers) {
Browser* new_browser = GetBrowserNotInSet(excluded_browsers);
if (new_browser == NULL) {
@@ -269,7 +258,7 @@ static void NavigateToURLWithDispositionBlockUntilNavigationsComplete(
WindowOpenDisposition disposition,
int browser_test_flags) {
if (disposition == CURRENT_TAB && chrome::GetActiveWebContents(browser))
- WaitForLoadStop(chrome::GetActiveWebContents(browser));
+ content::WaitForLoadStop(chrome::GetActiveWebContents(browser));
NavigationController* controller =
chrome::GetActiveWebContents(browser) ?
&chrome::GetActiveWebContents(browser)->GetController() : NULL;
diff --git a/chrome/test/base/ui_test_utils.h b/chrome/test/base/ui_test_utils.h
index e7b4972..88baf6f 100644
--- a/chrome/test/base/ui_test_utils.h
+++ b/chrome/test/base/ui_test_utils.h
@@ -103,10 +103,6 @@ bool GetCurrentTabTitle(const Browser* browser, string16* title);
// race hazard. Use WindowedNotificationObserver instead.
void WaitForNewTab(Browser* browser);
-// Waits for a load stop for the specified |tab|'s controller, if the tab is
-// currently loading. Otherwise returns immediately.
-void WaitForLoadStop(content::WebContents* tab);
-
// Opens |url| in an incognito browser window with the incognito profile of
// |profile|, blocking until the navigation finishes. This will create a new
// browser if a browser with the incognito profile does not exist. Returns the
diff --git a/chrome/test/perf/rendering/throughput_tests.cc b/chrome/test/perf/rendering/throughput_tests.cc
index 2f27898..10fa750 100644
--- a/chrome/test/perf/rendering/throughput_tests.cc
+++ b/chrome/test/perf/rendering/throughput_tests.cc
@@ -28,6 +28,7 @@
#include "chrome/test/perf/perf_test.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
+#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
#include "content/test/gpu/gpu_test_config.h"
#include "googleurl/src/gurl.h"
@@ -326,7 +327,7 @@ class ThroughputTest : public BrowserPerfTest {
LOG(INFO) << gurl_.possibly_invalid_spec();
ui_test_utils::NavigateToURLWithDisposition(
browser(), gurl_, CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE);
- ui_test_utils::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
+ content::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
// Let the test spin up.
LOG(INFO) << "Spinning up test...";
diff --git a/content/browser/renderer_host/render_view_host_manager_browsertest.cc b/content/browser/renderer_host/render_view_host_manager_browsertest.cc
index e44b597..5f19a2c 100644
--- a/content/browser/renderer_host/render_view_host_manager_browsertest.cc
+++ b/content/browser/renderer_host/render_view_host_manager_browsertest.cc
@@ -86,7 +86,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, NoScriptAccessAfterSwapOut) {
EXPECT_EQ(1, browser()->active_index());
// Wait for the navigation in the new tab to finish, if it hasn't.
- ui_test_utils::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
+ content::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
EXPECT_EQ("/files/navigate_opener.html",
chrome::GetActiveWebContents(browser())->GetURL().path());
EXPECT_EQ(1, browser()->active_index());
@@ -168,7 +168,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
chrome::GetActiveWebContents(browser())->GetURL().path());
// Wait for the cross-site transition in the new tab to finish.
- ui_test_utils::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
+ content::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
chrome::GetActiveWebContents(browser()));
EXPECT_FALSE(web_contents->GetRenderManagerForTesting()->
@@ -226,7 +226,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
chrome::GetActiveWebContents(browser())->GetURL().path());
// Wait for the cross-site transition in the new tab to finish.
- ui_test_utils::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
+ content::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
chrome::GetActiveWebContents(browser()));
EXPECT_FALSE(web_contents->GetRenderManagerForTesting()->
@@ -281,7 +281,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
EXPECT_EQ(1, browser()->active_index());
// Wait for the cross-site transition in the new tab to finish.
- ui_test_utils::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
+ content::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
EXPECT_EQ("/files/title2.html",
chrome::GetActiveWebContents(browser())->GetURL().path());
@@ -326,7 +326,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
EXPECT_TRUE(success);
// Wait for the cross-site transition in the current tab to finish.
- ui_test_utils::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
+ content::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
// Opens in same tab.
EXPECT_EQ(1, browser()->tab_count());
@@ -382,7 +382,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
EXPECT_EQ(1, browser()->active_index());
// Wait for the navigation in the new tab to finish, if it hasn't.
- ui_test_utils::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
+ content::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
EXPECT_EQ("/files/navigate_opener.html",
chrome::GetActiveWebContents(browser())->GetURL().path());
EXPECT_EQ(1, browser()->active_index());
@@ -490,7 +490,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
// Wait for the navigation in the new tab to finish, if it hasn't, then
// send it to post_message.html on a different site.
content::WebContents* foo_contents = chrome::GetActiveWebContents(browser());
- ui_test_utils::WaitForLoadStop(foo_contents);
+ content::WaitForLoadStop(foo_contents);
EXPECT_EQ("/files/navigate_opener.html", foo_contents->GetURL().path());
EXPECT_EQ(1, browser()->active_index());
ui_test_utils::NavigateToURL(browser(),
@@ -513,7 +513,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
// Wait for the navigation in the new tab to finish, if it hasn't, then
// send it to post_message.html on the original site.
content::WebContents* new_contents = chrome::GetActiveWebContents(browser());
- ui_test_utils::WaitForLoadStop(new_contents);
+ content::WaitForLoadStop(new_contents);
EXPECT_EQ("/files/title2.html", new_contents->GetURL().path());
EXPECT_EQ(1, browser()->active_index());
ui_test_utils::NavigateToURL(
@@ -627,7 +627,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
EXPECT_EQ(1, browser()->active_index());
// Wait for the navigation in the new tab to finish, if it hasn't.
- ui_test_utils::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
+ content::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
EXPECT_EQ("/files/navigate_opener.html",
chrome::GetActiveWebContents(browser())->GetURL().path());
EXPECT_EQ(1, browser()->active_index());
@@ -711,7 +711,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
EXPECT_EQ(1, browser()->active_index());
// Wait for the navigation in the new tab to finish, if it hasn't.
- ui_test_utils::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
+ content::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
EXPECT_EQ("/files/navigate_opener.html",
chrome::GetActiveWebContents(browser())->GetURL().path());
EXPECT_EQ(1, browser()->active_index());
@@ -797,7 +797,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest, ClickLinkAfter204Error) {
EXPECT_TRUE(success);
// Wait for the cross-site transition in the current tab to finish.
- ui_test_utils::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
+ content::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
// Opens in same tab.
EXPECT_EQ(1, browser()->tab_count());
@@ -974,7 +974,7 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostManagerTest,
EXPECT_EQ(1, browser()->active_index());
// Wait for the navigation in the new tab to finish, if it hasn't.
- ui_test_utils::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
+ content::WaitForLoadStop(chrome::GetActiveWebContents(browser()));
EXPECT_EQ("/files/navigate_opener.html",
chrome::GetActiveWebContents(browser())->GetURL().path());
EXPECT_EQ(1, browser()->active_index());
diff --git a/content/public/test/browser_test_utils.h b/content/public/test/browser_test_utils.h
index f9eb108a..bee82a0 100644
--- a/content/public/test/browser_test_utils.h
+++ b/content/public/test/browser_test_utils.h
@@ -49,6 +49,10 @@ class WebContents;
// Generate a URL for a file path including a query string.
GURL GetFileUrlWithQuery(const FilePath& path, const std::string& query_string);
+// Waits for a load stop for the specified |web_contents|'s controller, if the
+// tab is currently web_contents. Otherwise returns immediately.
+void WaitForLoadStop(WebContents* web_contents);
+
// Simulates clicking at the center of the given tab asynchronously.
void SimulateMouseClick(WebContents* web_contents);
diff --git a/content/test/browser_test_utils.cc b/content/test/browser_test_utils.cc
index 6b194f8..71bba08 100644
--- a/content/test/browser_test_utils.cc
+++ b/content/test/browser_test_utils.cc
@@ -159,6 +159,18 @@ GURL GetFileUrlWithQuery(const FilePath& path,
return url;
}
+void WaitForLoadStop(WebContents* web_contents) {
+ WindowedNotificationObserver load_stop_observer(
+ NOTIFICATION_LOAD_STOP,
+ Source<NavigationController>(&web_contents->GetController()));
+ // In many cases, the load may have finished before we get here. Only wait if
+ // the tab still has a pending navigation.
+ if (!web_contents->IsLoading())
+ return;
+ load_stop_observer.Wait();
+}
+
+
void SimulateMouseClick(WebContents* web_contents) {
int x = web_contents->GetView()->GetContainerSize().width() / 2;
int y = web_contents->GetView()->GetContainerSize().height() / 2;