Index: chrome/test/ui_test_utils.h |
diff --git a/chrome/test/ui_test_utils.h b/chrome/test/ui_test_utils.h |
index fefbb4feadd7b0f7832df0087adab1e890bad41d..cb3483155885b2e2323b55c391ce93a90e91c940 100644 |
--- a/chrome/test/ui_test_utils.h |
+++ b/chrome/test/ui_test_utils.h |
@@ -471,6 +471,34 @@ class WindowedNotificationObserverWithDetails |
DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserverWithDetails); |
}; |
+// Watches title changes on a tab, blocking until an expected title is set. |
+class TitleWatcher : public NotificationObserver { |
+ public: |
+ // |tab_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(TabContents* tab_contents, const string16& expected_title); |
+ ~TitleWatcher(); |
+ |
+ // Waits until the title for the tab is set to the |expected_title| |
+ // passed into the constructor. |
+ bool Wait() WARN_UNUSED_RESULT; |
+ |
+ private: |
+ // NotificationObserver |
+ virtual void Observe(NotificationType type, |
+ const NotificationSource& source, |
+ const NotificationDetails& details) OVERRIDE; |
+ |
+ TabContents* expected_tab_; |
+ string16 expected_title_; |
+ NotificationRegistrar notification_registrar_; |
+ bool title_observed_; |
+ bool quit_loop_on_observation_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(TitleWatcher); |
+}; |
+ |
// See SendKeyPressAndWait. This function additionally performs a check on the |
// NotificationDetails using the provided Details<U>. |
template <class U> |