Chromium Code Reviews| 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 83ea128e9c5f8a1c7bb6faea38b374be7b770563..b9aa0977010ef898e7fa19c35a8f054f666a5f3f 100644 |
| --- a/content/public/test/browser_test_utils.h |
| +++ b/content/public/test/browser_test_utils.h |
| @@ -5,6 +5,7 @@ |
| #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
| #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
| +#include <queue> |
| #include <string> |
| #include <vector> |
| @@ -212,6 +213,37 @@ class TestWebSocketServer { |
| DISALLOW_COPY_AND_ASSIGN(TestWebSocketServer); |
| }; |
| +// Watches for responses from the DOMAutomationController and keeps them in a |
| +// queue. Useful for waiting for a message to be received. |
| +class DOMMessageQueue : public content::NotificationObserver { |
|
jam
2012/09/24 16:45:37
nit: get rid of "content::" everywhere here since
|
| + public: |
| + // Constructs a DOMMessageQueue and begins listening for messages from the |
| + // DOMAutomationController. Do not construct this until the browser has |
| + // started. |
| + DOMMessageQueue(); |
| + virtual ~DOMMessageQueue(); |
| + |
| + // Removes all messages in the message queue. |
| + void ClearQueue(); |
| + |
| + // Wait for the next message to arrive. |message| will be set to the next |
| + // message, if not null. Returns true on success. |
| + bool WaitForMessage(std::string* message) WARN_UNUSED_RESULT; |
| + |
| + // Overridden content::NotificationObserver methods. |
| + virtual void Observe(int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) OVERRIDE; |
| + |
| + private: |
| + content::NotificationRegistrar registrar_; |
| + std::queue<std::string> message_queue_; |
| + bool waiting_for_message_; |
| + scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(DOMMessageQueue); |
| +}; |
| + |
| } // namespace content |
| #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |