| 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_
|
|
|