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 <utility> | 10 #include <utility> |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 DiscardMainWindow(); | 253 DiscardMainWindow(); |
254 instance_ = NULL; | 254 instance_ = NULL; |
255 } | 255 } |
256 | 256 |
257 bool BlinkTestController::PrepareForLayoutTest( | 257 bool BlinkTestController::PrepareForLayoutTest( |
258 const GURL& test_url, | 258 const GURL& test_url, |
259 const base::FilePath& current_working_directory, | 259 const base::FilePath& current_working_directory, |
260 bool enable_pixel_dumping, | 260 bool enable_pixel_dumping, |
261 const std::string& expected_pixel_hash) { | 261 const std::string& expected_pixel_hash) { |
262 DCHECK(CalledOnValidThread()); | 262 DCHECK(CalledOnValidThread()); |
| 263 VLOG(1) << "Preparing for the next layout test..."; |
| 264 |
| 265 if (!base::SharedMemory::IsHandleValid(layout_dump_flags_memory_.handle())) { |
| 266 if (!layout_dump_flags_memory_.CreateAnonymous( |
| 267 sizeof(test_runner::LayoutDumpFlags))) { |
| 268 // TODO / DO NOT SUBMIT: Report the error somehow. |
| 269 CHECK(false); |
| 270 } |
| 271 } |
| 272 DCHECK(base::SharedMemory::IsHandleValid(layout_dump_flags_memory_.handle())); |
| 273 |
263 test_phase_ = DURING_TEST; | 274 test_phase_ = DURING_TEST; |
264 current_working_directory_ = current_working_directory; | 275 current_working_directory_ = current_working_directory; |
265 enable_pixel_dumping_ = enable_pixel_dumping; | 276 enable_pixel_dumping_ = enable_pixel_dumping; |
266 expected_pixel_hash_ = expected_pixel_hash; | 277 expected_pixel_hash_ = expected_pixel_hash; |
267 test_url_ = test_url; | 278 test_url_ = test_url; |
268 need_to_send_test_configuration_to_renderer_ = true; | 279 need_to_send_test_configuration_to_renderer_ = true; |
269 printer_->reset(); | 280 printer_->reset(); |
270 frame_to_layout_dump_map_.clear(); | 281 frame_to_layout_dump_map_.clear(); |
271 render_process_host_observer_.RemoveAll(); | 282 render_process_host_observer_.RemoveAll(); |
272 ShellBrowserContext* browser_context = | 283 ShellBrowserContext* browser_context = |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 ShellTestConfiguration params; | 598 ShellTestConfiguration params; |
588 params.current_working_directory = current_working_directory_; | 599 params.current_working_directory = current_working_directory_; |
589 params.temp_path = temp_path_; | 600 params.temp_path = temp_path_; |
590 params.test_url = test_url_; | 601 params.test_url = test_url_; |
591 params.enable_pixel_dumping = enable_pixel_dumping_; | 602 params.enable_pixel_dumping = enable_pixel_dumping_; |
592 params.allow_external_pages = | 603 params.allow_external_pages = |
593 base::CommandLine::ForCurrentProcess()->HasSwitch( | 604 base::CommandLine::ForCurrentProcess()->HasSwitch( |
594 switches::kAllowExternalPages); | 605 switches::kAllowExternalPages); |
595 params.expected_pixel_hash = expected_pixel_hash_; | 606 params.expected_pixel_hash = expected_pixel_hash_; |
596 params.initial_size = initial_size_; | 607 params.initial_size = initial_size_; |
| 608 params.layout_dump_flags_memory_handle = |
| 609 base::SharedMemory::DuplicateHandle(layout_dump_flags_memory_.handle()); |
597 | 610 |
598 if (need_to_send_test_configuration_to_renderer_) { | 611 if (need_to_send_test_configuration_to_renderer_) { |
599 need_to_send_test_configuration_to_renderer_ = false; | 612 need_to_send_test_configuration_to_renderer_ = false; |
600 frame->Send( | 613 frame->Send( |
601 new ShellViewMsg_SetTestConfiguration(frame->GetRoutingID(), params)); | 614 new ShellViewMsg_SetTestConfiguration(frame->GetRoutingID(), params)); |
602 } else { | 615 } else { |
603 frame->Send(new ShellViewMsg_ReplicateTestConfiguration( | 616 frame->Send(new ShellViewMsg_ReplicateTestConfiguration( |
604 frame->GetRoutingID(), params)); | 617 frame->GetRoutingID(), params)); |
605 } | 618 } |
606 } | 619 } |
607 | 620 |
608 void BlinkTestController::OnTestFinished() { | 621 void BlinkTestController::OnTestFinished() { |
| 622 VLOG(1) << "Test finished"; |
| 623 |
609 test_phase_ = CLEAN_UP; | 624 test_phase_ = CLEAN_UP; |
610 if (!printer_->output_finished()) | 625 if (!printer_->output_finished()) |
611 printer_->PrintImageFooter(); | 626 printer_->PrintImageFooter(); |
612 RenderViewHost* render_view_host = | 627 RenderViewHost* render_view_host = |
613 main_window_->web_contents()->GetRenderViewHost(); | 628 main_window_->web_contents()->GetRenderViewHost(); |
614 main_window_->web_contents()->ExitFullscreen(/*will_cause_resize=*/false); | 629 main_window_->web_contents()->ExitFullscreen(/*will_cause_resize=*/false); |
615 | 630 |
616 ShellBrowserContext* browser_context = | 631 ShellBrowserContext* browser_context = |
617 ShellContentBrowserClient::Get()->browser_context(); | 632 ShellContentBrowserClient::Get()->browser_context(); |
618 StoragePartition* storage_partition = | 633 StoragePartition* storage_partition = |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
660 printer_->PrintAudioBlock(dump); | 675 printer_->PrintAudioBlock(dump); |
661 printer_->PrintAudioFooter(); | 676 printer_->PrintAudioFooter(); |
662 } | 677 } |
663 | 678 |
664 void BlinkTestController::OnTextDump(const std::string& dump) { | 679 void BlinkTestController::OnTextDump(const std::string& dump) { |
665 printer_->PrintTextHeader(); | 680 printer_->PrintTextHeader(); |
666 printer_->PrintTextBlock(dump); | 681 printer_->PrintTextBlock(dump); |
667 printer_->PrintTextFooter(); | 682 printer_->PrintTextFooter(); |
668 } | 683 } |
669 | 684 |
670 void BlinkTestController::OnInitiateLayoutDump( | 685 void BlinkTestController::OnInitiateLayoutDump(bool dump_child_frames) { |
671 const test_runner::LayoutDumpFlags& layout_dump_flags) { | 686 if (dump_child_frames) { |
672 DCHECK(layout_dump_flags.dump_child_frames()); | 687 pending_layout_dumps_ = main_window_->web_contents()->SendToAllFrames( |
673 pending_layout_dumps_ = main_window_->web_contents()->SendToAllFrames( | 688 new ShellViewMsg_LayoutDumpRequest(MSG_ROUTING_NONE)); |
674 new ShellViewMsg_LayoutDumpRequest(MSG_ROUTING_NONE, layout_dump_flags)); | 689 VLOG(1) << "Asking all " << pending_layout_dumps_ |
| 690 << " frames for a layout dump."; |
| 691 } else { |
| 692 VLOG(1) << "Asking the main frame for a layout dump."; |
| 693 RenderFrameHost* main_frame = main_window_->web_contents()->GetMainFrame(); |
| 694 main_frame->Send( |
| 695 new ShellViewMsg_LayoutDumpRequest(main_frame->GetRoutingID())); |
| 696 pending_layout_dumps_ = 1; |
| 697 } |
675 } | 698 } |
676 | 699 |
677 void BlinkTestController::OnLayoutDumpResponse(RenderFrameHost* sender, | 700 void BlinkTestController::OnLayoutDumpResponse(RenderFrameHost* sender, |
678 const std::string& dump) { | 701 const std::string& dump) { |
| 702 VLOG(1) << "Got layout dump response from frame " |
| 703 << sender->GetFrameTreeNodeId(); |
| 704 |
679 // Store the result. | 705 // Store the result. |
680 auto pair = frame_to_layout_dump_map_.insert( | 706 auto pair = frame_to_layout_dump_map_.insert( |
681 std::make_pair(sender->GetFrameTreeNodeId(), dump)); | 707 std::make_pair(sender->GetFrameTreeNodeId(), dump)); |
682 bool insertion_took_place = pair.second; | 708 bool insertion_took_place = pair.second; |
683 DCHECK(insertion_took_place); | 709 DCHECK(insertion_took_place); |
684 | 710 |
685 // See if we need to wait for more responses. | 711 // See if we need to wait for more responses. |
686 pending_layout_dumps_--; | 712 pending_layout_dumps_--; |
687 DCHECK_LE(0, pending_layout_dumps_); | 713 DCHECK_LE(0, pending_layout_dumps_); |
688 if (pending_layout_dumps_ > 0) | 714 if (pending_layout_dumps_ > 0) |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 Shell* devtools_shell = devtools_frontend_ ? | 829 Shell* devtools_shell = devtools_frontend_ ? |
804 devtools_frontend_->frontend_shell() : NULL; | 830 devtools_frontend_->frontend_shell() : NULL; |
805 for (size_t i = 0; i < open_windows.size(); ++i) { | 831 for (size_t i = 0; i < open_windows.size(); ++i) { |
806 if (open_windows[i] != main_window_ && open_windows[i] != devtools_shell) | 832 if (open_windows[i] != main_window_ && open_windows[i] != devtools_shell) |
807 open_windows[i]->Close(); | 833 open_windows[i]->Close(); |
808 } | 834 } |
809 base::MessageLoop::current()->RunUntilIdle(); | 835 base::MessageLoop::current()->RunUntilIdle(); |
810 } | 836 } |
811 | 837 |
812 void BlinkTestController::OnResetDone() { | 838 void BlinkTestController::OnResetDone() { |
| 839 VLOG(1) << "Reset done."; |
813 if (is_leak_detection_enabled_) { | 840 if (is_leak_detection_enabled_) { |
814 if (main_window_ && main_window_->web_contents()) { | 841 if (main_window_ && main_window_->web_contents()) { |
815 RenderViewHost* render_view_host = | 842 RenderViewHost* render_view_host = |
816 main_window_->web_contents()->GetRenderViewHost(); | 843 main_window_->web_contents()->GetRenderViewHost(); |
817 render_view_host->Send( | 844 render_view_host->Send( |
818 new ShellViewMsg_TryLeakDetection(render_view_host->GetRoutingID())); | 845 new ShellViewMsg_TryLeakDetection(render_view_host->GetRoutingID())); |
819 } | 846 } |
820 return; | 847 return; |
821 } | 848 } |
822 | 849 |
| 850 VLOG(1) << "Quitting the message loop..."; |
823 base::ThreadTaskRunnerHandle::Get()->PostTask( | 851 base::ThreadTaskRunnerHandle::Get()->PostTask( |
824 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | 852 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
825 } | 853 } |
826 | 854 |
827 void BlinkTestController::OnLeakDetectionDone( | 855 void BlinkTestController::OnLeakDetectionDone( |
828 const LeakDetectionResult& result) { | 856 const LeakDetectionResult& result) { |
829 if (!result.leaked) { | 857 if (!result.leaked) { |
830 base::ThreadTaskRunnerHandle::Get()->PostTask( | 858 base::ThreadTaskRunnerHandle::Get()->PostTask( |
831 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | 859 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
832 return; | 860 return; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 } else { | 906 } else { |
879 printer_->AddErrorMessage(base::StringPrintf( | 907 printer_->AddErrorMessage(base::StringPrintf( |
880 "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.", | 908 "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.", |
881 event_name.c_str())); | 909 event_name.c_str())); |
882 return; | 910 return; |
883 } | 911 } |
884 bluetooth_chooser_factory_->SendEvent(event, argument); | 912 bluetooth_chooser_factory_->SendEvent(event, argument); |
885 } | 913 } |
886 | 914 |
887 } // namespace content | 915 } // namespace content |
OLD | NEW |