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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 const NotificationDetails& details) override; | 344 const NotificationDetails& details) override; |
345 | 345 |
346 private: | 346 private: |
347 NotificationRegistrar registrar_; | 347 NotificationRegistrar registrar_; |
348 std::queue<std::string> message_queue_; | 348 std::queue<std::string> message_queue_; |
349 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 349 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
350 | 350 |
351 DISALLOW_COPY_AND_ASSIGN(DOMMessageQueue); | 351 DISALLOW_COPY_AND_ASSIGN(DOMMessageQueue); |
352 }; | 352 }; |
353 | 353 |
| 354 // Used to wait for a new WebContents to be created. Instantiate this object |
| 355 // before the operation that will create the window. |
| 356 class WebContentsAddedObserver { |
| 357 public: |
| 358 WebContentsAddedObserver(); |
| 359 ~WebContentsAddedObserver(); |
| 360 |
| 361 // Will run a message loop to wait for the new window if it hasn't been |
| 362 // created since the constructor |
| 363 WebContents* GetWebContents(); |
| 364 |
| 365 // Will tell whether RenderViewCreated Callback has invoked |
| 366 bool RenderViewCreatedCalled(); |
| 367 |
| 368 private: |
| 369 class RenderViewCreatedObserver; |
| 370 |
| 371 void WebContentsCreated(WebContents* web_contents); |
| 372 |
| 373 // Callback to WebContentCreated(). Cached so that we can unregister it. |
| 374 base::Callback<void(WebContents*)> web_contents_created_callback_; |
| 375 |
| 376 WebContents* web_contents_; |
| 377 scoped_ptr<RenderViewCreatedObserver> child_observer_; |
| 378 scoped_refptr<MessageLoopRunner> runner_; |
| 379 |
| 380 DISALLOW_COPY_AND_ASSIGN(WebContentsAddedObserver); |
| 381 }; |
| 382 |
354 } // namespace content | 383 } // namespace content |
355 | 384 |
356 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ | 385 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_UTILS_H_ |
OLD | NEW |