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 <utility> | 11 #include <utility> |
| 11 | 12 |
| 12 #include "base/base64.h" | 13 #include "base/base64.h" |
| 13 #include "base/callback.h" | 14 #include "base/callback.h" |
| 14 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 15 #include "base/location.h" | 16 #include "base/location.h" |
| 16 #include "base/logging.h" | 17 #include "base/logging.h" |
| 17 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
| 18 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
| 19 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 DCHECK(CalledOnValidThread()); | 263 DCHECK(CalledOnValidThread()); |
| 263 test_phase_ = DURING_TEST; | 264 test_phase_ = DURING_TEST; |
| 264 current_working_directory_ = current_working_directory; | 265 current_working_directory_ = current_working_directory; |
| 265 enable_pixel_dumping_ = enable_pixel_dumping; | 266 enable_pixel_dumping_ = enable_pixel_dumping; |
| 266 expected_pixel_hash_ = expected_pixel_hash; | 267 expected_pixel_hash_ = expected_pixel_hash; |
| 267 test_url_ = test_url; | 268 test_url_ = test_url; |
| 268 need_to_send_test_configuration_to_renderer_ = true; | 269 need_to_send_test_configuration_to_renderer_ = true; |
| 269 printer_->reset(); | 270 printer_->reset(); |
| 270 frame_to_layout_dump_map_.clear(); | 271 frame_to_layout_dump_map_.clear(); |
| 271 render_process_host_observer_.RemoveAll(); | 272 render_process_host_observer_.RemoveAll(); |
| 273 accumulated_layout_dump_flags_changes_.Clear(); | |
| 272 ShellBrowserContext* browser_context = | 274 ShellBrowserContext* browser_context = |
| 273 ShellContentBrowserClient::Get()->browser_context(); | 275 ShellContentBrowserClient::Get()->browser_context(); |
| 274 if (test_url.spec().find("compositing/") != std::string::npos) | 276 if (test_url.spec().find("compositing/") != std::string::npos) |
| 275 is_compositing_test_ = true; | 277 is_compositing_test_ = true; |
| 276 initial_size_ = Shell::GetShellDefaultSize(); | 278 initial_size_ = Shell::GetShellDefaultSize(); |
| 277 // The W3C SVG layout tests use a different size than the other layout tests. | 279 // The W3C SVG layout tests use a different size than the other layout tests. |
| 278 if (test_url.spec().find("W3C-SVG-1.1") != std::string::npos) | 280 if (test_url.spec().find("W3C-SVG-1.1") != std::string::npos) |
| 279 initial_size_ = gfx::Size(kTestSVGWindowWidthDip, kTestSVGWindowHeightDip); | 281 initial_size_ = gfx::Size(kTestSVGWindowWidthDip, kTestSVGWindowHeightDip); |
| 280 if (!main_window_) { | 282 if (!main_window_) { |
| 281 main_window_ = content::Shell::CreateNewWindow( | 283 main_window_ = content::Shell::CreateNewWindow( |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 433 | 435 |
| 434 return handled; | 436 return handled; |
| 435 } | 437 } |
| 436 | 438 |
| 437 bool BlinkTestController::OnMessageReceived( | 439 bool BlinkTestController::OnMessageReceived( |
| 438 const IPC::Message& message, | 440 const IPC::Message& message, |
| 439 RenderFrameHost* render_frame_host) { | 441 RenderFrameHost* render_frame_host) { |
| 440 bool handled = true; | 442 bool handled = true; |
| 441 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(BlinkTestController, message, | 443 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(BlinkTestController, message, |
| 442 render_frame_host) | 444 render_frame_host) |
| 445 IPC_MESSAGE_HANDLER(ShellViewHostMsg_LayoutDumpFlagsChanged, | |
| 446 OnLayoutDumpFlagsChanged) | |
| 443 IPC_MESSAGE_HANDLER(ShellViewHostMsg_LayoutDumpResponse, | 447 IPC_MESSAGE_HANDLER(ShellViewHostMsg_LayoutDumpResponse, |
| 444 OnLayoutDumpResponse) | 448 OnLayoutDumpResponse) |
| 445 IPC_MESSAGE_UNHANDLED(handled = false) | 449 IPC_MESSAGE_UNHANDLED(handled = false) |
| 446 IPC_END_MESSAGE_MAP() | 450 IPC_END_MESSAGE_MAP() |
| 447 return handled; | 451 return handled; |
| 448 } | 452 } |
| 449 | 453 |
| 450 void BlinkTestController::PluginCrashed(const base::FilePath& plugin_path, | 454 void BlinkTestController::PluginCrashed(const base::FilePath& plugin_path, |
| 451 base::ProcessId plugin_pid) { | 455 base::ProcessId plugin_pid) { |
| 452 DCHECK(CalledOnValidThread()); | 456 DCHECK(CalledOnValidThread()); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 594 switches::kAllowExternalPages); | 598 switches::kAllowExternalPages); |
| 595 params.expected_pixel_hash = expected_pixel_hash_; | 599 params.expected_pixel_hash = expected_pixel_hash_; |
| 596 params.initial_size = initial_size_; | 600 params.initial_size = initial_size_; |
| 597 | 601 |
| 598 if (need_to_send_test_configuration_to_renderer_) { | 602 if (need_to_send_test_configuration_to_renderer_) { |
| 599 need_to_send_test_configuration_to_renderer_ = false; | 603 need_to_send_test_configuration_to_renderer_ = false; |
| 600 frame->Send( | 604 frame->Send( |
| 601 new ShellViewMsg_SetTestConfiguration(frame->GetRoutingID(), params)); | 605 new ShellViewMsg_SetTestConfiguration(frame->GetRoutingID(), params)); |
| 602 } else { | 606 } else { |
| 603 frame->Send(new ShellViewMsg_ReplicateTestConfiguration( | 607 frame->Send(new ShellViewMsg_ReplicateTestConfiguration( |
| 604 frame->GetRoutingID(), params)); | 608 frame->GetRoutingID(), params, accumulated_layout_dump_flags_changes_)); |
| 605 } | 609 } |
| 606 } | 610 } |
| 607 | 611 |
| 608 void BlinkTestController::OnTestFinished() { | 612 void BlinkTestController::OnTestFinished() { |
| 609 test_phase_ = CLEAN_UP; | 613 test_phase_ = CLEAN_UP; |
| 610 if (!printer_->output_finished()) | 614 if (!printer_->output_finished()) |
| 611 printer_->PrintImageFooter(); | 615 printer_->PrintImageFooter(); |
| 612 RenderViewHost* render_view_host = | 616 RenderViewHost* render_view_host = |
| 613 main_window_->web_contents()->GetRenderViewHost(); | 617 main_window_->web_contents()->GetRenderViewHost(); |
| 614 main_window_->web_contents()->ExitFullscreen(/*will_cause_resize=*/false); | 618 main_window_->web_contents()->ExitFullscreen(/*will_cause_resize=*/false); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 660 printer_->PrintAudioBlock(dump); | 664 printer_->PrintAudioBlock(dump); |
| 661 printer_->PrintAudioFooter(); | 665 printer_->PrintAudioFooter(); |
| 662 } | 666 } |
| 663 | 667 |
| 664 void BlinkTestController::OnTextDump(const std::string& dump) { | 668 void BlinkTestController::OnTextDump(const std::string& dump) { |
| 665 printer_->PrintTextHeader(); | 669 printer_->PrintTextHeader(); |
| 666 printer_->PrintTextBlock(dump); | 670 printer_->PrintTextBlock(dump); |
| 667 printer_->PrintTextFooter(); | 671 printer_->PrintTextFooter(); |
| 668 } | 672 } |
| 669 | 673 |
| 670 void BlinkTestController::OnInitiateLayoutDump( | 674 void BlinkTestController::OnInitiateLayoutDump() { |
| 671 const test_runner::LayoutDumpFlags& layout_dump_flags) { | |
| 672 DCHECK(layout_dump_flags.dump_child_frames()); | |
| 673 pending_layout_dumps_ = main_window_->web_contents()->SendToAllFrames( | 675 pending_layout_dumps_ = main_window_->web_contents()->SendToAllFrames( |
| 674 new ShellViewMsg_LayoutDumpRequest(MSG_ROUTING_NONE, layout_dump_flags)); | 676 new ShellViewMsg_LayoutDumpRequest(MSG_ROUTING_NONE)); |
| 677 } | |
| 678 | |
| 679 void BlinkTestController::OnLayoutDumpFlagsChanged( | |
| 680 RenderFrameHost* sender, | |
| 681 const base::DictionaryValue& changed_layout_dump_flags) { | |
| 682 // Stash the changes for future renderers. | |
| 683 accumulated_layout_dump_flags_changes_.MergeDictionary( | |
| 684 &changed_layout_dump_flags); | |
| 685 | |
| 686 // Only need to send the propagation message once per renderer process. | |
| 687 std::set<int> already_covered_process_ids; | |
|
dcheng
2016/03/08 23:09:37
Will we have a better way of doing this in the fut
Łukasz Anforowicz
2016/03/10 22:24:21
This is a very good question. I don't know the an
dcheng
2016/03/12 01:21:50
Please don't block this CL on my objections. At th
Łukasz Anforowicz
2016/03/14 16:23:13
Cool, thanks. :-)
| |
| 688 | |
| 689 // No need to propagate the changes back to the process that originated them. | |
| 690 // (propagating them back could also clobber subsequent changes in the | |
| 691 // originator). | |
| 692 already_covered_process_ids.insert(sender->GetProcess()->GetID()); | |
| 693 | |
| 694 // Propagate the changes to all the renderer processes associated with the | |
| 695 // main window. | |
| 696 for (RenderFrameHost* frame : main_window_->web_contents()->GetAllFrames()) { | |
| 697 bool inserted_new_item = | |
| 698 already_covered_process_ids.insert(frame->GetProcess()->GetID()).second; | |
| 699 if (inserted_new_item) { | |
| 700 frame->Send(new ShellViewMsg_ReplicateLayoutDumpFlagsChanges( | |
| 701 frame->GetRoutingID(), changed_layout_dump_flags)); | |
| 702 } | |
| 703 } | |
| 675 } | 704 } |
| 676 | 705 |
| 677 void BlinkTestController::OnLayoutDumpResponse(RenderFrameHost* sender, | 706 void BlinkTestController::OnLayoutDumpResponse(RenderFrameHost* sender, |
| 678 const std::string& dump) { | 707 const std::string& dump) { |
| 679 // Store the result. | 708 // Store the result. |
| 680 auto pair = frame_to_layout_dump_map_.insert( | 709 auto pair = frame_to_layout_dump_map_.insert( |
| 681 std::make_pair(sender->GetFrameTreeNodeId(), dump)); | 710 std::make_pair(sender->GetFrameTreeNodeId(), dump)); |
| 682 bool insertion_took_place = pair.second; | 711 bool insertion_took_place = pair.second; |
| 683 DCHECK(insertion_took_place); | 712 DCHECK(insertion_took_place); |
| 684 | 713 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 878 } else { | 907 } else { |
| 879 printer_->AddErrorMessage(base::StringPrintf( | 908 printer_->AddErrorMessage(base::StringPrintf( |
| 880 "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.", | 909 "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.", |
| 881 event_name.c_str())); | 910 event_name.c_str())); |
| 882 return; | 911 return; |
| 883 } | 912 } |
| 884 bluetooth_chooser_factory_->SendEvent(event, argument); | 913 bluetooth_chooser_factory_->SendEvent(event, argument); |
| 885 } | 914 } |
| 886 | 915 |
| 887 } // namespace content | 916 } // namespace content |
| OLD | NEW |