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

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

Powered by Google App Engine
This is Rietveld 408576698