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 url { | 35 namespace url { |
34 class Origin; | 36 class Origin; |
35 } | 37 } |
36 | 38 |
37 namespace content { | 39 namespace content { |
38 | 40 |
39 class LayoutTestBluetoothChooserFactory; | 41 class LayoutTestBluetoothChooserFactory; |
40 class LayoutTestDevToolsFrontend; | 42 class LayoutTestDevToolsFrontend; |
| 43 class RenderFrameHost; |
41 class Shell; | 44 class Shell; |
42 | 45 |
43 #if defined(OS_ANDROID) | 46 #if defined(OS_ANDROID) |
44 // Android uses a nested message loop for running layout tests because the | 47 // Android uses a nested message loop for running layout tests because the |
45 // default message loop, provided by the system, does not offer a blocking | 48 // default message loop, provided by the system, does not offer a blocking |
46 // Run() method. The loop itself, implemented as NestedMessagePumpAndroid, | 49 // Run() method. The loop itself, implemented as NestedMessagePumpAndroid, |
47 // uses a base::WaitableEvent allowing it to sleep until more events arrive. | 50 // uses a base::WaitableEvent allowing it to sleep until more events arrive. |
48 class ScopedAllowWaitForAndroidLayoutTests { | 51 class ScopedAllowWaitForAndroidLayoutTests { |
49 private: | 52 private: |
50 base::ThreadRestrictions::ScopedAllowWait wait; | 53 base::ThreadRestrictions::ScopedAllowWait wait; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 const BluetoothChooser::EventHandler& event_handler, | 140 const BluetoothChooser::EventHandler& event_handler, |
138 const url::Origin& origin); | 141 const url::Origin& origin); |
139 | 142 |
140 BlinkTestResultPrinter* printer() { return printer_.get(); } | 143 BlinkTestResultPrinter* printer() { return printer_.get(); } |
141 void set_printer(BlinkTestResultPrinter* printer) { printer_.reset(printer); } | 144 void set_printer(BlinkTestResultPrinter* printer) { printer_.reset(printer); } |
142 | 145 |
143 void DevToolsProcessCrashed(); | 146 void DevToolsProcessCrashed(); |
144 | 147 |
145 // WebContentsObserver implementation. | 148 // WebContentsObserver implementation. |
146 bool OnMessageReceived(const IPC::Message& message) override; | 149 bool OnMessageReceived(const IPC::Message& message) override; |
| 150 bool OnMessageReceived(const IPC::Message& message, |
| 151 RenderFrameHost* render_frame_host) override; |
147 void PluginCrashed(const base::FilePath& plugin_path, | 152 void PluginCrashed(const base::FilePath& plugin_path, |
148 base::ProcessId plugin_pid) override; | 153 base::ProcessId plugin_pid) override; |
149 void RenderViewCreated(RenderViewHost* render_view_host) override; | 154 void RenderViewCreated(RenderViewHost* render_view_host) override; |
150 void RenderProcessGone(base::TerminationStatus status) override; | 155 void RenderProcessGone(base::TerminationStatus status) override; |
151 void WebContentsDestroyed() override; | 156 void WebContentsDestroyed() override; |
152 | 157 |
153 // NotificationObserver implementation. | 158 // NotificationObserver implementation. |
154 void Observe(int type, | 159 void Observe(int type, |
155 const NotificationSource& source, | 160 const NotificationSource& source, |
156 const NotificationDetails& details) override; | 161 const NotificationDetails& details) override; |
(...skipping 10 matching lines...) Expand all Loading... |
167 | 172 |
168 static BlinkTestController* instance_; | 173 static BlinkTestController* instance_; |
169 | 174 |
170 void DiscardMainWindow(); | 175 void DiscardMainWindow(); |
171 void SendTestConfiguration(); | 176 void SendTestConfiguration(); |
172 | 177 |
173 // Message handlers. | 178 // Message handlers. |
174 void OnAudioDump(const std::vector<unsigned char>& audio_dump); | 179 void OnAudioDump(const std::vector<unsigned char>& audio_dump); |
175 void OnImageDump(const std::string& actual_pixel_hash, const SkBitmap& image); | 180 void OnImageDump(const std::string& actual_pixel_hash, const SkBitmap& image); |
176 void OnTextDump(const std::string& dump); | 181 void OnTextDump(const std::string& dump); |
| 182 void OnInitiateLayoutDump(test_runner::LayoutDumpFlags layout_dump_flags); |
| 183 void OnLayoutDumpResponse(RenderFrameHost* sender, const std::string& dump); |
177 void OnPrintMessage(const std::string& message); | 184 void OnPrintMessage(const std::string& message); |
178 void OnOverridePreferences(const WebPreferences& prefs); | 185 void OnOverridePreferences(const WebPreferences& prefs); |
179 void OnTestFinished(); | 186 void OnTestFinished(); |
180 void OnClearDevToolsLocalStorage(); | 187 void OnClearDevToolsLocalStorage(); |
181 void OnShowDevTools(const std::string& settings, | 188 void OnShowDevTools(const std::string& settings, |
182 const std::string& frontend_url); | 189 const std::string& frontend_url); |
183 void OnCloseDevTools(); | 190 void OnCloseDevTools(); |
184 void OnGoToOffset(int offset); | 191 void OnGoToOffset(int offset); |
185 void OnReload(); | 192 void OnReload(); |
186 void OnLoadURLForFrame(const GURL& url, const std::string& frame_name); | 193 void OnLoadURLForFrame(const GURL& url, const std::string& frame_name); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 | 233 |
227 NotificationRegistrar registrar_; | 234 NotificationRegistrar registrar_; |
228 | 235 |
229 const bool is_leak_detection_enabled_; | 236 const bool is_leak_detection_enabled_; |
230 bool crash_when_leak_found_; | 237 bool crash_when_leak_found_; |
231 | 238 |
232 LayoutTestDevToolsFrontend* devtools_frontend_; | 239 LayoutTestDevToolsFrontend* devtools_frontend_; |
233 | 240 |
234 scoped_ptr<LayoutTestBluetoothChooserFactory> bluetooth_chooser_factory_; | 241 scoped_ptr<LayoutTestBluetoothChooserFactory> bluetooth_chooser_factory_; |
235 | 242 |
| 243 // Map from frame_tree_node_id into frame-specific dumps. |
| 244 std::map<int, std::string> frame_to_layout_dump_map_; |
| 245 // Number of ShellViewHostMsg_LayoutDumpResponse messages we are waiting for. |
| 246 int pending_layout_dumps_; |
| 247 |
236 #if defined(OS_ANDROID) | 248 #if defined(OS_ANDROID) |
237 // Because of the nested message pump implementation, Android needs to allow | 249 // Because of the nested message pump implementation, Android needs to allow |
238 // waiting on the UI thread while layout tests are being ran. | 250 // waiting on the UI thread while layout tests are being ran. |
239 ScopedAllowWaitForAndroidLayoutTests reduced_restrictions_; | 251 ScopedAllowWaitForAndroidLayoutTests reduced_restrictions_; |
240 #endif | 252 #endif |
241 | 253 |
242 DISALLOW_COPY_AND_ASSIGN(BlinkTestController); | 254 DISALLOW_COPY_AND_ASSIGN(BlinkTestController); |
243 }; | 255 }; |
244 | 256 |
245 } // namespace content | 257 } // namespace content |
246 | 258 |
247 #endif // CONTENT_SHELL_BROWSER_BLINK_TEST_CONTROLLER_H_ | 259 #endif // CONTENT_SHELL_BROWSER_BLINK_TEST_CONTROLLER_H_ |
OLD | NEW |