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_LAYOUT_TEST_BLINK_TEST_CONTROLLER_H_ | 5 #ifndef CONTENT_SHELL_BROWSER_LAYOUT_TEST_BLINK_TEST_CONTROLLER_H_ |
6 #define CONTENT_SHELL_BROWSER_LAYOUT_TEST_BLINK_TEST_CONTROLLER_H_ | 6 #define CONTENT_SHELL_BROWSER_LAYOUT_TEST_BLINK_TEST_CONTROLLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <ostream> | 10 #include <ostream> |
11 #include <set> | |
11 #include <string> | 12 #include <string> |
12 | 13 |
13 #include "base/cancelable_callback.h" | 14 #include "base/cancelable_callback.h" |
14 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
15 #include "base/macros.h" | 16 #include "base/macros.h" |
16 #include "base/scoped_observer.h" | 17 #include "base/scoped_observer.h" |
17 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
18 #include "base/threading/non_thread_safe.h" | 19 #include "base/threading/non_thread_safe.h" |
19 #include "base/values.h" | 20 #include "base/values.h" |
20 #include "build/build_config.h" | 21 #include "build/build_config.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 ~BlinkTestController() override; | 127 ~BlinkTestController() override; |
127 | 128 |
128 // True if the controller is ready for testing. | 129 // True if the controller is ready for testing. |
129 bool PrepareForLayoutTest(const GURL& test_url, | 130 bool PrepareForLayoutTest(const GURL& test_url, |
130 const base::FilePath& current_working_directory, | 131 const base::FilePath& current_working_directory, |
131 bool enable_pixel_dumping, | 132 bool enable_pixel_dumping, |
132 const std::string& expected_pixel_hash); | 133 const std::string& expected_pixel_hash); |
133 // True if the controller was reset successfully. | 134 // True if the controller was reset successfully. |
134 bool ResetAfterLayoutTest(); | 135 bool ResetAfterLayoutTest(); |
135 | 136 |
137 // Makes sure that the potentially new renderer associated with |frame| is 1) | |
138 // initialized for the test, 2) kept-up-to-date wrt test flags and 3) | |
139 // monitored for crashes. | |
140 void HandleNewRenderFrameHost(RenderFrameHost* frame); | |
141 | |
136 void SetTempPath(const base::FilePath& temp_path); | 142 void SetTempPath(const base::FilePath& temp_path); |
137 void RendererUnresponsive(); | 143 void RendererUnresponsive(); |
138 void OverrideWebkitPrefs(WebPreferences* prefs); | 144 void OverrideWebkitPrefs(WebPreferences* prefs); |
139 void OpenURL(const GURL& url); | 145 void OpenURL(const GURL& url); |
140 void TestFinishedInSecondaryRenderer(); | 146 void TestFinishedInSecondaryRenderer(); |
141 bool IsMainWindow(WebContents* web_contents) const; | 147 bool IsMainWindow(WebContents* web_contents) const; |
142 std::unique_ptr<BluetoothChooser> RunBluetoothChooser( | 148 std::unique_ptr<BluetoothChooser> RunBluetoothChooser( |
143 RenderFrameHost* frame, | 149 RenderFrameHost* frame, |
144 const BluetoothChooser::EventHandler& event_handler); | 150 const BluetoothChooser::EventHandler& event_handler); |
145 | 151 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 private: | 183 private: |
178 enum TestPhase { | 184 enum TestPhase { |
179 BETWEEN_TESTS, | 185 BETWEEN_TESTS, |
180 DURING_TEST, | 186 DURING_TEST, |
181 CLEAN_UP | 187 CLEAN_UP |
182 }; | 188 }; |
183 | 189 |
184 static BlinkTestController* instance_; | 190 static BlinkTestController* instance_; |
185 | 191 |
186 void DiscardMainWindow(); | 192 void DiscardMainWindow(); |
187 void HandleNewRenderFrameHost( | |
188 RenderFrameHost* frame_representing_target_process); | |
189 | 193 |
190 // Message handlers. | 194 // Message handlers. |
191 void OnAudioDump(const std::vector<unsigned char>& audio_dump); | 195 void OnAudioDump(const std::vector<unsigned char>& audio_dump); |
192 void OnImageDump(const std::string& actual_pixel_hash, const SkBitmap& image); | 196 void OnImageDump(const std::string& actual_pixel_hash, const SkBitmap& image); |
193 void OnTextDump(const std::string& dump); | 197 void OnTextDump(const std::string& dump); |
194 void OnInitiateLayoutDump(); | 198 void OnInitiateLayoutDump(); |
195 void OnLayoutTestRuntimeFlagsChanged( | 199 void OnLayoutTestRuntimeFlagsChanged( |
196 RenderFrameHost* sender, | 200 RenderFrameHost* sender, |
197 const base::DictionaryValue& changed_layout_test_runtime_flags); | 201 const base::DictionaryValue& changed_layout_test_runtime_flags); |
198 void OnLayoutDumpResponse(RenderFrameHost* sender, const std::string& dump); | 202 void OnLayoutDumpResponse(RenderFrameHost* sender, const std::string& dump); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 std::unique_ptr<LayoutTestBluetoothChooserFactory> bluetooth_chooser_factory_; | 263 std::unique_ptr<LayoutTestBluetoothChooserFactory> bluetooth_chooser_factory_; |
260 | 264 |
261 // Map from frame_tree_node_id into frame-specific dumps. | 265 // Map from frame_tree_node_id into frame-specific dumps. |
262 std::map<int, std::string> frame_to_layout_dump_map_; | 266 std::map<int, std::string> frame_to_layout_dump_map_; |
263 // Number of ShellViewHostMsg_LayoutDumpResponse messages we are waiting for. | 267 // Number of ShellViewHostMsg_LayoutDumpResponse messages we are waiting for. |
264 int pending_layout_dumps_; | 268 int pending_layout_dumps_; |
265 | 269 |
266 // Renderer processes are observed to detect crashes. | 270 // Renderer processes are observed to detect crashes. |
267 ScopedObserver<RenderProcessHost, RenderProcessHostObserver> | 271 ScopedObserver<RenderProcessHost, RenderProcessHostObserver> |
268 render_process_host_observer_; | 272 render_process_host_observer_; |
273 std::set<RenderProcessHost*> all_observed_render_process_hosts_; | |
Łukasz Anforowicz
2016/04/15 20:15:29
This field is somewhat redundant - render_process_
| |
274 std::set<RenderProcessHost*> main_window_render_process_hosts_; | |
269 | 275 |
270 // Changes reported by OnLayoutTestRuntimeFlagsChanged that have accumulated | 276 // Changes reported by OnLayoutTestRuntimeFlagsChanged that have accumulated |
271 // since PrepareForLayoutTest (i.e. changes that need to be send to a fresh | 277 // since PrepareForLayoutTest (i.e. changes that need to be send to a fresh |
272 // renderer created while test is in progress). | 278 // renderer created while test is in progress). |
273 base::DictionaryValue accumulated_layout_test_runtime_flags_changes_; | 279 base::DictionaryValue accumulated_layout_test_runtime_flags_changes_; |
274 | 280 |
275 #if defined(OS_ANDROID) | 281 #if defined(OS_ANDROID) |
276 // Because of the nested message pump implementation, Android needs to allow | 282 // Because of the nested message pump implementation, Android needs to allow |
277 // waiting on the UI thread while layout tests are being ran. | 283 // waiting on the UI thread while layout tests are being ran. |
278 ScopedAllowWaitForAndroidLayoutTests reduced_restrictions_; | 284 ScopedAllowWaitForAndroidLayoutTests reduced_restrictions_; |
279 #endif | 285 #endif |
280 | 286 |
281 DISALLOW_COPY_AND_ASSIGN(BlinkTestController); | 287 DISALLOW_COPY_AND_ASSIGN(BlinkTestController); |
282 }; | 288 }; |
283 | 289 |
284 } // namespace content | 290 } // namespace content |
285 | 291 |
286 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_BLINK_TEST_CONTROLLER_H_ | 292 #endif // CONTENT_SHELL_BROWSER_LAYOUT_TEST_BLINK_TEST_CONTROLLER_H_ |
OLD | NEW |