Chromium Code Reviews| 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 |