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

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

Issue 1889673002: Move LayoutAndPaintAsyncThen to a separate compilation unit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing... 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_and_paint_async_then.h"
18 #include "components/test_runner/layout_dump.h" 19 #include "components/test_runner/layout_dump.h"
19 #include "components/test_runner/mock_content_settings_client.h" 20 #include "components/test_runner/mock_content_settings_client.h"
20 #include "components/test_runner/mock_credential_manager_client.h" 21 #include "components/test_runner/mock_credential_manager_client.h"
21 #include "components/test_runner/mock_screen_orientation_client.h" 22 #include "components/test_runner/mock_screen_orientation_client.h"
22 #include "components/test_runner/mock_web_speech_recognizer.h" 23 #include "components/test_runner/mock_web_speech_recognizer.h"
23 #include "components/test_runner/mock_web_user_media_client.h" 24 #include "components/test_runner/mock_web_user_media_client.h"
24 #include "components/test_runner/pixel_dump.h" 25 #include "components/test_runner/pixel_dump.h"
25 #include "components/test_runner/spell_check_client.h" 26 #include "components/test_runner/spell_check_client.h"
26 #include "components/test_runner/test_interfaces.h" 27 #include "components/test_runner/test_interfaces.h"
27 #include "components/test_runner/test_preferences.h" 28 #include "components/test_runner/test_preferences.h"
(...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 } 1591 }
1591 1592
1592 void TestRunner::SetDelegate(WebTestDelegate* delegate) { 1593 void TestRunner::SetDelegate(WebTestDelegate* delegate) {
1593 delegate_ = delegate; 1594 delegate_ = delegate;
1594 mock_content_settings_client_->SetDelegate(delegate); 1595 mock_content_settings_client_->SetDelegate(delegate);
1595 spellcheck_->SetDelegate(delegate); 1596 spellcheck_->SetDelegate(delegate);
1596 if (speech_recognizer_) 1597 if (speech_recognizer_)
1597 speech_recognizer_->SetDelegate(delegate); 1598 speech_recognizer_->SetDelegate(delegate);
1598 } 1599 }
1599 1600
1600 void TestRunner::SetWebView(WebView* webView, WebTestProxyBase* proxy) { 1601 void TestRunner::SetWebView(WebView* webView) {
1601 web_view_ = webView; 1602 web_view_ = webView;
1602 proxy_ = proxy;
1603 } 1603 }
1604 1604
1605 void TestRunner::Reset() { 1605 void TestRunner::Reset() {
1606 if (web_view_) { 1606 if (web_view_) {
1607 web_view_->setZoomLevel(0); 1607 web_view_->setZoomLevel(0);
1608 web_view_->setTextZoomFactor(1); 1608 web_view_->setTextZoomFactor(1);
1609 web_view_->setTabKeyCyclesThroughElements(true); 1609 web_view_->setTabKeyCyclesThroughElements(true);
1610 #if !defined(OS_MACOSX) && !defined(OS_WIN) 1610 #if !defined(OS_MACOSX) && !defined(OS_WIN)
1611 // (Constants copied because we can't depend on the header that defined 1611 // (Constants copied because we can't depend on the header that defined
1612 // them from this file.) 1612 // them from this file.)
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1838 bitmap.eraseColor(0); 1838 bitmap.eraseColor(0);
1839 } 1839 }
1840 callback.Run(bitmap); 1840 callback.Run(bitmap);
1841 return; 1841 return;
1842 } 1842 }
1843 1843
1844 callback.Run(drag_image_.getSkBitmap()); 1844 callback.Run(drag_image_.getSkBitmap());
1845 return; 1845 return;
1846 } 1846 }
1847 1847
1848 test_runner::DumpPixelsAsync(proxy_->web_view(), layout_test_runtime_flags_, 1848 test_runner::DumpPixelsAsync(web_view_, layout_test_runtime_flags_,
1849 delegate_->GetDeviceScaleFactorForTest(), 1849 delegate_->GetDeviceScaleFactorForTest(),
1850 callback); 1850 callback);
1851 } 1851 }
1852 1852
1853 void TestRunner::ReplicateLayoutTestRuntimeFlagsChanges( 1853 void TestRunner::ReplicateLayoutTestRuntimeFlagsChanges(
1854 const base::DictionaryValue& changed_values) { 1854 const base::DictionaryValue& changed_values) {
1855 layout_test_runtime_flags_.tracked_dictionary().ApplyUntrackedChanges( 1855 layout_test_runtime_flags_.tracked_dictionary().ApplyUntrackedChanges(
1856 changed_values); 1856 changed_values);
1857 } 1857 }
1858 1858
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
2625 std::string TestRunner::GetAcceptLanguages() const { 2625 std::string TestRunner::GetAcceptLanguages() const {
2626 return layout_test_runtime_flags_.accept_languages(); 2626 return layout_test_runtime_flags_.accept_languages();
2627 } 2627 }
2628 2628
2629 void TestRunner::SetAcceptLanguages(const std::string& accept_languages) { 2629 void TestRunner::SetAcceptLanguages(const std::string& accept_languages) {
2630 if (accept_languages == GetAcceptLanguages()) 2630 if (accept_languages == GetAcceptLanguages())
2631 return; 2631 return;
2632 2632
2633 layout_test_runtime_flags_.set_accept_languages(accept_languages); 2633 layout_test_runtime_flags_.set_accept_languages(accept_languages);
2634 OnLayoutTestRuntimeFlagsChanged(); 2634 OnLayoutTestRuntimeFlagsChanged();
2635 proxy_->web_view()->acceptLanguagesChanged(); 2635 web_view_->acceptLanguagesChanged();
2636 } 2636 }
2637 2637
2638 void TestRunner::SetPluginsEnabled(bool enabled) { 2638 void TestRunner::SetPluginsEnabled(bool enabled) {
2639 delegate_->Preferences()->plugins_enabled = enabled; 2639 delegate_->Preferences()->plugins_enabled = enabled;
2640 delegate_->ApplyPreferences(); 2640 delegate_->ApplyPreferences();
2641 } 2641 }
2642 2642
2643 bool TestRunner::GetAnimationScheduled() const { 2643 bool TestRunner::GetAnimationScheduled() const {
2644 bool is_animation_scheduled = !views_with_scheduled_animations_.empty(); 2644 bool is_animation_scheduled = !views_with_scheduled_animations_.empty();
2645 return is_animation_scheduled; 2645 return is_animation_scheduled;
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
2878 2878
2879 void TestRunner::SetDatabaseQuota(int quota) { 2879 void TestRunner::SetDatabaseQuota(int quota) {
2880 delegate_->SetDatabaseQuota(quota); 2880 delegate_->SetDatabaseQuota(quota);
2881 } 2881 }
2882 2882
2883 void TestRunner::SetAlwaysAcceptCookies(bool accept) { 2883 void TestRunner::SetAlwaysAcceptCookies(bool accept) {
2884 delegate_->SetAcceptAllCookies(accept); 2884 delegate_->SetAcceptAllCookies(accept);
2885 } 2885 }
2886 2886
2887 void TestRunner::SetWindowIsKey(bool value) { 2887 void TestRunner::SetWindowIsKey(bool value) {
2888 SetFocus(proxy_->web_view(), value); 2888 SetFocus(web_view_, value);
2889 } 2889 }
2890 2890
2891 void TestRunner::SetFocus(blink::WebView* web_view, bool focus) { 2891 void TestRunner::SetFocus(blink::WebView* web_view, bool focus) {
2892 if (focus) { 2892 if (focus) {
2893 if (previously_focused_view_ != web_view) { 2893 if (previously_focused_view_ != web_view) {
2894 delegate_->SetFocus(previously_focused_view_, false); 2894 delegate_->SetFocus(previously_focused_view_, false);
2895 delegate_->SetFocus(web_view, true); 2895 delegate_->SetFocus(web_view, true);
2896 previously_focused_view_ = web_view; 2896 previously_focused_view_ = web_view;
2897 } 2897 }
2898 } else { 2898 } else {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
3039 if (web_view_) 3039 if (web_view_)
3040 web_view_->setPageOverlayColor(SK_ColorCYAN); 3040 web_view_->setPageOverlayColor(SK_ColorCYAN);
3041 } 3041 }
3042 3042
3043 void TestRunner::RemoveWebPageOverlay() { 3043 void TestRunner::RemoveWebPageOverlay() {
3044 if (web_view_) 3044 if (web_view_)
3045 web_view_->setPageOverlayColor(SK_ColorTRANSPARENT); 3045 web_view_->setPageOverlayColor(SK_ColorTRANSPARENT);
3046 } 3046 }
3047 3047
3048 void TestRunner::LayoutAndPaintAsync() { 3048 void TestRunner::LayoutAndPaintAsync() {
3049 proxy_->LayoutAndPaintAsyncThen(base::Closure()); 3049 test_runner::LayoutAndPaintAsyncThen(web_view_, base::Closure());
3050 } 3050 }
3051 3051
3052 void TestRunner::LayoutAndPaintAsyncThen(v8::Local<v8::Function> callback) { 3052 void TestRunner::LayoutAndPaintAsyncThen(v8::Local<v8::Function> callback) {
3053 proxy_->LayoutAndPaintAsyncThen(CreateClosureThatPostsV8Callback(callback)); 3053 test_runner::LayoutAndPaintAsyncThen(
3054 web_view_, CreateClosureThatPostsV8Callback(callback));
3054 } 3055 }
3055 3056
3056 void TestRunner::GetManifestThen(v8::Local<v8::Function> callback) { 3057 void TestRunner::GetManifestThen(v8::Local<v8::Function> callback) {
3057 v8::UniquePersistent<v8::Function> persistent_callback( 3058 v8::UniquePersistent<v8::Function> persistent_callback(
3058 blink::mainThreadIsolate(), callback); 3059 blink::mainThreadIsolate(), callback);
3059 3060
3060 if (!web_view_) { 3061 if (!web_view_) {
3061 WebURLResponse response; 3062 WebURLResponse response;
3062 response.setHTTPStatusCode(404); 3063 response.setHTTPStatusCode(404);
3063 GetManifestCallback(std::move(persistent_callback), response, ""); 3064 GetManifestCallback(std::move(persistent_callback), response, "");
3064 return; 3065 return;
3065 } 3066 }
3066 3067
3067 delegate_->FetchManifest( 3068 delegate_->FetchManifest(
3068 web_view_, web_view_->mainFrame()->document().manifestURL(), 3069 web_view_, web_view_->mainFrame()->document().manifestURL(),
3069 base::Bind(&TestRunner::GetManifestCallback, weak_factory_.GetWeakPtr(), 3070 base::Bind(&TestRunner::GetManifestCallback, weak_factory_.GetWeakPtr(),
3070 base::Passed(std::move(persistent_callback)))); 3071 base::Passed(std::move(persistent_callback))));
3071 } 3072 }
3072 3073
3073 void TestRunner::CapturePixelsAsyncThen(v8::Local<v8::Function> callback) { 3074 void TestRunner::CapturePixelsAsyncThen(v8::Local<v8::Function> callback) {
3074 v8::UniquePersistent<v8::Function> persistent_callback( 3075 v8::UniquePersistent<v8::Function> persistent_callback(
3075 blink::mainThreadIsolate(), callback); 3076 blink::mainThreadIsolate(), callback);
3076 3077
3077 if (!web_view_) { 3078 if (!web_view_) {
3078 CapturePixelsCallback(std::move(persistent_callback), SkBitmap()); 3079 CapturePixelsCallback(std::move(persistent_callback), SkBitmap());
3079 return; 3080 return;
3080 } 3081 }
3081 3082
3082 DumpPixelsAsync( 3083 DumpPixelsAsync(
3083 proxy_->web_view(), 3084 web_view_,
3084 base::Bind(&TestRunner::CapturePixelsCallback, weak_factory_.GetWeakPtr(), 3085 base::Bind(&TestRunner::CapturePixelsCallback, weak_factory_.GetWeakPtr(),
3085 base::Passed(std::move(persistent_callback)))); 3086 base::Passed(std::move(persistent_callback))));
3086 } 3087 }
3087 3088
3088 void TestRunner::OnLayoutTestRuntimeFlagsChanged() { 3089 void TestRunner::OnLayoutTestRuntimeFlagsChanged() {
3089 if (layout_test_runtime_flags_.tracked_dictionary().changed_values().empty()) 3090 if (layout_test_runtime_flags_.tracked_dictionary().changed_values().empty())
3090 return; 3091 return;
3091 3092
3092 delegate_->OnLayoutTestRuntimeFlagsChanged( 3093 delegate_->OnLayoutTestRuntimeFlagsChanged(
3093 layout_test_runtime_flags_.tracked_dictionary().changed_values()); 3094 layout_test_runtime_flags_.tracked_dictionary().changed_values());
(...skipping 14 matching lines...) Expand all
3108 int x, int y, v8::Local<v8::Function> callback) { 3109 int x, int y, v8::Local<v8::Function> callback) {
3109 v8::UniquePersistent<v8::Function> persistent_callback( 3110 v8::UniquePersistent<v8::Function> persistent_callback(
3110 blink::mainThreadIsolate(), callback); 3111 blink::mainThreadIsolate(), callback);
3111 3112
3112 if (!web_view_) { 3113 if (!web_view_) {
3113 CapturePixelsCallback(std::move(persistent_callback), SkBitmap()); 3114 CapturePixelsCallback(std::move(persistent_callback), SkBitmap());
3114 return; 3115 return;
3115 } 3116 }
3116 3117
3117 CopyImageAtAndCapturePixels( 3118 CopyImageAtAndCapturePixels(
3118 proxy_->web_view(), x, y, 3119 web_view_, x, y,
3119 base::Bind(&TestRunner::CapturePixelsCallback, weak_factory_.GetWeakPtr(), 3120 base::Bind(&TestRunner::CapturePixelsCallback, weak_factory_.GetWeakPtr(),
3120 base::Passed(std::move(persistent_callback)))); 3121 base::Passed(std::move(persistent_callback))));
3121 } 3122 }
3122 3123
3123 void TestRunner::GetManifestCallback( 3124 void TestRunner::GetManifestCallback(
3124 v8::UniquePersistent<v8::Function> callback, 3125 v8::UniquePersistent<v8::Function> callback,
3125 const blink::WebURLResponse& response, 3126 const blink::WebURLResponse& response,
3126 const std::string& data) { 3127 const std::string& data) {
3127 PostV8CallbackWithArgs(std::move(callback), 0, nullptr); 3128 PostV8CallbackWithArgs(std::move(callback), 0, nullptr);
3128 } 3129 }
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
3275 } 3276 }
3276 3277
3277 void TestRunner::DidLosePointerLockInternal() { 3278 void TestRunner::DidLosePointerLockInternal() {
3278 bool was_locked = pointer_locked_; 3279 bool was_locked = pointer_locked_;
3279 pointer_locked_ = false; 3280 pointer_locked_ = false;
3280 if (was_locked) 3281 if (was_locked)
3281 web_view_->didLosePointerLock(); 3282 web_view_->didLosePointerLock();
3282 } 3283 }
3283 3284
3284 } // namespace test_runner 3285 } // 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