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