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

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

Issue 2594913002: Replace IPC messages in layout_test_render_frame_observer. (Closed)
Patch Set: Removed a redundant line Created 3 years, 10 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
« no previous file with comments | « content/shell/browser/layout_test/blink_test_controller.h ('k') | content/shell/common/OWNERS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 20 matching lines...) Expand all
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
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
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->allow_external_pages = false;
611 params.test_url = test_url_; 613 params->current_working_directory = current_working_directory_;
612 params.enable_pixel_dumping = enable_pixel_dumping_; 614 params->temp_path = temp_path_;
613 params.allow_external_pages = 615 params->test_url = test_url_;
616 params->enable_pixel_dumping = enable_pixel_dumping_;
617 params->allow_external_pages =
614 base::CommandLine::ForCurrentProcess()->HasSwitch( 618 base::CommandLine::ForCurrentProcess()->HasSwitch(
615 switches::kAllowExternalPages); 619 switches::kAllowExternalPages);
616 params.expected_pixel_hash = expected_pixel_hash_; 620 params->expected_pixel_hash = expected_pixel_hash_;
617 params.initial_size = initial_size_; 621 params->initial_size = initial_size_;
618 622
619 if (did_send_initial_test_configuration_) { 623 if (did_send_initial_test_configuration_) {
620 frame->Send(new ShellViewMsg_ReplicateTestConfiguration( 624 GetLayoutTestControlPtr(frame)->ReplicateTestConfiguration(
621 frame->GetRoutingID(), params)); 625 std::move(params));
622 } else { 626 } else {
623 did_send_initial_test_configuration_ = true; 627 did_send_initial_test_configuration_ = true;
624 frame->Send( 628 GetLayoutTestControlPtr(frame)->SetTestConfiguration(std::move(params));
625 new ShellViewMsg_SetTestConfiguration(frame->GetRoutingID(), params));
626 } 629 }
627 } 630 }
628 631
629 // Is this a previously unknown renderer process? 632 // Is this a previously unknown renderer process?
630 if (!render_process_host_observer_.IsObserving(process)) { 633 if (!render_process_host_observer_.IsObserving(process)) {
631 render_process_host_observer_.Add(process); 634 render_process_host_observer_.Add(process);
632 all_observed_render_process_hosts_.insert(process); 635 all_observed_render_process_hosts_.insert(process);
633 636
634 if (!main_window) { 637 if (!main_window) {
635 frame->Send( 638 GetLayoutTestControlPtr(frame)->SetupSecondaryRenderer();
636 new ShellViewMsg_SetupSecondaryRenderer(frame->GetRoutingID()));
637 } 639 }
638 640
639 process->Send(new LayoutTestMsg_ReplicateLayoutTestRuntimeFlagsChanges( 641 process->Send(new LayoutTestMsg_ReplicateLayoutTestRuntimeFlagsChanges(
640 accumulated_layout_test_runtime_flags_changes_)); 642 accumulated_layout_test_runtime_flags_changes_));
641 } 643 }
642 } 644 }
643 645
644 void BlinkTestController::OnTestFinished() { 646 void BlinkTestController::OnTestFinished() {
645 test_phase_ = CLEAN_UP; 647 test_phase_ = CLEAN_UP;
646 if (!printer_->output_finished()) 648 if (!printer_->output_finished())
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 printer_->PrintAudioFooter(); 699 printer_->PrintAudioFooter();
698 } 700 }
699 701
700 void BlinkTestController::OnTextDump(const std::string& dump) { 702 void BlinkTestController::OnTextDump(const std::string& dump) {
701 printer_->PrintTextHeader(); 703 printer_->PrintTextHeader();
702 printer_->PrintTextBlock(dump); 704 printer_->PrintTextBlock(dump);
703 printer_->PrintTextFooter(); 705 printer_->PrintTextFooter();
704 } 706 }
705 707
706 void BlinkTestController::OnInitiateLayoutDump() { 708 void BlinkTestController::OnInitiateLayoutDump() {
707 pending_layout_dumps_ = main_window_->web_contents()->SendToAllFrames( 709 int number_of_messages = 0;
708 new ShellViewMsg_LayoutDumpRequest(MSG_ROUTING_NONE)); 710 for (RenderFrameHost* rfh : main_window_->web_contents()->GetAllFrames()) {
711 if (!rfh->IsRenderFrameLive())
712 continue;
713
714 ++number_of_messages;
715 GetLayoutTestControlPtr(rfh)->LayoutDumpRequest();
716 }
717
718 pending_layout_dumps_ = number_of_messages;
709 } 719 }
710 720
711 void BlinkTestController::OnLayoutTestRuntimeFlagsChanged( 721 void BlinkTestController::OnLayoutTestRuntimeFlagsChanged(
712 int sender_process_host_id, 722 int sender_process_host_id,
713 const base::DictionaryValue& changed_layout_test_runtime_flags) { 723 const base::DictionaryValue& changed_layout_test_runtime_flags) {
714 // Stash the accumulated changes for future, not-yet-created renderers. 724 // Stash the accumulated changes for future, not-yet-created renderers.
715 accumulated_layout_test_runtime_flags_changes_.MergeDictionary( 725 accumulated_layout_test_runtime_flags_changes_.MergeDictionary(
716 &changed_layout_test_runtime_flags); 726 &changed_layout_test_runtime_flags);
717 727
718 // Propagate the changes to all the tracked renderer processes. 728 // Propagate the changes to all the tracked renderer processes.
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 event = BluetoothChooser::Event::RESCAN; 956 event = BluetoothChooser::Event::RESCAN;
947 } else { 957 } else {
948 printer_->AddErrorMessage(base::StringPrintf( 958 printer_->AddErrorMessage(base::StringPrintf(
949 "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.", 959 "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.",
950 event_name.c_str())); 960 event_name.c_str()));
951 return; 961 return;
952 } 962 }
953 bluetooth_chooser_factory_->SendEvent(event, argument); 963 bluetooth_chooser_factory_->SendEvent(event, argument);
954 } 964 }
955 965
966 mojom::LayoutTestControl* BlinkTestController::GetLayoutTestControlPtr(
967 RenderFrameHost* frame) {
968 if (layout_test_control_map_.find(frame) == layout_test_control_map_.end()) {
969 frame->GetRemoteAssociatedInterfaces()->GetInterface(
970 &layout_test_control_map_[frame]);
971 layout_test_control_map_[frame].set_connection_error_handler(
972 base::Bind(&BlinkTestController::HandleLayoutTestControlError,
973 base::Unretained(this), frame));
974 }
975 DCHECK(layout_test_control_map_[frame].get());
976 return layout_test_control_map_[frame].get();
977 }
978
979 void BlinkTestController::HandleLayoutTestControlError(RenderFrameHost* frame) {
980 layout_test_control_map_.erase(frame);
981 }
982
956 } // namespace content 983 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/browser/layout_test/blink_test_controller.h ('k') | content/shell/common/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698