OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/layers/layer_utils.h" | 5 #include "cc/layers/layer_utils.h" |
6 | 6 |
7 #include "cc/animation/transform_operations.h" | 7 #include "cc/animation/transform_operations.h" |
8 #include "cc/layers/layer_impl.h" | 8 #include "cc/layers/layer_impl.h" |
9 #include "cc/test/animation_test_common.h" | 9 #include "cc/test/animation_test_common.h" |
10 #include "cc/test/fake_impl_proxy.h" | 10 #include "cc/test/fake_impl_proxy.h" |
11 #include "cc/test/fake_layer_tree_host_impl.h" | 11 #include "cc/test/fake_layer_tree_host_impl.h" |
12 #include "cc/test/test_shared_bitmap_manager.h" | 12 #include "cc/test/test_shared_bitmap_manager.h" |
| 13 #include "cc/test/test_task_graph_runner.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "ui/gfx/geometry/box_f.h" | 15 #include "ui/gfx/geometry/box_f.h" |
15 #include "ui/gfx/test/gfx_util.h" | 16 #include "ui/gfx/test/gfx_util.h" |
16 | 17 |
17 namespace cc { | 18 namespace cc { |
18 namespace { | 19 namespace { |
19 | 20 |
20 float diagonal(float width, float height) { | 21 float diagonal(float width, float height) { |
21 return std::sqrt(width * width + height * height); | 22 return std::sqrt(width * width + height * height); |
22 } | 23 } |
23 | 24 |
24 class LayerUtilsGetAnimationBoundsTest : public testing::Test { | 25 class LayerUtilsGetAnimationBoundsTest : public testing::Test { |
25 public: | 26 public: |
26 LayerUtilsGetAnimationBoundsTest() | 27 LayerUtilsGetAnimationBoundsTest() |
27 : host_impl_(&proxy_, &shared_bitmap_manager_), | 28 : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_), |
28 root_(CreateThreeNodeTree(&host_impl_)), | 29 root_(CreateThreeNodeTree(&host_impl_)), |
29 parent_(root_->children()[0]), | 30 parent_(root_->children()[0]), |
30 child_(parent_->children()[0]) {} | 31 child_(parent_->children()[0]) {} |
31 | 32 |
32 LayerImpl* root() { return root_.get(); } | 33 LayerImpl* root() { return root_.get(); } |
33 LayerImpl* parent() { return parent_; } | 34 LayerImpl* parent() { return parent_; } |
34 LayerImpl* child() { return child_; } | 35 LayerImpl* child() { return child_; } |
35 | 36 |
36 private: | 37 private: |
37 static scoped_ptr<LayerImpl> CreateThreeNodeTree( | 38 static scoped_ptr<LayerImpl> CreateThreeNodeTree( |
38 LayerTreeHostImpl* host_impl) { | 39 LayerTreeHostImpl* host_impl) { |
39 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl->active_tree(), 1); | 40 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl->active_tree(), 1); |
40 root->AddChild(LayerImpl::Create(host_impl->active_tree(), 2)); | 41 root->AddChild(LayerImpl::Create(host_impl->active_tree(), 2)); |
41 root->children()[0]->AddChild( | 42 root->children()[0]->AddChild( |
42 LayerImpl::Create(host_impl->active_tree(), 3)); | 43 LayerImpl::Create(host_impl->active_tree(), 3)); |
43 return root.Pass(); | 44 return root.Pass(); |
44 } | 45 } |
45 | 46 |
46 FakeImplProxy proxy_; | 47 FakeImplProxy proxy_; |
47 TestSharedBitmapManager shared_bitmap_manager_; | 48 TestSharedBitmapManager shared_bitmap_manager_; |
| 49 TestTaskGraphRunner task_graph_runner_; |
48 FakeLayerTreeHostImpl host_impl_; | 50 FakeLayerTreeHostImpl host_impl_; |
49 scoped_ptr<LayerImpl> root_; | 51 scoped_ptr<LayerImpl> root_; |
50 LayerImpl* parent_; | 52 LayerImpl* parent_; |
51 LayerImpl* child_; | 53 LayerImpl* child_; |
52 }; | 54 }; |
53 | 55 |
54 TEST_F(LayerUtilsGetAnimationBoundsTest, ScaleRoot) { | 56 TEST_F(LayerUtilsGetAnimationBoundsTest, ScaleRoot) { |
55 double duration = 1.0; | 57 double duration = 1.0; |
56 | 58 |
57 TransformOperations start; | 59 TransformOperations start; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 child()->SetPosition(gfx::PointF(150.f, 50.f)); | 260 child()->SetPosition(gfx::PointF(150.f, 50.f)); |
259 child()->SetBounds(bounds); | 261 child()->SetBounds(bounds); |
260 | 262 |
261 gfx::BoxF box; | 263 gfx::BoxF box; |
262 bool success = LayerUtils::GetAnimationBounds(*child(), &box); | 264 bool success = LayerUtils::GetAnimationBounds(*child(), &box); |
263 EXPECT_FALSE(success); | 265 EXPECT_FALSE(success); |
264 } | 266 } |
265 | 267 |
266 } // namespace | 268 } // namespace |
267 } // namespace cc | 269 } // namespace cc |
OLD | NEW |