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

Side by Side Diff: cc/test/layer_tree_test.cc

Issue 1417053005: cc: Split ThreadProxy into ProxyMain and ProxyImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments from #18. Created 5 years 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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/test/layer_tree_test.h" 5 #include "cc/test/layer_tree_test.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/thread_task_runner_handle.h" 10 #include "base/thread_task_runner_handle.h"
(...skipping 12 matching lines...) Expand all
23 #include "cc/test/fake_layer_tree_host_client.h" 23 #include "cc/test/fake_layer_tree_host_client.h"
24 #include "cc/test/fake_output_surface.h" 24 #include "cc/test/fake_output_surface.h"
25 #include "cc/test/test_context_provider.h" 25 #include "cc/test/test_context_provider.h"
26 #include "cc/test/test_gpu_memory_buffer_manager.h" 26 #include "cc/test/test_gpu_memory_buffer_manager.h"
27 #include "cc/test/test_shared_bitmap_manager.h" 27 #include "cc/test/test_shared_bitmap_manager.h"
28 #include "cc/test/test_task_graph_runner.h" 28 #include "cc/test/test_task_graph_runner.h"
29 #include "cc/trees/layer_tree_host_client.h" 29 #include "cc/trees/layer_tree_host_client.h"
30 #include "cc/trees/layer_tree_host_impl.h" 30 #include "cc/trees/layer_tree_host_impl.h"
31 #include "cc/trees/layer_tree_host_single_thread_client.h" 31 #include "cc/trees/layer_tree_host_single_thread_client.h"
32 #include "cc/trees/layer_tree_impl.h" 32 #include "cc/trees/layer_tree_impl.h"
33 #include "cc/trees/proxy_impl.h"
34 #include "cc/trees/proxy_main.h"
33 #include "cc/trees/single_thread_proxy.h" 35 #include "cc/trees/single_thread_proxy.h"
34 #include "cc/trees/thread_proxy.h" 36 #include "cc/trees/threaded_channel.h"
35 #include "testing/gmock/include/gmock/gmock.h" 37 #include "testing/gmock/include/gmock/gmock.h"
36 #include "ui/gfx/geometry/size_conversions.h" 38 #include "ui/gfx/geometry/size_conversions.h"
37 39
38 namespace cc { 40 namespace cc {
39 41
40 void CreateVirtualViewportLayers(Layer* root_layer, 42 void CreateVirtualViewportLayers(Layer* root_layer,
41 scoped_refptr<Layer> outer_scroll_layer, 43 scoped_refptr<Layer> outer_scroll_layer,
42 const gfx::Size& inner_bounds, 44 const gfx::Size& inner_bounds,
43 const gfx::Size& outer_bounds, 45 const gfx::Size& outer_bounds,
44 LayerTreeHost* host, 46 LayerTreeHost* host,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 107 }
106 108
107 void TestHooks::CreateResourceAndTileTaskWorkerPool( 109 void TestHooks::CreateResourceAndTileTaskWorkerPool(
108 LayerTreeHostImpl* host_impl, 110 LayerTreeHostImpl* host_impl,
109 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, 111 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool,
110 scoped_ptr<ResourcePool>* resource_pool) { 112 scoped_ptr<ResourcePool>* resource_pool) {
111 host_impl->LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool( 113 host_impl->LayerTreeHostImpl::CreateResourceAndTileTaskWorkerPool(
112 tile_task_worker_pool, resource_pool); 114 tile_task_worker_pool, resource_pool);
113 } 115 }
114 116
115 // Adapts ThreadProxy for test. Injects test hooks for testing. 117 // Creates a ProxyImpl that notifies the supplied |test_hooks| of various
116 class ThreadProxyForTest : public ThreadProxy { 118 // actions.
119 class ProxyImplForTest : public ProxyImpl {
vmpstr 2015/12/04 00:25:40 Maybe just TestProxyImpl?
Khushal 2015/12/04 22:45:22 I kept it consistent with the current naming schem
vmpstr 2015/12/07 22:14:42 Ok, let's keep it as it is for now. There's way to
117 public: 120 public:
118 static scoped_ptr<Proxy> Create( 121 static scoped_ptr<ProxyImpl> Create(
119 TestHooks* test_hooks, 122 TestHooks* test_hooks,
120 LayerTreeHost* host, 123 ChannelImpl* channel_impl,
124 LayerTreeHost* layer_tree_host,
121 TaskRunnerProvider* task_runner_provider, 125 TaskRunnerProvider* task_runner_provider,
122 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 126 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
123 return make_scoped_ptr( 127 return make_scoped_ptr(new ProxyImplForTest(
124 new ThreadProxyForTest(test_hooks, host, task_runner_provider, 128 test_hooks, channel_impl, layer_tree_host, task_runner_provider,
125 std::move(external_begin_frame_source))); 129 std::move(external_begin_frame_source)));
126 } 130 }
127 131
128 ~ThreadProxyForTest() override {}
129
130 private: 132 private:
131 TestHooks* test_hooks_; 133 TestHooks* test_hooks_;
132 134
133 void SetNeedsUpdateLayers() override {
134 ThreadProxy::SetNeedsUpdateLayers();
135 test_hooks_->DidSetNeedsUpdateLayers();
136 }
137
138 void ScheduledActionSendBeginMainFrame(const BeginFrameArgs& args) override { 135 void ScheduledActionSendBeginMainFrame(const BeginFrameArgs& args) override {
139 test_hooks_->ScheduledActionWillSendBeginMainFrame(); 136 test_hooks_->ScheduledActionWillSendBeginMainFrame();
140 ThreadProxy::ScheduledActionSendBeginMainFrame(args); 137 ProxyImpl::ScheduledActionSendBeginMainFrame(args);
141 test_hooks_->ScheduledActionSendBeginMainFrame(); 138 test_hooks_->ScheduledActionSendBeginMainFrame();
142 } 139 }
143 140
144 DrawResult ScheduledActionDrawAndSwapIfPossible() override { 141 DrawResult ScheduledActionDrawAndSwapIfPossible() override {
145 DrawResult result = ThreadProxy::ScheduledActionDrawAndSwapIfPossible(); 142 DrawResult result = ProxyImpl::ScheduledActionDrawAndSwapIfPossible();
146 test_hooks_->ScheduledActionDrawAndSwapIfPossible(); 143 test_hooks_->ScheduledActionDrawAndSwapIfPossible();
147 return result; 144 return result;
148 } 145 }
149 146
150 void ScheduledActionAnimate() override { 147 void ScheduledActionAnimate() override {
151 ThreadProxy::ScheduledActionAnimate(); 148 ProxyImpl::ScheduledActionAnimate();
152 test_hooks_->ScheduledActionAnimate(); 149 test_hooks_->ScheduledActionAnimate();
153 } 150 }
154 151
155 void ScheduledActionCommit() override { 152 void ScheduledActionCommit() override {
156 ThreadProxy::ScheduledActionCommit(); 153 ProxyImpl::ScheduledActionCommit();
157 test_hooks_->ScheduledActionCommit(); 154 test_hooks_->ScheduledActionCommit();
158 } 155 }
159 156
160 void ScheduledActionBeginOutputSurfaceCreation() override { 157 void ScheduledActionBeginOutputSurfaceCreation() override {
161 ThreadProxy::ScheduledActionBeginOutputSurfaceCreation(); 158 ProxyImpl::ScheduledActionBeginOutputSurfaceCreation();
162 test_hooks_->ScheduledActionBeginOutputSurfaceCreation(); 159 test_hooks_->ScheduledActionBeginOutputSurfaceCreation();
163 } 160 }
164 161
165 void ScheduledActionPrepareTiles() override { 162 void ScheduledActionPrepareTiles() override {
166 ThreadProxy::ScheduledActionPrepareTiles(); 163 ProxyImpl::ScheduledActionPrepareTiles();
167 test_hooks_->ScheduledActionPrepareTiles(); 164 test_hooks_->ScheduledActionPrepareTiles();
168 } 165 }
169 166
170 void ScheduledActionInvalidateOutputSurface() override { 167 void ScheduledActionInvalidateOutputSurface() override {
171 ThreadProxy::ScheduledActionInvalidateOutputSurface(); 168 ProxyImpl::ScheduledActionInvalidateOutputSurface();
172 test_hooks_->ScheduledActionInvalidateOutputSurface(); 169 test_hooks_->ScheduledActionInvalidateOutputSurface();
173 } 170 }
174 171
175 void SendBeginMainFrameNotExpectedSoon() override { 172 void SendBeginMainFrameNotExpectedSoon() override {
176 ThreadProxy::SendBeginMainFrameNotExpectedSoon(); 173 ProxyImpl::SendBeginMainFrameNotExpectedSoon();
177 test_hooks_->SendBeginMainFrameNotExpectedSoon(); 174 test_hooks_->SendBeginMainFrameNotExpectedSoon();
178 } 175 }
179 176
180 void DidActivateSyncTree() override { 177 void DidActivateSyncTree() override {
181 ThreadProxy::DidActivateSyncTree(); 178 ProxyImpl::DidActivateSyncTree();
182 test_hooks_->DidActivateSyncTree(); 179 test_hooks_->DidActivateSyncTree();
183 } 180 }
184 181
185 void SetThrottleFrameProductionOnImpl(bool throttle) override { 182 void SetThrottleFrameProductionOnImpl(bool throttle) override {
186 test_hooks_->SetThrottleFrameProductionOnImpl(throttle); 183 test_hooks_->SetThrottleFrameProductionOnImpl(throttle);
187 ThreadProxy::SetThrottleFrameProductionOnImpl(throttle); 184 ProxyImpl::SetThrottleFrameProductionOnImpl(throttle);
188 } 185 }
189 186
190 void InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) override { 187 void InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) override {
191 test_hooks_->InitializeOutputSurfaceOnImpl(output_surface); 188 test_hooks_->InitializeOutputSurfaceOnImpl(output_surface);
192 ThreadProxy::InitializeOutputSurfaceOnImpl(output_surface); 189 ProxyImpl::InitializeOutputSurfaceOnImpl(output_surface);
193 } 190 }
194 191
195 void MainThreadHasStoppedFlingingOnImpl() override { 192 void MainThreadHasStoppedFlingingOnImpl() override {
196 test_hooks_->MainThreadHasStoppedFlingingOnImpl(); 193 test_hooks_->MainThreadHasStoppedFlingingOnImpl();
197 ThreadProxy::MainThreadHasStoppedFlingingOnImpl(); 194 ProxyImpl::MainThreadHasStoppedFlingingOnImpl();
198 } 195 }
199 196
200 void SetInputThrottledUntilCommitOnImpl(bool is_throttled) override { 197 void SetInputThrottledUntilCommitOnImpl(bool is_throttled) override {
201 test_hooks_->SetInputThrottledUntilCommitOnImpl(is_throttled); 198 test_hooks_->SetInputThrottledUntilCommitOnImpl(is_throttled);
202 ThreadProxy::SetInputThrottledUntilCommitOnImpl(is_throttled); 199 ProxyImpl::SetInputThrottledUntilCommitOnImpl(is_throttled);
203 } 200 }
204 201
205 void UpdateTopControlsStateOnImpl(TopControlsState constraints, 202 void UpdateTopControlsStateOnImpl(TopControlsState constraints,
206 TopControlsState current, 203 TopControlsState current,
207 bool animate) override { 204 bool animate) override {
208 test_hooks_->UpdateTopControlsStateOnImpl(constraints, current, animate); 205 test_hooks_->UpdateTopControlsStateOnImpl(constraints, current, animate);
209 ThreadProxy::UpdateTopControlsStateOnImpl(constraints, current, animate); 206 ProxyImpl::UpdateTopControlsStateOnImpl(constraints, current, animate);
210 } 207 }
211 208
212 void SetDeferCommitsOnImpl(bool defer_commits) const override { 209 void SetDeferCommitsOnImpl(bool defer_commits) const override {
213 test_hooks_->SetDeferCommitsOnImpl(defer_commits); 210 test_hooks_->SetDeferCommitsOnImpl(defer_commits);
214 ThreadProxy::SetDeferCommitsOnImpl(defer_commits); 211 ProxyImpl::SetDeferCommitsOnImpl(defer_commits);
215 } 212 }
216 213
217 void BeginMainFrameAbortedOnImpl( 214 void BeginMainFrameAbortedOnImpl(
218 CommitEarlyOutReason reason, 215 CommitEarlyOutReason reason,
219 base::TimeTicks main_thread_start_time) override { 216 base::TimeTicks main_thread_start_time) override {
220 test_hooks_->BeginMainFrameAbortedOnImpl(reason); 217 test_hooks_->BeginMainFrameAbortedOnImpl(reason);
221 ThreadProxy::BeginMainFrameAbortedOnImpl(reason, main_thread_start_time); 218 ProxyImpl::BeginMainFrameAbortedOnImpl(reason, main_thread_start_time);
222 } 219 }
223 220
224 void SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) override { 221 void SetNeedsRedrawOnImpl(const gfx::Rect& damage_rect) override {
225 test_hooks_->SetNeedsRedrawOnImpl(damage_rect); 222 test_hooks_->SetNeedsRedrawOnImpl(damage_rect);
226 ThreadProxy::SetNeedsRedrawOnImpl(damage_rect); 223 ProxyImpl::SetNeedsRedrawOnImpl(damage_rect);
227 }; 224 };
228 225
229 void SetNeedsCommitOnImpl() override { 226 void SetNeedsCommitOnImpl() override {
230 test_hooks_->SetNeedsCommitOnImpl(); 227 test_hooks_->SetNeedsCommitOnImpl();
231 ThreadProxy::SetNeedsCommitOnImpl(); 228 ProxyImpl::SetNeedsCommitOnImpl();
232 } 229 }
233 230
234 void FinishAllRenderingOnImpl(CompletionEvent* completion) override { 231 void FinishAllRenderingOnImpl(CompletionEvent* completion) override {
235 test_hooks_->FinishAllRenderingOnImpl(); 232 test_hooks_->FinishAllRenderingOnImpl();
236 ThreadProxy::FinishAllRenderingOnImpl(completion); 233 ProxyImpl::FinishAllRenderingOnImpl(completion);
237 }; 234 };
238 235
239 void SetVisibleOnImpl(bool visible) override { 236 void SetVisibleOnImpl(bool visible) override {
240 test_hooks_->SetVisibleOnImpl(visible); 237 test_hooks_->SetVisibleOnImpl(visible);
241 ThreadProxy::SetVisibleOnImpl(visible); 238 ProxyImpl::SetVisibleOnImpl(visible);
242 } 239 }
243 240
244 void ReleaseOutputSurfaceOnImpl(CompletionEvent* completion) override { 241 void ReleaseOutputSurfaceOnImpl(CompletionEvent* completion) override {
245 test_hooks_->ReleaseOutputSurfaceOnImpl(); 242 test_hooks_->ReleaseOutputSurfaceOnImpl();
246 ThreadProxy::ReleaseOutputSurfaceOnImpl(completion); 243 ProxyImpl::ReleaseOutputSurfaceOnImpl(completion);
247 } 244 }
248 245
249 void FinishGLOnImpl(CompletionEvent* completion) override { 246 void FinishGLOnImpl(CompletionEvent* completion) override {
250 test_hooks_->FinishGLOnImpl(); 247 test_hooks_->FinishGLOnImpl();
251 ThreadProxy::FinishGLOnImpl(completion); 248 ProxyImpl::FinishGLOnImpl(completion);
252 } 249 }
253 250
254 void StartCommitOnImpl(CompletionEvent* completion, 251 void StartCommitOnImpl(CompletionEvent* completion,
255 LayerTreeHost* layer_tree_host, 252 LayerTreeHost* layer_tree_host,
256 base::TimeTicks main_thread_start_time, 253 base::TimeTicks main_thread_start_time,
257 bool hold_commit_for_activation) override { 254 bool hold_commit_for_activation) override {
258 test_hooks_->StartCommitOnImpl(); 255 test_hooks_->StartCommitOnImpl();
259 ThreadProxy::StartCommitOnImpl(completion, layer_tree_host, 256 ProxyImpl::StartCommitOnImpl(completion, layer_tree_host,
260 main_thread_start_time, 257 main_thread_start_time,
261 hold_commit_for_activation); 258 hold_commit_for_activation);
262 } 259 }
263 260
264 void InitializeImplOnImpl(CompletionEvent* completion, 261 ProxyImplForTest(TestHooks* test_hooks,
vmpstr 2015/12/04 00:25:40 Can you move this to the top of the private block
Khushal 2015/12/04 22:45:22 Done.
265 LayerTreeHost* layer_tree_host) override { 262 ChannelImpl* channel_impl,
266 ThreadProxy::InitializeImplOnImpl(completion, layer_tree_host); 263 LayerTreeHost* layer_tree_host,
267 test_hooks_->InitializeImplOnImpl(); 264 TaskRunnerProvider* task_runner_provider,
265 scoped_ptr<BeginFrameSource> external_begin_frame_source)
266 : ProxyImpl(channel_impl,
267 layer_tree_host,
268 task_runner_provider,
269 std::move(external_begin_frame_source)),
270 test_hooks_(test_hooks) {}
271 };
272
273 // ThreadedChannel that notifies |test_hooks| of internal actions by ProxyImpl.
274 class ThreadedChannelForTest : public ThreadedChannel {
275 public:
276 static scoped_ptr<ThreadedChannel> Create(
277 TestHooks* test_hooks,
278 ProxyMain* proxy_main,
279 TaskRunnerProvider* task_runner_provider) {
280 return make_scoped_ptr(new ThreadedChannelForTest(test_hooks, proxy_main,
281 task_runner_provider));
268 } 282 }
269 283
270 void LayerTreeHostClosedOnImpl(CompletionEvent* completion) override { 284 private:
271 test_hooks_->WillCloseLayerTreeHostOnImpl(); 285 TestHooks* test_hooks_;
272 ThreadProxy::LayerTreeHostClosedOnImpl(completion); 286
287 scoped_ptr<ProxyImpl> CreateProxyImpl(
288 ChannelImpl* channel_impl,
289 LayerTreeHost* layer_tree_host,
290 TaskRunnerProvider* task_runner_provider,
291 scoped_ptr<BeginFrameSource> external_begin_frame_source) override {
292 return ProxyImplForTest::Create(test_hooks_, channel_impl, layer_tree_host,
293 task_runner_provider,
294 std::move(external_begin_frame_source));
295 }
296
297 ThreadedChannelForTest(TestHooks* test_hooks,
298 ProxyMain* proxy_main,
299 TaskRunnerProvider* task_runner_provider)
300 : ThreadedChannel(proxy_main, task_runner_provider),
301 test_hooks_(test_hooks) {}
302 };
303
304 // Creates a ProxyMain that notifies the supplied |test_hooks| of various
305 // actions.
306 class ProxyMainForTest : public ProxyMain {
307 public:
308 static scoped_ptr<ProxyMain> Create(
309 TestHooks* test_hooks,
310 LayerTreeHost* host,
311 TaskRunnerProvider* task_runner_provider,
312 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
313 return make_scoped_ptr(
314 new ProxyMainForTest(test_hooks, host, task_runner_provider,
315 std::move(external_begin_frame_source)));
316 }
317
318 ~ProxyMainForTest() override {}
319
320 private:
321 TestHooks* test_hooks_;
vmpstr 2015/12/04 00:25:40 Can you put functions before variables
Khushal 2015/12/04 22:45:22 Done.
322
323 void SetNeedsUpdateLayers() override {
324 ProxyMain::SetNeedsUpdateLayers();
325 test_hooks_->DidSetNeedsUpdateLayers();
273 } 326 }
274 327
275 void DidCompleteSwapBuffers() override { 328 void DidCompleteSwapBuffers() override {
276 test_hooks_->ReceivedDidCompleteSwapBuffers(); 329 test_hooks_->ReceivedDidCompleteSwapBuffers();
277 ThreadProxy::DidCompleteSwapBuffers(); 330 ProxyMain::DidCompleteSwapBuffers();
278 } 331 }
279 332
280 void SetRendererCapabilitiesMainCopy( 333 void SetRendererCapabilitiesMainCopy(
281 const RendererCapabilities& capabilities) override { 334 const RendererCapabilities& capabilities) override {
282 test_hooks_->ReceivedSetRendererCapabilitiesMainCopy(capabilities); 335 test_hooks_->ReceivedSetRendererCapabilitiesMainCopy(capabilities);
283 ThreadProxy::SetRendererCapabilitiesMainCopy(capabilities); 336 ProxyMain::SetRendererCapabilitiesMainCopy(capabilities);
284 } 337 }
285 338
286 void BeginMainFrameNotExpectedSoon() override { 339 void BeginMainFrameNotExpectedSoon() override {
287 test_hooks_->ReceivedBeginMainFrameNotExpectedSoon(); 340 test_hooks_->ReceivedBeginMainFrameNotExpectedSoon();
288 ThreadProxy::BeginMainFrameNotExpectedSoon(); 341 ProxyMain::BeginMainFrameNotExpectedSoon();
289 } 342 }
290 343
291 void DidCommitAndDrawFrame() override { 344 void DidCommitAndDrawFrame() override {
292 test_hooks_->ReceivedDidCommitAndDrawFrame(); 345 test_hooks_->ReceivedDidCommitAndDrawFrame();
293 ThreadProxy::DidCommitAndDrawFrame(); 346 ProxyMain::DidCommitAndDrawFrame();
294 } 347 }
295 348
296 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> events) override { 349 void SetAnimationEvents(scoped_ptr<AnimationEventsVector> events) override {
297 test_hooks_->ReceivedSetAnimationEvents(); 350 test_hooks_->ReceivedSetAnimationEvents();
298 ThreadProxy::SetAnimationEvents(std::move(events)); 351 ProxyMain::SetAnimationEvents(std::move(events));
299 } 352 }
300 353
301 void DidLoseOutputSurface() override { 354 void DidLoseOutputSurface() override {
302 test_hooks_->ReceivedDidLoseOutputSurface(); 355 test_hooks_->ReceivedDidLoseOutputSurface();
303 ThreadProxy::DidLoseOutputSurface(); 356 ProxyMain::DidLoseOutputSurface();
304 } 357 }
305 358
306 void RequestNewOutputSurface() override { 359 void RequestNewOutputSurface() override {
307 test_hooks_->ReceivedRequestNewOutputSurface(); 360 test_hooks_->ReceivedRequestNewOutputSurface();
308 ThreadProxy::RequestNewOutputSurface(); 361 ProxyMain::RequestNewOutputSurface();
309 } 362 }
310 363
311 void DidInitializeOutputSurface( 364 void DidInitializeOutputSurface(
312 bool success, 365 bool success,
313 const RendererCapabilities& capabilities) override { 366 const RendererCapabilities& capabilities) override {
314 test_hooks_->ReceivedDidInitializeOutputSurface(success, capabilities); 367 test_hooks_->ReceivedDidInitializeOutputSurface(success, capabilities);
315 ThreadProxy::DidInitializeOutputSurface(success, capabilities); 368 ProxyMain::DidInitializeOutputSurface(success, capabilities);
316 } 369 }
317 370
318 void DidCompletePageScaleAnimation() override { 371 void DidCompletePageScaleAnimation() override {
319 test_hooks_->ReceivedDidCompletePageScaleAnimation(); 372 test_hooks_->ReceivedDidCompletePageScaleAnimation();
320 ThreadProxy::DidCompletePageScaleAnimation(); 373 ProxyMain::DidCompletePageScaleAnimation();
321 } 374 }
322 375
323 void PostFrameTimingEventsOnMain( 376 void PostFrameTimingEventsOnMain(
324 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, 377 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events,
325 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) 378 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events)
326 override { 379 override {
327 test_hooks_->ReceivedPostFrameTimingEventsOnMain(); 380 test_hooks_->ReceivedPostFrameTimingEventsOnMain();
328 ThreadProxy::PostFrameTimingEventsOnMain(std::move(composite_events), 381 ProxyMain::PostFrameTimingEventsOnMain(std::move(composite_events),
329 std::move(main_frame_events)); 382 std::move(main_frame_events));
330 } 383 }
331 384
332 void BeginMainFrame(scoped_ptr<BeginMainFrameAndCommitState> 385 void BeginMainFrame(scoped_ptr<BeginMainFrameAndCommitState>
333 begin_main_frame_state) override { 386 begin_main_frame_state) override {
334 test_hooks_->ReceivedBeginMainFrame(); 387 test_hooks_->ReceivedBeginMainFrame();
335 ThreadProxy::BeginMainFrame(std::move(begin_main_frame_state)); 388 ProxyMain::BeginMainFrame(std::move(begin_main_frame_state));
336 }; 389 };
337 390
338 ThreadProxyForTest(TestHooks* test_hooks, 391 ProxyMainForTest(TestHooks* test_hooks,
339 LayerTreeHost* host, 392 LayerTreeHost* host,
340 TaskRunnerProvider* task_runner_provider, 393 TaskRunnerProvider* task_runner_provider,
341 scoped_ptr<BeginFrameSource> external_begin_frame_source) 394 scoped_ptr<BeginFrameSource> external_begin_frame_source)
342 : ThreadProxy(host, 395 : ProxyMain(host,
343 task_runner_provider, 396 task_runner_provider,
344 std::move(external_begin_frame_source)), 397 std::move(external_begin_frame_source)),
345 test_hooks_(test_hooks) {} 398 test_hooks_(test_hooks) {}
346 }; 399 };
347 400
348 // Adapts ThreadProxy for test. Injects test hooks for testing. 401 // Creates a SingleThreadProxy that notifies the supplied |test_hooks| of
402 // various actions.
349 class SingleThreadProxyForTest : public SingleThreadProxy { 403 class SingleThreadProxyForTest : public SingleThreadProxy {
350 public: 404 public:
351 static scoped_ptr<Proxy> Create( 405 static scoped_ptr<Proxy> Create(
352 TestHooks* test_hooks, 406 TestHooks* test_hooks,
353 LayerTreeHost* host, 407 LayerTreeHost* host,
354 LayerTreeHostSingleThreadClient* client, 408 LayerTreeHostSingleThreadClient* client,
355 TaskRunnerProvider* task_runner_provider, 409 TaskRunnerProvider* task_runner_provider,
356 scoped_ptr<BeginFrameSource> external_begin_frame_source) { 410 scoped_ptr<BeginFrameSource> external_begin_frame_source) {
357 return make_scoped_ptr(new SingleThreadProxyForTest( 411 return make_scoped_ptr(new SingleThreadProxyForTest(
358 test_hooks, host, client, task_runner_provider, 412 test_hooks, host, client, task_runner_provider,
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 params.shared_bitmap_manager = shared_bitmap_manager; 755 params.shared_bitmap_manager = shared_bitmap_manager;
702 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager; 756 params.gpu_memory_buffer_manager = gpu_memory_buffer_manager;
703 params.task_graph_runner = task_graph_runner; 757 params.task_graph_runner = task_graph_runner;
704 params.settings = &settings; 758 params.settings = &settings;
705 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( 759 scoped_ptr<LayerTreeHostForTesting> layer_tree_host(
706 new LayerTreeHostForTesting(test_hooks, &params)); 760 new LayerTreeHostForTesting(test_hooks, &params));
707 scoped_ptr<TaskRunnerProvider> task_runner_provider = 761 scoped_ptr<TaskRunnerProvider> task_runner_provider =
708 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); 762 TaskRunnerProvider::Create(main_task_runner, impl_task_runner);
709 scoped_ptr<Proxy> proxy; 763 scoped_ptr<Proxy> proxy;
710 if (impl_task_runner.get()) { 764 if (impl_task_runner.get()) {
711 proxy = ThreadProxyForTest::Create( 765 scoped_ptr<ProxyMain> proxy_main = ProxyMainForTest::Create(
712 test_hooks, layer_tree_host.get(), task_runner_provider.get(), 766 test_hooks, layer_tree_host.get(), task_runner_provider.get(),
713 std::move(external_begin_frame_source)); 767 std::move(external_begin_frame_source));
768 scoped_ptr<ThreadedChannel> threaded_channel =
769 ThreadedChannelForTest::Create(test_hooks, proxy_main.get(),
770 task_runner_provider.get());
771 proxy_main->SetChannel(std::move(threaded_channel));
vmpstr 2015/12/04 00:25:40 Can you inline the creation in the function? It do
Khushal 2015/12/04 22:45:22 Done.
772 proxy = std::move(proxy_main);
714 } else { 773 } else {
715 proxy = SingleThreadProxyForTest::Create( 774 proxy = SingleThreadProxyForTest::Create(
716 test_hooks, layer_tree_host.get(), client, task_runner_provider.get(), 775 test_hooks, layer_tree_host.get(), client, task_runner_provider.get(),
717 std::move(external_begin_frame_source)); 776 std::move(external_begin_frame_source));
718 } 777 }
719 layer_tree_host->InitializeForTesting(std::move(task_runner_provider), 778 layer_tree_host->InitializeForTesting(std::move(task_runner_provider),
720 std::move(proxy)); 779 std::move(proxy));
721 return layer_tree_host; 780 return layer_tree_host;
722 } 781 }
723 782
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 // We check for a null task_runner_provider here as we sometimes ask for the 1213 // We check for a null task_runner_provider here as we sometimes ask for the
1155 // layer tree host when the task_runner_provider does not exist, often for 1214 // layer tree host when the task_runner_provider does not exist, often for
1156 // checking settings after a test has completed. For example, 1215 // checking settings after a test has completed. For example,
1157 // LTHPixelResourceTest::RunPixelResourceTest. See elsewhere in this file for 1216 // LTHPixelResourceTest::RunPixelResourceTest. See elsewhere in this file for
1158 // other examples. 1217 // other examples.
1159 DCHECK(!task_runner_provider() || task_runner_provider()->IsMainThread() || 1218 DCHECK(!task_runner_provider() || task_runner_provider()->IsMainThread() ||
1160 task_runner_provider()->IsMainThreadBlocked()); 1219 task_runner_provider()->IsMainThreadBlocked());
1161 return layer_tree_host_.get(); 1220 return layer_tree_host_.get();
1162 } 1221 }
1163 1222
1223 ProxyMain* LayerTreeTest::GetProxyMain() const {
1224 DCHECK(HasImplThread());
1225 return static_cast<ProxyMain*>(proxy());
1226 }
1227
1228 ProxyImpl* LayerTreeTest::GetProxyImpl() const {
vmpstr 2015/12/04 00:25:40 Should this return ProxyImplForTest, which can als
Khushal 2015/12/04 22:45:22 Sure. It seemed to me that the test classes in thi
vmpstr 2015/12/07 22:14:42 If that's helpful, we can do that. It's usually mu
Khushal 2015/12/08 02:19:35 Done.
1229 DCHECK(HasImplThread());
1230 ThreadedChannel* threaded_channel =
1231 static_cast<ThreadedChannel*>(GetProxyMain()->channel_main());
1232 ProxyImpl* proxy_impl = threaded_channel->GetProxyImplForTesting();
1233
1234 // We check for null ProxyImpl since ProxyImpl exists in the ThreadedChannel
1235 // only after it is initialized.
1236 DCHECK(proxy_impl);
1237 return proxy_impl;
1238 }
1239
1164 } // namespace cc 1240 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698