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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 598 current_pid_ = base::GetProcId(process_handle); | 600 current_pid_ = base::GetProcId(process_handle); |
| 599 } | 601 } |
| 600 | 602 |
| 601 // Is this the 1st time this renderer contains parts of the main test window? | 603 // Is this the 1st time this renderer contains parts of the main test window? |
| 602 if (main_window && | 604 if (main_window && |
| 603 !base::ContainsKey(main_window_render_process_hosts_, process)) { | 605 !base::ContainsKey(main_window_render_process_hosts_, process)) { |
| 604 main_window_render_process_hosts_.insert(process); | 606 main_window_render_process_hosts_.insert(process); |
| 605 | 607 |
| 606 // Make sure the new renderer process has a test configuration shared with | 608 // Make sure the new renderer process has a test configuration shared with |
| 607 // other renderers. | 609 // other renderers. |
| 608 ShellTestConfiguration params; | 610 mojom::ShellTestConfigurationPtr params = |
| 609 params.current_working_directory = current_working_directory_; | 611 mojom::ShellTestConfiguration::New(); |
| 610 params.temp_path = temp_path_; | 612 params->enable_pixel_dumping = true; |
|
Łukasz Anforowicz
2017/02/07 17:36:31
nit: The line above can be removed - we always se
Jia
2017/02/07 22:10:16
Done. Yes that's right. I put in here to "simulate
| |
| 611 params.test_url = test_url_; | 613 params->allow_external_pages = false; |
| 612 params.enable_pixel_dumping = enable_pixel_dumping_; | 614 params->current_working_directory = current_working_directory_; |
| 613 params.allow_external_pages = | 615 params->temp_path = temp_path_; |
| 616 params->test_url = test_url_; | |
| 617 params->enable_pixel_dumping = enable_pixel_dumping_; | |
| 618 params->allow_external_pages = | |
| 614 base::CommandLine::ForCurrentProcess()->HasSwitch( | 619 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 615 switches::kAllowExternalPages); | 620 switches::kAllowExternalPages); |
| 616 params.expected_pixel_hash = expected_pixel_hash_; | 621 params->expected_pixel_hash = expected_pixel_hash_; |
| 617 params.initial_size = initial_size_; | 622 params->initial_size = initial_size_; |
| 618 | 623 |
| 619 if (did_send_initial_test_configuration_) { | 624 if (did_send_initial_test_configuration_) { |
| 620 frame->Send(new ShellViewMsg_ReplicateTestConfiguration( | 625 GetLayoutTestControlPtr(frame)->ReplicateTestConfiguration( |
| 621 frame->GetRoutingID(), params)); | 626 std::move(params)); |
| 622 } else { | 627 } else { |
| 623 did_send_initial_test_configuration_ = true; | 628 did_send_initial_test_configuration_ = true; |
| 624 frame->Send( | 629 GetLayoutTestControlPtr(frame)->SetTestConfiguration(std::move(params)); |
| 625 new ShellViewMsg_SetTestConfiguration(frame->GetRoutingID(), params)); | |
| 626 } | 630 } |
| 627 } | 631 } |
| 628 | 632 |
| 629 // Is this a previously unknown renderer process? | 633 // Is this a previously unknown renderer process? |
| 630 if (!render_process_host_observer_.IsObserving(process)) { | 634 if (!render_process_host_observer_.IsObserving(process)) { |
| 631 render_process_host_observer_.Add(process); | 635 render_process_host_observer_.Add(process); |
| 632 all_observed_render_process_hosts_.insert(process); | 636 all_observed_render_process_hosts_.insert(process); |
| 633 | 637 |
| 634 if (!main_window) { | 638 if (!main_window) { |
| 635 frame->Send( | 639 GetLayoutTestControlPtr(frame)->SetupSecondaryRenderer(); |
| 636 new ShellViewMsg_SetupSecondaryRenderer(frame->GetRoutingID())); | |
| 637 } | 640 } |
| 638 | 641 |
| 639 process->Send(new LayoutTestMsg_ReplicateLayoutTestRuntimeFlagsChanges( | 642 process->Send(new LayoutTestMsg_ReplicateLayoutTestRuntimeFlagsChanges( |
| 640 accumulated_layout_test_runtime_flags_changes_)); | 643 accumulated_layout_test_runtime_flags_changes_)); |
| 641 } | 644 } |
| 642 } | 645 } |
| 643 | 646 |
| 644 void BlinkTestController::OnTestFinished() { | 647 void BlinkTestController::OnTestFinished() { |
| 645 test_phase_ = CLEAN_UP; | 648 test_phase_ = CLEAN_UP; |
| 646 if (!printer_->output_finished()) | 649 if (!printer_->output_finished()) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 697 printer_->PrintAudioFooter(); | 700 printer_->PrintAudioFooter(); |
| 698 } | 701 } |
| 699 | 702 |
| 700 void BlinkTestController::OnTextDump(const std::string& dump) { | 703 void BlinkTestController::OnTextDump(const std::string& dump) { |
| 701 printer_->PrintTextHeader(); | 704 printer_->PrintTextHeader(); |
| 702 printer_->PrintTextBlock(dump); | 705 printer_->PrintTextBlock(dump); |
| 703 printer_->PrintTextFooter(); | 706 printer_->PrintTextFooter(); |
| 704 } | 707 } |
| 705 | 708 |
| 706 void BlinkTestController::OnInitiateLayoutDump() { | 709 void BlinkTestController::OnInitiateLayoutDump() { |
| 707 pending_layout_dumps_ = main_window_->web_contents()->SendToAllFrames( | 710 int number_of_messages = 0; |
| 708 new ShellViewMsg_LayoutDumpRequest(MSG_ROUTING_NONE)); | 711 for (RenderFrameHost* rfh : main_window_->web_contents()->GetAllFrames()) { |
| 712 if (!rfh->IsRenderFrameLive()) | |
| 713 continue; | |
| 714 | |
| 715 ++number_of_messages; | |
| 716 GetLayoutTestControlPtr(rfh)->LayoutDumpRequest(); | |
| 717 } | |
| 718 | |
| 719 pending_layout_dumps_ = number_of_messages; | |
| 709 } | 720 } |
| 710 | 721 |
| 711 void BlinkTestController::OnLayoutTestRuntimeFlagsChanged( | 722 void BlinkTestController::OnLayoutTestRuntimeFlagsChanged( |
| 712 int sender_process_host_id, | 723 int sender_process_host_id, |
| 713 const base::DictionaryValue& changed_layout_test_runtime_flags) { | 724 const base::DictionaryValue& changed_layout_test_runtime_flags) { |
| 714 // Stash the accumulated changes for future, not-yet-created renderers. | 725 // Stash the accumulated changes for future, not-yet-created renderers. |
| 715 accumulated_layout_test_runtime_flags_changes_.MergeDictionary( | 726 accumulated_layout_test_runtime_flags_changes_.MergeDictionary( |
| 716 &changed_layout_test_runtime_flags); | 727 &changed_layout_test_runtime_flags); |
| 717 | 728 |
| 718 // Propagate the changes to all the tracked renderer processes. | 729 // Propagate the changes to all the tracked renderer processes. |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 946 event = BluetoothChooser::Event::RESCAN; | 957 event = BluetoothChooser::Event::RESCAN; |
| 947 } else { | 958 } else { |
| 948 printer_->AddErrorMessage(base::StringPrintf( | 959 printer_->AddErrorMessage(base::StringPrintf( |
| 949 "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.", | 960 "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.", |
| 950 event_name.c_str())); | 961 event_name.c_str())); |
| 951 return; | 962 return; |
| 952 } | 963 } |
| 953 bluetooth_chooser_factory_->SendEvent(event, argument); | 964 bluetooth_chooser_factory_->SendEvent(event, argument); |
| 954 } | 965 } |
| 955 | 966 |
| 967 mojom::LayoutTestControl* BlinkTestController::GetLayoutTestControlPtr( | |
| 968 RenderFrameHost* frame) { | |
| 969 if (layout_test_control_map_.find(frame) == layout_test_control_map_.end()) { | |
| 970 frame->GetRemoteAssociatedInterfaces()->GetInterface( | |
| 971 &layout_test_control_map_[frame]); | |
| 972 layout_test_control_map_[frame].set_connection_error_handler( | |
| 973 base::Bind(&BlinkTestController::HandleLayoutTestControlError, | |
| 974 base::Unretained(this), frame)); | |
| 975 } | |
| 976 DCHECK(layout_test_control_map_[frame].get()); | |
| 977 return layout_test_control_map_[frame].get(); | |
| 978 } | |
| 979 | |
| 980 void BlinkTestController::HandleLayoutTestControlError(RenderFrameHost* frame) { | |
| 981 LOG(INFO) << "BlinkTestController::HandleLayoutTestControlError"; | |
|
tibell
2017/02/07 00:50:50
Remove
Jia
2017/02/07 00:56:52
Done.
| |
| 982 layout_test_control_map_.erase(frame); | |
| 983 } | |
| 984 | |
| 956 } // namespace content | 985 } // namespace content |
| OLD | NEW |