summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-20 05:40:59 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-20 05:40:59 +0000
commit35daebe09bf03548ca99e58bc6ebb57d5b7a520d (patch)
tree0f50f5e4bbb1579d98154d50800543d9ea05301b
parent86fcebea2f4f126302400b13a8176a7e43d0a7ab (diff)
downloadchromium_src-35daebe09bf03548ca99e58bc6ebb57d5b7a520d.zip
chromium_src-35daebe09bf03548ca99e58bc6ebb57d5b7a520d.tar.gz
chromium_src-35daebe09bf03548ca99e58bc6ebb57d5b7a520d.tar.bz2
Move TitleWatcher from ui_test_utils.h to browser_test_utils.h so it can be reused by content_browsertests.
BUG=90448 TBR=scottmg Review URL: https://chromiumcodereview.appspot.com/10815025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147618 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/content_settings/content_settings_browsertest.cc9
-rw-r--r--chrome/browser/errorpage_browsertest.cc5
-rw-r--r--chrome/browser/external_extension_browsertest.cc3
-rw-r--r--chrome/browser/history/history_browsertest.cc3
-rw-r--r--chrome/browser/prerender/prefetch_browsertest.cc5
-rw-r--r--chrome/browser/prerender/prerender_browsertest.cc9
-rw-r--r--chrome/browser/referrer_policy_browsertest.cc13
-rw-r--r--chrome/browser/ssl/ssl_browser_tests.cc5
-rw-r--r--chrome/browser/ui/browser_browsertest.cc7
-rw-r--r--chrome/browser/ui/login/login_prompt_browsertest.cc9
-rw-r--r--chrome/browser/ui/panels/old_panel_browsertest.cc7
-rw-r--r--chrome/browser/unload_browsertest.cc3
-rw-r--r--chrome/test/base/ui_test_utils.cc67
-rw-r--r--chrome/test/base/ui_test_utils.h38
-rw-r--r--content/browser/media_browsertest.cc3
-rw-r--r--content/browser/mouseleave_browsertest.cc8
-rw-r--r--content/browser/plugin_browsertest.cc9
-rw-r--r--content/browser/renderer_host/resource_dispatcher_host_browsertest.cc5
-rw-r--r--content/browser/session_history_browsertest.cc3
-rw-r--r--content/browser/worker_host/test/worker_browsertest.cc3
-rw-r--r--content/public/test/browser_test_utils.h48
-rw-r--r--content/test/browser_test_utils.cc72
-rw-r--r--content/test/layout_browsertest.cc3
23 files changed, 185 insertions, 152 deletions
diff --git a/chrome/browser/content_settings/content_settings_browsertest.cc b/chrome/browser/content_settings/content_settings_browsertest.cc
index dab1fdc..dc6720b 100644
--- a/chrome/browser/content_settings/content_settings_browsertest.cc
+++ b/chrome/browser/content_settings/content_settings_browsertest.cc
@@ -19,6 +19,7 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
+#include "content/public/test/browser_test_utils.h"
#include "net/test/test_server.h"
// Regression test for http://crbug.com/63649.
@@ -107,7 +108,7 @@ IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, Basic) {
ui_test_utils::NavigateToURL(browser(), url);
string16 expected_title(ASCIIToUTF16("OK"));
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser()), expected_title);
content::RenderViewHost* host =
@@ -128,7 +129,7 @@ IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, LoadAllBlockedPlugins) {
ui_test_utils::NavigateToURL(browser(), url);
string16 expected_title1(ASCIIToUTF16("1"));
- ui_test_utils::TitleWatcher title_watcher1(
+ content::TitleWatcher title_watcher1(
chrome::GetActiveWebContents(browser()), expected_title1);
content::RenderViewHost* host =
@@ -138,7 +139,7 @@ IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, LoadAllBlockedPlugins) {
EXPECT_EQ(expected_title1, title_watcher1.WaitAndGetTitle());
string16 expected_title2(ASCIIToUTF16("2"));
- ui_test_utils::TitleWatcher title_watcher2(
+ content::TitleWatcher title_watcher2(
chrome::GetActiveWebContents(browser()), expected_title2);
ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
@@ -162,7 +163,7 @@ IN_PROC_BROWSER_TEST_F(ClickToPlayPluginTest, NoCallbackAtLoad) {
L"", L"CallOnStartup = function() { document.title = \"OK\"; }"));
string16 expected_title(ASCIIToUTF16("OK"));
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser()), expected_title);
content::RenderViewHost* host =
diff --git a/chrome/browser/errorpage_browsertest.cc b/chrome/browser/errorpage_browsertest.cc
index 824514c..6ea6fd0 100644
--- a/chrome/browser/errorpage_browsertest.cc
+++ b/chrome/browser/errorpage_browsertest.cc
@@ -12,6 +12,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 "content/public/test/test_navigation_observer.h"
#include "content/test/net/url_request_failed_job.h"
#include "content/test/net/url_request_mock_http_job.h"
@@ -39,7 +40,7 @@ class ErrorPageTest : public InProcessBrowserTest {
void NavigateToURLAndWaitForTitle(const GURL& url,
const std::string& expected_title,
int num_navigations) {
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser()),
ASCIIToUTF16(expected_title));
@@ -85,7 +86,7 @@ class ErrorPageTest : public InProcessBrowserTest {
void NavigateHistoryAndWaitForTitle(const std::string& expected_title,
int num_navigations,
HistoryNavigationDirection direction) {
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser()),
ASCIIToUTF16(expected_title));
diff --git a/chrome/browser/external_extension_browsertest.cc b/chrome/browser/external_extension_browsertest.cc
index aabfb29..b356427 100644
--- a/chrome/browser/external_extension_browsertest.cc
+++ b/chrome/browser/external_extension_browsertest.cc
@@ -12,6 +12,7 @@
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
+#include "content/public/test/browser_test_utils.h"
#include "net/test/test_server.h"
namespace {
@@ -68,7 +69,7 @@ class SearchProviderTest : public InProcessBrowserTest {
const IsSearchProviderTestData& data) {
string16 title = data.tab->GetTitle();
if (title.empty()) {
- ui_test_utils::TitleWatcher title_watcher(data.tab, ASCIIToUTF16("OK"));
+ content::TitleWatcher title_watcher(data.tab, ASCIIToUTF16("OK"));
title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
title = title_watcher.WaitAndGetTitle();
}
diff --git a/chrome/browser/history/history_browsertest.cc b/chrome/browser/history/history_browsertest.cc
index 117b043..0835454 100644
--- a/chrome/browser/history/history_browsertest.cc
+++ b/chrome/browser/history/history_browsertest.cc
@@ -20,6 +20,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 "content/public/test/test_browser_thread.h"
#include "googleurl/src/gurl.h"
@@ -138,7 +139,7 @@ class HistoryBrowserTest : public InProcessBrowserTest {
void LoadAndWaitForURL(const GURL& url) {
string16 expected_title(ASCIIToUTF16("OK"));
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser()), expected_title);
title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
ui_test_utils::NavigateToURL(browser(), url);
diff --git a/chrome/browser/prerender/prefetch_browsertest.cc b/chrome/browser/prerender/prefetch_browsertest.cc
index d104b9e..4d0d40e 100644
--- a/chrome/browser/prerender/prefetch_browsertest.cc
+++ b/chrome/browser/prerender/prefetch_browsertest.cc
@@ -9,6 +9,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/test/browser_test_utils.h"
namespace {
@@ -52,7 +53,7 @@ IN_PROC_BROWSER_TEST_F(PrefetchBrowserTest, PrefetchOn) {
GURL url = test_server()->GetURL(kPrefetchPage);
const string16 expected_title = ASCIIToUTF16("link onload");
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser()),
expected_title);
ui_test_utils::NavigateToURL(browser(), url);
@@ -65,7 +66,7 @@ IN_PROC_BROWSER_TEST_F(PrefetchBrowserTestNoPrefetching, PrefetchOff) {
GURL url = test_server()->GetURL(kPrefetchPage);
const string16 expected_title = ASCIIToUTF16("link onerror");
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser()),
expected_title);
ui_test_utils::NavigateToURL(browser(), url);
diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc
index 7ac63bb..ae5f0f4 100644
--- a/chrome/browser/prerender/prerender_browsertest.cc
+++ b/chrome/browser/prerender/prerender_browsertest.cc
@@ -48,6 +48,7 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
+#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h"
#include "grit/generated_resources.h"
@@ -250,7 +251,7 @@ class TestPrerenderContents : public PrerenderContents {
session_storage_namespace);
string16 ready_title = ASCIIToUTF16(kReadyTitle);
if (prerender_should_wait_for_ready_title_)
- ready_title_watcher_.reset(new ui_test_utils::TitleWatcher(
+ ready_title_watcher_.reset(new content::TitleWatcher(
web_contents, ready_title));
return web_contents;
}
@@ -364,7 +365,7 @@ class TestPrerenderContents : public PrerenderContents {
// If true, before calling DidPrerenderPass, will wait for the title of the
// prerendered page to turn to "READY".
bool prerender_should_wait_for_ready_title_;
- scoped_ptr<ui_test_utils::TitleWatcher> ready_title_watcher_;
+ scoped_ptr<content::TitleWatcher> ready_title_watcher_;
};
// PrerenderManager that uses TestPrerenderContents.
@@ -689,7 +690,7 @@ class PrerenderBrowserTest : virtual public InProcessBrowserTest {
void NavigateToDestUrlAndWaitForPassTitle() {
string16 expected_title = ASCIIToUTF16(kPassTitle);
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
GetPrerenderContents()->prerender_contents()->web_contents(),
expected_title);
NavigateToDestURL();
@@ -2114,7 +2115,7 @@ IN_PROC_BROWSER_TEST_F(PrerenderBrowserTest, MAYBE_PrerenderUnload) {
set_loader_path("files/prerender/prerender_loader_with_unload.html");
PrerenderTestURL("files/prerender/prerender_page.html", FINAL_STATUS_USED, 1);
string16 expected_title = ASCIIToUTF16("Unloaded");
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(current_browser()), expected_title);
NavigateToDestURL();
EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
diff --git a/chrome/browser/referrer_policy_browsertest.cc b/chrome/browser/referrer_policy_browsertest.cc
index 043f796..6f129cb 100644
--- a/chrome/browser/referrer_policy_browsertest.cc
+++ b/chrome/browser/referrer_policy_browsertest.cc
@@ -18,6 +18,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/test/test_server.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
@@ -88,7 +89,7 @@ class ReferrerPolicyTest : public InProcessBrowserTest {
// Adds all possible titles to the TitleWatcher, so we don't time out
// waiting for the title if the test fails.
void AddAllPossibleTitles(const GURL& url,
- ui_test_utils::TitleWatcher* title_watcher) {
+ content::TitleWatcher* title_watcher) {
title_watcher->AlsoWaitForTitle(
GetExpectedTitle(url, EXPECT_EMPTY_REFERRER));
title_watcher->AlsoWaitForTitle(
@@ -140,7 +141,7 @@ class ReferrerPolicyTest : public InProcessBrowserTest {
string16 expected_title = GetExpectedTitle(start_url, expected_referrer);
content::WebContents* tab = chrome::GetActiveWebContents(browser());
- ui_test_utils::TitleWatcher title_watcher(tab, expected_title);
+ content::TitleWatcher title_watcher(tab, expected_title);
// Watch for all possible outcomes to avoid timeouts if something breaks.
AddAllPossibleTitles(start_url, &title_watcher);
@@ -380,8 +381,8 @@ IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, History) {
string16 expected_title =
GetExpectedTitle(start_url, EXPECT_ORIGIN_AS_REFERRER);
content::WebContents* tab = chrome::GetActiveWebContents(browser());
- scoped_ptr<ui_test_utils::TitleWatcher> title_watcher(
- new ui_test_utils::TitleWatcher(tab, expected_title));
+ scoped_ptr<content::TitleWatcher> title_watcher(
+ new content::TitleWatcher(tab, expected_title));
// Watch for all possible outcomes to avoid timeouts if something breaks.
AddAllPossibleTitles(start_url, title_watcher.get());
@@ -390,14 +391,14 @@ IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, History) {
chrome::GoBack(browser(), CURRENT_TAB);
EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle());
- title_watcher.reset(new ui_test_utils::TitleWatcher(tab, expected_title));
+ title_watcher.reset(new content::TitleWatcher(tab, expected_title));
AddAllPossibleTitles(start_url, title_watcher.get());
// Reload to B.
chrome::Reload(browser(), CURRENT_TAB);
EXPECT_EQ(expected_title, title_watcher->WaitAndGetTitle());
- title_watcher.reset(new ui_test_utils::TitleWatcher(tab, expected_title));
+ title_watcher.reset(new content::TitleWatcher(tab, expected_title));
AddAllPossibleTitles(start_url, title_watcher.get());
// Shift-reload to B.
diff --git a/chrome/browser/ssl/ssl_browser_tests.cc b/chrome/browser/ssl/ssl_browser_tests.cc
index 7b95adf..40df6c6 100644
--- a/chrome/browser/ssl/ssl_browser_tests.cc
+++ b/chrome/browser/ssl/ssl_browser_tests.cc
@@ -30,6 +30,7 @@
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/security_style.h"
#include "content/public/common/ssl_status.h"
+#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_renderer_host.h"
#include "net/base/cert_status_flags.h"
#include "net/test/test_server.h"
@@ -528,7 +529,7 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestWSSInvalidCertAndClose) {
// Setup page title observer.
WebContents* tab = chrome::GetActiveWebContents(browser());
- ui_test_utils::TitleWatcher watcher(tab, ASCIIToUTF16("PASS"));
+ content::TitleWatcher watcher(tab, ASCIIToUTF16("PASS"));
watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
// Create GURLs to test pages.
@@ -578,7 +579,7 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestWSSInvalidCertAndGoForward) {
// Setup page title observer.
WebContents* tab = chrome::GetActiveWebContents(browser());
- ui_test_utils::TitleWatcher watcher(tab, ASCIIToUTF16("PASS"));
+ content::TitleWatcher watcher(tab, ASCIIToUTF16("PASS"));
watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
// Visit bad HTTPS page.
diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc
index ab9ae08..3de80e4 100644
--- a/chrome/browser/ui/browser_browsertest.cc
+++ b/chrome/browser/ui/browser_browsertest.cc
@@ -62,6 +62,7 @@
#include "content/public/common/page_transition_types.h"
#include "content/public/common/renderer_preferences.h"
#include "content/public/common/url_constants.h"
+#include "content/public/test/browser_test_utils.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "net/base/mock_host_resolver.h"
@@ -1436,7 +1437,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, WindowOpenClose) {
FilePath(), FilePath().AppendASCII("window.close.html"));
string16 title = ASCIIToUTF16("Title Of Awesomeness");
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser()), title);
ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), url, 2);
EXPECT_EQ(title, title_watcher.WaitAndGetTitle());
@@ -1458,7 +1459,7 @@ IN_PROC_BROWSER_TEST_F(ShowModalDialogTest, BasicTest) {
FilePath(), FilePath().AppendASCII("showmodaldialog.html"));
string16 expected_title(ASCIIToUTF16("SUCCESS"));
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser()), expected_title);
ui_test_utils::NavigateToURL(browser(), url);
@@ -1471,7 +1472,7 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, DisallowFileUrlUniversalAccessTest) {
FilePath(), FilePath().AppendASCII("fileurl_universalaccess.html"));
string16 expected_title(ASCIIToUTF16("Disallowed"));
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser()), expected_title);
title_watcher.AlsoWaitForTitle(ASCIIToUTF16("Allowed"));
ui_test_utils::NavigateToURL(browser(), url);
diff --git a/chrome/browser/ui/login/login_prompt_browsertest.cc b/chrome/browser/ui/login/login_prompt_browsertest.cc
index cb843cb..8f59d83 100644
--- a/chrome/browser/ui/login/login_prompt_browsertest.cc
+++ b/chrome/browser/ui/login/login_prompt_browsertest.cc
@@ -19,6 +19,7 @@
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_browser_thread.h"
#include "net/base/auth.h"
#include "net/base/mock_host_resolver.h"
@@ -314,7 +315,7 @@ IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, TestBasicAuth) {
string16 expected_title =
ExpectedTitleFromAuth(ASCIIToUTF16("basicuser"), ASCIIToUTF16("secret"));
- ui_test_utils::TitleWatcher title_watcher(contents, expected_title);
+ content::TitleWatcher title_watcher(contents, expected_title);
EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
}
@@ -363,7 +364,7 @@ IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, TestDigestAuth) {
auth_supplied_waiter.Wait();
string16 expected_title = ExpectedTitleFromAuth(username, password);
- ui_test_utils::TitleWatcher title_watcher(contents, expected_title);
+ content::TitleWatcher title_watcher(contents, expected_title);
EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
}
@@ -413,8 +414,8 @@ IN_PROC_BROWSER_TEST_F(LoginPromptBrowserTest, TestTwoAuths) {
UTF8ToUTF16(username_basic_), UTF8ToUTF16(password_));
string16 expected_title2 = ExpectedTitleFromAuth(
UTF8ToUTF16(username_digest_), UTF8ToUTF16(password_));
- ui_test_utils::TitleWatcher title_watcher1(contents1, expected_title1);
- ui_test_utils::TitleWatcher title_watcher2(contents2, expected_title2);
+ content::TitleWatcher title_watcher1(contents1, expected_title1);
+ content::TitleWatcher title_watcher2(contents2, expected_title2);
handler1->SetAuth(UTF8ToUTF16(username_basic_), UTF8ToUTF16(password_));
handler2->SetAuth(UTF8ToUTF16(username_digest_), UTF8ToUTF16(password_));
diff --git a/chrome/browser/ui/panels/old_panel_browsertest.cc b/chrome/browser/ui/panels/old_panel_browsertest.cc
index 55b6259..0b2d4d1 100644
--- a/chrome/browser/ui/panels/old_panel_browsertest.cc
+++ b/chrome/browser/ui/panels/old_panel_browsertest.cc
@@ -36,6 +36,7 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
+#include "content/public/test/browser_test_utils.h"
#include "content/test/net/url_request_mock_http_job.h"
#include "net/base/net_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -1380,8 +1381,8 @@ IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, OnBeforeUnloadOnClose) {
// Close panel and respond to the onbeforeunload dialog with cancel. This is
// equivalent to clicking "Stay on this page"
- scoped_ptr<ui_test_utils::TitleWatcher> title_watcher(
- new ui_test_utils::TitleWatcher(web_contents, title_first_close));
+ scoped_ptr<content::TitleWatcher> title_watcher(
+ new content::TitleWatcher(web_contents, title_first_close));
panel->Close();
AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog();
alert->native_dialog()->CancelAppModalDialog();
@@ -1391,7 +1392,7 @@ IN_PROC_BROWSER_TEST_F(OldPanelBrowserTest, OnBeforeUnloadOnClose) {
// Close panel and respond to the onbeforeunload dialog with close. This is
// equivalent to clicking the OS close button on the dialog.
title_watcher.reset(
- new ui_test_utils::TitleWatcher(web_contents, title_second_close));
+ new content::TitleWatcher(web_contents, title_second_close));
panel->Close();
alert = ui_test_utils::WaitForAppModalDialog();
alert->native_dialog()->CloseAppModalDialog();
diff --git a/chrome/browser/unload_browsertest.cc b/chrome/browser/unload_browsertest.cc
index 46b9658..b98d984 100644
--- a/chrome/browser/unload_browsertest.cc
+++ b/chrome/browser/unload_browsertest.cc
@@ -24,6 +24,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/test/browser_test_utils.h"
#include "content/test/net/url_request_mock_http_job.h"
#include "net/url_request/url_request_test_util.h"
@@ -275,7 +276,7 @@ IN_PROC_BROWSER_TEST_F(UnloadTest, BrowserCloseBeforeUnloadCancel) {
// won't put up the beforeunload dialog because it's waiting for an ack from
// the renderer.
string16 expected_title = ASCIIToUTF16("cancelled");
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser()), expected_title);
ClickModalDialogButton(false);
ASSERT_EQ(expected_title, title_watcher.WaitAndGetTitle());
diff --git a/chrome/test/base/ui_test_utils.cc b/chrome/test/base/ui_test_utils.cc
index cbde78e..e1fbf90 100644
--- a/chrome/test/base/ui_test_utils.cc
+++ b/chrome/test/base/ui_test_utils.cc
@@ -979,73 +979,6 @@ void WindowedTabAddedNotificationObserver::Observe(
content::WindowedNotificationObserver::Observe(type, source, details);
}
-TitleWatcher::TitleWatcher(WebContents* web_contents,
- const string16& expected_title)
- : web_contents_(web_contents),
- expected_title_observed_(false),
- quit_loop_on_observation_(false) {
- EXPECT_TRUE(web_contents != NULL);
- expected_titles_.push_back(expected_title);
- notification_registrar_.Add(this,
- content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
- content::Source<WebContents>(web_contents));
-
- // When navigating through the history, the restored NavigationEntry's title
- // will be used. If the entry ends up having the same title after we return
- // to it, as will usually be the case, the
- // NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED will then be suppressed, since the
- // NavigationEntry's title hasn't changed.
- notification_registrar_.Add(
- this,
- content::NOTIFICATION_LOAD_STOP,
- content::Source<NavigationController>(&web_contents->GetController()));
-}
-
-void TitleWatcher::AlsoWaitForTitle(const string16& expected_title) {
- expected_titles_.push_back(expected_title);
-}
-
-TitleWatcher::~TitleWatcher() {
-}
-
-const string16& TitleWatcher::WaitAndGetTitle() {
- if (expected_title_observed_)
- return observed_title_;
- quit_loop_on_observation_ = true;
- message_loop_runner_ = new content::MessageLoopRunner;
- message_loop_runner_->Run();
- return observed_title_;
-}
-
-void TitleWatcher::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- if (type == content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED) {
- WebContents* source_contents = content::Source<WebContents>(source).ptr();
- ASSERT_EQ(web_contents_, source_contents);
- } else if (type == content::NOTIFICATION_LOAD_STOP) {
- NavigationController* controller =
- content::Source<NavigationController>(source).ptr();
- ASSERT_EQ(&web_contents_->GetController(), controller);
- } else {
- FAIL() << "Unexpected notification received.";
- }
-
- std::vector<string16>::const_iterator it =
- std::find(expected_titles_.begin(),
- expected_titles_.end(),
- web_contents_->GetTitle());
- if (it == expected_titles_.end())
- return;
- observed_title_ = *it;
- expected_title_observed_ = true;
- if (quit_loop_on_observation_) {
- // Only call Quit once, on first Observe:
- quit_loop_on_observation_ = false;
- message_loop_runner_->Quit();
- }
-}
-
BrowserAddedObserver::BrowserAddedObserver()
: notification_observer_(
chrome::NOTIFICATION_BROWSER_OPENED,
diff --git a/chrome/test/base/ui_test_utils.h b/chrome/test/base/ui_test_utils.h
index 7aa6469..797f1e3 100644
--- a/chrome/test/base/ui_test_utils.h
+++ b/chrome/test/base/ui_test_utils.h
@@ -425,44 +425,6 @@ class WindowedNotificationObserverWithDetails
DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserverWithDetails);
};
-// Watches title changes on a tab, blocking until an expected title is set.
-class TitleWatcher : public content::NotificationObserver {
- public:
- // |web_contents| must be non-NULL and needs to stay alive for the
- // entire lifetime of |this|. |expected_title| is the title that |this|
- // will wait for.
- TitleWatcher(content::WebContents* web_contents,
- const string16& expected_title);
- virtual ~TitleWatcher();
-
- // Adds another title to watch for.
- void AlsoWaitForTitle(const string16& expected_title);
-
- // Waits until the title matches either expected_title or one of the titles
- // added with AlsoWaitForTitle. Returns the value of the most recently
- // observed matching title.
- const string16& WaitAndGetTitle() WARN_UNUSED_RESULT;
-
- private:
- // content::NotificationObserver
- virtual void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) OVERRIDE;
-
- content::WebContents* web_contents_;
- std::vector<string16> expected_titles_;
- content::NotificationRegistrar notification_registrar_;
- scoped_refptr<content::MessageLoopRunner> message_loop_runner_;
-
- // The most recently observed expected title, if any.
- string16 observed_title_;
-
- bool expected_title_observed_;
- bool quit_loop_on_observation_;
-
- DISALLOW_COPY_AND_ASSIGN(TitleWatcher);
-};
-
// Convenience class for waiting for a new browser to be created.
// Like WindowedNotificationObserver, this class provides a safe, non-racey
// way to wait for a new browser to be created.
diff --git a/content/browser/media_browsertest.cc b/content/browser/media_browsertest.cc
index d90f450..10f0fc4 100644
--- a/content/browser/media_browsertest.cc
+++ b/content/browser/media_browsertest.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/test/browser_test_utils.h"
#include "content/test/layout_browsertest.h"
#include "googleurl/src/gurl.h"
@@ -30,7 +31,7 @@ class MediaTest : public InProcessBrowserTest {
const string16 kPlaying = ASCIIToUTF16("PLAYING");
const string16 kFailed = ASCIIToUTF16("FAILED");
const string16 kError = ASCIIToUTF16("ERROR");
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser()), kPlaying);
title_watcher.AlsoWaitForTitle(kFailed);
title_watcher.AlsoWaitForTitle(kError);
diff --git a/content/browser/mouseleave_browsertest.cc b/content/browser/mouseleave_browsertest.cc
index 367665e..def9789 100644
--- a/content/browser/mouseleave_browsertest.cc
+++ b/content/browser/mouseleave_browsertest.cc
@@ -10,6 +10,7 @@
#include "chrome/test/base/ui_test_utils.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 "ui/ui_controls/ui_controls.h"
namespace {
@@ -51,7 +52,7 @@ IN_PROC_BROWSER_TEST_F(MouseLeaveTest, MAYBE_TestOnMouseOut) {
// Navigate to the test html page.
string16 load_expected_title(ASCIIToUTF16("onload"));
- ui_test_utils::TitleWatcher load_title_watcher(tab, load_expected_title);
+ content::TitleWatcher load_title_watcher(tab, load_expected_title);
ui_test_utils::NavigateToURL(browser(), test_url);
// Wait for the onload() handler to complete so we can do the
// next part of the test.
@@ -63,8 +64,7 @@ IN_PROC_BROWSER_TEST_F(MouseLeaveTest, MAYBE_TestOnMouseOut) {
// Wait on the correct intermediate title.
string16 entered_expected_title(ASCIIToUTF16("entered"));
- ui_test_utils::TitleWatcher entered_title_watcher(
- tab, entered_expected_title);
+ content::TitleWatcher entered_title_watcher(tab, entered_expected_title);
EXPECT_EQ(entered_expected_title, entered_title_watcher.WaitAndGetTitle());
// Move the cursor above the content again, which should trigger
@@ -73,7 +73,7 @@ IN_PROC_BROWSER_TEST_F(MouseLeaveTest, MAYBE_TestOnMouseOut) {
// Wait on the correct final value of the cookie.
string16 left_expected_title(ASCIIToUTF16("left"));
- ui_test_utils::TitleWatcher left_title_watcher(tab, left_expected_title);
+ content::TitleWatcher left_title_watcher(tab, left_expected_title);
EXPECT_EQ(left_expected_title, left_title_watcher.WaitAndGetTitle());
}
diff --git a/content/browser/plugin_browsertest.cc b/content/browser/plugin_browsertest.cc
index 4cd42bf..d8ab3a1 100644
--- a/content/browser/plugin_browsertest.cc
+++ b/content/browser/plugin_browsertest.cc
@@ -11,6 +11,7 @@
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_switches.h"
+#include "content/public/test/browser_test_utils.h"
#include "content/test/net/url_request_mock_http_job.h"
#include "webkit/plugins/plugin_switches.h"
@@ -84,7 +85,7 @@ class PluginTest : public InProcessBrowserTest {
void LoadAndWait(const GURL& url) {
string16 expected_title(ASCIIToUTF16("OK"));
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser()), expected_title);
title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
title_watcher.AlsoWaitForTitle(ASCIIToUTF16("plugin_not_found"));
@@ -175,7 +176,7 @@ IN_PROC_BROWSER_TEST_F(PluginTest,
browser(), GetURL("execute_script_delete_in_mouse_up.html"));
string16 expected_title(ASCIIToUTF16("OK"));
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser()), expected_title);
title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
ui_test_utils::SimulateMouseClick(chrome::GetActiveWebContents(browser()));
@@ -202,7 +203,7 @@ IN_PROC_BROWSER_TEST_F(PluginTest, SelfDeletePluginInvokeAlert) {
0);
string16 expected_title(ASCIIToUTF16("OK"));
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser()), expected_title);
title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
@@ -400,7 +401,7 @@ IN_PROC_BROWSER_TEST_F(PluginTest, DISABLED_PluginConvertPointTest) {
ui_test_utils::NavigateToURL(browser(), GetURL("convert_point.html"));
string16 expected_title(ASCIIToUTF16("OK"));
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser()), expected_title);
title_watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL"));
// TODO(stuartmorgan): When the automation system supports sending clicks,
diff --git a/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc b/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc
index 6ee54c5..763a259 100644
--- a/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc
+++ b/content/browser/renderer_host/resource_dispatcher_host_browsertest.cc
@@ -18,6 +18,7 @@
#include "content/public/browser/notification_types.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
+#include "content/public/test/browser_test_utils.h"
#include "content/test/net/url_request_failed_job.h"
#include "content/test/net/url_request_mock_http_job.h"
#include "net/base/net_errors.h"
@@ -86,7 +87,7 @@ class ResourceDispatcherHostBrowserTest : public InProcessBrowserTest,
const std::string& expected_title,
int expected_navigations) {
string16 expected_title16(ASCIIToUTF16(expected_title));
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser()), expected_title16);
ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
browser(), url, expected_navigations);
@@ -400,7 +401,7 @@ IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest,
// pages of which the error page is one. Instead, use automation to kick
// off the navigation, and wait to see that the tab loads.
string16 expected_title16(ASCIIToUTF16("Title Of Awesomeness"));
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser()), expected_title16);
bool success;
diff --git a/content/browser/session_history_browsertest.cc b/content/browser/session_history_browsertest.cc
index fe28fe4..e918988 100644
--- a/content/browser/session_history_browsertest.cc
+++ b/content/browser/session_history_browsertest.cc
@@ -13,6 +13,7 @@
#include "content/public/browser/notification_types.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
+#include "content/public/test/browser_test_utils.h"
#include "net/test/test_server.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -68,7 +69,7 @@ class SessionHistoryTest : public InProcessBrowserTest {
void NavigateAndCheckTitle(const char* filename,
const std::string& expected_title) {
string16 expected_title16(ASCIIToUTF16(expected_title));
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser()), expected_title16);
ui_test_utils::NavigateToURL(browser(), GetURL(filename));
ASSERT_EQ(expected_title16, title_watcher.WaitAndGetTitle());
diff --git a/content/browser/worker_host/test/worker_browsertest.cc b/content/browser/worker_host/test/worker_browsertest.cc
index 0532452..dc50052 100644
--- a/content/browser/worker_host/test/worker_browsertest.cc
+++ b/content/browser/worker_host/test/worker_browsertest.cc
@@ -18,6 +18,7 @@
#include "content/browser/worker_host/worker_service_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_paths.h"
+#include "content/public/test/browser_test_utils.h"
#include "content/test/layout_browsertest.h"
#include "googleurl/src/gurl.h"
@@ -287,7 +288,7 @@ class WorkerTest : public InProcessBrowserTest {
const std::string& query) {
GURL url = GetTestURL(test_case, query);
const string16 expected_title = ASCIIToUTF16("OK");
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser), expected_title);
ui_test_utils::NavigateToURL(browser, url);
string16 final_title = title_watcher.WaitAndGetTitle();
diff --git a/content/public/test/browser_test_utils.h b/content/public/test/browser_test_utils.h
index e295dd2..0e0bac8 100644
--- a/content/public/test/browser_test_utils.h
+++ b/content/public/test/browser_test_utils.h
@@ -5,7 +5,14 @@
#ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_
#define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_
+#include <vector>
+
#include "base/callback_forward.h"
+#include "base/compiler_specific.h"
+#include "base/memory/ref_counted.h"
+#include "base/string16.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
#include "googleurl/src/gurl.h"
namespace base {
@@ -21,6 +28,47 @@ class RunLoop;
namespace content {
+class MessageLoopRunner;
+class WebContents;
+
+// Watches title changes on a tab, blocking until an expected title is set.
+class TitleWatcher : public NotificationObserver {
+ public:
+ // |web_contents| must be non-NULL and needs to stay alive for the
+ // entire lifetime of |this|. |expected_title| is the title that |this|
+ // will wait for.
+ TitleWatcher(WebContents* web_contents,
+ const string16& expected_title);
+ virtual ~TitleWatcher();
+
+ // Adds another title to watch for.
+ void AlsoWaitForTitle(const string16& expected_title);
+
+ // Waits until the title matches either expected_title or one of the titles
+ // added with AlsoWaitForTitle. Returns the value of the most recently
+ // observed matching title.
+ const string16& WaitAndGetTitle() WARN_UNUSED_RESULT;
+
+ private:
+ // NotificationObserver
+ virtual void Observe(int type,
+ const NotificationSource& source,
+ const NotificationDetails& details) OVERRIDE;
+
+ WebContents* web_contents_;
+ std::vector<string16> expected_titles_;
+ NotificationRegistrar notification_registrar_;
+ scoped_refptr<MessageLoopRunner> message_loop_runner_;
+
+ // The most recently observed expected title, if any.
+ string16 observed_title_;
+
+ bool expected_title_observed_;
+ bool quit_loop_on_observation_;
+
+ DISALLOW_COPY_AND_ASSIGN(TitleWatcher);
+};
+
} // namespace content
#endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_
diff --git a/content/test/browser_test_utils.cc b/content/test/browser_test_utils.cc
index 145c432..6c55430 100644
--- a/content/test/browser_test_utils.cc
+++ b/content/test/browser_test_utils.cc
@@ -4,6 +4,78 @@
#include "content/public/test/browser_test_utils.h"
+#include "content/public/browser/notification_types.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/test/test_utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
namespace content {
+TitleWatcher::TitleWatcher(WebContents* web_contents,
+ const string16& expected_title)
+ : web_contents_(web_contents),
+ expected_title_observed_(false),
+ quit_loop_on_observation_(false) {
+ EXPECT_TRUE(web_contents != NULL);
+ expected_titles_.push_back(expected_title);
+ notification_registrar_.Add(this,
+ NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
+ Source<WebContents>(web_contents));
+
+ // When navigating through the history, the restored NavigationEntry's title
+ // will be used. If the entry ends up having the same title after we return
+ // to it, as will usually be the case, the
+ // NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED will then be suppressed, since the
+ // NavigationEntry's title hasn't changed.
+ notification_registrar_.Add(
+ this,
+ NOTIFICATION_LOAD_STOP,
+ Source<NavigationController>(&web_contents->GetController()));
+}
+
+void TitleWatcher::AlsoWaitForTitle(const string16& expected_title) {
+ expected_titles_.push_back(expected_title);
+}
+
+TitleWatcher::~TitleWatcher() {
+}
+
+const string16& TitleWatcher::WaitAndGetTitle() {
+ if (expected_title_observed_)
+ return observed_title_;
+ quit_loop_on_observation_ = true;
+ message_loop_runner_ = new MessageLoopRunner;
+ message_loop_runner_->Run();
+ return observed_title_;
+}
+
+void TitleWatcher::Observe(int type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ if (type == NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED) {
+ WebContents* source_contents = Source<WebContents>(source).ptr();
+ ASSERT_EQ(web_contents_, source_contents);
+ } else if (type == NOTIFICATION_LOAD_STOP) {
+ NavigationController* controller =
+ Source<NavigationController>(source).ptr();
+ ASSERT_EQ(&web_contents_->GetController(), controller);
+ } else {
+ FAIL() << "Unexpected notification received.";
+ }
+
+ std::vector<string16>::const_iterator it =
+ std::find(expected_titles_.begin(),
+ expected_titles_.end(),
+ web_contents_->GetTitle());
+ if (it == expected_titles_.end())
+ return;
+ observed_title_ = *it;
+ expected_title_observed_ = true;
+ if (quit_loop_on_observation_) {
+ // Only call Quit once, on first Observe:
+ quit_loop_on_observation_ = false;
+ message_loop_runner_->Quit();
+ }
+}
+
} // namespace content
diff --git a/content/test/layout_browsertest.cc b/content/test/layout_browsertest.cc
index 9ccd9db..b45477a 100644
--- a/content/test/layout_browsertest.cc
+++ b/content/test/layout_browsertest.cc
@@ -19,6 +19,7 @@
#include "chrome/test/base/ui_test_utils.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/common/content_paths.h"
+#include "content/public/test/browser_test_utils.h"
#include "net/base/net_util.h"
#if defined(OS_WIN)
@@ -185,7 +186,7 @@ void InProcessBrowserLayoutTest::RunLayoutTestInternal(
const std::string& test_case_file_name, const GURL& url) {
LOG(INFO) << "Navigating to URL " << url << " and blocking.";
const string16 expected_title = ASCIIToUTF16("done");
- ui_test_utils::TitleWatcher title_watcher(
+ content::TitleWatcher title_watcher(
chrome::GetActiveWebContents(browser()), expected_title);
ui_test_utils::NavigateToURL(browser(), url);
LOG(INFO) << "Navigation completed, now waiting for title.";