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_CONTENT_BROWSER_TEST_UTILS_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_UTILS_H_ |
6 #define CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_UTILS_H_ | 6 #define CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_UTILS_H_ |
7 | 7 |
| 8 #include "base/callback.h" |
8 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
9 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
10 #include "url/gurl.h" | 11 #include "url/gurl.h" |
11 | 12 |
12 namespace base { | 13 namespace base { |
13 class FilePath; | 14 class FilePath; |
14 } | 15 } |
15 | 16 |
16 namespace gfx { | 17 namespace gfx { |
17 class Rect; | 18 class Rect; |
18 } | 19 } |
19 | 20 |
20 // A collections of functions designed for use with content_shell based browser | 21 // A collections of functions designed for use with content_shell based browser |
21 // tests. | 22 // tests. |
22 // Note: if a function here also works with browser_tests, it should be in | 23 // Note: if a function here also works with browser_tests, it should be in |
23 // content\public\test\browser_test_utils.h | 24 // content\public\test\browser_test_utils.h |
24 | 25 |
25 namespace content { | 26 namespace content { |
26 | 27 |
27 class MessageLoopRunner; | 28 class MessageLoopRunner; |
| 29 class RenderViewCreatedObserver; |
28 class Shell; | 30 class Shell; |
| 31 class WebContents; |
29 | 32 |
30 // Generate the file path for testing a particular test. | 33 // Generate the file path for testing a particular test. |
31 // The file for the tests is all located in | 34 // The file for the tests is all located in |
32 // content/test/data/dir/<file> | 35 // content/test/data/dir/<file> |
33 // The returned path is FilePath format. | 36 // The returned path is FilePath format. |
34 base::FilePath GetTestFilePath(const char* dir, const char* file); | 37 base::FilePath GetTestFilePath(const char* dir, const char* file); |
35 | 38 |
36 // Generate the URL for testing a particular test. | 39 // Generate the URL for testing a particular test. |
37 // HTML for the tests is all located in | 40 // HTML for the tests is all located in |
38 // test_root_directory/dir/<file> | 41 // test_root_directory/dir/<file> |
(...skipping 30 matching lines...) Expand all Loading... |
69 | 72 |
70 private: | 73 private: |
71 void ShellCreated(Shell* shell); | 74 void ShellCreated(Shell* shell); |
72 | 75 |
73 Shell* shell_; | 76 Shell* shell_; |
74 scoped_refptr<MessageLoopRunner> runner_; | 77 scoped_refptr<MessageLoopRunner> runner_; |
75 | 78 |
76 DISALLOW_COPY_AND_ASSIGN(ShellAddedObserver); | 79 DISALLOW_COPY_AND_ASSIGN(ShellAddedObserver); |
77 }; | 80 }; |
78 | 81 |
| 82 // Used to wait for a new WebContents to be created. Instantiate this object |
| 83 // before the operation that will create the window. |
| 84 class WebContentsAddedObserver { |
| 85 public: |
| 86 WebContentsAddedObserver(); |
| 87 ~WebContentsAddedObserver(); |
| 88 |
| 89 // Will run a message loop to wait for the new window if it hasn't been |
| 90 // created since the constructor |
| 91 WebContents* GetWebContents(); |
| 92 |
| 93 // Will tell whether RenderViewCreated Callback has invoked |
| 94 bool RenderViewCreatedCalled(); |
| 95 |
| 96 base::Callback<void(WebContents*)> web_contents_created_callback_; |
| 97 |
| 98 private: |
| 99 void WebContentsCreated(WebContents* web_contents); |
| 100 |
| 101 // Callback invoked on WebContents creation. |
| 102 WebContents* web_contents_; |
| 103 scoped_ptr<RenderViewCreatedObserver> child_observer_; |
| 104 scoped_refptr<MessageLoopRunner> runner_; |
| 105 |
| 106 DISALLOW_COPY_AND_ASSIGN(WebContentsAddedObserver); |
| 107 }; |
| 108 |
79 #if defined OS_MACOSX | 109 #if defined OS_MACOSX |
80 void SetWindowBounds(gfx::NativeWindow window, const gfx::Rect& bounds); | 110 void SetWindowBounds(gfx::NativeWindow window, const gfx::Rect& bounds); |
81 #endif | 111 #endif |
82 | 112 |
83 } // namespace content | 113 } // namespace content |
84 | 114 |
85 #endif // CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_UTILS_H_ | 115 #endif // CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_UTILS_H_ |
OLD | NEW |