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

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

Issue 1715573002: Replicating LayoutDumpFlags across OOPIFs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@replicating-pixel-dump-flag
Patch Set: Maybe this is ready for review. Created 4 years, 9 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 <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
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 scoped_ptr<BluetoothChooser> BlinkTestController::RunBluetoothChooser( 391 scoped_ptr<BluetoothChooser> BlinkTestController::RunBluetoothChooser(
390 RenderFrameHost* frame, 392 RenderFrameHost* frame,
391 const BluetoothChooser::EventHandler& event_handler) { 393 const BluetoothChooser::EventHandler& event_handler) {
392 if (bluetooth_chooser_factory_) { 394 if (bluetooth_chooser_factory_) {
393 return bluetooth_chooser_factory_->RunBluetoothChooser(frame, 395 return bluetooth_chooser_factory_->RunBluetoothChooser(frame,
394 event_handler); 396 event_handler);
395 } 397 }
396 return nullptr; 398 return nullptr;
397 } 399 }
398 400
399 bool BlinkTestController::OnMessageReceived(const IPC::Message& message) { 401 bool BlinkTestController::OnMessageReceived(const IPC::Message& message) {
jochen (gone - plz use gerrit) 2016/03/04 12:50:37 just override OnMessageReceived(const IPC::Message
Łukasz Anforowicz 2016/03/04 19:58:56 Done. Thanks for pushing in this direction. I've
400 DCHECK(CalledOnValidThread()); 402 DCHECK(CalledOnValidThread());
401 bool handled = true; 403 bool handled = true;
402 IPC_BEGIN_MESSAGE_MAP(BlinkTestController, message) 404 IPC_BEGIN_MESSAGE_MAP(BlinkTestController, message)
403 IPC_MESSAGE_HANDLER(ShellViewHostMsg_PrintMessage, OnPrintMessage) 405 IPC_MESSAGE_HANDLER(ShellViewHostMsg_PrintMessage, OnPrintMessage)
404 IPC_MESSAGE_HANDLER(ShellViewHostMsg_TextDump, OnTextDump) 406 IPC_MESSAGE_HANDLER(ShellViewHostMsg_TextDump, OnTextDump)
405 IPC_MESSAGE_HANDLER(ShellViewHostMsg_InitiateLayoutDump, 407 IPC_MESSAGE_HANDLER(ShellViewHostMsg_InitiateLayoutDump,
406 OnInitiateLayoutDump) 408 OnInitiateLayoutDump)
409 IPC_MESSAGE_HANDLER(ShellViewHostMsg_LayoutDumpFlagsChanged,
410 OnLayoutDumpFlagsChanged)
407 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ImageDump, OnImageDump) 411 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ImageDump, OnImageDump)
408 IPC_MESSAGE_HANDLER(ShellViewHostMsg_AudioDump, OnAudioDump) 412 IPC_MESSAGE_HANDLER(ShellViewHostMsg_AudioDump, OnAudioDump)
409 IPC_MESSAGE_HANDLER(ShellViewHostMsg_OverridePreferences, 413 IPC_MESSAGE_HANDLER(ShellViewHostMsg_OverridePreferences,
410 OnOverridePreferences) 414 OnOverridePreferences)
411 IPC_MESSAGE_HANDLER(ShellViewHostMsg_TestFinished, OnTestFinished) 415 IPC_MESSAGE_HANDLER(ShellViewHostMsg_TestFinished, OnTestFinished)
412 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ClearDevToolsLocalStorage, 416 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ClearDevToolsLocalStorage,
413 OnClearDevToolsLocalStorage) 417 OnClearDevToolsLocalStorage)
414 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ShowDevTools, OnShowDevTools) 418 IPC_MESSAGE_HANDLER(ShellViewHostMsg_ShowDevTools, OnShowDevTools)
415 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CloseDevTools, OnCloseDevTools) 419 IPC_MESSAGE_HANDLER(ShellViewHostMsg_CloseDevTools, OnCloseDevTools)
416 IPC_MESSAGE_HANDLER(ShellViewHostMsg_GoToOffset, OnGoToOffset) 420 IPC_MESSAGE_HANDLER(ShellViewHostMsg_GoToOffset, OnGoToOffset)
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 const base::DictionaryValue& changed_layout_dump_flags,
681 const std::string& change_originator_guid) {
682 accumulated_layout_dump_flags_changes_.MergeDictionary(
683 &changed_layout_dump_flags);
684
685 std::set<int> already_covered_process_ids;
686 for (RenderFrameHost* frame : main_window_->web_contents()->GetAllFrames()) {
687 // TODO(lukasza): Skip original sender of the change notification.
688 // Note - this is not just perf optimization - we also don't want to
689 // clobber changes that might have happened in the original sender
690 // since it sent the notification.
691 bool inserted =
692 already_covered_process_ids.insert(frame->GetProcess()->GetID()).second;
693 if (inserted) {
694 frame->Send(new ShellViewMsg_ReplicateLayoutDumpFlagsChanges(
695 frame->GetRoutingID(), changed_layout_dump_flags,
696 change_originator_guid));
697 }
698 }
675 } 699 }
676 700
677 void BlinkTestController::OnLayoutDumpResponse(RenderFrameHost* sender, 701 void BlinkTestController::OnLayoutDumpResponse(RenderFrameHost* sender,
678 const std::string& dump) { 702 const std::string& dump) {
679 // Store the result. 703 // Store the result.
680 auto pair = frame_to_layout_dump_map_.insert( 704 auto pair = frame_to_layout_dump_map_.insert(
681 std::make_pair(sender->GetFrameTreeNodeId(), dump)); 705 std::make_pair(sender->GetFrameTreeNodeId(), dump));
682 bool insertion_took_place = pair.second; 706 bool insertion_took_place = pair.second;
683 DCHECK(insertion_took_place); 707 DCHECK(insertion_took_place);
684 708
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 } else { 902 } else {
879 printer_->AddErrorMessage(base::StringPrintf( 903 printer_->AddErrorMessage(base::StringPrintf(
880 "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.", 904 "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.",
881 event_name.c_str())); 905 event_name.c_str()));
882 return; 906 return;
883 } 907 }
884 bluetooth_chooser_factory_->SendEvent(event, argument); 908 bluetooth_chooser_factory_->SendEvent(event, argument);
885 } 909 }
886 910
887 } // namespace content 911 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698