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 <string> | 9 #include <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
12 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/process.h" | 15 #include "base/process.h" |
15 #include "base/scoped_temp_dir.h" | 16 #include "base/scoped_temp_dir.h" |
16 #include "base/string16.h" | 17 #include "base/string16.h" |
17 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 206 |
206 // Holds port number which the python websocket server uses. | 207 // Holds port number which the python websocket server uses. |
207 int port_; | 208 int port_; |
208 | 209 |
209 // If the python websocket server serves with TLS. | 210 // If the python websocket server serves with TLS. |
210 bool secure_; | 211 bool secure_; |
211 | 212 |
212 DISALLOW_COPY_AND_ASSIGN(TestWebSocketServer); | 213 DISALLOW_COPY_AND_ASSIGN(TestWebSocketServer); |
213 }; | 214 }; |
214 | 215 |
| 216 // Watches for responses from the DOMAutomationController and keeps them in a |
| 217 // queue. Useful for waiting for a message to be received. |
| 218 class DOMMessageQueue : public NotificationObserver { |
| 219 public: |
| 220 // Constructs a DOMMessageQueue and begins listening for messages from the |
| 221 // DOMAutomationController. Do not construct this until the browser has |
| 222 // started. |
| 223 DOMMessageQueue(); |
| 224 virtual ~DOMMessageQueue(); |
| 225 |
| 226 // Removes all messages in the message queue. |
| 227 void ClearQueue(); |
| 228 |
| 229 // Wait for the next message to arrive. |message| will be set to the next |
| 230 // message, if not null. Returns true on success. |
| 231 bool WaitForMessage(std::string* message) WARN_UNUSED_RESULT; |
| 232 |
| 233 // Overridden NotificationObserver methods. |
| 234 virtual void Observe(int type, |
| 235 const NotificationSource& source, |
| 236 const NotificationDetails& details) OVERRIDE; |
| 237 |
| 238 private: |
| 239 NotificationRegistrar registrar_; |
| 240 std::queue<std::string> message_queue_; |
| 241 bool waiting_for_message_; |
| 242 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| 243 |
| 244 DISALLOW_COPY_AND_ASSIGN(DOMMessageQueue); |
| 245 }; |
| 246 |
215 } // namespace content | 247 } // namespace content |
216 | 248 |
217 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 249 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
OLD | NEW |