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

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

Issue 2174663005: Add WebWidgetTestProxy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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/test/pixel_test_output_surface.h" 15 #include "cc/test/pixel_test_output_surface.h"
16 #include "cc/test/test_delegating_output_surface.h" 16 #include "cc/test/test_delegating_output_surface.h"
17 #include "components/scheduler/test/renderer_scheduler_test_support.h" 17 #include "components/scheduler/test/renderer_scheduler_test_support.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/web/WebHistoryItem.h" 45 #include "third_party/WebKit/public/web/WebHistoryItem.h"
44 #include "third_party/WebKit/public/web/WebView.h" 46 #include "third_party/WebKit/public/web/WebView.h"
45 47
(...skipping 14 matching lines...) Expand all
60 using blink::WebRect; 62 using blink::WebRect;
61 using blink::WebSize; 63 using blink::WebSize;
62 64
63 namespace content { 65 namespace content {
64 66
65 namespace { 67 namespace {
66 68
67 base::LazyInstance<ViewProxyCreationCallback>::Leaky 69 base::LazyInstance<ViewProxyCreationCallback>::Leaky
68 g_view_test_proxy_callback = LAZY_INSTANCE_INITIALIZER; 70 g_view_test_proxy_callback = LAZY_INSTANCE_INITIALIZER;
69 71
72 base::LazyInstance<WidgetProxyCreationCallback>::Leaky
73 g_widget_test_proxy_callback = LAZY_INSTANCE_INITIALIZER;
74
70 base::LazyInstance<FrameProxyCreationCallback>::Leaky 75 base::LazyInstance<FrameProxyCreationCallback>::Leaky
71 g_frame_test_proxy_callback = LAZY_INSTANCE_INITIALIZER; 76 g_frame_test_proxy_callback = LAZY_INSTANCE_INITIALIZER;
72 77
73 using WebViewTestProxyType = 78 using WebViewTestProxyType =
74 test_runner::WebViewTestProxy<RenderViewImpl, 79 test_runner::WebViewTestProxy<RenderViewImpl,
75 CompositorDependencies*, 80 CompositorDependencies*,
76 const ViewMsg_New_Params&>; 81 const ViewMsg_New_Params&>;
82 using WebWidgetTestProxyType =
83 test_runner::WebWidgetTestProxy<RenderWidget,
84 CompositorDependencies*,
85 blink::WebPopupType,
86 const blink::WebScreenInfo&,
87 bool,
88 bool,
89 bool>;
77 using WebFrameTestProxyType = 90 using WebFrameTestProxyType =
78 test_runner::WebFrameTestProxy<RenderFrameImpl, 91 test_runner::WebFrameTestProxy<RenderFrameImpl,
79 const RenderFrameImpl::CreateParams&>; 92 const RenderFrameImpl::CreateParams&>;
80 93
81 RenderViewImpl* CreateWebViewTestProxy(CompositorDependencies* compositor_deps, 94 RenderViewImpl* CreateWebViewTestProxy(CompositorDependencies* compositor_deps,
82 const ViewMsg_New_Params& params) { 95 const ViewMsg_New_Params& params) {
83 WebViewTestProxyType* render_view_proxy = 96 WebViewTestProxyType* render_view_proxy =
84 new WebViewTestProxyType(compositor_deps, params); 97 new WebViewTestProxyType(compositor_deps, params);
85 if (g_view_test_proxy_callback == 0) 98 if (g_view_test_proxy_callback == 0)
86 return render_view_proxy; 99 return render_view_proxy;
87 g_view_test_proxy_callback.Get().Run(render_view_proxy, render_view_proxy); 100 g_view_test_proxy_callback.Get().Run(render_view_proxy, render_view_proxy);
88 return render_view_proxy; 101 return render_view_proxy;
89 } 102 }
90 103
104 RenderWidget* CreateWebWidgetTestProxy(CompositorDependencies* compositor_deps,
105 blink::WebPopupType popup_type,
106 const blink::WebScreenInfo& screen_info,
107 bool swapped_out,
108 bool hidden,
109 bool never_visible) {
110 WebWidgetTestProxyType* render_widget_proxy =
111 new WebWidgetTestProxyType(compositor_deps, popup_type, screen_info,
112 swapped_out, hidden, never_visible);
113 if (g_widget_test_proxy_callback == 0)
114 return render_widget_proxy;
115 g_widget_test_proxy_callback.Get().Run(render_widget_proxy->web_widget(),
116 render_widget_proxy);
117 return render_widget_proxy;
118 }
119
91 RenderFrameImpl* CreateWebFrameTestProxy( 120 RenderFrameImpl* CreateWebFrameTestProxy(
92 const RenderFrameImpl::CreateParams& params) { 121 const RenderFrameImpl::CreateParams& params) {
93 WebFrameTestProxyType* render_frame_proxy = new WebFrameTestProxyType(params); 122 WebFrameTestProxyType* render_frame_proxy = new WebFrameTestProxyType(params);
94 if (g_frame_test_proxy_callback == 0) 123 if (g_frame_test_proxy_callback == 0)
95 return render_frame_proxy; 124 return render_frame_proxy;
96 g_frame_test_proxy_callback.Get().Run(render_frame_proxy, render_frame_proxy); 125 g_frame_test_proxy_callback.Get().Run(render_frame_proxy, render_frame_proxy);
97 return render_frame_proxy; 126 return render_frame_proxy;
98 } 127 }
99 128
100 #if defined(OS_WIN) 129 #if defined(OS_WIN)
(...skipping 21 matching lines...) Expand all
122 151
123 test_runner::WebFrameTestProxyBase* GetWebFrameTestProxyBase( 152 test_runner::WebFrameTestProxyBase* GetWebFrameTestProxyBase(
124 RenderFrame* render_frame) { 153 RenderFrame* render_frame) {
125 WebFrameTestProxyType* render_frame_proxy = 154 WebFrameTestProxyType* render_frame_proxy =
126 static_cast<WebFrameTestProxyType*>(render_frame); 155 static_cast<WebFrameTestProxyType*>(render_frame);
127 return static_cast<test_runner::WebFrameTestProxyBase*>(render_frame_proxy); 156 return static_cast<test_runner::WebFrameTestProxyBase*>(render_frame_proxy);
128 } 157 }
129 158
130 void EnableWebTestProxyCreation( 159 void EnableWebTestProxyCreation(
131 const ViewProxyCreationCallback& view_proxy_creation_callback, 160 const ViewProxyCreationCallback& view_proxy_creation_callback,
161 const WidgetProxyCreationCallback& widget_proxy_creation_callback,
132 const FrameProxyCreationCallback& frame_proxy_creation_callback) { 162 const FrameProxyCreationCallback& frame_proxy_creation_callback) {
133 g_view_test_proxy_callback.Get() = view_proxy_creation_callback; 163 g_view_test_proxy_callback.Get() = view_proxy_creation_callback;
164 g_widget_test_proxy_callback.Get() = widget_proxy_creation_callback;
134 g_frame_test_proxy_callback.Get() = frame_proxy_creation_callback; 165 g_frame_test_proxy_callback.Get() = frame_proxy_creation_callback;
135 RenderViewImpl::InstallCreateHook(CreateWebViewTestProxy); 166 RenderViewImpl::InstallCreateHook(CreateWebViewTestProxy);
167 RenderWidget::InstallCreateHook(CreateWebWidgetTestProxy);
136 RenderFrameImpl::InstallCreateHook(CreateWebFrameTestProxy); 168 RenderFrameImpl::InstallCreateHook(CreateWebFrameTestProxy);
137 } 169 }
138 170
139 void FetchManifestDoneCallback(std::unique_ptr<ManifestFetcher> fetcher, 171 void FetchManifestDoneCallback(std::unique_ptr<ManifestFetcher> fetcher,
140 const FetchManifestCallback& callback, 172 const FetchManifestCallback& callback,
141 const blink::WebURLResponse& response, 173 const blink::WebURLResponse& response,
142 const std::string& data) { 174 const std::string& data) {
143 // |fetcher| will be autodeleted here as it is going out of scope. 175 // |fetcher| will be autodeleted here as it is going out of scope.
144 callback.Run(response, data); 176 callback.Run(response, data);
145 } 177 }
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 return result; 528 return result;
497 } 529 }
498 530
499 void SchedulerRunIdleTasks(const base::Closure& callback) { 531 void SchedulerRunIdleTasks(const base::Closure& callback) {
500 scheduler::RendererScheduler* scheduler = 532 scheduler::RendererScheduler* scheduler =
501 content::RenderThreadImpl::current()->GetRendererScheduler(); 533 content::RenderThreadImpl::current()->GetRendererScheduler();
502 scheduler::RunIdleTasksForTesting(scheduler, callback); 534 scheduler::RunIdleTasksForTesting(scheduler, callback);
503 } 535 }
504 536
505 } // namespace content 537 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698