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/memory/ref_counted.h" |
8 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
9 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
10 | 11 |
11 class FilePath; | 12 class FilePath; |
12 | 13 |
13 namespace gfx { | 14 namespace gfx { |
14 class Rect; | 15 class Rect; |
15 } | 16 } |
16 | 17 |
17 // A collections of functions designed for use with content_browsertests. | 18 // A collections of functions designed for use with content_browsertests. |
18 // Note: if a function here also works with browser_tests, it should be in | 19 // Note: if a function here also works with browser_tests, it should be in |
19 // content\public\test\browser_test_utils.h | 20 // content\public\test\browser_test_utils.h |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 | 23 |
| 24 class MessageLoopRunner; |
23 class Shell; | 25 class Shell; |
24 | 26 |
25 // Generate the file path for testing a particular test. | 27 // Generate the file path for testing a particular test. |
26 // The file for the tests is all located in | 28 // The file for the tests is all located in |
27 // content/test/data/dir/<file> | 29 // content/test/data/dir/<file> |
28 // The returned path is FilePath format. | 30 // The returned path is FilePath format. |
29 FilePath GetTestFilePath(const char* dir, const char* file); | 31 FilePath GetTestFilePath(const char* dir, const char* file); |
30 | 32 |
31 // Generate the URL for testing a particular test. | 33 // Generate the URL for testing a particular test. |
32 // HTML for the tests is all located in | 34 // HTML for the tests is all located in |
33 // test_root_directory/dir/<file> | 35 // test_root_directory/dir/<file> |
34 // The returned path is GURL format. | 36 // The returned path is GURL format. |
35 GURL GetTestUrl(const char* dir, const char* file); | 37 GURL GetTestUrl(const char* dir, const char* file); |
36 | 38 |
37 // Navigates the selected tab of |window| to |url|, blocking until the | 39 // Navigates the selected tab of |window| to |url|, blocking until the |
38 // navigation finishes. | 40 // navigation finishes. |
39 void NavigateToURL(Shell* window, const GURL& url); | 41 void NavigateToURL(Shell* window, const GURL& url); |
40 | 42 |
41 // Navigates the selected tab of |window| to |url|, blocking until the given | 43 // Navigates the selected tab of |window| to |url|, blocking until the given |
42 // number of navigations finishes. | 44 // number of navigations finishes. |
43 void NavigateToURLBlockUntilNavigationsComplete(Shell* window, | 45 void NavigateToURLBlockUntilNavigationsComplete(Shell* window, |
44 const GURL& url, | 46 const GURL& url, |
45 int number_of_navigations); | 47 int number_of_navigations); |
46 | 48 |
47 // Wait until an application modal dialog is requested. | 49 // Wait until an application modal dialog is requested. |
48 void WaitForAppModalDialog(Shell* window); | 50 void WaitForAppModalDialog(Shell* window); |
49 | 51 |
| 52 // Used to wait for a new Shell window to be created. Instantiate this object |
| 53 // before the operation that will create the window. |
| 54 class ShellAddedObserver { |
| 55 public: |
| 56 ShellAddedObserver(); |
| 57 ~ShellAddedObserver(); |
| 58 |
| 59 // Will run a message loop to wait for the new window if it hasn't been |
| 60 // created since the constructor. |
| 61 Shell* GetShell(); |
| 62 |
| 63 private: |
| 64 void ShellCreated(Shell* shell); |
| 65 |
| 66 Shell* shell_; |
| 67 scoped_refptr<MessageLoopRunner> runner_; |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(ShellAddedObserver); |
| 70 }; |
| 71 |
50 #if defined OS_MACOSX | 72 #if defined OS_MACOSX |
51 void SetWindowBounds(gfx::NativeWindow window, const gfx::Rect& bounds); | 73 void SetWindowBounds(gfx::NativeWindow window, const gfx::Rect& bounds); |
52 #endif | 74 #endif |
53 | 75 |
54 } // namespace content | 76 } // namespace content |
55 | 77 |
56 #endif // CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_H_ | 78 #endif // CONTENT_TEST_CONTENT_BROWSER_TEST_UTILS_H_ |
OLD | NEW |