OLD | NEW |
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 #include <algorithm> | 8 #include <algorithm> |
9 #include <clocale> | 9 #include <clocale> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
24 #include "base/strings/stringprintf.h" | 24 #include "base/strings/stringprintf.h" |
25 #include "base/strings/sys_string_conversions.h" | 25 #include "base/strings/sys_string_conversions.h" |
26 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
27 #include "base/thread_task_runner_handle.h" | 27 #include "base/thread_task_runner_handle.h" |
28 #include "base/time/time.h" | 28 #include "base/time/time.h" |
29 #include "build/build_config.h" | 29 #include "build/build_config.h" |
30 #include "components/plugins/renderer/plugin_placeholder.h" | 30 #include "components/plugins/renderer/plugin_placeholder.h" |
31 #include "components/test_runner/app_banner_client.h" | 31 #include "components/test_runner/app_banner_client.h" |
32 #include "components/test_runner/gamepad_controller.h" | 32 #include "components/test_runner/gamepad_controller.h" |
| 33 #include "components/test_runner/layout_dump.h" |
| 34 #include "components/test_runner/layout_dump_flags.h" |
33 #include "components/test_runner/mock_screen_orientation_client.h" | 35 #include "components/test_runner/mock_screen_orientation_client.h" |
34 #include "components/test_runner/test_interfaces.h" | 36 #include "components/test_runner/test_interfaces.h" |
35 #include "components/test_runner/web_task.h" | 37 #include "components/test_runner/web_task.h" |
36 #include "components/test_runner/web_test_interfaces.h" | 38 #include "components/test_runner/web_test_interfaces.h" |
37 #include "components/test_runner/web_test_proxy.h" | 39 #include "components/test_runner/web_test_proxy.h" |
38 #include "components/test_runner/web_test_runner.h" | 40 #include "components/test_runner/web_test_runner.h" |
39 #include "content/public/common/content_switches.h" | 41 #include "content/public/common/content_switches.h" |
40 #include "content/public/common/url_constants.h" | 42 #include "content/public/common/url_constants.h" |
41 #include "content/public/common/web_preferences.h" | 43 #include "content/public/common/web_preferences.h" |
42 #include "content/public/renderer/media_stream_api.h" | 44 #include "content/public/renderer/media_stream_api.h" |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 bool handled = true; | 814 bool handled = true; |
813 IPC_BEGIN_MESSAGE_MAP(BlinkTestRunner, message) | 815 IPC_BEGIN_MESSAGE_MAP(BlinkTestRunner, message) |
814 IPC_MESSAGE_HANDLER(ShellViewMsg_SetTestConfiguration, | 816 IPC_MESSAGE_HANDLER(ShellViewMsg_SetTestConfiguration, |
815 OnSetTestConfiguration) | 817 OnSetTestConfiguration) |
816 IPC_MESSAGE_HANDLER(ShellViewMsg_SessionHistory, OnSessionHistory) | 818 IPC_MESSAGE_HANDLER(ShellViewMsg_SessionHistory, OnSessionHistory) |
817 IPC_MESSAGE_HANDLER(ShellViewMsg_Reset, OnReset) | 819 IPC_MESSAGE_HANDLER(ShellViewMsg_Reset, OnReset) |
818 IPC_MESSAGE_HANDLER(ShellViewMsg_NotifyDone, OnNotifyDone) | 820 IPC_MESSAGE_HANDLER(ShellViewMsg_NotifyDone, OnNotifyDone) |
819 IPC_MESSAGE_HANDLER(ShellViewMsg_TryLeakDetection, OnTryLeakDetection) | 821 IPC_MESSAGE_HANDLER(ShellViewMsg_TryLeakDetection, OnTryLeakDetection) |
820 IPC_MESSAGE_HANDLER(ShellViewMsg_ReplyBluetoothManualChooserEvents, | 822 IPC_MESSAGE_HANDLER(ShellViewMsg_ReplyBluetoothManualChooserEvents, |
821 OnReplyBluetoothManualChooserEvents) | 823 OnReplyBluetoothManualChooserEvents) |
| 824 IPC_MESSAGE_HANDLER(ShellViewMsg_LayoutDumpCompleted, OnLayoutDumpCompleted) |
822 IPC_MESSAGE_UNHANDLED(handled = false) | 825 IPC_MESSAGE_UNHANDLED(handled = false) |
823 IPC_END_MESSAGE_MAP() | 826 IPC_END_MESSAGE_MAP() |
824 | 827 |
825 return handled; | 828 return handled; |
826 } | 829 } |
827 | 830 |
828 void BlinkTestRunner::Navigate(const GURL& url) { | 831 void BlinkTestRunner::Navigate(const GURL& url) { |
829 focus_on_next_commit_ = true; | 832 focus_on_next_commit_ = true; |
830 if (!is_main_window_ && | 833 if (!is_main_window_ && |
831 LayoutTestRenderProcessObserver::GetInstance()->main_test_runner() == | 834 LayoutTestRenderProcessObserver::GetInstance()->main_test_runner() == |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 | 883 |
881 void BlinkTestRunner::CaptureDump() { | 884 void BlinkTestRunner::CaptureDump() { |
882 test_runner::WebTestInterfaces* interfaces = | 885 test_runner::WebTestInterfaces* interfaces = |
883 LayoutTestRenderProcessObserver::GetInstance()->test_interfaces(); | 886 LayoutTestRenderProcessObserver::GetInstance()->test_interfaces(); |
884 TRACE_EVENT0("shell", "BlinkTestRunner::CaptureDump"); | 887 TRACE_EVENT0("shell", "BlinkTestRunner::CaptureDump"); |
885 | 888 |
886 if (interfaces->TestRunner()->ShouldDumpAsAudio()) { | 889 if (interfaces->TestRunner()->ShouldDumpAsAudio()) { |
887 std::vector<unsigned char> vector_data; | 890 std::vector<unsigned char> vector_data; |
888 interfaces->TestRunner()->GetAudioData(&vector_data); | 891 interfaces->TestRunner()->GetAudioData(&vector_data); |
889 Send(new ShellViewHostMsg_AudioDump(routing_id(), vector_data)); | 892 Send(new ShellViewHostMsg_AudioDump(routing_id(), vector_data)); |
890 } else { | 893 CaptureDumpContinued(); |
891 const base::CommandLine& command_line = | 894 return; |
892 *base::CommandLine::ForCurrentProcess(); | 895 } |
893 Send(new ShellViewHostMsg_TextDump( | |
894 routing_id(), proxy()->CaptureTree( | |
895 false, command_line.HasSwitch(switches::kDumpLineBoxTrees)))); | |
896 | 896 |
897 if (test_config_.enable_pixel_dumping && | 897 std::string custom_text_dump; |
898 interfaces->TestRunner()->ShouldGeneratePixelResults()) { | 898 if (interfaces->TestRunner()->HasCustomTextDump(&custom_text_dump)) { |
899 CHECK(render_view()->GetWebView()->isAcceleratedCompositingActive()); | 899 Send(new ShellViewHostMsg_TextDump(routing_id(), custom_text_dump + "\n")); |
900 proxy()->CapturePixelsAsync(base::Bind( | 900 CaptureDumpContinued(); |
901 &BlinkTestRunner::CaptureDumpPixels, base::Unretained(this))); | 901 return; |
902 return; | |
903 } | |
904 } | 902 } |
| 903 |
| 904 test_runner::LayoutDumpFlags layout_dump_flags = |
| 905 interfaces->TestRunner()->GetLayoutDumpFlags(); |
| 906 layout_dump_flags.dump_line_box_trees = |
| 907 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 908 switches::kDumpLineBoxTrees); |
| 909 |
| 910 if (!layout_dump_flags.dump_child_frames) { |
| 911 std::string layout_dump = DumpLayout( |
| 912 render_view()->GetMainRenderFrame()->GetWebFrame(), layout_dump_flags); |
| 913 OnLayoutDumpCompleted(layout_dump); |
| 914 return; |
| 915 } |
| 916 |
| 917 Send( |
| 918 new ShellViewHostMsg_InitiateLayoutDump(routing_id(), layout_dump_flags)); |
| 919 // OnLayoutDumpCompleted will be eventually called by an IPC from the browser. |
| 920 } |
| 921 |
| 922 void BlinkTestRunner::OnLayoutDumpCompleted(std::string completed_layout_dump) { |
| 923 test_runner::WebTestInterfaces* interfaces = |
| 924 LayoutTestRenderProcessObserver::GetInstance()->test_interfaces(); |
| 925 if (interfaces->TestRunner()->ShouldDumpBackForwardList()) { |
| 926 completed_layout_dump.append(proxy()->DumpBackForwardLists()); |
| 927 } |
| 928 |
| 929 Send(new ShellViewHostMsg_TextDump(routing_id(), completed_layout_dump)); |
| 930 |
| 931 CaptureDumpContinued(); |
| 932 } |
| 933 |
| 934 void BlinkTestRunner::CaptureDumpContinued() { |
| 935 test_runner::WebTestInterfaces* interfaces = |
| 936 LayoutTestRenderProcessObserver::GetInstance()->test_interfaces(); |
| 937 if (test_config_.enable_pixel_dumping && |
| 938 interfaces->TestRunner()->ShouldGeneratePixelResults() && |
| 939 !interfaces->TestRunner()->ShouldDumpAsAudio()) { |
| 940 CHECK(render_view()->GetWebView()->isAcceleratedCompositingActive()); |
| 941 proxy()->CapturePixelsAsync(base::Bind( |
| 942 &BlinkTestRunner::OnPixelsDumpCompleted, base::Unretained(this))); |
| 943 return; |
| 944 } |
| 945 |
905 #ifndef NDEBUG | 946 #ifndef NDEBUG |
906 // Force a layout/paint by the end of the test to ensure test coverage of | 947 // Force a layout/paint by the end of the test to ensure test coverage of |
907 // incremental painting. | 948 // incremental painting. |
908 proxy()->LayoutAndPaintAsyncThen(base::Bind( | 949 proxy()->LayoutAndPaintAsyncThen(base::Bind( |
909 &BlinkTestRunner::CaptureDumpComplete, base::Unretained(this))); | 950 &BlinkTestRunner::CaptureDumpComplete, base::Unretained(this))); |
910 return; | |
911 #else | 951 #else |
912 CaptureDumpComplete(); | 952 CaptureDumpComplete(); |
913 #endif | 953 #endif |
914 } | 954 } |
915 | 955 |
916 void BlinkTestRunner::CaptureDumpPixels(const SkBitmap& snapshot) { | 956 void BlinkTestRunner::OnPixelsDumpCompleted(const SkBitmap& snapshot) { |
917 DCHECK_NE(0, snapshot.info().width()); | 957 DCHECK_NE(0, snapshot.info().width()); |
918 DCHECK_NE(0, snapshot.info().height()); | 958 DCHECK_NE(0, snapshot.info().height()); |
919 | 959 |
920 SkAutoLockPixels snapshot_lock(snapshot); | 960 SkAutoLockPixels snapshot_lock(snapshot); |
921 // The snapshot arrives from the GPU process via shared memory. Because MSan | 961 // The snapshot arrives from the GPU process via shared memory. Because MSan |
922 // can't track initializedness across processes, we must assure it that the | 962 // can't track initializedness across processes, we must assure it that the |
923 // pixels are in fact initialized. | 963 // pixels are in fact initialized. |
924 MSAN_UNPOISON(snapshot.getPixels(), snapshot.getSize()); | 964 MSAN_UNPOISON(snapshot.getPixels(), snapshot.getSize()); |
925 base::MD5Digest digest; | 965 base::MD5Digest digest; |
926 base::MD5Sum(snapshot.getPixels(), snapshot.getSize(), &digest); | 966 base::MD5Sum(snapshot.getPixels(), snapshot.getSize(), &digest); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 get_bluetooth_events_callbacks_.pop_front(); | 1046 get_bluetooth_events_callbacks_.pop_front(); |
1007 callback.Run(events); | 1047 callback.Run(events); |
1008 } | 1048 } |
1009 | 1049 |
1010 void BlinkTestRunner::ReportLeakDetectionResult( | 1050 void BlinkTestRunner::ReportLeakDetectionResult( |
1011 const LeakDetectionResult& report) { | 1051 const LeakDetectionResult& report) { |
1012 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); | 1052 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); |
1013 } | 1053 } |
1014 | 1054 |
1015 } // namespace content | 1055 } // namespace content |
OLD | NEW |