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

Side by Side Diff: content/test/layouttest_support.cc

Issue 2238573002: Add WebWidgetTestProxy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add missing files Created 4 years, 4 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/public/test/layouttest_support.h" 5 #include "content/public/test/layouttest_support.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "cc/output/copy_output_request.h" 15 #include "cc/output/copy_output_request.h"
16 #include "cc/test/pixel_test_output_surface.h" 16 #include "cc/test/pixel_test_output_surface.h"
17 #include "cc/test/test_delegating_output_surface.h" 17 #include "cc/test/test_delegating_output_surface.h"
18 #include "components/test_runner/test_common.h" 18 #include "components/test_runner/test_common.h"
19 #include "components/test_runner/web_frame_test_proxy.h" 19 #include "components/test_runner/web_frame_test_proxy.h"
20 #include "components/test_runner/web_view_test_proxy.h" 20 #include "components/test_runner/web_view_test_proxy.h"
21 #include "components/test_runner/web_widget_test_proxy.h"
21 #include "content/browser/bluetooth/bluetooth_device_chooser_controller.h" 22 #include "content/browser/bluetooth/bluetooth_device_chooser_controller.h"
22 #include "content/browser/renderer_host/render_process_host_impl.h" 23 #include "content/browser/renderer_host/render_process_host_impl.h"
23 #include "content/browser/renderer_host/render_widget_host_impl.h" 24 #include "content/browser/renderer_host/render_widget_host_impl.h"
24 #include "content/common/gpu/client/context_provider_command_buffer.h" 25 #include "content/common/gpu/client/context_provider_command_buffer.h"
25 #include "content/common/site_isolation_policy.h" 26 #include "content/common/site_isolation_policy.h"
26 #include "content/public/common/page_state.h" 27 #include "content/public/common/page_state.h"
27 #include "content/public/renderer/renderer_gamepad_provider.h" 28 #include "content/public/renderer/renderer_gamepad_provider.h"
28 #include "content/renderer/fetchers/manifest_fetcher.h" 29 #include "content/renderer/fetchers/manifest_fetcher.h"
29 #include "content/renderer/gpu/render_widget_compositor.h" 30 #include "content/renderer/gpu/render_widget_compositor.h"
30 #include "content/renderer/history_entry.h" 31 #include "content/renderer/history_entry.h"
31 #include "content/renderer/history_serialization.h" 32 #include "content/renderer/history_serialization.h"
32 #include "content/renderer/layout_test_dependencies.h" 33 #include "content/renderer/layout_test_dependencies.h"
33 #include "content/renderer/render_frame_impl.h" 34 #include "content/renderer/render_frame_impl.h"
34 #include "content/renderer/render_thread_impl.h" 35 #include "content/renderer/render_thread_impl.h"
35 #include "content/renderer/render_view_impl.h" 36 #include "content/renderer/render_view_impl.h"
37 #include "content/renderer/render_widget.h"
36 #include "content/renderer/renderer_blink_platform_impl.h" 38 #include "content/renderer/renderer_blink_platform_impl.h"
37 #include "content/shell/common/shell_switches.h" 39 #include "content/shell/common/shell_switches.h"
38 #include "gpu/ipc/service/image_transport_surface.h" 40 #include "gpu/ipc/service/image_transport_surface.h"
39 #include "third_party/WebKit/public/platform/WebFloatRect.h" 41 #include "third_party/WebKit/public/platform/WebFloatRect.h"
40 #include "third_party/WebKit/public/platform/WebGamepads.h" 42 #include "third_party/WebKit/public/platform/WebGamepads.h"
41 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic eMotionData.h" 43 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic eMotionData.h"
42 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic eOrientationData.h" 44 #include "third_party/WebKit/public/platform/modules/device_orientation/WebDevic eOrientationData.h"
43 #include "third_party/WebKit/public/platform/scheduler/test/renderer_scheduler_t est_support.h" 45 #include "third_party/WebKit/public/platform/scheduler/test/renderer_scheduler_t est_support.h"
44 #include "third_party/WebKit/public/web/WebHistoryItem.h" 46 #include "third_party/WebKit/public/web/WebHistoryItem.h"
45 #include "third_party/WebKit/public/web/WebView.h" 47 #include "third_party/WebKit/public/web/WebView.h"
(...skipping 15 matching lines...) Expand all
61 using blink::WebRect; 63 using blink::WebRect;
62 using blink::WebSize; 64 using blink::WebSize;
63 65
64 namespace content { 66 namespace content {
65 67
66 namespace { 68 namespace {
67 69
68 base::LazyInstance<ViewProxyCreationCallback>::Leaky 70 base::LazyInstance<ViewProxyCreationCallback>::Leaky
69 g_view_test_proxy_callback = LAZY_INSTANCE_INITIALIZER; 71 g_view_test_proxy_callback = LAZY_INSTANCE_INITIALIZER;
70 72
73 base::LazyInstance<WidgetProxyCreationCallback>::Leaky
74 g_widget_test_proxy_callback = LAZY_INSTANCE_INITIALIZER;
75
71 base::LazyInstance<FrameProxyCreationCallback>::Leaky 76 base::LazyInstance<FrameProxyCreationCallback>::Leaky
72 g_frame_test_proxy_callback = LAZY_INSTANCE_INITIALIZER; 77 g_frame_test_proxy_callback = LAZY_INSTANCE_INITIALIZER;
73 78
74 using WebViewTestProxyType = 79 using WebViewTestProxyType =
75 test_runner::WebViewTestProxy<RenderViewImpl, 80 test_runner::WebViewTestProxy<RenderViewImpl,
76 CompositorDependencies*, 81 CompositorDependencies*,
77 const ViewMsg_New_Params&>; 82 const ViewMsg_New_Params&>;
83 using WebWidgetTestProxyType =
84 test_runner::WebWidgetTestProxy<RenderWidget,
85 CompositorDependencies*,
86 blink::WebPopupType,
87 const blink::WebScreenInfo&,
88 bool,
89 bool,
90 bool>;
78 using WebFrameTestProxyType = 91 using WebFrameTestProxyType =
79 test_runner::WebFrameTestProxy<RenderFrameImpl, 92 test_runner::WebFrameTestProxy<RenderFrameImpl,
80 const RenderFrameImpl::CreateParams&>; 93 const RenderFrameImpl::CreateParams&>;
81 94
82 RenderViewImpl* CreateWebViewTestProxy(CompositorDependencies* compositor_deps, 95 RenderViewImpl* CreateWebViewTestProxy(CompositorDependencies* compositor_deps,
83 const ViewMsg_New_Params& params) { 96 const ViewMsg_New_Params& params) {
84 WebViewTestProxyType* render_view_proxy = 97 WebViewTestProxyType* render_view_proxy =
85 new WebViewTestProxyType(compositor_deps, params); 98 new WebViewTestProxyType(compositor_deps, params);
86 if (g_view_test_proxy_callback == 0) 99 if (g_view_test_proxy_callback == 0)
87 return render_view_proxy; 100 return render_view_proxy;
88 g_view_test_proxy_callback.Get().Run(render_view_proxy, render_view_proxy); 101 g_view_test_proxy_callback.Get().Run(render_view_proxy, render_view_proxy);
89 return render_view_proxy; 102 return render_view_proxy;
90 } 103 }
91 104
105 RenderWidget* CreateWebWidgetTestProxy(CompositorDependencies* compositor_deps,
106 blink::WebPopupType popup_type,
107 const blink::WebScreenInfo& screen_info,
108 bool swapped_out,
109 bool hidden,
110 bool never_visible) {
111 WebWidgetTestProxyType* render_widget_proxy =
112 new WebWidgetTestProxyType(compositor_deps, popup_type, screen_info,
113 swapped_out, hidden, never_visible);
114 return render_widget_proxy;
115 }
116
117 void RenderWidgetInitialized(RenderWidget* render_widget) {
118 WebWidgetTestProxyType* render_widget_proxy =
119 static_cast<WebWidgetTestProxyType*>(render_widget);
120 if (!g_widget_test_proxy_callback.Get().is_null()) {
121 g_widget_test_proxy_callback.Get().Run(render_widget->webwidget(),
122 render_widget_proxy);
123 }
124 }
125
92 RenderFrameImpl* CreateWebFrameTestProxy( 126 RenderFrameImpl* CreateWebFrameTestProxy(
93 const RenderFrameImpl::CreateParams& params) { 127 const RenderFrameImpl::CreateParams& params) {
94 WebFrameTestProxyType* render_frame_proxy = new WebFrameTestProxyType(params); 128 WebFrameTestProxyType* render_frame_proxy = new WebFrameTestProxyType(params);
95 if (g_frame_test_proxy_callback == 0) 129 if (g_frame_test_proxy_callback == 0)
96 return render_frame_proxy; 130 return render_frame_proxy;
97 g_frame_test_proxy_callback.Get().Run(render_frame_proxy, render_frame_proxy); 131 g_frame_test_proxy_callback.Get().Run(render_frame_proxy, render_frame_proxy);
98 return render_frame_proxy; 132 return render_frame_proxy;
99 } 133 }
100 134
101 #if defined(OS_WIN) 135 #if defined(OS_WIN)
(...skipping 21 matching lines...) Expand all
123 157
124 test_runner::WebFrameTestProxyBase* GetWebFrameTestProxyBase( 158 test_runner::WebFrameTestProxyBase* GetWebFrameTestProxyBase(
125 RenderFrame* render_frame) { 159 RenderFrame* render_frame) {
126 WebFrameTestProxyType* render_frame_proxy = 160 WebFrameTestProxyType* render_frame_proxy =
127 static_cast<WebFrameTestProxyType*>(render_frame); 161 static_cast<WebFrameTestProxyType*>(render_frame);
128 return static_cast<test_runner::WebFrameTestProxyBase*>(render_frame_proxy); 162 return static_cast<test_runner::WebFrameTestProxyBase*>(render_frame_proxy);
129 } 163 }
130 164
131 void EnableWebTestProxyCreation( 165 void EnableWebTestProxyCreation(
132 const ViewProxyCreationCallback& view_proxy_creation_callback, 166 const ViewProxyCreationCallback& view_proxy_creation_callback,
167 const WidgetProxyCreationCallback& widget_proxy_creation_callback,
133 const FrameProxyCreationCallback& frame_proxy_creation_callback) { 168 const FrameProxyCreationCallback& frame_proxy_creation_callback) {
134 g_view_test_proxy_callback.Get() = view_proxy_creation_callback; 169 g_view_test_proxy_callback.Get() = view_proxy_creation_callback;
170 g_widget_test_proxy_callback.Get() = widget_proxy_creation_callback;
135 g_frame_test_proxy_callback.Get() = frame_proxy_creation_callback; 171 g_frame_test_proxy_callback.Get() = frame_proxy_creation_callback;
136 RenderViewImpl::InstallCreateHook(CreateWebViewTestProxy); 172 RenderViewImpl::InstallCreateHook(CreateWebViewTestProxy);
173 RenderWidget::InstallCreateHook(CreateWebWidgetTestProxy,
174 RenderWidgetInitialized);
137 RenderFrameImpl::InstallCreateHook(CreateWebFrameTestProxy); 175 RenderFrameImpl::InstallCreateHook(CreateWebFrameTestProxy);
138 } 176 }
139 177
140 void FetchManifestDoneCallback(std::unique_ptr<ManifestFetcher> fetcher, 178 void FetchManifestDoneCallback(std::unique_ptr<ManifestFetcher> fetcher,
141 const FetchManifestCallback& callback, 179 const FetchManifestCallback& callback,
142 const blink::WebURLResponse& response, 180 const blink::WebURLResponse& response,
143 const std::string& data) { 181 const std::string& data) {
144 // |fetcher| will be autodeleted here as it is going out of scope. 182 // |fetcher| will be autodeleted here as it is going out of scope.
145 callback.Run(response, data); 183 callback.Run(response, data);
146 } 184 }
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 return result; 602 return result;
565 } 603 }
566 604
567 void SchedulerRunIdleTasks(const base::Closure& callback) { 605 void SchedulerRunIdleTasks(const base::Closure& callback) {
568 blink::scheduler::RendererScheduler* scheduler = 606 blink::scheduler::RendererScheduler* scheduler =
569 content::RenderThreadImpl::current()->GetRendererScheduler(); 607 content::RenderThreadImpl::current()->GetRendererScheduler();
570 blink::scheduler::RunIdleTasksForTesting(scheduler, callback); 608 blink::scheduler::RunIdleTasksForTesting(scheduler, callback);
571 } 609 }
572 610
573 } // namespace content 611 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698