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