Chromium Code Reviews| 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 #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 20 matching lines...) Expand all Loading... | |
| 31 #include "content/public/browser/notification_service.h" | 31 #include "content/public/browser/notification_service.h" |
| 32 #include "content/public/browser/notification_types.h" | 32 #include "content/public/browser/notification_types.h" |
| 33 #include "content/public/browser/render_frame_host.h" | 33 #include "content/public/browser/render_frame_host.h" |
| 34 #include "content/public/browser/render_process_host.h" | 34 #include "content/public/browser/render_process_host.h" |
| 35 #include "content/public/browser/render_view_host.h" | 35 #include "content/public/browser/render_view_host.h" |
| 36 #include "content/public/browser/render_widget_host.h" | 36 #include "content/public/browser/render_widget_host.h" |
| 37 #include "content/public/browser/render_widget_host_view.h" | 37 #include "content/public/browser/render_widget_host_view.h" |
| 38 #include "content/public/browser/service_worker_context.h" | 38 #include "content/public/browser/service_worker_context.h" |
| 39 #include "content/public/browser/storage_partition.h" | 39 #include "content/public/browser/storage_partition.h" |
| 40 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
| 41 #include "content/public/common/associated_interface_provider.h" | |
| 41 #include "content/public/common/bindings_policy.h" | 42 #include "content/public/common/bindings_policy.h" |
| 42 #include "content/public/common/content_switches.h" | 43 #include "content/public/common/content_switches.h" |
| 43 #include "content/public/common/url_constants.h" | 44 #include "content/public/common/url_constants.h" |
| 44 #include "content/shell/browser/layout_test/layout_test_bluetooth_chooser_factor y.h" | 45 #include "content/shell/browser/layout_test/layout_test_bluetooth_chooser_factor y.h" |
| 45 #include "content/shell/browser/layout_test/layout_test_devtools_frontend.h" | 46 #include "content/shell/browser/layout_test/layout_test_devtools_frontend.h" |
| 46 #include "content/shell/browser/layout_test/layout_test_first_device_bluetooth_c hooser.h" | 47 #include "content/shell/browser/layout_test/layout_test_first_device_bluetooth_c hooser.h" |
| 47 #include "content/shell/browser/shell.h" | 48 #include "content/shell/browser/shell.h" |
| 48 #include "content/shell/browser/shell_browser_context.h" | 49 #include "content/shell/browser/shell_browser_context.h" |
| 49 #include "content/shell/browser/shell_content_browser_client.h" | 50 #include "content/shell/browser/shell_content_browser_client.h" |
| 50 #include "content/shell/browser/shell_devtools_frontend.h" | 51 #include "content/shell/browser/shell_devtools_frontend.h" |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 273 test_url_ = test_url; | 274 test_url_ = test_url; |
| 274 else | 275 else |
| 275 test_url_ = LayoutTestDevToolsFrontend::MapJSTestURL(test_url); | 276 test_url_ = LayoutTestDevToolsFrontend::MapJSTestURL(test_url); |
| 276 did_send_initial_test_configuration_ = false; | 277 did_send_initial_test_configuration_ = false; |
| 277 printer_->reset(); | 278 printer_->reset(); |
| 278 frame_to_layout_dump_map_.clear(); | 279 frame_to_layout_dump_map_.clear(); |
| 279 render_process_host_observer_.RemoveAll(); | 280 render_process_host_observer_.RemoveAll(); |
| 280 all_observed_render_process_hosts_.clear(); | 281 all_observed_render_process_hosts_.clear(); |
| 281 main_window_render_process_hosts_.clear(); | 282 main_window_render_process_hosts_.clear(); |
| 282 accumulated_layout_test_runtime_flags_changes_.Clear(); | 283 accumulated_layout_test_runtime_flags_changes_.Clear(); |
| 284 layout_test_control_map_.clear(); | |
| 283 ShellBrowserContext* browser_context = | 285 ShellBrowserContext* browser_context = |
| 284 ShellContentBrowserClient::Get()->browser_context(); | 286 ShellContentBrowserClient::Get()->browser_context(); |
| 285 is_compositing_test_ = | 287 is_compositing_test_ = |
| 286 test_url_.spec().find("compositing/") != std::string::npos; | 288 test_url_.spec().find("compositing/") != std::string::npos; |
| 287 initial_size_ = Shell::GetShellDefaultSize(); | 289 initial_size_ = Shell::GetShellDefaultSize(); |
| 288 // The W3C SVG layout tests use a different size than the other layout tests. | 290 // The W3C SVG layout tests use a different size than the other layout tests. |
| 289 if (test_url_.spec().find("W3C-SVG-1.1") != std::string::npos) | 291 if (test_url_.spec().find("W3C-SVG-1.1") != std::string::npos) |
| 290 initial_size_ = gfx::Size(kTestSVGWindowWidthDip, kTestSVGWindowHeightDip); | 292 initial_size_ = gfx::Size(kTestSVGWindowWidthDip, kTestSVGWindowHeightDip); |
| 291 if (!main_window_) { | 293 if (!main_window_) { |
| 292 main_window_ = content::Shell::CreateNewWindow( | 294 main_window_ = content::Shell::CreateNewWindow( |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 611 params.temp_path = temp_path_; | 613 params.temp_path = temp_path_; |
| 612 params.test_url = test_url_; | 614 params.test_url = test_url_; |
| 613 params.enable_pixel_dumping = enable_pixel_dumping_; | 615 params.enable_pixel_dumping = enable_pixel_dumping_; |
| 614 params.allow_external_pages = | 616 params.allow_external_pages = |
| 615 base::CommandLine::ForCurrentProcess()->HasSwitch( | 617 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 616 switches::kAllowExternalPages); | 618 switches::kAllowExternalPages); |
| 617 params.expected_pixel_hash = expected_pixel_hash_; | 619 params.expected_pixel_hash = expected_pixel_hash_; |
| 618 params.initial_size = initial_size_; | 620 params.initial_size = initial_size_; |
| 619 | 621 |
| 620 if (did_send_initial_test_configuration_) { | 622 if (did_send_initial_test_configuration_) { |
| 621 frame->Send(new ShellViewMsg_ReplicateTestConfiguration( | 623 GetLayoutTestControlPtr(frame)->ReplicateTestConfiguration(params); |
| 622 frame->GetRoutingID(), params)); | |
| 623 } else { | 624 } else { |
| 624 did_send_initial_test_configuration_ = true; | 625 did_send_initial_test_configuration_ = true; |
| 625 frame->Send( | 626 GetLayoutTestControlPtr(frame)->SetTestConfiguration(params); |
| 626 new ShellViewMsg_SetTestConfiguration(frame->GetRoutingID(), params)); | |
| 627 } | 627 } |
| 628 } | 628 } |
| 629 | 629 |
| 630 // Is this a previously unknown renderer process? | 630 // Is this a previously unknown renderer process? |
| 631 if (!render_process_host_observer_.IsObserving(process)) { | 631 if (!render_process_host_observer_.IsObserving(process)) { |
| 632 render_process_host_observer_.Add(process); | 632 render_process_host_observer_.Add(process); |
| 633 all_observed_render_process_hosts_.insert(process); | 633 all_observed_render_process_hosts_.insert(process); |
| 634 | 634 |
| 635 if (!main_window) { | 635 if (!main_window) { |
| 636 frame->Send( | 636 GetLayoutTestControlPtr(frame)->SetupSecondaryRenderer(); |
| 637 new ShellViewMsg_SetupSecondaryRenderer(frame->GetRoutingID())); | |
| 638 } | 637 } |
| 639 | 638 |
| 640 process->Send(new LayoutTestMsg_ReplicateLayoutTestRuntimeFlagsChanges( | 639 process->Send(new LayoutTestMsg_ReplicateLayoutTestRuntimeFlagsChanges( |
| 641 accumulated_layout_test_runtime_flags_changes_)); | 640 accumulated_layout_test_runtime_flags_changes_)); |
| 642 } | 641 } |
| 643 } | 642 } |
| 644 | 643 |
| 645 void BlinkTestController::OnTestFinished() { | 644 void BlinkTestController::OnTestFinished() { |
| 646 test_phase_ = CLEAN_UP; | 645 test_phase_ = CLEAN_UP; |
| 647 if (!printer_->output_finished()) | 646 if (!printer_->output_finished()) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 698 printer_->PrintAudioFooter(); | 697 printer_->PrintAudioFooter(); |
| 699 } | 698 } |
| 700 | 699 |
| 701 void BlinkTestController::OnTextDump(const std::string& dump) { | 700 void BlinkTestController::OnTextDump(const std::string& dump) { |
| 702 printer_->PrintTextHeader(); | 701 printer_->PrintTextHeader(); |
| 703 printer_->PrintTextBlock(dump); | 702 printer_->PrintTextBlock(dump); |
| 704 printer_->PrintTextFooter(); | 703 printer_->PrintTextFooter(); |
| 705 } | 704 } |
| 706 | 705 |
| 707 void BlinkTestController::OnInitiateLayoutDump() { | 706 void BlinkTestController::OnInitiateLayoutDump() { |
| 708 pending_layout_dumps_ = main_window_->web_contents()->SendToAllFrames( | 707 int number_of_messages = 0; |
| 709 new ShellViewMsg_LayoutDumpRequest(MSG_ROUTING_NONE)); | 708 for (RenderFrameHost* rfh : main_window_->web_contents()->GetAllFrames()) { |
| 709 if (!rfh->IsRenderFrameLive()) | |
| 710 continue; | |
| 711 | |
| 712 ++number_of_messages; | |
| 713 GetLayoutTestControlPtr(rfh)->LayoutDumpRequest(); | |
| 714 } | |
| 715 | |
| 716 pending_layout_dumps_ = number_of_messages; | |
| 710 } | 717 } |
| 711 | 718 |
| 712 void BlinkTestController::OnLayoutTestRuntimeFlagsChanged( | 719 void BlinkTestController::OnLayoutTestRuntimeFlagsChanged( |
| 713 int sender_process_host_id, | 720 int sender_process_host_id, |
| 714 const base::DictionaryValue& changed_layout_test_runtime_flags) { | 721 const base::DictionaryValue& changed_layout_test_runtime_flags) { |
| 715 // Stash the accumulated changes for future, not-yet-created renderers. | 722 // Stash the accumulated changes for future, not-yet-created renderers. |
| 716 accumulated_layout_test_runtime_flags_changes_.MergeDictionary( | 723 accumulated_layout_test_runtime_flags_changes_.MergeDictionary( |
| 717 &changed_layout_test_runtime_flags); | 724 &changed_layout_test_runtime_flags); |
| 718 | 725 |
| 719 // Propagate the changes to all the tracked renderer processes. | 726 // Propagate the changes to all the tracked renderer processes. |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 947 event = BluetoothChooser::Event::RESCAN; | 954 event = BluetoothChooser::Event::RESCAN; |
| 948 } else { | 955 } else { |
| 949 printer_->AddErrorMessage(base::StringPrintf( | 956 printer_->AddErrorMessage(base::StringPrintf( |
| 950 "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.", | 957 "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.", |
| 951 event_name.c_str())); | 958 event_name.c_str())); |
| 952 return; | 959 return; |
| 953 } | 960 } |
| 954 bluetooth_chooser_factory_->SendEvent(event, argument); | 961 bluetooth_chooser_factory_->SendEvent(event, argument); |
| 955 } | 962 } |
| 956 | 963 |
| 964 mojom::LayoutTestControl* BlinkTestController::GetLayoutTestControlPtr( | |
| 965 RenderFrameHost* frame) { | |
| 966 if (layout_test_control_map_.find(frame) == layout_test_control_map_.end()) { | |
| 967 frame->GetRemoteAssociatedInterfaces()->GetInterface( | |
| 968 &layout_test_control_map_[frame]); | |
| 969 } | |
| 970 return layout_test_control_map_[frame].get(); | |
|
Mike West
2017/01/20 12:04:24
Nit: Maybe DCHECK that we end up with a pointer?
Jia
2017/01/23 02:37:39
Done.
| |
| 971 } | |
| 972 | |
| 957 } // namespace content | 973 } // namespace content |
| OLD | NEW |