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

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

Issue 2942573003: [DevTools] New harness for inspector-protocol layout tests (Closed)
Patch Set: unified Created 3 years, 6 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 26 matching lines...) Expand all
37 #include "content/public/browser/render_view_host.h" 37 #include "content/public/browser/render_view_host.h"
38 #include "content/public/browser/render_widget_host.h" 38 #include "content/public/browser/render_widget_host.h"
39 #include "content/public/browser/render_widget_host_view.h" 39 #include "content/public/browser/render_widget_host_view.h"
40 #include "content/public/browser/service_worker_context.h" 40 #include "content/public/browser/service_worker_context.h"
41 #include "content/public/browser/storage_partition.h" 41 #include "content/public/browser/storage_partition.h"
42 #include "content/public/browser/web_contents.h" 42 #include "content/public/browser/web_contents.h"
43 #include "content/public/common/associated_interface_provider.h" 43 #include "content/public/common/associated_interface_provider.h"
44 #include "content/public/common/bindings_policy.h" 44 #include "content/public/common/bindings_policy.h"
45 #include "content/public/common/content_switches.h" 45 #include "content/public/common/content_switches.h"
46 #include "content/public/common/url_constants.h" 46 #include "content/public/common/url_constants.h"
47 #include "content/shell/browser/layout_test/devtools_protocol_test_bindings.h"
47 #include "content/shell/browser/layout_test/layout_test_bluetooth_chooser_factor y.h" 48 #include "content/shell/browser/layout_test/layout_test_bluetooth_chooser_factor y.h"
48 #include "content/shell/browser/layout_test/layout_test_content_browser_client.h " 49 #include "content/shell/browser/layout_test/layout_test_content_browser_client.h "
49 #include "content/shell/browser/layout_test/layout_test_devtools_bindings.h" 50 #include "content/shell/browser/layout_test/layout_test_devtools_bindings.h"
50 #include "content/shell/browser/layout_test/layout_test_first_device_bluetooth_c hooser.h" 51 #include "content/shell/browser/layout_test/layout_test_first_device_bluetooth_c hooser.h"
51 #include "content/shell/browser/shell.h" 52 #include "content/shell/browser/shell.h"
52 #include "content/shell/browser/shell_browser_context.h" 53 #include "content/shell/browser/shell_browser_context.h"
53 #include "content/shell/browser/shell_content_browser_client.h" 54 #include "content/shell/browser/shell_content_browser_client.h"
54 #include "content/shell/browser/shell_devtools_frontend.h" 55 #include "content/shell/browser/shell_devtools_frontend.h"
55 #include "content/shell/common/layout_test/layout_test_messages.h" 56 #include "content/shell/common/layout_test/layout_test_messages.h"
56 #include "content/shell/common/layout_test/layout_test_switches.h" 57 #include "content/shell/common/layout_test/layout_test_switches.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 DiscardMainWindow(); 286 DiscardMainWindow();
286 instance_ = NULL; 287 instance_ = NULL;
287 } 288 }
288 289
289 bool BlinkTestController::PrepareForLayoutTest( 290 bool BlinkTestController::PrepareForLayoutTest(
290 const GURL& test_url, 291 const GURL& test_url,
291 const base::FilePath& current_working_directory, 292 const base::FilePath& current_working_directory,
292 bool enable_pixel_dumping, 293 bool enable_pixel_dumping,
293 const std::string& expected_pixel_hash) { 294 const std::string& expected_pixel_hash) {
294 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); 295 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
296 fprintf(stderr, "PrepareForLayoutTest: %s\n", test_url.spec().c_str());
295 test_phase_ = DURING_TEST; 297 test_phase_ = DURING_TEST;
296 current_working_directory_ = current_working_directory; 298 current_working_directory_ = current_working_directory;
297 enable_pixel_dumping_ = enable_pixel_dumping; 299 enable_pixel_dumping_ = enable_pixel_dumping;
298 expected_pixel_hash_ = expected_pixel_hash; 300 expected_pixel_hash_ = expected_pixel_hash;
299 if (test_url.spec().find("/inspector-unit/") == std::string::npos) 301 GURL devtools_protocol_test_url =
302 DevToolsProtocolTestBindings::GetProtocolTestURL(test_url);
303 if (!devtools_protocol_test_url.is_empty())
304 test_url_ = devtools_protocol_test_url;
305 else if (test_url.spec().find("/inspector-unit/") != std::string::npos)
306 test_url_ = LayoutTestDevToolsBindings::MapJSTestURL(test_url);
307 else
300 test_url_ = test_url; 308 test_url_ = test_url;
301 else
302 test_url_ = LayoutTestDevToolsBindings::MapJSTestURL(test_url);
303 did_send_initial_test_configuration_ = false; 309 did_send_initial_test_configuration_ = false;
304 printer_->reset(); 310 printer_->reset();
305 frame_to_layout_dump_map_.clear(); 311 frame_to_layout_dump_map_.clear();
306 render_process_host_observer_.RemoveAll(); 312 render_process_host_observer_.RemoveAll();
307 all_observed_render_process_hosts_.clear(); 313 all_observed_render_process_hosts_.clear();
308 main_window_render_process_hosts_.clear(); 314 main_window_render_process_hosts_.clear();
309 accumulated_layout_test_runtime_flags_changes_.Clear(); 315 accumulated_layout_test_runtime_flags_changes_.Clear();
310 layout_test_control_map_.clear(); 316 layout_test_control_map_.clear();
311 ShellBrowserContext* browser_context = 317 ShellBrowserContext* browser_context =
312 ShellContentBrowserClient::Get()->browser_context(); 318 ShellContentBrowserClient::Get()->browser_context();
313 is_compositing_test_ = 319 is_compositing_test_ =
314 test_url_.spec().find("compositing/") != std::string::npos; 320 test_url_.spec().find("compositing/") != std::string::npos;
315 initial_size_ = Shell::GetShellDefaultSize(); 321 initial_size_ = Shell::GetShellDefaultSize();
316 // The W3C SVG layout tests use a different size than the other layout tests. 322 // The W3C SVG layout tests use a different size than the other layout tests.
317 if (test_url_.spec().find("W3C-SVG-1.1") != std::string::npos) 323 if (test_url_.spec().find("W3C-SVG-1.1") != std::string::npos)
318 initial_size_ = gfx::Size(kTestSVGWindowWidthDip, kTestSVGWindowHeightDip); 324 initial_size_ = gfx::Size(kTestSVGWindowWidthDip, kTestSVGWindowHeightDip);
319 if (!main_window_) { 325 if (!main_window_) {
320 main_window_ = content::Shell::CreateNewWindow( 326 main_window_ = content::Shell::CreateNewWindow(
321 browser_context, 327 browser_context,
322 GURL(), 328 GURL(),
323 NULL, 329 NULL,
324 initial_size_); 330 initial_size_);
325 WebContentsObserver::Observe(main_window_->web_contents()); 331 WebContentsObserver::Observe(main_window_->web_contents());
332 if (!devtools_protocol_test_url.is_empty()) {
333 devtools_protocol_test_bindings_.reset(
334 new DevToolsProtocolTestBindings(main_window_->web_contents()));
335 }
326 current_pid_ = base::kNullProcessId; 336 current_pid_ = base::kNullProcessId;
327 default_prefs_ = 337 default_prefs_ =
328 main_window_->web_contents()->GetRenderViewHost()->GetWebkitPreferences(); 338 main_window_->web_contents()->GetRenderViewHost()->GetWebkitPreferences();
329 main_window_->LoadURL(test_url_); 339 main_window_->LoadURL(test_url_);
330 } else { 340 } else {
331 #if defined(OS_MACOSX) 341 #if defined(OS_MACOSX)
332 // Shell::SizeTo is not implemented on all platforms. 342 // Shell::SizeTo is not implemented on all platforms.
333 main_window_->SizeTo(initial_size_); 343 main_window_->SizeTo(initial_size_);
334 #endif 344 #endif
335 main_window_->web_contents() 345 main_window_->web_contents()
336 ->GetRenderViewHost() 346 ->GetRenderViewHost()
337 ->GetWidget() 347 ->GetWidget()
338 ->GetView() 348 ->GetView()
339 ->SetSize(initial_size_); 349 ->SetSize(initial_size_);
340 main_window_->web_contents() 350 main_window_->web_contents()
341 ->GetRenderViewHost() 351 ->GetRenderViewHost()
342 ->GetWidget() 352 ->GetWidget()
343 ->WasResized(); 353 ->WasResized();
344 RenderViewHost* render_view_host = 354 RenderViewHost* render_view_host =
345 main_window_->web_contents()->GetRenderViewHost(); 355 main_window_->web_contents()->GetRenderViewHost();
346 356
357 if (!devtools_protocol_test_url.is_empty()) {
358 devtools_protocol_test_bindings_.reset(
359 new DevToolsProtocolTestBindings(main_window_->web_contents()));
360 }
361
347 // Compositing tests override the default preferences (see 362 // Compositing tests override the default preferences (see
348 // BlinkTestController::OverrideWebkitPrefs) so we force them to be 363 // BlinkTestController::OverrideWebkitPrefs) so we force them to be
349 // calculated again to ensure is_compositing_test_ changes are picked up. 364 // calculated again to ensure is_compositing_test_ changes are picked up.
350 OverrideWebkitPrefs(&default_prefs_); 365 OverrideWebkitPrefs(&default_prefs_);
351 366
352 render_view_host->UpdateWebkitPreferences(default_prefs_); 367 render_view_host->UpdateWebkitPreferences(default_prefs_);
353 HandleNewRenderFrameHost(render_view_host->GetMainFrame()); 368 HandleNewRenderFrameHost(render_view_host->GetMainFrame());
354 369
355 NavigationController::LoadURLParams params(test_url_); 370 NavigationController::LoadURLParams params(test_url_);
356 params.transition_type = ui::PageTransitionFromInt( 371 params.transition_type = ui::PageTransitionFromInt(
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); 612 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
598 printer_->AddErrorMessage("#CRASHED - gpu"); 613 printer_->AddErrorMessage("#CRASHED - gpu");
599 DiscardMainWindow(); 614 DiscardMainWindow();
600 } 615 }
601 616
602 void BlinkTestController::DiscardMainWindow() { 617 void BlinkTestController::DiscardMainWindow() {
603 // If we're running a test, we need to close all windows and exit the message 618 // If we're running a test, we need to close all windows and exit the message
604 // loop. Otherwise, we're already outside of the message loop, and we just 619 // loop. Otherwise, we're already outside of the message loop, and we just
605 // discard the main window. 620 // discard the main window.
606 devtools_bindings_.reset(); 621 devtools_bindings_.reset();
622 devtools_protocol_test_bindings_.reset();
607 WebContentsObserver::Observe(NULL); 623 WebContentsObserver::Observe(NULL);
608 if (test_phase_ != BETWEEN_TESTS) { 624 if (test_phase_ != BETWEEN_TESTS) {
609 Shell::CloseAllWindows(); 625 Shell::CloseAllWindows();
610 base::ThreadTaskRunnerHandle::Get()->PostTask( 626 base::ThreadTaskRunnerHandle::Get()->PostTask(
611 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); 627 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
612 test_phase_ = CLEAN_UP; 628 test_phase_ = CLEAN_UP;
613 } else if (main_window_) { 629 } else if (main_window_) {
614 main_window_->Close(); 630 main_window_->Close();
615 } 631 }
616 main_window_ = NULL; 632 main_window_ = NULL;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 } 693 }
678 } 694 }
679 695
680 void BlinkTestController::OnTestFinished() { 696 void BlinkTestController::OnTestFinished() {
681 test_phase_ = CLEAN_UP; 697 test_phase_ = CLEAN_UP;
682 if (!printer_->output_finished()) 698 if (!printer_->output_finished())
683 printer_->PrintImageFooter(); 699 printer_->PrintImageFooter();
684 RenderViewHost* render_view_host = 700 RenderViewHost* render_view_host =
685 main_window_->web_contents()->GetRenderViewHost(); 701 main_window_->web_contents()->GetRenderViewHost();
686 main_window_->web_contents()->ExitFullscreen(/*will_cause_resize=*/false); 702 main_window_->web_contents()->ExitFullscreen(/*will_cause_resize=*/false);
703 devtools_protocol_test_bindings_.reset();
687 704
688 ShellBrowserContext* browser_context = 705 ShellBrowserContext* browser_context =
689 ShellContentBrowserClient::Get()->browser_context(); 706 ShellContentBrowserClient::Get()->browser_context();
690 StoragePartition* storage_partition = 707 StoragePartition* storage_partition =
691 BrowserContext::GetStoragePartition(browser_context, nullptr); 708 BrowserContext::GetStoragePartition(browser_context, nullptr);
692 storage_partition->GetServiceWorkerContext()->ClearAllServiceWorkersForTest( 709 storage_partition->GetServiceWorkerContext()->ClearAllServiceWorkersForTest(
693 base::Bind(base::IgnoreResult(&BlinkTestController::Send), 710 base::Bind(base::IgnoreResult(&BlinkTestController::Send),
694 base::Unretained(this), 711 base::Unretained(this),
695 new ShellViewMsg_Reset(render_view_host->GetRoutingID()))); 712 new ShellViewMsg_Reset(render_view_host->GetRoutingID())));
696 storage_partition->ClearBluetoothAllowedDevicesMapForTesting(); 713 storage_partition->ClearBluetoothAllowedDevicesMapForTesting();
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 } 1033 }
1017 DCHECK(layout_test_control_map_[frame].get()); 1034 DCHECK(layout_test_control_map_[frame].get());
1018 return layout_test_control_map_[frame].get(); 1035 return layout_test_control_map_[frame].get();
1019 } 1036 }
1020 1037
1021 void BlinkTestController::HandleLayoutTestControlError(RenderFrameHost* frame) { 1038 void BlinkTestController::HandleLayoutTestControlError(RenderFrameHost* frame) {
1022 layout_test_control_map_.erase(frame); 1039 layout_test_control_map_.erase(frame);
1023 } 1040 }
1024 1041
1025 } // namespace content 1042 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698