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