Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Side by Side Diff: content/shell/browser/layout_test/blink_test_controller.cc

Issue 2742623002: DevTools: improve test infrastructure w/ devtools driving the test (Closed)
Patch Set: fixup Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "content/shell/browser/layout_test/blink_test_controller.h" 5 #include "content/shell/browser/layout_test/blink_test_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <iostream> 9 #include <iostream>
10 #include <set> 10 #include <set>
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 } 222 }
223 223
224 BlinkTestController::BlinkTestController() 224 BlinkTestController::BlinkTestController()
225 : main_window_(NULL), 225 : main_window_(NULL),
226 test_phase_(BETWEEN_TESTS), 226 test_phase_(BETWEEN_TESTS),
227 is_leak_detection_enabled_( 227 is_leak_detection_enabled_(
228 base::CommandLine::ForCurrentProcess()->HasSwitch( 228 base::CommandLine::ForCurrentProcess()->HasSwitch(
229 switches::kEnableLeakDetection)), 229 switches::kEnableLeakDetection)),
230 crash_when_leak_found_(false), 230 crash_when_leak_found_(false),
231 devtools_frontend_(NULL), 231 devtools_frontend_(NULL),
232 inspected_window_(NULL),
dgozman 2017/03/10 00:17:17 nullptr
232 render_process_host_observer_(this) { 233 render_process_host_observer_(this) {
233 CHECK(!instance_); 234 CHECK(!instance_);
234 instance_ = this; 235 instance_ = this;
235 236
236 if (is_leak_detection_enabled_) { 237 if (is_leak_detection_enabled_) {
237 std::string switchValue = 238 std::string switchValue =
238 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 239 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
239 switches::kEnableLeakDetection); 240 switches::kEnableLeakDetection);
240 crash_when_leak_found_ = switchValue == switches::kCrashOnFailure; 241 crash_when_leak_found_ = switchValue == switches::kCrashOnFailure;
241 } 242 }
(...skipping 24 matching lines...) Expand all
266 bool enable_pixel_dumping, 267 bool enable_pixel_dumping,
267 const std::string& expected_pixel_hash) { 268 const std::string& expected_pixel_hash) {
268 DCHECK(CalledOnValidThread()); 269 DCHECK(CalledOnValidThread());
269 test_phase_ = DURING_TEST; 270 test_phase_ = DURING_TEST;
270 current_working_directory_ = current_working_directory; 271 current_working_directory_ = current_working_directory;
271 enable_pixel_dumping_ = enable_pixel_dumping; 272 enable_pixel_dumping_ = enable_pixel_dumping;
272 expected_pixel_hash_ = expected_pixel_hash; 273 expected_pixel_hash_ = expected_pixel_hash;
273 if (test_url.spec().find("/inspector-unit/") == std::string::npos) 274 if (test_url.spec().find("/inspector-unit/") == std::string::npos)
274 test_url_ = test_url; 275 test_url_ = test_url;
275 else 276 else
276 test_url_ = LayoutTestDevToolsFrontend::MapJSTestURL(test_url); 277 test_url_ = LayoutTestDevToolsFrontend::MapUnitTestURL(test_url);
277 did_send_initial_test_configuration_ = false; 278 did_send_initial_test_configuration_ = false;
278 printer_->reset(); 279 printer_->reset();
279 frame_to_layout_dump_map_.clear(); 280 frame_to_layout_dump_map_.clear();
280 render_process_host_observer_.RemoveAll(); 281 render_process_host_observer_.RemoveAll();
281 all_observed_render_process_hosts_.clear(); 282 all_observed_render_process_hosts_.clear();
282 main_window_render_process_hosts_.clear(); 283 main_window_render_process_hosts_.clear();
283 accumulated_layout_test_runtime_flags_changes_.Clear(); 284 accumulated_layout_test_runtime_flags_changes_.Clear();
284 layout_test_control_map_.clear(); 285 layout_test_control_map_.clear();
285 ShellBrowserContext* browser_context = 286 ShellBrowserContext* browser_context =
286 ShellContentBrowserClient::Get()->browser_context(); 287 ShellContentBrowserClient::Get()->browser_context();
287 is_compositing_test_ = 288 is_compositing_test_ =
288 test_url_.spec().find("compositing/") != std::string::npos; 289 test_url_.spec().find("compositing/") != std::string::npos;
289 initial_size_ = Shell::GetShellDefaultSize(); 290 initial_size_ = Shell::GetShellDefaultSize();
290 // The W3C SVG layout tests use a different size than the other layout tests. 291 // The W3C SVG layout tests use a different size than the other layout tests.
291 if (test_url_.spec().find("W3C-SVG-1.1") != std::string::npos) 292 if (test_url_.spec().find("W3C-SVG-1.1") != std::string::npos)
292 initial_size_ = gfx::Size(kTestSVGWindowWidthDip, kTestSVGWindowHeightDip); 293 initial_size_ = gfx::Size(kTestSVGWindowWidthDip, kTestSVGWindowHeightDip);
293 if (!main_window_) { 294 if (test_url_.spec().find("/devtools-js/") != std::string::npos) {
295 if (devtools_frontend_ && inspected_window_) {
296 inspected_window_->LoadURL(GURL(url::kAboutBlankURL));
dgozman 2017/03/10 00:17:17 Did we detach at the end of previous test? It woul
297 test_url_ = LayoutTestDevToolsFrontend::MapIntegrationTestURL(test_url);
298 main_window_->LoadURL(test_url_);
299 } else {
300 inspected_window_ = content::Shell::CreateNewWindow(
301 browser_context, GURL(), NULL, initial_size_);
302 inspected_window_->LoadURL(GURL(url::kAboutBlankURL));
303 devtools_frontend_ = LayoutTestDevToolsFrontend::CreateDevToolsMainWindow(
304 *inspected_window_, test_url_.spec());
305 main_window_ = devtools_frontend_->frontend_shell();
306 test_url_ = LayoutTestDevToolsFrontend::MapIntegrationTestURL(test_url);
307 WebContentsObserver::Observe(main_window_->web_contents());
308 current_pid_ = base::kNullProcessId;
309 default_prefs_ = main_window_->web_contents()
310 ->GetRenderViewHost()
311 ->GetWebkitPreferences();
312 main_window_->LoadURL(test_url_);
313 }
314 } else if (!main_window_) {
294 main_window_ = content::Shell::CreateNewWindow( 315 main_window_ = content::Shell::CreateNewWindow(
295 browser_context, 316 browser_context,
296 GURL(), 317 GURL(),
297 NULL, 318 NULL,
298 initial_size_); 319 initial_size_);
299 WebContentsObserver::Observe(main_window_->web_contents()); 320 WebContentsObserver::Observe(main_window_->web_contents());
300 current_pid_ = base::kNullProcessId; 321 current_pid_ = base::kNullProcessId;
301 default_prefs_ = 322 default_prefs_ =
302 main_window_->web_contents()->GetRenderViewHost()->GetWebkitPreferences(); 323 main_window_->web_contents()->GetRenderViewHost()->GetWebkitPreferences();
303 main_window_->LoadURL(test_url_); 324 main_window_->LoadURL(test_url_);
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 session_histories, 897 session_histories,
877 current_entry_indexes)); 898 current_entry_indexes));
878 } 899 }
879 900
880 void BlinkTestController::OnCloseRemainingWindows() { 901 void BlinkTestController::OnCloseRemainingWindows() {
881 DevToolsAgentHost::DetachAllClients(); 902 DevToolsAgentHost::DetachAllClients();
882 std::vector<Shell*> open_windows(Shell::windows()); 903 std::vector<Shell*> open_windows(Shell::windows());
883 Shell* devtools_shell = devtools_frontend_ ? 904 Shell* devtools_shell = devtools_frontend_ ?
884 devtools_frontend_->frontend_shell() : NULL; 905 devtools_frontend_->frontend_shell() : NULL;
885 for (size_t i = 0; i < open_windows.size(); ++i) { 906 for (size_t i = 0; i < open_windows.size(); ++i) {
886 if (open_windows[i] != main_window_ && open_windows[i] != devtools_shell) 907 if (open_windows[i] != main_window_ && open_windows[i] != devtools_shell &&
908 open_windows[i] != inspected_window_)
887 open_windows[i]->Close(); 909 open_windows[i]->Close();
888 } 910 }
889 base::RunLoop().RunUntilIdle(); 911 base::RunLoop().RunUntilIdle();
890 } 912 }
891 913
892 void BlinkTestController::OnResetDone() { 914 void BlinkTestController::OnResetDone() {
893 if (is_leak_detection_enabled_) { 915 if (is_leak_detection_enabled_) {
894 if (main_window_ && main_window_->web_contents()) { 916 if (main_window_ && main_window_->web_contents()) {
895 RenderViewHost* render_view_host = 917 RenderViewHost* render_view_host =
896 main_window_->web_contents()->GetRenderViewHost(); 918 main_window_->web_contents()->GetRenderViewHost();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 } 997 }
976 DCHECK(layout_test_control_map_[frame].get()); 998 DCHECK(layout_test_control_map_[frame].get());
977 return layout_test_control_map_[frame].get(); 999 return layout_test_control_map_[frame].get();
978 } 1000 }
979 1001
980 void BlinkTestController::HandleLayoutTestControlError(RenderFrameHost* frame) { 1002 void BlinkTestController::HandleLayoutTestControlError(RenderFrameHost* frame) {
981 layout_test_control_map_.erase(frame); 1003 layout_test_control_map_.erase(frame);
982 } 1004 }
983 1005
984 } // namespace content 1006 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698