Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
| 6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 | 216 |
| 217 std::vector<string16> expected_titles_; | 217 std::vector<string16> expected_titles_; |
| 218 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 218 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| 219 | 219 |
| 220 // The most recently observed expected title, if any. | 220 // The most recently observed expected title, if any. |
| 221 string16 observed_title_; | 221 string16 observed_title_; |
| 222 | 222 |
| 223 DISALLOW_COPY_AND_ASSIGN(TitleWatcher); | 223 DISALLOW_COPY_AND_ASSIGN(TitleWatcher); |
| 224 }; | 224 }; |
| 225 | 225 |
| 226 // Watches a WebContents and blocks until it is destroyed. | |
| 227 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
| |
| 228 public: | |
| 229 explicit WebContentsDestroyedWatcher(WebContents* web_contents); | |
| 230 virtual ~WebContentsDestroyedWatcher(); | |
| 231 | |
| 232 // Waits until the WebContents is destroyed. | |
| 233 void Wait(); | |
| 234 | |
| 235 private: | |
| 236 // Overridden WebContentsObserver methods. | |
| 237 virtual void WebContentsDestroyed(WebContents* web_contents) OVERRIDE; | |
| 238 | |
| 239 scoped_refptr<MessageLoopRunner> message_loop_runner_; | |
| 240 | |
| 241 DISALLOW_COPY_AND_ASSIGN(WebContentsDestroyedWatcher); | |
| 242 }; | |
| 243 | |
| 226 // Watches for responses from the DOMAutomationController and keeps them in a | 244 // Watches for responses from the DOMAutomationController and keeps them in a |
| 227 // queue. Useful for waiting for a message to be received. | 245 // queue. Useful for waiting for a message to be received. |
| 228 class DOMMessageQueue : public NotificationObserver { | 246 class DOMMessageQueue : public NotificationObserver { |
| 229 public: | 247 public: |
| 230 // Constructs a DOMMessageQueue and begins listening for messages from the | 248 // Constructs a DOMMessageQueue and begins listening for messages from the |
| 231 // DOMAutomationController. Do not construct this until the browser has | 249 // DOMAutomationController. Do not construct this until the browser has |
| 232 // started. | 250 // started. |
| 233 DOMMessageQueue(); | 251 DOMMessageQueue(); |
| 234 virtual ~DOMMessageQueue(); | 252 virtual ~DOMMessageQueue(); |
| 235 | 253 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 250 std::queue<std::string> message_queue_; | 268 std::queue<std::string> message_queue_; |
| 251 bool waiting_for_message_; | 269 bool waiting_for_message_; |
| 252 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 270 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| 253 | 271 |
| 254 DISALLOW_COPY_AND_ASSIGN(DOMMessageQueue); | 272 DISALLOW_COPY_AND_ASSIGN(DOMMessageQueue); |
| 255 }; | 273 }; |
| 256 | 274 |
| 257 } // namespace content | 275 } // namespace content |
| 258 | 276 |
| 259 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 277 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
| OLD | NEW |