OLD | NEW |
---|---|
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 "cc/animation/animation.h" | 8 #include "cc/animation/animation.h" |
9 #include "cc/animation/animation_registrar.h" | 9 #include "cc/animation/animation_registrar.h" |
10 #include "cc/animation/layer_animation_controller.h" | 10 #include "cc/animation/layer_animation_controller.h" |
11 #include "cc/animation/timing_function.h" | 11 #include "cc/animation/timing_function.h" |
12 #include "cc/base/switches.h" | 12 #include "cc/base/switches.h" |
13 #include "cc/input/input_handler.h" | 13 #include "cc/input/input_handler.h" |
14 #include "cc/layers/content_layer.h" | 14 #include "cc/layers/content_layer.h" |
15 #include "cc/layers/layer.h" | 15 #include "cc/layers/layer.h" |
16 #include "cc/layers/layer_impl.h" | 16 #include "cc/layers/layer_impl.h" |
17 #include "cc/test/animation_test_common.h" | 17 #include "cc/test/animation_test_common.h" |
18 #include "cc/test/fake_layer_tree_host_client.h" | 18 #include "cc/test/fake_layer_tree_host_client.h" |
19 #include "cc/test/fake_output_surface.h" | 19 #include "cc/test/fake_output_surface.h" |
20 #include "cc/test/test_context_provider.h" | 20 #include "cc/test/test_context_provider.h" |
21 #include "cc/test/test_shared_bitmap_manager.h" | |
21 #include "cc/test/tiled_layer_test_common.h" | 22 #include "cc/test/tiled_layer_test_common.h" |
22 #include "cc/trees/layer_tree_host_client.h" | 23 #include "cc/trees/layer_tree_host_client.h" |
23 #include "cc/trees/layer_tree_host_impl.h" | 24 #include "cc/trees/layer_tree_host_impl.h" |
24 #include "cc/trees/layer_tree_host_single_thread_client.h" | 25 #include "cc/trees/layer_tree_host_single_thread_client.h" |
25 #include "cc/trees/layer_tree_impl.h" | 26 #include "cc/trees/layer_tree_impl.h" |
26 #include "cc/trees/single_thread_proxy.h" | 27 #include "cc/trees/single_thread_proxy.h" |
27 #include "testing/gmock/include/gmock/gmock.h" | 28 #include "testing/gmock/include/gmock/gmock.h" |
28 #include "ui/gfx/frame_time.h" | 29 #include "ui/gfx/frame_time.h" |
29 #include "ui/gfx/size_conversions.h" | 30 #include "ui/gfx/size_conversions.h" |
30 | 31 |
(...skipping 15 matching lines...) Expand all Loading... | |
46 } | 47 } |
47 | 48 |
48 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. | 49 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. |
49 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { | 50 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { |
50 public: | 51 public: |
51 static scoped_ptr<LayerTreeHostImplForTesting> Create( | 52 static scoped_ptr<LayerTreeHostImplForTesting> Create( |
52 TestHooks* test_hooks, | 53 TestHooks* test_hooks, |
53 const LayerTreeSettings& settings, | 54 const LayerTreeSettings& settings, |
54 LayerTreeHostImplClient* host_impl_client, | 55 LayerTreeHostImplClient* host_impl_client, |
55 Proxy* proxy, | 56 Proxy* proxy, |
57 SharedBitmapManager* manager, | |
56 RenderingStatsInstrumentation* stats_instrumentation) { | 58 RenderingStatsInstrumentation* stats_instrumentation) { |
57 return make_scoped_ptr(new LayerTreeHostImplForTesting( | 59 return make_scoped_ptr( |
58 test_hooks, settings, host_impl_client, proxy, stats_instrumentation)); | 60 new LayerTreeHostImplForTesting(test_hooks, |
61 settings, | |
62 host_impl_client, | |
63 proxy, | |
64 manager, | |
65 stats_instrumentation)); | |
59 } | 66 } |
60 | 67 |
61 protected: | 68 protected: |
62 LayerTreeHostImplForTesting( | 69 LayerTreeHostImplForTesting( |
63 TestHooks* test_hooks, | 70 TestHooks* test_hooks, |
64 const LayerTreeSettings& settings, | 71 const LayerTreeSettings& settings, |
65 LayerTreeHostImplClient* host_impl_client, | 72 LayerTreeHostImplClient* host_impl_client, |
66 Proxy* proxy, | 73 Proxy* proxy, |
74 SharedBitmapManager* manager, | |
67 RenderingStatsInstrumentation* stats_instrumentation) | 75 RenderingStatsInstrumentation* stats_instrumentation) |
68 : LayerTreeHostImpl(settings, | 76 : LayerTreeHostImpl(settings, |
69 host_impl_client, | 77 host_impl_client, |
70 proxy, | 78 proxy, |
71 stats_instrumentation, | 79 stats_instrumentation, |
72 NULL, | 80 manager, |
73 0), | 81 0), |
74 test_hooks_(test_hooks), | 82 test_hooks_(test_hooks), |
75 block_notify_ready_to_activate_for_testing_(false), | 83 block_notify_ready_to_activate_for_testing_(false), |
76 notify_ready_to_activate_was_blocked_(false) {} | 84 notify_ready_to_activate_was_blocked_(false) {} |
77 | 85 |
78 virtual void BeginImplFrame(const BeginFrameArgs& args) OVERRIDE { | 86 virtual void BeginImplFrame(const BeginFrameArgs& args) OVERRIDE { |
79 test_hooks_->WillBeginImplFrameOnThread(this, args); | 87 test_hooks_->WillBeginImplFrameOnThread(this, args); |
80 LayerTreeHostImpl::BeginImplFrame(args); | 88 LayerTreeHostImpl::BeginImplFrame(args); |
81 test_hooks_->DidBeginImplFrameOnThread(this, args); | 89 test_hooks_->DidBeginImplFrameOnThread(this, args); |
82 } | 90 } |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 new LayerTreeHostForTesting(test_hooks, client, settings)); | 295 new LayerTreeHostForTesting(test_hooks, client, settings)); |
288 if (impl_task_runner.get()) | 296 if (impl_task_runner.get()) |
289 layer_tree_host->InitializeThreaded(impl_task_runner); | 297 layer_tree_host->InitializeThreaded(impl_task_runner); |
290 else | 298 else |
291 layer_tree_host->InitializeSingleThreaded(client); | 299 layer_tree_host->InitializeSingleThreaded(client); |
292 return layer_tree_host.Pass(); | 300 return layer_tree_host.Pass(); |
293 } | 301 } |
294 | 302 |
295 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( | 303 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( |
296 LayerTreeHostImplClient* host_impl_client) OVERRIDE { | 304 LayerTreeHostImplClient* host_impl_client) OVERRIDE { |
305 shared_bitmap_manager_.reset(new TestSharedBitmapManager()); | |
297 return LayerTreeHostImplForTesting::Create( | 306 return LayerTreeHostImplForTesting::Create( |
298 test_hooks_, | 307 test_hooks_, |
299 settings(), | 308 settings(), |
300 host_impl_client, | 309 host_impl_client, |
301 proxy(), | 310 proxy(), |
302 rendering_stats_instrumentation()).PassAs<LayerTreeHostImpl>(); | 311 shared_bitmap_manager_.get(), |
312 rendering_stats_instrumentation()).PassAs<LayerTreeHostImpl>(); | |
303 } | 313 } |
304 | 314 |
305 virtual void SetNeedsCommit() OVERRIDE { | 315 virtual void SetNeedsCommit() OVERRIDE { |
306 if (!test_started_) | 316 if (!test_started_) |
307 return; | 317 return; |
308 LayerTreeHost::SetNeedsCommit(); | 318 LayerTreeHost::SetNeedsCommit(); |
309 } | 319 } |
310 | 320 |
311 void set_test_started(bool started) { test_started_ = started; } | 321 void set_test_started(bool started) { test_started_ = started; } |
312 | 322 |
313 virtual void DidDeferCommit() OVERRIDE { test_hooks_->DidDeferCommit(); } | 323 virtual void DidDeferCommit() OVERRIDE { test_hooks_->DidDeferCommit(); } |
314 | 324 |
315 private: | 325 private: |
316 LayerTreeHostForTesting(TestHooks* test_hooks, | 326 LayerTreeHostForTesting(TestHooks* test_hooks, |
317 LayerTreeHostClient* client, | 327 LayerTreeHostClient* client, |
318 const LayerTreeSettings& settings) | 328 const LayerTreeSettings& settings) |
319 : LayerTreeHost(client, NULL, settings), | 329 : LayerTreeHost(client, NULL, settings), |
320 test_hooks_(test_hooks), | 330 test_hooks_(test_hooks), |
danakj
2014/03/18 23:42:44
set the shared_bitmap_manager_ here instead? then
| |
321 test_started_(false) {} | 331 test_started_(false) {} |
322 | 332 |
333 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; | |
323 TestHooks* test_hooks_; | 334 TestHooks* test_hooks_; |
324 bool test_started_; | 335 bool test_started_; |
325 }; | 336 }; |
326 | 337 |
327 LayerTreeTest::LayerTreeTest() | 338 LayerTreeTest::LayerTreeTest() |
328 : beginning_(false), | 339 : beginning_(false), |
329 end_when_begin_returns_(false), | 340 end_when_begin_returns_(false), |
330 timed_out_(false), | 341 timed_out_(false), |
331 scheduled_(false), | 342 scheduled_(false), |
332 schedule_when_set_visible_true_(false), | 343 schedule_when_set_visible_true_(false), |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
706 return -1; | 717 return -1; |
707 } | 718 } |
708 | 719 |
709 void LayerTreeTest::DestroyLayerTreeHost() { | 720 void LayerTreeTest::DestroyLayerTreeHost() { |
710 if (layer_tree_host_ && layer_tree_host_->root_layer()) | 721 if (layer_tree_host_ && layer_tree_host_->root_layer()) |
711 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); | 722 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); |
712 layer_tree_host_.reset(); | 723 layer_tree_host_.reset(); |
713 } | 724 } |
714 | 725 |
715 } // namespace cc | 726 } // namespace cc |
OLD | NEW |