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

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

Issue 242783003: cc: Add testing stubs for proxy test (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Makes proxy test more general for single & threaded proxy Created 6 years, 7 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 | Annotate | Revision Log
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 "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/test_shared_bitmap_manager.h"
22 #include "cc/test/tiled_layer_test_common.h" 22 #include "cc/test/tiled_layer_test_common.h"
23 #include "cc/trees/layer_tree_host_client.h" 23 #include "cc/trees/layer_tree_host_client.h"
24 #include "cc/trees/layer_tree_host_impl.h" 24 #include "cc/trees/layer_tree_host_impl.h"
25 #include "cc/trees/layer_tree_host_single_thread_client.h" 25 #include "cc/trees/layer_tree_host_single_thread_client.h"
26 #include "cc/trees/layer_tree_impl.h" 26 #include "cc/trees/layer_tree_impl.h"
27 #include "cc/trees/single_thread_proxy.h" 27 #include "cc/trees/single_thread_proxy.h"
28 #include "cc/trees/thread_proxy.h"
28 #include "testing/gmock/include/gmock/gmock.h" 29 #include "testing/gmock/include/gmock/gmock.h"
29 #include "ui/gfx/frame_time.h" 30 #include "ui/gfx/frame_time.h"
30 #include "ui/gfx/size_conversions.h" 31 #include "ui/gfx/size_conversions.h"
31 32
32 namespace cc { 33 namespace cc {
33 34
34 TestHooks::TestHooks() {} 35 TestHooks::TestHooks() {}
35 36
36 TestHooks::~TestHooks() {} 37 TestHooks::~TestHooks() {}
37 38
39 DrawResult TestHooks::ScheduledActionDrawAndSwapIfPossible() {
40 return INVALID_RESULT;
41 }
42
43 DrawResult TestHooks::ScheduledActionDrawAndSwapForced() {
44 return INVALID_RESULT;
45 }
46
47 DrawResult TestHooks::ScheduledActionDrawAndReadback() {
48 return INVALID_RESULT;
49 }
50
51 base::TimeDelta TestHooks::DrawDurationEstimate() {
52 return base::TimeDelta();
53 }
54
55 base::TimeDelta TestHooks::BeginMainFrameToCommitDurationEstimate() {
56 return base::TimeDelta();
57 }
58
59 base::TimeDelta TestHooks::CommitToActivateDurationEstimate() {
60 return base::TimeDelta();
61 }
62
38 DrawResult TestHooks::PrepareToDrawOnThread( 63 DrawResult TestHooks::PrepareToDrawOnThread(
39 LayerTreeHostImpl* host_impl, 64 LayerTreeHostImpl* host_impl,
40 LayerTreeHostImpl::FrameData* frame_data, 65 LayerTreeHostImpl::FrameData* frame_data,
41 DrawResult draw_result) { 66 DrawResult draw_result) {
42 return draw_result; 67 return draw_result;
43 } 68 }
44 69
45 base::TimeDelta TestHooks::LowFrequencyAnimationInterval() const { 70 base::TimeDelta TestHooks::LowFrequencyAnimationInterval() const {
46 return base::TimeDelta::FromMilliseconds(16); 71 return base::TimeDelta::FromMilliseconds(16);
47 } 72 }
48 73
74 // Adapts ThreadProxy for test. Injects test hooks for testing.
75 class ThreadProxyForTest : public ThreadProxy {
76 public:
77 static scoped_ptr<Proxy> Create(
78 TestHooks* test_hooks,
79 LayerTreeHost* host,
80 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
81 return make_scoped_ptr(
82 new ThreadProxyForTest(test_hooks,
83 host,
84 impl_task_runner)).PassAs<Proxy>();
85 }
86
87 virtual ~ThreadProxyForTest() {}
88
89 void test() {
90 test_hooks_->Layout();
91 }
92
93 private:
94 TestHooks* test_hooks_;
95
96 virtual void ScheduledActionBeginOutputSurfaceCreation() OVERRIDE {
97 ThreadProxy::ScheduledActionBeginOutputSurfaceCreation();
98 test_hooks_->ScheduledActionBeginOutputSurfaceCreation();
99 }
100
101 ThreadProxyForTest(
102 TestHooks* test_hooks,
103 LayerTreeHost* host,
104 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner)
105 : ThreadProxy(host, impl_task_runner),
106 test_hooks_(test_hooks) {
107 }
108 };
109
49 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. 110 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks.
50 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { 111 class LayerTreeHostImplForTesting : public LayerTreeHostImpl {
51 public: 112 public:
52 static scoped_ptr<LayerTreeHostImplForTesting> Create( 113 static scoped_ptr<LayerTreeHostImplForTesting> Create(
53 TestHooks* test_hooks, 114 TestHooks* test_hooks,
54 const LayerTreeSettings& settings, 115 const LayerTreeSettings& settings,
55 LayerTreeHostImplClient* host_impl_client, 116 LayerTreeHostImplClient* host_impl_client,
56 Proxy* proxy, 117 Proxy* proxy,
57 SharedBitmapManager* manager, 118 SharedBitmapManager* manager,
58 RenderingStatsInstrumentation* stats_instrumentation) { 119 RenderingStatsInstrumentation* stats_instrumentation) {
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting. 339 // Adapts LayerTreeHost for test. Injects LayerTreeHostImplForTesting.
279 class LayerTreeHostForTesting : public LayerTreeHost { 340 class LayerTreeHostForTesting : public LayerTreeHost {
280 public: 341 public:
281 static scoped_ptr<LayerTreeHostForTesting> Create( 342 static scoped_ptr<LayerTreeHostForTesting> Create(
282 TestHooks* test_hooks, 343 TestHooks* test_hooks,
283 LayerTreeHostClientForTesting* client, 344 LayerTreeHostClientForTesting* client,
284 const LayerTreeSettings& settings, 345 const LayerTreeSettings& settings,
285 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { 346 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
286 scoped_ptr<LayerTreeHostForTesting> layer_tree_host( 347 scoped_ptr<LayerTreeHostForTesting> layer_tree_host(
287 new LayerTreeHostForTesting(test_hooks, client, settings)); 348 new LayerTreeHostForTesting(test_hooks, client, settings));
288 if (impl_task_runner.get()) 349 if (impl_task_runner.get()) {
289 layer_tree_host->InitializeThreaded(impl_task_runner); 350 layer_tree_host->InitializeForTesting(
290 else 351 ThreadProxyForTest::Create(test_hooks,
291 layer_tree_host->InitializeSingleThreaded(client); 352 layer_tree_host.get(),
353 impl_task_runner));
354 } else {
355 layer_tree_host->InitializeForTesting(
356 SingleThreadProxy::Create(layer_tree_host.get(), client));
357 }
292 return layer_tree_host.Pass(); 358 return layer_tree_host.Pass();
293 } 359 }
294 360
295 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( 361 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl(
296 LayerTreeHostImplClient* host_impl_client) OVERRIDE { 362 LayerTreeHostImplClient* host_impl_client) OVERRIDE {
297 return LayerTreeHostImplForTesting::Create( 363 return LayerTreeHostImplForTesting::Create(
298 test_hooks_, 364 test_hooks_,
299 settings(), 365 settings(),
300 host_impl_client, 366 host_impl_client,
301 proxy(), 367 proxy(),
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 return -1; 745 return -1;
680 } 746 }
681 747
682 void LayerTreeTest::DestroyLayerTreeHost() { 748 void LayerTreeTest::DestroyLayerTreeHost() {
683 if (layer_tree_host_ && layer_tree_host_->root_layer()) 749 if (layer_tree_host_ && layer_tree_host_->root_layer())
684 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); 750 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL);
685 layer_tree_host_.reset(); 751 layer_tree_host_.reset();
686 } 752 }
687 753
688 } // namespace cc 754 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698