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

Unified Diff: content/public/test/browser_test_utils.h

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 | « content/browser/worker_host/test/worker_browsertest.cc ('k') | content/test/browser_test_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/browser_test_utils.h
===================================================================
--- content/public/test/browser_test_utils.h (revision 147602)
+++ content/public/test/browser_test_utils.h (working copy)
@@ -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 @@
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_
« no previous file with comments | « content/browser/worker_host/test/worker_browsertest.cc ('k') | content/test/browser_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698