| 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 "base/values.h" | 29 #include "base/values.h" |
| 30 #include "build/build_config.h" | 30 #include "build/build_config.h" |
| 31 #include "components/plugins/renderer/plugin_placeholder.h" | 31 #include "components/plugins/renderer/plugin_placeholder.h" |
| 32 #include "components/test_runner/gamepad_controller.h" | 32 #include "components/test_runner/gamepad_controller.h" |
| 33 #include "components/test_runner/pixel_dump.h" | |
| 34 #include "components/test_runner/web_test_interfaces.h" | 33 #include "components/test_runner/web_test_interfaces.h" |
| 35 #include "components/test_runner/web_test_proxy.h" | 34 #include "components/test_runner/web_test_proxy.h" |
| 36 #include "components/test_runner/web_test_runner.h" | 35 #include "components/test_runner/web_test_runner.h" |
| 37 #include "content/public/common/content_switches.h" | 36 #include "content/public/common/content_switches.h" |
| 38 #include "content/public/common/url_constants.h" | 37 #include "content/public/common/url_constants.h" |
| 39 #include "content/public/common/web_preferences.h" | 38 #include "content/public/common/web_preferences.h" |
| 40 #include "content/public/renderer/media_stream_utils.h" | 39 #include "content/public/renderer/media_stream_utils.h" |
| 41 #include "content/public/renderer/render_frame.h" | 40 #include "content/public/renderer/render_frame.h" |
| 42 #include "content/public/renderer/render_view.h" | 41 #include "content/public/renderer/render_view.h" |
| 43 #include "content/public/renderer/render_view_visitor.h" | 42 #include "content/public/renderer/render_view_visitor.h" |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 blink::WebLocalFrame* frame, const blink::WebPluginParams& params) { | 722 blink::WebLocalFrame* frame, const blink::WebPluginParams& params) { |
| 724 if (params.mimeType != "application/x-plugin-placeholder-test") | 723 if (params.mimeType != "application/x-plugin-placeholder-test") |
| 725 return nullptr; | 724 return nullptr; |
| 726 | 725 |
| 727 plugins::PluginPlaceholder* placeholder = | 726 plugins::PluginPlaceholder* placeholder = |
| 728 new plugins::PluginPlaceholder(render_view()->GetMainRenderFrame(), frame, | 727 new plugins::PluginPlaceholder(render_view()->GetMainRenderFrame(), frame, |
| 729 params, "<div>Test content</div>"); | 728 params, "<div>Test content</div>"); |
| 730 return placeholder->plugin(); | 729 return placeholder->plugin(); |
| 731 } | 730 } |
| 732 | 731 |
| 733 float BlinkTestRunner::GetDeviceScaleFactorForTest() const { | 732 blink::WebPoint BlinkTestRunner::ConvertDIPToNative( |
| 734 return render_view()->GetDeviceScaleFactorForTest(); | 733 const blink::WebPoint& point_in_dip) const { |
| 734 float scale = render_view()->GetDeviceScaleFactorForTest(); |
| 735 return blink::WebPoint(point_in_dip.x * scale, |
| 736 point_in_dip.y * scale); |
| 735 } | 737 } |
| 736 | 738 |
| 737 bool BlinkTestRunner::AddMediaStreamVideoSourceAndTrack( | 739 bool BlinkTestRunner::AddMediaStreamVideoSourceAndTrack( |
| 738 blink::WebMediaStream* stream) { | 740 blink::WebMediaStream* stream) { |
| 739 DCHECK(stream); | 741 DCHECK(stream); |
| 740 #if defined(ENABLE_WEBRTC) | 742 #if defined(ENABLE_WEBRTC) |
| 741 return AddVideoTrackToMediaStream( | 743 return AddVideoTrackToMediaStream( |
| 742 make_scoped_ptr(new MockVideoCapturerSource()), | 744 make_scoped_ptr(new MockVideoCapturerSource()), |
| 743 false, // is_remote | 745 false, // is_remote |
| 744 false, // is_readonly | 746 false, // is_readonly |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 CaptureDumpContinued(); | 889 CaptureDumpContinued(); |
| 888 } | 890 } |
| 889 | 891 |
| 890 void BlinkTestRunner::CaptureDumpContinued() { | 892 void BlinkTestRunner::CaptureDumpContinued() { |
| 891 test_runner::WebTestInterfaces* interfaces = | 893 test_runner::WebTestInterfaces* interfaces = |
| 892 LayoutTestRenderProcessObserver::GetInstance()->test_interfaces(); | 894 LayoutTestRenderProcessObserver::GetInstance()->test_interfaces(); |
| 893 if (test_config_.enable_pixel_dumping && | 895 if (test_config_.enable_pixel_dumping && |
| 894 interfaces->TestRunner()->ShouldGeneratePixelResults() && | 896 interfaces->TestRunner()->ShouldGeneratePixelResults() && |
| 895 !interfaces->TestRunner()->ShouldDumpAsAudio()) { | 897 !interfaces->TestRunner()->ShouldDumpAsAudio()) { |
| 896 CHECK(render_view()->GetWebView()->isAcceleratedCompositingActive()); | 898 CHECK(render_view()->GetWebView()->isAcceleratedCompositingActive()); |
| 897 interfaces->TestRunner()->DumpPixelsAsync( | 899 proxy()->CapturePixelsAsync(base::Bind( |
| 898 render_view()->GetWebView(), | 900 &BlinkTestRunner::OnPixelsDumpCompleted, base::Unretained(this))); |
| 899 base::Bind(&BlinkTestRunner::OnPixelsDumpCompleted, | |
| 900 base::Unretained(this))); | |
| 901 return; | 901 return; |
| 902 } | 902 } |
| 903 | 903 |
| 904 #ifndef NDEBUG | 904 #ifndef NDEBUG |
| 905 // Force a layout/paint by the end of the test to ensure test coverage of | 905 // Force a layout/paint by the end of the test to ensure test coverage of |
| 906 // incremental painting. | 906 // incremental painting. |
| 907 proxy()->LayoutAndPaintAsyncThen(base::Bind( | 907 proxy()->LayoutAndPaintAsyncThen(base::Bind( |
| 908 &BlinkTestRunner::CaptureDumpComplete, base::Unretained(this))); | 908 &BlinkTestRunner::CaptureDumpComplete, base::Unretained(this))); |
| 909 #else | 909 #else |
| 910 CaptureDumpComplete(); | 910 CaptureDumpComplete(); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 get_bluetooth_events_callbacks_.pop_front(); | 1009 get_bluetooth_events_callbacks_.pop_front(); |
| 1010 callback.Run(events); | 1010 callback.Run(events); |
| 1011 } | 1011 } |
| 1012 | 1012 |
| 1013 void BlinkTestRunner::ReportLeakDetectionResult( | 1013 void BlinkTestRunner::ReportLeakDetectionResult( |
| 1014 const LeakDetectionResult& report) { | 1014 const LeakDetectionResult& report) { |
| 1015 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); | 1015 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); |
| 1016 } | 1016 } |
| 1017 | 1017 |
| 1018 } // namespace content | 1018 } // namespace content |
| OLD | NEW |