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

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

Powered by Google App Engine
This is Rietveld 408576698