Chromium Code Reviews| 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/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "content/public/browser/web_contents_delegate.h" | |
| 11 #include "content/public/common/page_type.h" | 12 #include "content/public/common/page_type.h" |
| 12 #include "ui/gfx/native_widget_types.h" | 13 #include "ui/gfx/native_widget_types.h" |
| 13 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 14 | 15 |
| 15 namespace base { | 16 namespace base { |
| 16 class FilePath; | 17 class FilePath; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace gfx { | 20 namespace gfx { |
| 20 class Rect; | 21 class Rect; |
| 21 } | 22 } |
| 22 | 23 |
| 23 // A collections of functions designed for use with content_shell based browser | 24 // A collections of functions designed for use with content_shell based browser |
| 24 // tests. | 25 // tests. |
| 25 // Note: if a function here also works with browser_tests, it should be in | 26 // Note: if a function here also works with browser_tests, it should be in |
| 26 // content\public\test\browser_test_utils.h | 27 // content\public\test\browser_test_utils.h |
| 27 | 28 |
| 28 namespace content { | 29 namespace content { |
| 29 | 30 |
| 30 class MessageLoopRunner; | 31 class MessageLoopRunner; |
| 31 class Shell; | 32 class Shell; |
| 33 class WebContents; | |
| 32 | 34 |
| 33 // Generate the file path for testing a particular test. | 35 // Generate the file path for testing a particular test. |
| 34 // The file for the tests is all located in | 36 // The file for the tests is all located in |
| 35 // content/test/data/dir/<file> | 37 // content/test/data/dir/<file> |
| 36 // The returned path is FilePath format. | 38 // The returned path is FilePath format. |
| 37 base::FilePath GetTestFilePath(const char* dir, const char* file); | 39 base::FilePath GetTestFilePath(const char* dir, const char* file); |
| 38 | 40 |
| 39 // Generate the URL for testing a particular test. | 41 // Generate the URL for testing a particular test. |
| 40 // HTML for the tests is all located in | 42 // HTML for the tests is all located in |
| 41 // test_root_directory/dir/<file> | 43 // test_root_directory/dir/<file> |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 | 93 |
| 92 private: | 94 private: |
| 93 void ShellCreated(Shell* shell); | 95 void ShellCreated(Shell* shell); |
| 94 | 96 |
| 95 Shell* shell_; | 97 Shell* shell_; |
| 96 scoped_refptr<MessageLoopRunner> runner_; | 98 scoped_refptr<MessageLoopRunner> runner_; |
| 97 | 99 |
| 98 DISALLOW_COPY_AND_ASSIGN(ShellAddedObserver); | 100 DISALLOW_COPY_AND_ASSIGN(ShellAddedObserver); |
| 99 }; | 101 }; |
| 100 | 102 |
| 103 // A WebContentsDelegate that catches messages sent to the console. | |
| 104 class ConsoleObserverDelegate : public WebContentsDelegate { | |
| 105 public: | |
| 106 ConsoleObserverDelegate(WebContents* web_contents, const std::string& filter); | |
| 107 | |
| 108 ~ConsoleObserverDelegate() override; | |
|
Charlie Reis
2016/05/24 22:54:17
nit: No blank line above.
meacer
2016/05/31 23:57:54
Done.
| |
| 109 | |
| 110 bool AddMessageToConsole(WebContents* source, | |
|
Charlie Reis
2016/05/24 22:54:17
nit: // WebContentsDelegate overrides.
meacer
2016/05/31 23:57:54
Done.
| |
| 111 int32_t level, | |
| 112 const base::string16& message, | |
| 113 int32_t line_no, | |
| 114 const base::string16& source_id) override; | |
| 115 | |
| 116 std::string message() { return message_; } | |
|
Charlie Reis
2016/05/24 22:54:17
nit: This is now a public interface, so it needs c
meacer
2016/05/31 23:57:54
Done.
| |
| 117 | |
| 118 void Wait(); | |
|
Charlie Reis
2016/05/24 22:54:17
// Wait for the next message sent to the console.
meacer
2016/05/31 23:57:54
Done.
| |
| 119 | |
| 120 private: | |
| 121 WebContents* web_contents_; | |
| 122 std::string filter_; | |
| 123 std::string message_; | |
| 124 | |
| 125 // The MessageLoopRunner used to spin the message loop. | |
| 126 scoped_refptr<MessageLoopRunner> message_loop_runner_; | |
| 127 | |
| 128 DISALLOW_COPY_AND_ASSIGN(ConsoleObserverDelegate); | |
| 129 }; | |
| 130 | |
| 101 #if defined OS_MACOSX | 131 #if defined OS_MACOSX |
| 102 void SetWindowBounds(gfx::NativeWindow window, const gfx::Rect& bounds); | 132 void SetWindowBounds(gfx::NativeWindow window, const gfx::Rect& bounds); |
| 103 #endif | 133 #endif |
| 104 | 134 |
| 105 } // namespace content | 135 } // namespace content |
| 106 | 136 |
| 107 #endif // CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_UTILS_H_ | 137 #endif // CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_UTILS_H_ |
| OLD | NEW |