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

Unified Diff: chrome/test/ui_test_utils.cc

Issue 7046053: Add PrerenderUnload browser test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move TitleWatcher to ui_test_utils Created 9 years, 6 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
« chrome/test/ui_test_utils.h ('K') | « chrome/test/ui_test_utils.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/ui_test_utils.cc
diff --git a/chrome/test/ui_test_utils.cc b/chrome/test/ui_test_utils.cc
index a0f2fb1325b1d21e12c387064c900596e43ccc95..eb1ae022ab1adcbe6136205db7cdccea85b2cb95 100644
--- a/chrome/test/ui_test_utils.cc
+++ b/chrome/test/ui_test_utils.cc
@@ -1000,4 +1000,44 @@ bool TakeEntirePageSnapshot(RenderViewHost* rvh, SkBitmap* bitmap) {
return taker.TakeEntirePageSnapshot(rvh, bitmap);
}
+TitleWatcher::TitleWatcher(TabContents* tab_contents,
+ const string16& expected_title)
+ : expected_tab_(tab_contents),
+ expected_title_(expected_title),
+ title_observed_(false),
+ quit_loop_on_observation_(false) {
+ EXPECT_TRUE(tab_contents != NULL);
+ notification_registrar_.Add(this,
+ NotificationType::TAB_CONTENTS_TITLE_UPDATED,
+ Source<TabContents>(tab_contents));
+}
+
+TitleWatcher::~TitleWatcher() {
+}
+
+bool TitleWatcher::WaitForTitleChange() {
+ if (title_observed_)
+ return true;
+ quit_loop_on_observation_ = true;
+ ui_test_utils::RunMessageLoop();
+ return title_observed_;
+}
+
+void TitleWatcher::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) OVERRIDE {
+ if (type != NotificationType::TAB_CONTENTS_TITLE_UPDATED)
+ return;
+
+ TabContents* source_contents = Source<TabContents>(source).ptr();
+ ASSERT_EQ(expected_tab_, source_contents);
+ if (source_contents->GetTitle() != expected_title_)
+ return;
+
+ title_observed_ = true;
+ if (quit_loop_on_observation_)
+ MessageLoopForUI::current()->Quit();
+}
+
Paweł Hajdan Jr. 2011/06/09 20:08:27 nit: Remove redundant empty line.
cbentzel 2011/06/10 00:41:31 Done.
+
} // namespace ui_test_utils
« chrome/test/ui_test_utils.h ('K') | « chrome/test/ui_test_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698