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

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

Issue 26277010: Create content::WebContentsDestroyedWatcher, use it in many tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years, 2 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
Index: content/public/test/browser_test_utils.h
diff --git a/content/public/test/browser_test_utils.h b/content/public/test/browser_test_utils.h
index eb3dd6e08184d4f5b133b8328db94350ea1b323f..a0f4902953f4b27a32088ed4a8d2ebbb8980b089 100644
--- a/content/public/test/browser_test_utils.h
+++ b/content/public/test/browser_test_utils.h
@@ -223,6 +223,24 @@ class TitleWatcher : public WebContentsObserver {
DISALLOW_COPY_AND_ASSIGN(TitleWatcher);
};
+// Watches a WebContents and blocks until it is destroyed.
+class WebContentsDestroyedWatcher : public WebContentsObserver {
jam 2013/10/15 16:50:52 i'm curious why this API isn't just a method? i.e.
Avi (use Gerrit) 2013/10/15 16:57:24 Er... yeah. Good point, I hadn't thought about sim
Avi (use Gerrit) 2013/10/15 20:16:32 Actually, no, that's not a good design. That just
jam 2013/10/15 20:47:15 Yes I understand why we use that pattern in other
jam 2013/10/15 20:48:04 also, in this situation, if the WC is destroyed be
+ public:
+ explicit WebContentsDestroyedWatcher(WebContents* web_contents);
+ virtual ~WebContentsDestroyedWatcher();
+
+ // Waits until the WebContents is destroyed.
+ void Wait();
+
+ private:
+ // Overridden WebContentsObserver methods.
+ virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE;
+
+ scoped_refptr<MessageLoopRunner> message_loop_runner_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebContentsDestroyedWatcher);
+};
+
// Watches for responses from the DOMAutomationController and keeps them in a
// queue. Useful for waiting for a message to be received.
class DOMMessageQueue : public NotificationObserver {

Powered by Google App Engine
This is Rietveld 408576698