OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_SHELL_BROWSER_BLINK_TEST_CONTROLLER_H_ | 5 #ifndef CONTENT_SHELL_BROWSER_BLINK_TEST_CONTROLLER_H_ |
6 #define CONTENT_SHELL_BROWSER_BLINK_TEST_CONTROLLER_H_ | 6 #define CONTENT_SHELL_BROWSER_BLINK_TEST_CONTROLLER_H_ |
7 | 7 |
| 8 #include <map> |
8 #include <ostream> | 9 #include <ostream> |
9 #include <string> | 10 #include <string> |
10 | 11 |
11 #include "base/cancelable_callback.h" | 12 #include "base/cancelable_callback.h" |
12 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
16 #include "base/threading/non_thread_safe.h" | 17 #include "base/threading/non_thread_safe.h" |
17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "components/test_runner/layout_dump_flags.h" |
18 #include "content/public/browser/bluetooth_chooser.h" | 20 #include "content/public/browser/bluetooth_chooser.h" |
19 #include "content/public/browser/gpu_data_manager_observer.h" | 21 #include "content/public/browser/gpu_data_manager_observer.h" |
20 #include "content/public/browser/notification_observer.h" | 22 #include "content/public/browser/notification_observer.h" |
21 #include "content/public/browser/notification_registrar.h" | 23 #include "content/public/browser/notification_registrar.h" |
22 #include "content/public/browser/web_contents_observer.h" | 24 #include "content/public/browser/web_contents_observer.h" |
23 #include "content/public/common/web_preferences.h" | 25 #include "content/public/common/web_preferences.h" |
24 #include "content/shell/common/leak_detection_result.h" | 26 #include "content/shell/common/leak_detection_result.h" |
25 #include "ui/gfx/geometry/size.h" | 27 #include "ui/gfx/geometry/size.h" |
26 | 28 |
27 #if defined(OS_ANDROID) | 29 #if defined(OS_ANDROID) |
28 #include "base/threading/thread_restrictions.h" | 30 #include "base/threading/thread_restrictions.h" |
29 #endif | 31 #endif |
30 | 32 |
31 class SkBitmap; | 33 class SkBitmap; |
32 | 34 |
33 namespace content { | 35 namespace content { |
34 | 36 |
35 class LayoutTestBluetoothChooserFactory; | 37 class LayoutTestBluetoothChooserFactory; |
36 class LayoutTestDevToolsFrontend; | 38 class LayoutTestDevToolsFrontend; |
| 39 class RenderFrameHost; |
37 class Shell; | 40 class Shell; |
38 | 41 |
39 #if defined(OS_ANDROID) | 42 #if defined(OS_ANDROID) |
40 // Android uses a nested message loop for running layout tests because the | 43 // Android uses a nested message loop for running layout tests because the |
41 // default message loop, provided by the system, does not offer a blocking | 44 // default message loop, provided by the system, does not offer a blocking |
42 // Run() method. The loop itself, implemented as NestedMessagePumpAndroid, | 45 // Run() method. The loop itself, implemented as NestedMessagePumpAndroid, |
43 // uses a base::WaitableEvent allowing it to sleep until more events arrive. | 46 // uses a base::WaitableEvent allowing it to sleep until more events arrive. |
44 class ScopedAllowWaitForAndroidLayoutTests { | 47 class ScopedAllowWaitForAndroidLayoutTests { |
45 private: | 48 private: |
46 base::ThreadRestrictions::ScopedAllowWait wait; | 49 base::ThreadRestrictions::ScopedAllowWait wait; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 const BluetoothChooser::EventHandler& event_handler, | 136 const BluetoothChooser::EventHandler& event_handler, |
134 const GURL& origin); | 137 const GURL& origin); |
135 | 138 |
136 BlinkTestResultPrinter* printer() { return printer_.get(); } | 139 BlinkTestResultPrinter* printer() { return printer_.get(); } |
137 void set_printer(BlinkTestResultPrinter* printer) { printer_.reset(printer); } | 140 void set_printer(BlinkTestResultPrinter* printer) { printer_.reset(printer); } |
138 | 141 |
139 void DevToolsProcessCrashed(); | 142 void DevToolsProcessCrashed(); |
140 | 143 |
141 // WebContentsObserver implementation. | 144 // WebContentsObserver implementation. |
142 bool OnMessageReceived(const IPC::Message& message) override; | 145 bool OnMessageReceived(const IPC::Message& message) override; |
| 146 bool OnMessageReceived(const IPC::Message& message, |
| 147 RenderFrameHost* render_frame_host) override; |
143 void PluginCrashed(const base::FilePath& plugin_path, | 148 void PluginCrashed(const base::FilePath& plugin_path, |
144 base::ProcessId plugin_pid) override; | 149 base::ProcessId plugin_pid) override; |
145 void RenderViewCreated(RenderViewHost* render_view_host) override; | 150 void RenderViewCreated(RenderViewHost* render_view_host) override; |
146 void RenderProcessGone(base::TerminationStatus status) override; | 151 void RenderProcessGone(base::TerminationStatus status) override; |
147 void WebContentsDestroyed() override; | 152 void WebContentsDestroyed() override; |
148 | 153 |
149 // NotificationObserver implementation. | 154 // NotificationObserver implementation. |
150 void Observe(int type, | 155 void Observe(int type, |
151 const NotificationSource& source, | 156 const NotificationSource& source, |
152 const NotificationDetails& details) override; | 157 const NotificationDetails& details) override; |
(...skipping 10 matching lines...) Expand all Loading... |
163 | 168 |
164 static BlinkTestController* instance_; | 169 static BlinkTestController* instance_; |
165 | 170 |
166 void DiscardMainWindow(); | 171 void DiscardMainWindow(); |
167 void SendTestConfiguration(); | 172 void SendTestConfiguration(); |
168 | 173 |
169 // Message handlers. | 174 // Message handlers. |
170 void OnAudioDump(const std::vector<unsigned char>& audio_dump); | 175 void OnAudioDump(const std::vector<unsigned char>& audio_dump); |
171 void OnImageDump(const std::string& actual_pixel_hash, const SkBitmap& image); | 176 void OnImageDump(const std::string& actual_pixel_hash, const SkBitmap& image); |
172 void OnTextDump(const std::string& dump); | 177 void OnTextDump(const std::string& dump); |
| 178 void OnInitiateLayoutDump(test_runner::LayoutDumpFlags layout_dump_flags); |
| 179 void OnLayoutDumpResponse(RenderFrameHost* sender, const std::string& dump); |
173 void OnPrintMessage(const std::string& message); | 180 void OnPrintMessage(const std::string& message); |
174 void OnOverridePreferences(const WebPreferences& prefs); | 181 void OnOverridePreferences(const WebPreferences& prefs); |
175 void OnTestFinished(); | 182 void OnTestFinished(); |
176 void OnClearDevToolsLocalStorage(); | 183 void OnClearDevToolsLocalStorage(); |
177 void OnShowDevTools(const std::string& settings, | 184 void OnShowDevTools(const std::string& settings, |
178 const std::string& frontend_url); | 185 const std::string& frontend_url); |
179 void OnCloseDevTools(); | 186 void OnCloseDevTools(); |
180 void OnGoToOffset(int offset); | 187 void OnGoToOffset(int offset); |
181 void OnReload(); | 188 void OnReload(); |
182 void OnLoadURLForFrame(const GURL& url, const std::string& frame_name); | 189 void OnLoadURLForFrame(const GURL& url, const std::string& frame_name); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 229 |
223 NotificationRegistrar registrar_; | 230 NotificationRegistrar registrar_; |
224 | 231 |
225 const bool is_leak_detection_enabled_; | 232 const bool is_leak_detection_enabled_; |
226 bool crash_when_leak_found_; | 233 bool crash_when_leak_found_; |
227 | 234 |
228 LayoutTestDevToolsFrontend* devtools_frontend_; | 235 LayoutTestDevToolsFrontend* devtools_frontend_; |
229 | 236 |
230 scoped_ptr<LayoutTestBluetoothChooserFactory> bluetooth_chooser_factory_; | 237 scoped_ptr<LayoutTestBluetoothChooserFactory> bluetooth_chooser_factory_; |
231 | 238 |
| 239 // Map from frame_tree_node_id into frame-specific dumps. |
| 240 std::map<int, std::string> frame_to_layout_dump_map_; |
| 241 // Number of ShellViewHostMsg_LayoutDumpResponse messages we are waiting for. |
| 242 int pending_layout_dumps_; |
| 243 |
232 #if defined(OS_ANDROID) | 244 #if defined(OS_ANDROID) |
233 // Because of the nested message pump implementation, Android needs to allow | 245 // Because of the nested message pump implementation, Android needs to allow |
234 // waiting on the UI thread while layout tests are being ran. | 246 // waiting on the UI thread while layout tests are being ran. |
235 ScopedAllowWaitForAndroidLayoutTests reduced_restrictions_; | 247 ScopedAllowWaitForAndroidLayoutTests reduced_restrictions_; |
236 #endif | 248 #endif |
237 | 249 |
238 DISALLOW_COPY_AND_ASSIGN(BlinkTestController); | 250 DISALLOW_COPY_AND_ASSIGN(BlinkTestController); |
239 }; | 251 }; |
240 | 252 |
241 } // namespace content | 253 } // namespace content |
242 | 254 |
243 #endif // CONTENT_SHELL_BROWSER_BLINK_TEST_CONTROLLER_H_ | 255 #endif // CONTENT_SHELL_BROWSER_BLINK_TEST_CONTROLLER_H_ |
OLD | NEW |