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_TEST_CONTENT_BROWSER_TEST_UTILS_H_ | 5 #ifndef CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_H_ |
6 #define CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_H_ | 6 #define CONTENT_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_browsertests. | 21 // A collections of functions designed for use with content_browsertests. |
21 // Note: if a function here also works with browser_tests, it should be in | 22 // Note: if a function here also works with browser_tests, it should be in |
22 // content\public\test\browser_test_utils.h | 23 // content\public\test\browser_test_utils.h |
23 | 24 |
24 namespace content { | 25 namespace content { |
25 | 26 |
26 class MessageLoopRunner; | 27 class MessageLoopRunner; |
28 class RenderViewCreatedObserver; | |
29 class RenderViewHost; | |
jam
2014/05/15 19:30:19
nit: not needed
Jimmy Jo
2014/05/16 01:15:47
Done.
| |
27 class Shell; | 30 class Shell; |
28 | 31 class WebContents; |
29 // Generate the file path for testing a particular test. | 32 // Generate the file path for testing a particular test. |
30 // The file for the tests is all located in | 33 // The file for the tests is all located in |
31 // content/test/data/dir/<file> | 34 // content/test/data/dir/<file> |
32 // The returned path is FilePath format. | 35 // The returned path is FilePath format. |
33 base::FilePath GetTestFilePath(const char* dir, const char* file); | 36 base::FilePath GetTestFilePath(const char* dir, const char* file); |
34 | 37 |
35 // Generate the URL for testing a particular test. | 38 // Generate the URL for testing a particular test. |
36 // HTML for the tests is all located in | 39 // HTML for the tests is all located in |
37 // test_root_directory/dir/<file> | 40 // test_root_directory/dir/<file> |
38 // The returned path is GURL format. | 41 // The returned path is GURL format. |
(...skipping 25 matching lines...) Expand all Loading... | |
64 | 67 |
65 private: | 68 private: |
66 void ShellCreated(Shell* shell); | 69 void ShellCreated(Shell* shell); |
67 | 70 |
68 Shell* shell_; | 71 Shell* shell_; |
69 scoped_refptr<MessageLoopRunner> runner_; | 72 scoped_refptr<MessageLoopRunner> runner_; |
70 | 73 |
71 DISALLOW_COPY_AND_ASSIGN(ShellAddedObserver); | 74 DISALLOW_COPY_AND_ASSIGN(ShellAddedObserver); |
72 }; | 75 }; |
73 | 76 |
77 // Used to wait for a new WebContents to be created. Instantiate this object | |
78 // before the operation that will create the window. | |
79 class WebContentsAddedObserver { | |
80 public: | |
81 WebContentsAddedObserver(); | |
82 ~WebContentsAddedObserver(); | |
83 | |
84 WebContents* GetWebContents(); | |
85 bool RenderViewCreatedCalled(); | |
jam
2014/05/15 19:30:19
nit: please document these two methods
Jimmy Jo
2014/05/16 01:15:47
Done.
| |
86 private: | |
jam
2014/05/15 19:30:19
nit: blank line above this per style guide
Jimmy Jo
2014/05/16 01:15:47
Done.
| |
87 void WebContentsCreated(WebContents* web_contents); | |
88 | |
89 public: | |
jam
2014/05/15 19:30:19
nit: put a public section and then private, and do
Jimmy Jo
2014/05/16 01:15:47
Done.
| |
90 // Callback invoked on WebContents creation. | |
91 WebContents* web_contents_; | |
92 RenderViewCreatedObserver* child_observer_; | |
jam
2014/05/15 19:30:19
nit: put this in a scoped_ptr so it doesn't leak
Jimmy Jo
2014/05/16 01:15:47
Done.
| |
93 scoped_refptr<MessageLoopRunner> runner_; | |
94 base::Callback<void(WebContents*)> web_contents_created_callback_; | |
95 | |
96 DISALLOW_COPY_AND_ASSIGN(WebContentsAddedObserver); | |
97 }; | |
98 | |
74 #if defined OS_MACOSX | 99 #if defined OS_MACOSX |
75 void SetWindowBounds(gfx::NativeWindow window, const gfx::Rect& bounds); | 100 void SetWindowBounds(gfx::NativeWindow window, const gfx::Rect& bounds); |
76 #endif | 101 #endif |
77 | 102 |
78 } // namespace content | 103 } // namespace content |
79 | 104 |
80 #endif // CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_H_ | 105 #endif // CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_H_ |
OLD | NEW |