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

Side by Side Diff: content/shell/renderer/layout_test/blink_test_runner.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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer/layout_test/blink_test_runner.h" 5 #include "content/shell/renderer/layout_test/blink_test_runner.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <clocale> 10 #include <clocale>
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 return base::TimeDelta(base::Time::Now() - 325 return base::TimeDelta(base::Time::Now() -
326 base::Time::UnixEpoch()).ToInternalValue() / 326 base::Time::UnixEpoch()).ToInternalValue() /
327 base::Time::kMicrosecondsPerMillisecond; 327 base::Time::kMicrosecondsPerMillisecond;
328 } 328 }
329 329
330 WebString BlinkTestRunner::GetAbsoluteWebStringFromUTF8Path( 330 WebString BlinkTestRunner::GetAbsoluteWebStringFromUTF8Path(
331 const std::string& utf8_path) { 331 const std::string& utf8_path) {
332 base::FilePath path = base::FilePath::FromUTF8Unsafe(utf8_path); 332 base::FilePath path = base::FilePath::FromUTF8Unsafe(utf8_path);
333 if (!path.IsAbsolute()) { 333 if (!path.IsAbsolute()) {
334 GURL base_url = 334 GURL base_url =
335 net::FilePathToFileURL(test_config_.current_working_directory.Append( 335 net::FilePathToFileURL(test_config_->current_working_directory.Append(
336 FILE_PATH_LITERAL("foo"))); 336 FILE_PATH_LITERAL("foo")));
337 net::FileURLToFilePath(base_url.Resolve(utf8_path), &path); 337 net::FileURLToFilePath(base_url.Resolve(utf8_path), &path);
338 } 338 }
339 return blink::FilePathToWebString(path); 339 return blink::FilePathToWebString(path);
340 } 340 }
341 341
342 WebURL BlinkTestRunner::LocalFileToDataURL(const WebURL& file_url) { 342 WebURL BlinkTestRunner::LocalFileToDataURL(const WebURL& file_url) {
343 base::FilePath local_path; 343 base::FilePath local_path;
344 if (!net::FileURLToFilePath(file_url, &local_path)) 344 if (!net::FileURLToFilePath(file_url, &local_path))
345 return WebURL(); 345 return WebURL();
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 } 556 }
557 557
558 void BlinkTestRunner::SetBlockThirdPartyCookies(bool block) { 558 void BlinkTestRunner::SetBlockThirdPartyCookies(bool block) {
559 Send(new LayoutTestHostMsg_BlockThirdPartyCookies(routing_id(), block)); 559 Send(new LayoutTestHostMsg_BlockThirdPartyCookies(routing_id(), block));
560 } 560 }
561 561
562 std::string BlinkTestRunner::PathToLocalResource(const std::string& resource) { 562 std::string BlinkTestRunner::PathToLocalResource(const std::string& resource) {
563 #if defined(OS_WIN) 563 #if defined(OS_WIN)
564 if (base::StartsWith(resource, "/tmp/", base::CompareCase::SENSITIVE)) { 564 if (base::StartsWith(resource, "/tmp/", base::CompareCase::SENSITIVE)) {
565 // We want a temp file. 565 // We want a temp file.
566 GURL base_url = net::FilePathToFileURL(test_config_.temp_path); 566 GURL base_url = net::FilePathToFileURL(test_config_->temp_path);
567 return base_url.Resolve(resource.substr(sizeof("/tmp/") - 1)).spec(); 567 return base_url.Resolve(resource.substr(sizeof("/tmp/") - 1)).spec();
568 } 568 }
569 #endif 569 #endif
570 570
571 // Some layout tests use file://// which we resolve as a UNC path. Normalize 571 // Some layout tests use file://// which we resolve as a UNC path. Normalize
572 // them to just file:///. 572 // them to just file:///.
573 std::string result = resource; 573 std::string result = resource;
574 static const size_t kFileLen = sizeof("file:///") - 1; 574 static const size_t kFileLen = sizeof("file:///") - 1;
575 while (base::StartsWith(base::ToLowerASCII(result), "file:////", 575 while (base::StartsWith(base::ToLowerASCII(result), "file:////",
576 base::CompareCase::SENSITIVE)) { 576 base::CompareCase::SENSITIVE)) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 Send(new ShellViewHostMsg_Reload(routing_id())); 636 Send(new ShellViewHostMsg_Reload(routing_id()));
637 } 637 }
638 638
639 void BlinkTestRunner::LoadURLForFrame(const WebURL& url, 639 void BlinkTestRunner::LoadURLForFrame(const WebURL& url,
640 const std::string& frame_name) { 640 const std::string& frame_name) {
641 Send(new ShellViewHostMsg_LoadURLForFrame( 641 Send(new ShellViewHostMsg_LoadURLForFrame(
642 routing_id(), url, frame_name)); 642 routing_id(), url, frame_name));
643 } 643 }
644 644
645 bool BlinkTestRunner::AllowExternalPages() { 645 bool BlinkTestRunner::AllowExternalPages() {
646 return test_config_.allow_external_pages; 646 return test_config_->allow_external_pages;
647 } 647 }
648 648
649 std::string BlinkTestRunner::DumpHistoryForWindow(blink::WebView* web_view) { 649 std::string BlinkTestRunner::DumpHistoryForWindow(blink::WebView* web_view) {
650 size_t pos = 0; 650 size_t pos = 0;
651 std::vector<int>::iterator id; 651 std::vector<int>::iterator id;
652 for (id = routing_ids_.begin(); id != routing_ids_.end(); ++id, ++pos) { 652 for (id = routing_ids_.begin(); id != routing_ids_.end(); ++id, ++pos) {
653 RenderView* render_view = RenderView::FromRoutingID(*id); 653 RenderView* render_view = RenderView::FromRoutingID(*id);
654 if (!render_view) { 654 if (!render_view) {
655 NOTREACHED(); 655 NOTREACHED();
656 continue; 656 continue;
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 889
890 Send(new ShellViewHostMsg_TextDump(routing_id(), 890 Send(new ShellViewHostMsg_TextDump(routing_id(),
891 std::move(completed_layout_dump))); 891 std::move(completed_layout_dump)));
892 892
893 CaptureDumpContinued(); 893 CaptureDumpContinued();
894 } 894 }
895 895
896 void BlinkTestRunner::CaptureDumpContinued() { 896 void BlinkTestRunner::CaptureDumpContinued() {
897 test_runner::WebTestInterfaces* interfaces = 897 test_runner::WebTestInterfaces* interfaces =
898 LayoutTestRenderThreadObserver::GetInstance()->test_interfaces(); 898 LayoutTestRenderThreadObserver::GetInstance()->test_interfaces();
899 if (test_config_.enable_pixel_dumping && 899 if (test_config_->enable_pixel_dumping &&
900 interfaces->TestRunner()->ShouldGeneratePixelResults() && 900 interfaces->TestRunner()->ShouldGeneratePixelResults() &&
901 !interfaces->TestRunner()->ShouldDumpAsAudio()) { 901 !interfaces->TestRunner()->ShouldDumpAsAudio()) {
902 CHECK(render_view()->GetWebView()->isAcceleratedCompositingActive()); 902 CHECK(render_view()->GetWebView()->isAcceleratedCompositingActive());
903 interfaces->TestRunner()->DumpPixelsAsync( 903 interfaces->TestRunner()->DumpPixelsAsync(
904 render_view()->GetWebView(), 904 render_view()->GetWebView(),
905 base::Bind(&BlinkTestRunner::OnPixelsDumpCompleted, 905 base::Bind(&BlinkTestRunner::OnPixelsDumpCompleted,
906 base::Unretained(this))); 906 base::Unretained(this)));
907 return; 907 return;
908 } 908 }
909 909
910 CaptureDumpComplete(); 910 CaptureDumpComplete();
911 } 911 }
912 912
913 void BlinkTestRunner::OnPixelsDumpCompleted(const SkBitmap& snapshot) { 913 void BlinkTestRunner::OnPixelsDumpCompleted(const SkBitmap& snapshot) {
914 DCHECK_NE(0, snapshot.info().width()); 914 DCHECK_NE(0, snapshot.info().width());
915 DCHECK_NE(0, snapshot.info().height()); 915 DCHECK_NE(0, snapshot.info().height());
916 916
917 SkAutoLockPixels snapshot_lock(snapshot); 917 SkAutoLockPixels snapshot_lock(snapshot);
918 // The snapshot arrives from the GPU process via shared memory. Because MSan 918 // The snapshot arrives from the GPU process via shared memory. Because MSan
919 // can't track initializedness across processes, we must assure it that the 919 // can't track initializedness across processes, we must assure it that the
920 // pixels are in fact initialized. 920 // pixels are in fact initialized.
921 MSAN_UNPOISON(snapshot.getPixels(), snapshot.getSize()); 921 MSAN_UNPOISON(snapshot.getPixels(), snapshot.getSize());
922 base::MD5Digest digest; 922 base::MD5Digest digest;
923 base::MD5Sum(snapshot.getPixels(), snapshot.getSize(), &digest); 923 base::MD5Sum(snapshot.getPixels(), snapshot.getSize(), &digest);
924 std::string actual_pixel_hash = base::MD5DigestToBase16(digest); 924 std::string actual_pixel_hash = base::MD5DigestToBase16(digest);
925 925
926 if (actual_pixel_hash == test_config_.expected_pixel_hash) { 926 if (actual_pixel_hash == test_config_->expected_pixel_hash) {
927 SkBitmap empty_image; 927 SkBitmap empty_image;
928 Send(new ShellViewHostMsg_ImageDump( 928 Send(new ShellViewHostMsg_ImageDump(
929 routing_id(), actual_pixel_hash, empty_image)); 929 routing_id(), actual_pixel_hash, empty_image));
930 } else { 930 } else {
931 Send(new ShellViewHostMsg_ImageDump( 931 Send(new ShellViewHostMsg_ImageDump(
932 routing_id(), actual_pixel_hash, snapshot)); 932 routing_id(), actual_pixel_hash, snapshot));
933 } 933 }
934 934
935 CaptureDumpComplete(); 935 CaptureDumpComplete();
936 } 936 }
(...skipping 17 matching lines...) Expand all
954 DCHECK(!is_main_window_); 954 DCHECK(!is_main_window_);
955 955
956 test_runner::WebTestInterfaces* interfaces = 956 test_runner::WebTestInterfaces* interfaces =
957 LayoutTestRenderThreadObserver::GetInstance()->test_interfaces(); 957 LayoutTestRenderThreadObserver::GetInstance()->test_interfaces();
958 interfaces->SetTestIsRunning(true); 958 interfaces->SetTestIsRunning(true);
959 interfaces->ConfigureForTestWithURL(GURL(), false); 959 interfaces->ConfigureForTestWithURL(GURL(), false);
960 ForceResizeRenderView(render_view(), WebSize(800, 600)); 960 ForceResizeRenderView(render_view(), WebSize(800, 600));
961 } 961 }
962 962
963 void BlinkTestRunner::OnReplicateTestConfiguration( 963 void BlinkTestRunner::OnReplicateTestConfiguration(
964 const ShellTestConfiguration& params) { 964 mojom::ShellTestConfigurationPtr params) {
965 test_runner::WebTestInterfaces* interfaces = 965 test_runner::WebTestInterfaces* interfaces =
966 LayoutTestRenderThreadObserver::GetInstance()->test_interfaces(); 966 LayoutTestRenderThreadObserver::GetInstance()->test_interfaces();
967 967
968 test_config_ = params; 968 test_config_ = params.Clone();
969 969
970 is_main_window_ = true; 970 is_main_window_ = true;
971 interfaces->SetMainView(render_view()->GetWebView()); 971 interfaces->SetMainView(render_view()->GetWebView());
972 972
973 interfaces->SetTestIsRunning(true); 973 interfaces->SetTestIsRunning(true);
974 interfaces->ConfigureForTestWithURL(params.test_url, 974 interfaces->ConfigureForTestWithURL(params->test_url,
975 params.enable_pixel_dumping); 975 params->enable_pixel_dumping);
976 } 976 }
977 977
978 void BlinkTestRunner::OnSetTestConfiguration( 978 void BlinkTestRunner::OnSetTestConfiguration(
979 const ShellTestConfiguration& params) { 979 mojom::ShellTestConfigurationPtr params) {
980 OnReplicateTestConfiguration(params); 980 mojom::ShellTestConfigurationPtr local_params = params.Clone();
981 OnReplicateTestConfiguration(std::move(params));
981 982
982 ForceResizeRenderView( 983 ForceResizeRenderView(render_view(),
983 render_view(), 984 WebSize(local_params->initial_size.width(),
984 WebSize(params.initial_size.width(), params.initial_size.height())); 985 local_params->initial_size.height()));
985 LayoutTestRenderThreadObserver::GetInstance() 986 LayoutTestRenderThreadObserver::GetInstance()
986 ->test_interfaces() 987 ->test_interfaces()
987 ->TestRunner() 988 ->TestRunner()
988 ->SetFocus(render_view()->GetWebView(), true); 989 ->SetFocus(render_view()->GetWebView(), true);
989 } 990 }
990 991
991 void BlinkTestRunner::OnSessionHistory( 992 void BlinkTestRunner::OnSessionHistory(
992 const std::vector<int>& routing_ids, 993 const std::vector<int>& routing_ids,
993 const std::vector<std::vector<PageState>>& session_histories, 994 const std::vector<std::vector<PageState>>& session_histories,
994 const std::vector<unsigned>& current_entry_indexes) { 995 const std::vector<unsigned>& current_entry_indexes) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 void BlinkTestRunner::ReportLeakDetectionResult( 1035 void BlinkTestRunner::ReportLeakDetectionResult(
1035 const LeakDetectionResult& report) { 1036 const LeakDetectionResult& report) {
1036 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); 1037 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report));
1037 } 1038 }
1038 1039
1039 void BlinkTestRunner::OnDestruct() { 1040 void BlinkTestRunner::OnDestruct() {
1040 delete this; 1041 delete this;
1041 } 1042 }
1042 1043
1043 } // namespace content 1044 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698