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" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 base::TimeDelta TestHooks::LowFrequencyAnimationInterval() const { | 46 base::TimeDelta TestHooks::LowFrequencyAnimationInterval() const { |
47 return base::TimeDelta::FromMilliseconds(16); | 47 return base::TimeDelta::FromMilliseconds(16); |
48 } | 48 } |
49 | 49 |
50 // Adapts ThreadProxy for test. Injects test hooks for testing. | 50 // Adapts ThreadProxy for test. Injects test hooks for testing. |
51 class ThreadProxyForTest : public ThreadProxy { | 51 class ThreadProxyForTest : public ThreadProxy { |
52 public: | 52 public: |
53 static scoped_ptr<Proxy> Create( | 53 static scoped_ptr<Proxy> Create( |
54 TestHooks* test_hooks, | 54 TestHooks* test_hooks, |
55 LayerTreeHost* host, | 55 LayerTreeHost* host, |
| 56 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
56 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 57 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
57 return make_scoped_ptr( | 58 return make_scoped_ptr( |
58 new ThreadProxyForTest(test_hooks, | 59 new ThreadProxyForTest( |
59 host, | 60 test_hooks, host, main_task_runner, impl_task_runner)) |
60 impl_task_runner)).PassAs<Proxy>(); | 61 .PassAs<Proxy>(); |
61 } | 62 } |
62 | 63 |
63 virtual ~ThreadProxyForTest() {} | 64 virtual ~ThreadProxyForTest() {} |
64 | 65 |
65 void test() { | 66 void test() { |
66 test_hooks_->Layout(); | 67 test_hooks_->Layout(); |
67 } | 68 } |
68 | 69 |
69 private: | 70 private: |
70 TestHooks* test_hooks_; | 71 TestHooks* test_hooks_; |
(...skipping 21 matching lines...) Expand all Loading... |
92 } | 93 } |
93 | 94 |
94 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE { | 95 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE { |
95 ThreadProxy::ScheduledActionBeginOutputSurfaceCreation(); | 96 ThreadProxy::ScheduledActionBeginOutputSurfaceCreation(); |
96 test_hooks_->ScheduledActionBeginOutputSurfaceCreation(); | 97 test_hooks_->ScheduledActionBeginOutputSurfaceCreation(); |
97 } | 98 } |
98 | 99 |
99 ThreadProxyForTest( | 100 ThreadProxyForTest( |
100 TestHooks* test_hooks, | 101 TestHooks* test_hooks, |
101 LayerTreeHost* host, | 102 LayerTreeHost* host, |
| 103 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
102 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) | 104 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) |
103 : ThreadProxy(host, impl_task_runner), | 105 : ThreadProxy(host, main_task_runner, impl_task_runner), |
104 test_hooks_(test_hooks) { | 106 test_hooks_(test_hooks) {} |
105 } | |
106 }; | 107 }; |
107 | 108 |
108 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. | 109 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. |
109 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { | 110 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { |
110 public: | 111 public: |
111 static scoped_ptr<LayerTreeHostImplForTesting> Create( | 112 static scoped_ptr<LayerTreeHostImplForTesting> Create( |
112 TestHooks* test_hooks, | 113 TestHooks* test_hooks, |
113 const LayerTreeSettings& settings, | 114 const LayerTreeSettings& settings, |
114 LayerTreeHostImplClient* host_impl_client, | 115 LayerTreeHostImplClient* host_impl_client, |
115 Proxy* proxy, | 116 Proxy* proxy, |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 TestHooks* test_hooks_; | 329 TestHooks* test_hooks_; |
329 }; | 330 }; |
330 | 331 |
331 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. | 332 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. |
332 class LayerTreeHostForTesting : public LayerTreeHost { | 333 class LayerTreeHostForTesting : public LayerTreeHost { |
333 public: | 334 public: |
334 static scoped_ptr<LayerTreeHostForTesting> Create( | 335 static scoped_ptr<LayerTreeHostForTesting> Create( |
335 TestHooks* test_hooks, | 336 TestHooks* test_hooks, |
336 LayerTreeHostClientForTesting* client, | 337 LayerTreeHostClientForTesting* client, |
337 const LayerTreeSettings& settings, | 338 const LayerTreeSettings& settings, |
| 339 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
338 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 340 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
339 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( | 341 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( |
340 new LayerTreeHostForTesting(test_hooks, client, settings)); | 342 new LayerTreeHostForTesting(test_hooks, client, settings)); |
341 if (impl_task_runner.get()) { | 343 if (impl_task_runner.get()) { |
342 layer_tree_host->InitializeForTesting( | 344 layer_tree_host->InitializeForTesting( |
343 ThreadProxyForTest::Create(test_hooks, | 345 ThreadProxyForTest::Create(test_hooks, |
344 layer_tree_host.get(), | 346 layer_tree_host.get(), |
| 347 main_task_runner, |
345 impl_task_runner)); | 348 impl_task_runner)); |
346 } else { | 349 } else { |
347 layer_tree_host->InitializeForTesting( | 350 layer_tree_host->InitializeForTesting(SingleThreadProxy::Create( |
348 SingleThreadProxy::Create(layer_tree_host.get(), client)); | 351 layer_tree_host.get(), client, main_task_runner)); |
349 } | 352 } |
350 return layer_tree_host.Pass(); | 353 return layer_tree_host.Pass(); |
351 } | 354 } |
352 | 355 |
353 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( | 356 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( |
354 LayerTreeHostImplClient* host_impl_client) OVERRIDE { | 357 LayerTreeHostImplClient* host_impl_client) OVERRIDE { |
355 return LayerTreeHostImplForTesting::Create( | 358 return LayerTreeHostImplForTesting::Create( |
356 test_hooks_, | 359 test_hooks_, |
357 settings(), | 360 settings(), |
358 host_impl_client, | 361 host_impl_client, |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 } | 510 } |
508 | 511 |
509 void LayerTreeTest::DoBeginTest() { | 512 void LayerTreeTest::DoBeginTest() { |
510 client_ = LayerTreeHostClientForTesting::Create(this); | 513 client_ = LayerTreeHostClientForTesting::Create(this); |
511 | 514 |
512 DCHECK(!impl_thread_ || impl_thread_->message_loop_proxy().get()); | 515 DCHECK(!impl_thread_ || impl_thread_->message_loop_proxy().get()); |
513 layer_tree_host_ = LayerTreeHostForTesting::Create( | 516 layer_tree_host_ = LayerTreeHostForTesting::Create( |
514 this, | 517 this, |
515 client_.get(), | 518 client_.get(), |
516 settings_, | 519 settings_, |
| 520 base::MessageLoopProxy::current(), |
517 impl_thread_ ? impl_thread_->message_loop_proxy() : NULL); | 521 impl_thread_ ? impl_thread_->message_loop_proxy() : NULL); |
518 ASSERT_TRUE(layer_tree_host_); | 522 ASSERT_TRUE(layer_tree_host_); |
519 | 523 |
520 started_ = true; | 524 started_ = true; |
521 beginning_ = true; | 525 beginning_ = true; |
522 SetupTree(); | 526 SetupTree(); |
523 WillBeginTest(); | 527 WillBeginTest(); |
524 BeginTest(); | 528 BeginTest(); |
525 beginning_ = false; | 529 beginning_ = false; |
526 if (end_when_begin_returns_) | 530 if (end_when_begin_returns_) |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 return -1; | 740 return -1; |
737 } | 741 } |
738 | 742 |
739 void LayerTreeTest::DestroyLayerTreeHost() { | 743 void LayerTreeTest::DestroyLayerTreeHost() { |
740 if (layer_tree_host_ && layer_tree_host_->root_layer()) | 744 if (layer_tree_host_ && layer_tree_host_->root_layer()) |
741 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); | 745 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); |
742 layer_tree_host_.reset(); | 746 layer_tree_host_.reset(); |
743 } | 747 } |
744 | 748 |
745 } // namespace cc | 749 } // namespace cc |
OLD | NEW |