Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7836)

Unified Diff: chrome/test/base/ui_test_utils.cc

Issue 10815025: Move TitleWatcher from ui_test_utils.h to browser_test_utils.h so it can be reused by content_brows… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/base/ui_test_utils.h ('k') | content/browser/media_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/ui_test_utils.cc
===================================================================
--- chrome/test/base/ui_test_utils.cc (revision 147602)
+++ chrome/test/base/ui_test_utils.cc (working copy)
@@ -979,73 +979,6 @@
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,
« no previous file with comments | « chrome/test/base/ui_test_utils.h ('k') | content/browser/media_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698