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 "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "ui/gfx/box_f.h" | 14 #include "ui/gfx/box_f.h" |
14 #include "ui/gfx/test/gfx_util.h" | 15 #include "ui/gfx/test/gfx_util.h" |
15 | 16 |
16 namespace cc { | 17 namespace cc { |
17 namespace { | 18 namespace { |
18 | 19 |
19 float diagonal(float width, float height) { | 20 float diagonal(float width, float height) { |
20 return std::sqrt(width * width + height * height); | 21 return std::sqrt(width * width + height * height); |
21 } | 22 } |
22 | 23 |
23 class LayerUtilsGetAnimationBoundsTest : public testing::Test { | 24 class LayerUtilsGetAnimationBoundsTest : public testing::Test { |
24 public: | 25 public: |
25 LayerUtilsGetAnimationBoundsTest() | 26 LayerUtilsGetAnimationBoundsTest() |
26 : host_impl_(&proxy_), | 27 : host_impl_(&proxy_, &shared_bitmap_manager_), |
27 root_(CreateThreeNodeTree(host_impl_)), | 28 root_(CreateThreeNodeTree(host_impl_)), |
28 parent_(root_->children()[0]), | 29 parent_(root_->children()[0]), |
29 child_(parent_->children()[0]) {} | 30 child_(parent_->children()[0]) {} |
30 | 31 |
31 LayerImpl* root() { return root_.get(); } | 32 LayerImpl* root() { return root_.get(); } |
32 LayerImpl* parent() { return parent_; } | 33 LayerImpl* parent() { return parent_; } |
33 LayerImpl* child() { return child_; } | 34 LayerImpl* child() { return child_; } |
34 | 35 |
35 private: | 36 private: |
36 static scoped_ptr<LayerImpl> CreateThreeNodeTree( | 37 static scoped_ptr<LayerImpl> CreateThreeNodeTree( |
37 LayerTreeHostImpl& host_impl) { | 38 LayerTreeHostImpl& host_impl) { |
38 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); | 39 scoped_ptr<LayerImpl> root = LayerImpl::Create(host_impl.active_tree(), 1); |
39 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 2)); | 40 root->AddChild(LayerImpl::Create(host_impl.active_tree(), 2)); |
40 root->children()[0] | 41 root->children()[0] |
41 ->AddChild(LayerImpl::Create(host_impl.active_tree(), 3)); | 42 ->AddChild(LayerImpl::Create(host_impl.active_tree(), 3)); |
42 return root.Pass(); | 43 return root.Pass(); |
43 } | 44 } |
44 | 45 |
45 FakeImplProxy proxy_; | 46 FakeImplProxy proxy_; |
| 47 TestSharedBitmapManager shared_bitmap_manager_; |
46 FakeLayerTreeHostImpl host_impl_; | 48 FakeLayerTreeHostImpl host_impl_; |
47 scoped_ptr<LayerImpl> root_; | 49 scoped_ptr<LayerImpl> root_; |
48 LayerImpl* parent_; | 50 LayerImpl* parent_; |
49 LayerImpl* child_; | 51 LayerImpl* child_; |
50 }; | 52 }; |
51 | 53 |
52 TEST_F(LayerUtilsGetAnimationBoundsTest, ScaleRoot) { | 54 TEST_F(LayerUtilsGetAnimationBoundsTest, ScaleRoot) { |
53 double duration = 1.0; | 55 double duration = 1.0; |
54 | 56 |
55 TransformOperations start; | 57 TransformOperations start; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 child()->SetPosition(gfx::PointF(150.f, 50.f)); | 251 child()->SetPosition(gfx::PointF(150.f, 50.f)); |
250 child()->SetBounds(bounds); | 252 child()->SetBounds(bounds); |
251 | 253 |
252 gfx::BoxF box; | 254 gfx::BoxF box; |
253 bool success = LayerUtils::GetAnimationBounds(*child(), &box); | 255 bool success = LayerUtils::GetAnimationBounds(*child(), &box); |
254 EXPECT_FALSE(success); | 256 EXPECT_FALSE(success); |
255 } | 257 } |
256 | 258 |
257 } // namespace | 259 } // namespace |
258 } // namespace cc | 260 } // namespace cc |
OLD | NEW |