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

Side by Side Diff: components/test_runner/test_runner.cc

Issue 1842353002: Revert of Moving pixel-capturing code from web_test_proxy_base.* into pixel_dump.* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@replicating-accept-languages
Patch Set: Created 4 years, 8 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
« no previous file with comments | « components/test_runner/test_runner.h ('k') | components/test_runner/test_runner.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/test_runner/test_runner.h" 5 #include "components/test_runner/test_runner.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "components/test_runner/app_banner_client.h" 17 #include "components/test_runner/app_banner_client.h"
18 #include "components/test_runner/layout_dump.h" 18 #include "components/test_runner/layout_dump.h"
19 #include "components/test_runner/mock_credential_manager_client.h" 19 #include "components/test_runner/mock_credential_manager_client.h"
20 #include "components/test_runner/mock_screen_orientation_client.h" 20 #include "components/test_runner/mock_screen_orientation_client.h"
21 #include "components/test_runner/mock_web_speech_recognizer.h" 21 #include "components/test_runner/mock_web_speech_recognizer.h"
22 #include "components/test_runner/mock_web_user_media_client.h" 22 #include "components/test_runner/mock_web_user_media_client.h"
23 #include "components/test_runner/pixel_dump.h"
24 #include "components/test_runner/test_interfaces.h" 23 #include "components/test_runner/test_interfaces.h"
25 #include "components/test_runner/test_preferences.h" 24 #include "components/test_runner/test_preferences.h"
26 #include "components/test_runner/web_content_settings.h" 25 #include "components/test_runner/web_content_settings.h"
27 #include "components/test_runner/web_test_delegate.h" 26 #include "components/test_runner/web_test_delegate.h"
28 #include "components/test_runner/web_test_proxy.h" 27 #include "components/test_runner/web_test_proxy.h"
29 #include "gin/arguments.h" 28 #include "gin/arguments.h"
30 #include "gin/array_buffer.h" 29 #include "gin/array_buffer.h"
31 #include "gin/handle.h" 30 #include "gin/handle.h"
32 #include "gin/object_template_builder.h" 31 #include "gin/object_template_builder.h"
33 #include "gin/wrappable.h" 32 #include "gin/wrappable.h"
(...skipping 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after
1702 #endif 1701 #endif
1703 web_view_->setVisibilityState(WebPageVisibilityStateVisible, true); 1702 web_view_->setVisibilityState(WebPageVisibilityStateVisible, true);
1704 web_view_->mainFrame()->enableViewSourceMode(false); 1703 web_view_->mainFrame()->enableViewSourceMode(false);
1705 1704
1706 web_view_->setPageOverlayColor(SK_ColorTRANSPARENT); 1705 web_view_->setPageOverlayColor(SK_ColorTRANSPARENT);
1707 } 1706 }
1708 1707
1709 top_loading_frame_ = nullptr; 1708 top_loading_frame_ = nullptr;
1710 layout_test_runtime_flags_.Reset(); 1709 layout_test_runtime_flags_.Reset();
1711 mock_screen_orientation_client_->ResetData(); 1710 mock_screen_orientation_client_->ResetData();
1712 drag_image_.reset();
1713 wait_until_external_url_load_ = false; 1711 wait_until_external_url_load_ = false;
1714 1712
1715 WebSecurityPolicy::resetOriginAccessWhitelists(); 1713 WebSecurityPolicy::resetOriginAccessWhitelists();
1716 #if defined(__linux__) || defined(ANDROID) 1714 #if defined(__linux__) || defined(ANDROID)
1717 WebFontRendering::setSubpixelPositioning(false); 1715 WebFontRendering::setSubpixelPositioning(false);
1718 #endif 1716 #endif
1719 1717
1720 if (delegate_) { 1718 if (delegate_) {
1721 // Reset the default quota for each origin to 5MB 1719 // Reset the default quota for each origin to 5MB
1722 delegate_->SetDatabaseQuota(5 * 1024 * 1024); 1720 delegate_->SetDatabaseQuota(5 * 1024 * 1024);
(...skipping 18 matching lines...) Expand all
1741 dump_user_gesture_in_frame_load_callbacks_ = false; 1739 dump_user_gesture_in_frame_load_callbacks_ = false;
1742 dump_title_changes_ = false; 1740 dump_title_changes_ = false;
1743 dump_create_view_ = false; 1741 dump_create_view_ = false;
1744 can_open_windows_ = false; 1742 can_open_windows_ = false;
1745 dump_resource_load_callbacks_ = false; 1743 dump_resource_load_callbacks_ = false;
1746 dump_resource_request_callbacks_ = false; 1744 dump_resource_request_callbacks_ = false;
1747 dump_resource_response_mime_types_ = false; 1745 dump_resource_response_mime_types_ = false;
1748 dump_window_status_changes_ = false; 1746 dump_window_status_changes_ = false;
1749 dump_spell_check_callbacks_ = false; 1747 dump_spell_check_callbacks_ = false;
1750 dump_back_forward_list_ = false; 1748 dump_back_forward_list_ = false;
1749 dump_selection_rect_ = false;
1750 dump_drag_image_ = false;
1751 dump_navigation_policy_ = false; 1751 dump_navigation_policy_ = false;
1752 test_repaint_ = false; 1752 test_repaint_ = false;
1753 sweep_horizontally_ = false; 1753 sweep_horizontally_ = false;
1754 midi_accessor_result_ = true; 1754 midi_accessor_result_ = true;
1755 should_stay_on_page_after_handling_before_unload_ = false; 1755 should_stay_on_page_after_handling_before_unload_ = false;
1756 should_dump_resource_priorities_ = false; 1756 should_dump_resource_priorities_ = false;
1757 has_custom_text_output_ = false; 1757 has_custom_text_output_ = false;
1758 custom_text_output_.clear(); 1758 custom_text_output_.clear();
1759 1759
1760 http_headers_to_clear_.clear(); 1760 http_headers_to_clear_.clear();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1842 bool TestRunner::IsRecursiveLayoutDumpRequested() { 1842 bool TestRunner::IsRecursiveLayoutDumpRequested() {
1843 CheckResponseMimeType(); 1843 CheckResponseMimeType();
1844 return layout_test_runtime_flags_.dump_child_frames(); 1844 return layout_test_runtime_flags_.dump_child_frames();
1845 } 1845 }
1846 1846
1847 std::string TestRunner::DumpLayout(blink::WebLocalFrame* frame) { 1847 std::string TestRunner::DumpLayout(blink::WebLocalFrame* frame) {
1848 CheckResponseMimeType(); 1848 CheckResponseMimeType();
1849 return ::test_runner::DumpLayout(frame, layout_test_runtime_flags_); 1849 return ::test_runner::DumpLayout(frame, layout_test_runtime_flags_);
1850 } 1850 }
1851 1851
1852 void TestRunner::DumpPixelsAsync(
1853 blink::WebView* web_view,
1854 const base::Callback<void(const SkBitmap&)>& callback) {
1855 if (layout_test_runtime_flags_.dump_drag_image()) {
1856 if (drag_image_.isNull()) {
1857 // This means the test called dumpDragImage but did not initiate a drag.
1858 // Return a blank image so that the test fails.
1859 SkBitmap bitmap;
1860 bitmap.allocN32Pixels(1, 1);
1861 {
1862 SkAutoLockPixels lock(bitmap);
1863 bitmap.eraseColor(0);
1864 }
1865 callback.Run(bitmap);
1866 return;
1867 }
1868
1869 callback.Run(drag_image_.getSkBitmap());
1870 return;
1871 }
1872
1873 test_runner::DumpPixelsAsync(proxy_->GetWebView(), layout_test_runtime_flags_,
1874 delegate_->GetDeviceScaleFactorForTest(),
1875 callback);
1876 }
1877
1878 void TestRunner::ReplicateLayoutTestRuntimeFlagsChanges( 1852 void TestRunner::ReplicateLayoutTestRuntimeFlagsChanges(
1879 const base::DictionaryValue& changed_values) { 1853 const base::DictionaryValue& changed_values) {
1880 layout_test_runtime_flags_.tracked_dictionary().ApplyUntrackedChanges( 1854 layout_test_runtime_flags_.tracked_dictionary().ApplyUntrackedChanges(
1881 changed_values); 1855 changed_values);
1882 } 1856 }
1883 1857
1884 bool TestRunner::HasCustomTextDump(std::string* custom_text_dump) const { 1858 bool TestRunner::HasCustomTextDump(std::string* custom_text_dump) const {
1885 if (shouldDumpAsCustomText()) { 1859 if (shouldDumpAsCustomText()) {
1886 *custom_text_dump = customDumpText(); 1860 *custom_text_dump = customDumpText();
1887 return true; 1861 return true;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1951 } 1925 }
1952 1926
1953 bool TestRunner::shouldDumpSpellCheckCallbacks() const { 1927 bool TestRunner::shouldDumpSpellCheckCallbacks() const {
1954 return dump_spell_check_callbacks_; 1928 return dump_spell_check_callbacks_;
1955 } 1929 }
1956 1930
1957 bool TestRunner::ShouldDumpBackForwardList() const { 1931 bool TestRunner::ShouldDumpBackForwardList() const {
1958 return dump_back_forward_list_; 1932 return dump_back_forward_list_;
1959 } 1933 }
1960 1934
1935 bool TestRunner::shouldDumpSelectionRect() const {
1936 return dump_selection_rect_;
1937 }
1938
1961 bool TestRunner::isPrinting() const { 1939 bool TestRunner::isPrinting() const {
1962 return layout_test_runtime_flags_.is_printing(); 1940 return layout_test_runtime_flags_.is_printing();
1963 } 1941 }
1964 1942
1965 bool TestRunner::shouldWaitUntilExternalURLLoad() const { 1943 bool TestRunner::shouldWaitUntilExternalURLLoad() const {
1966 return wait_until_external_url_load_; 1944 return wait_until_external_url_load_;
1967 } 1945 }
1968 1946
1969 const std::set<std::string>* TestRunner::httpHeadersToClear() const { 1947 const std::set<std::string>* TestRunner::httpHeadersToClear() const {
1970 return &http_headers_to_clear_; 1948 return &http_headers_to_clear_;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2039 } 2017 }
2040 2018
2041 bool TestRunner::isPointerLocked() { 2019 bool TestRunner::isPointerLocked() {
2042 return pointer_locked_; 2020 return pointer_locked_;
2043 } 2021 }
2044 2022
2045 void TestRunner::setToolTipText(const WebString& text) { 2023 void TestRunner::setToolTipText(const WebString& text) {
2046 tooltip_text_ = text.utf8(); 2024 tooltip_text_ = text.utf8();
2047 } 2025 }
2048 2026
2049 void TestRunner::setDragImage( 2027 bool TestRunner::shouldDumpDragImage() {
2050 const blink::WebImage& drag_image) { 2028 return dump_drag_image_;
2051 if (layout_test_runtime_flags_.dump_drag_image()) {
2052 if (drag_image_.isNull())
2053 drag_image_ = drag_image;
2054 }
2055 } 2029 }
2056 2030
2057 bool TestRunner::shouldDumpNavigationPolicy() const { 2031 bool TestRunner::shouldDumpNavigationPolicy() const {
2058 return dump_navigation_policy_; 2032 return dump_navigation_policy_;
2059 } 2033 }
2060 2034
2061 bool TestRunner::midiAccessorResult() { 2035 bool TestRunner::midiAccessorResult() {
2062 return midi_accessor_result_; 2036 return midi_accessor_result_;
2063 } 2037 }
2064 2038
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
2827 2801
2828 void TestRunner::DumpSpellCheckCallbacks() { 2802 void TestRunner::DumpSpellCheckCallbacks() {
2829 dump_spell_check_callbacks_ = true; 2803 dump_spell_check_callbacks_ = true;
2830 } 2804 }
2831 2805
2832 void TestRunner::DumpBackForwardList() { 2806 void TestRunner::DumpBackForwardList() {
2833 dump_back_forward_list_ = true; 2807 dump_back_forward_list_ = true;
2834 } 2808 }
2835 2809
2836 void TestRunner::DumpSelectionRect() { 2810 void TestRunner::DumpSelectionRect() {
2837 layout_test_runtime_flags_.set_dump_selection_rect(true); 2811 dump_selection_rect_ = true;
2838 OnLayoutTestRuntimeFlagsChanged();
2839 } 2812 }
2840 2813
2841 void TestRunner::SetPrinting() { 2814 void TestRunner::SetPrinting() {
2842 layout_test_runtime_flags_.set_is_printing(true); 2815 layout_test_runtime_flags_.set_is_printing(true);
2843 OnLayoutTestRuntimeFlagsChanged(); 2816 OnLayoutTestRuntimeFlagsChanged();
2844 } 2817 }
2845 2818
2846 void TestRunner::ClearPrinting() { 2819 void TestRunner::ClearPrinting() {
2847 layout_test_runtime_flags_.set_is_printing(false); 2820 layout_test_runtime_flags_.set_is_printing(false);
2848 OnLayoutTestRuntimeFlagsChanged(); 2821 OnLayoutTestRuntimeFlagsChanged();
(...skipping 20 matching lines...) Expand all
2869 void TestRunner::ShowWebInspector(const std::string& str, 2842 void TestRunner::ShowWebInspector(const std::string& str,
2870 const std::string& frontend_url) { 2843 const std::string& frontend_url) {
2871 ShowDevTools(str, frontend_url); 2844 ShowDevTools(str, frontend_url);
2872 } 2845 }
2873 2846
2874 void TestRunner::WaitUntilExternalURLLoad() { 2847 void TestRunner::WaitUntilExternalURLLoad() {
2875 wait_until_external_url_load_ = true; 2848 wait_until_external_url_load_ = true;
2876 } 2849 }
2877 2850
2878 void TestRunner::DumpDragImage() { 2851 void TestRunner::DumpDragImage() {
2879 layout_test_runtime_flags_.set_dump_drag_image(true);
2880 DumpAsTextWithPixelResults(); 2852 DumpAsTextWithPixelResults();
2881 OnLayoutTestRuntimeFlagsChanged(); 2853 dump_drag_image_ = true;
2882 } 2854 }
2883 2855
2884 void TestRunner::DumpNavigationPolicy() { 2856 void TestRunner::DumpNavigationPolicy() {
2885 dump_navigation_policy_ = true; 2857 dump_navigation_policy_ = true;
2886 } 2858 }
2887 2859
2888 void TestRunner::DumpPageImportanceSignals() { 2860 void TestRunner::DumpPageImportanceSignals() {
2889 blink::WebPageImportanceSignals* signals = 2861 blink::WebPageImportanceSignals* signals =
2890 web_view_->pageImportanceSignals(); 2862 web_view_->pageImportanceSignals();
2891 if (!signals) 2863 if (!signals)
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
3090 scoped_ptr<InvokeCallbackTask> task( 3062 scoped_ptr<InvokeCallbackTask> task(
3091 new InvokeCallbackTask(this, callback)); 3063 new InvokeCallbackTask(this, callback));
3092 3064
3093 delegate_->FetchManifest( 3065 delegate_->FetchManifest(
3094 web_view_, web_view_->mainFrame()->document().manifestURL(), 3066 web_view_, web_view_->mainFrame()->document().manifestURL(),
3095 base::Bind(&TestRunner::GetManifestCallback, weak_factory_.GetWeakPtr(), 3067 base::Bind(&TestRunner::GetManifestCallback, weak_factory_.GetWeakPtr(),
3096 base::Passed(&task))); 3068 base::Passed(&task)));
3097 } 3069 }
3098 3070
3099 void TestRunner::CapturePixelsAsyncThen(v8::Local<v8::Function> callback) { 3071 void TestRunner::CapturePixelsAsyncThen(v8::Local<v8::Function> callback) {
3100 scoped_ptr<InvokeCallbackTask> task(new InvokeCallbackTask(this, callback)); 3072 scoped_ptr<InvokeCallbackTask> task(
3101 DumpPixelsAsync(proxy_->GetWebView(), 3073 new InvokeCallbackTask(this, callback));
3102 base::Bind(&TestRunner::CapturePixelsCallback, 3074 proxy_->CapturePixelsAsync(base::Bind(&TestRunner::CapturePixelsCallback,
3103 weak_factory_.GetWeakPtr(), base::Passed(&task))); 3075 weak_factory_.GetWeakPtr(),
3076 base::Passed(&task)));
3104 } 3077 }
3105 3078
3106 void TestRunner::OnLayoutTestRuntimeFlagsChanged() { 3079 void TestRunner::OnLayoutTestRuntimeFlagsChanged() {
3107 if (layout_test_runtime_flags_.tracked_dictionary().changed_values().empty()) 3080 if (layout_test_runtime_flags_.tracked_dictionary().changed_values().empty())
3108 return; 3081 return;
3109 3082
3110 delegate_->OnLayoutTestRuntimeFlagsChanged( 3083 delegate_->OnLayoutTestRuntimeFlagsChanged(
3111 layout_test_runtime_flags_.tracked_dictionary().changed_values()); 3084 layout_test_runtime_flags_.tracked_dictionary().changed_values());
3112 layout_test_runtime_flags_.tracked_dictionary().ResetChangeTracking(); 3085 layout_test_runtime_flags_.tracked_dictionary().ResetChangeTracking();
3113 } 3086 }
3114 3087
3115 void TestRunner::ForceNextWebGLContextCreationToFail() { 3088 void TestRunner::ForceNextWebGLContextCreationToFail() {
3116 if (web_view_) 3089 if (web_view_)
3117 web_view_->forceNextWebGLContextCreationToFail(); 3090 web_view_->forceNextWebGLContextCreationToFail();
3118 } 3091 }
3119 3092
3120 void TestRunner::ForceNextDrawingBufferCreationToFail() { 3093 void TestRunner::ForceNextDrawingBufferCreationToFail() {
3121 if (web_view_) 3094 if (web_view_)
3122 web_view_->forceNextDrawingBufferCreationToFail(); 3095 web_view_->forceNextDrawingBufferCreationToFail();
3123 } 3096 }
3124 3097
3125 void TestRunner::CopyImageAtAndCapturePixelsAsyncThen( 3098 void TestRunner::CopyImageAtAndCapturePixelsAsyncThen(
3126 int x, int y, v8::Local<v8::Function> callback) { 3099 int x, int y, v8::Local<v8::Function> callback) {
3127 scoped_ptr<InvokeCallbackTask> task( 3100 scoped_ptr<InvokeCallbackTask> task(
3128 new InvokeCallbackTask(this, callback)); 3101 new InvokeCallbackTask(this, callback));
3129 CopyImageAtAndCapturePixels( 3102 proxy_->CopyImageAtAndCapturePixels(
3130 proxy_->GetWebView(), x, y, 3103 x, y, base::Bind(&TestRunner::CapturePixelsCallback,
3131 base::Bind(&TestRunner::CapturePixelsCallback, weak_factory_.GetWeakPtr(), 3104 weak_factory_.GetWeakPtr(),
3132 base::Passed(&task))); 3105 base::Passed(&task)));
3133 } 3106 }
3134 3107
3135 void TestRunner::GetManifestCallback(scoped_ptr<InvokeCallbackTask> task, 3108 void TestRunner::GetManifestCallback(scoped_ptr<InvokeCallbackTask> task,
3136 const blink::WebURLResponse& response, 3109 const blink::WebURLResponse& response,
3137 const std::string& data) { 3110 const std::string& data) {
3138 InvokeCallback(std::move(task)); 3111 InvokeCallback(std::move(task));
3139 } 3112 }
3140 3113
3141 void TestRunner::CapturePixelsCallback(scoped_ptr<InvokeCallbackTask> task, 3114 void TestRunner::CapturePixelsCallback(scoped_ptr<InvokeCallbackTask> task,
3142 const SkBitmap& snapshot) { 3115 const SkBitmap& snapshot) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
3279 } 3252 }
3280 3253
3281 void TestRunner::DidLosePointerLockInternal() { 3254 void TestRunner::DidLosePointerLockInternal() {
3282 bool was_locked = pointer_locked_; 3255 bool was_locked = pointer_locked_;
3283 pointer_locked_ = false; 3256 pointer_locked_ = false;
3284 if (was_locked) 3257 if (was_locked)
3285 web_view_->didLosePointerLock(); 3258 web_view_->didLosePointerLock();
3286 } 3259 }
3287 3260
3288 } // namespace test_runner 3261 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/test_runner/test_runner.h ('k') | components/test_runner/test_runner.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698