OLD | NEW |
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/layer.h" | 5 #include "cc/layer.h" |
6 | 6 |
7 #include "cc/keyframed_animation_curve.h" | 7 #include "cc/keyframed_animation_curve.h" |
8 #include "cc/layer_impl.h" | 8 #include "cc/layer_impl.h" |
9 #include "cc/layer_painter.h" | 9 #include "cc/layer_painter.h" |
10 #include "cc/layer_tree_host.h" | 10 #include "cc/layer_tree_host.h" |
11 #include "cc/math_util.h" | 11 #include "cc/math_util.h" |
12 #include "cc/single_thread_proxy.h" | 12 #include "cc/single_thread_proxy.h" |
| 13 #include "cc/test/fake_impl_proxy.h" |
| 14 #include "cc/test/fake_layer_tree_host_client.h" |
| 15 #include "cc/test/fake_layer_tree_host_impl.h" |
| 16 #include "cc/test/geometry_test_utils.h" |
13 #include "cc/thread.h" | 17 #include "cc/thread.h" |
14 #include "cc/test/fake_layer_tree_host_client.h" | |
15 #include "cc/test/geometry_test_utils.h" | |
16 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "ui/gfx/transform.h" | 20 #include "ui/gfx/transform.h" |
19 | 21 |
20 using ::testing::AnyNumber; | 22 using ::testing::AnyNumber; |
21 using ::testing::AtLeast; | 23 using ::testing::AtLeast; |
22 using ::testing::Mock; | 24 using ::testing::Mock; |
23 using ::testing::StrictMock; | 25 using ::testing::StrictMock; |
24 using ::testing::_; | 26 using ::testing::_; |
25 | 27 |
(...skipping 30 matching lines...) Expand all Loading... |
56 | 58 |
57 class MockLayerPainter : public LayerPainter { | 59 class MockLayerPainter : public LayerPainter { |
58 public: | 60 public: |
59 virtual void paint(SkCanvas*, const gfx::Rect&, gfx::RectF&) OVERRIDE { } | 61 virtual void paint(SkCanvas*, const gfx::Rect&, gfx::RectF&) OVERRIDE { } |
60 }; | 62 }; |
61 | 63 |
62 | 64 |
63 class LayerTest : public testing::Test { | 65 class LayerTest : public testing::Test { |
64 public: | 66 public: |
65 LayerTest() | 67 LayerTest() |
| 68 : m_hostImpl(&m_proxy) |
66 { | 69 { |
67 } | 70 } |
68 | 71 |
69 protected: | 72 protected: |
70 virtual void SetUp() | 73 virtual void SetUp() |
71 { | 74 { |
72 m_layerTreeHost.reset(new StrictMock<MockLayerImplTreeHost>); | 75 m_layerTreeHost.reset(new StrictMock<MockLayerImplTreeHost>); |
73 } | 76 } |
74 | 77 |
75 virtual void TearDown() | 78 virtual void TearDown() |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 m_parent->addChild(m_child3); | 132 m_parent->addChild(m_child3); |
130 m_child1->addChild(m_grandChild1); | 133 m_child1->addChild(m_grandChild1); |
131 m_child1->addChild(m_grandChild2); | 134 m_child1->addChild(m_grandChild2); |
132 m_child2->addChild(m_grandChild3); | 135 m_child2->addChild(m_grandChild3); |
133 | 136 |
134 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); | 137 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |
135 | 138 |
136 verifyTestTreeInitialState(); | 139 verifyTestTreeInitialState(); |
137 } | 140 } |
138 | 141 |
| 142 FakeImplProxy m_proxy; |
| 143 FakeLayerTreeHostImpl m_hostImpl; |
| 144 |
139 scoped_ptr<StrictMock<MockLayerImplTreeHost> > m_layerTreeHost; | 145 scoped_ptr<StrictMock<MockLayerImplTreeHost> > m_layerTreeHost; |
140 scoped_refptr<Layer> m_parent, m_child1, m_child2, m_child3, m_grandChild1,
m_grandChild2, m_grandChild3; | 146 scoped_refptr<Layer> m_parent; |
| 147 scoped_refptr<Layer> m_child1; |
| 148 scoped_refptr<Layer> m_child2; |
| 149 scoped_refptr<Layer> m_child3; |
| 150 scoped_refptr<Layer> m_grandChild1; |
| 151 scoped_refptr<Layer> m_grandChild2; |
| 152 scoped_refptr<Layer> m_grandChild3; |
141 }; | 153 }; |
142 | 154 |
143 TEST_F(LayerTest, basicCreateAndDestroy) | 155 TEST_F(LayerTest, basicCreateAndDestroy) |
144 { | 156 { |
145 scoped_refptr<Layer> testLayer = Layer::create(); | 157 scoped_refptr<Layer> testLayer = Layer::create(); |
146 ASSERT_TRUE(testLayer); | 158 ASSERT_TRUE(testLayer); |
147 | 159 |
148 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(0); | 160 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(0); |
149 testLayer->setLayerTreeHost(m_layerTreeHost.get()); | 161 testLayer->setLayerTreeHost(m_layerTreeHost.get()); |
150 } | 162 } |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 EXPECT_FALSE(testLayer->needsDisplay()); | 552 EXPECT_FALSE(testLayer->needsDisplay()); |
541 | 553 |
542 // Test properties that should call setNeedsDisplay and setNeedsCommit | 554 // Test properties that should call setNeedsDisplay and setNeedsCommit |
543 EXPECT_SET_NEEDS_COMMIT(1, testLayer->setBounds(gfx::Size(5, 10))); | 555 EXPECT_SET_NEEDS_COMMIT(1, testLayer->setBounds(gfx::Size(5, 10))); |
544 EXPECT_TRUE(testLayer->needsDisplay()); | 556 EXPECT_TRUE(testLayer->needsDisplay()); |
545 } | 557 } |
546 | 558 |
547 TEST_F(LayerTest, verifyPushPropertiesAccumulatesUpdateRect) | 559 TEST_F(LayerTest, verifyPushPropertiesAccumulatesUpdateRect) |
548 { | 560 { |
549 scoped_refptr<Layer> testLayer = Layer::create(); | 561 scoped_refptr<Layer> testLayer = Layer::create(); |
550 scoped_ptr<LayerImpl> implLayer = LayerImpl::create(1); | 562 scoped_ptr<LayerImpl> implLayer = LayerImpl::create(&m_hostImpl, 1); |
551 | 563 |
552 testLayer->setNeedsDisplayRect(gfx::RectF(gfx::PointF(), gfx::SizeF(5, 5))); | 564 testLayer->setNeedsDisplayRect(gfx::RectF(gfx::PointF(), gfx::SizeF(5, 5))); |
553 testLayer->pushPropertiesTo(implLayer.get()); | 565 testLayer->pushPropertiesTo(implLayer.get()); |
554 EXPECT_FLOAT_RECT_EQ(gfx::RectF(gfx::PointF(), gfx::SizeF(5, 5)), implLayer-
>updateRect()); | 566 EXPECT_FLOAT_RECT_EQ(gfx::RectF(gfx::PointF(), gfx::SizeF(5, 5)), implLayer-
>updateRect()); |
555 | 567 |
556 // The LayerImpl's updateRect should be accumulated here, since we did not d
o anything to clear it. | 568 // The LayerImpl's updateRect should be accumulated here, since we did not d
o anything to clear it. |
557 testLayer->setNeedsDisplayRect(gfx::RectF(gfx::PointF(10, 10), gfx::SizeF(5,
5))); | 569 testLayer->setNeedsDisplayRect(gfx::RectF(gfx::PointF(10, 10), gfx::SizeF(5,
5))); |
558 testLayer->pushPropertiesTo(implLayer.get()); | 570 testLayer->pushPropertiesTo(implLayer.get()); |
559 EXPECT_FLOAT_RECT_EQ(gfx::RectF(gfx::PointF(), gfx::SizeF(15, 15)), implLaye
r->updateRect()); | 571 EXPECT_FLOAT_RECT_EQ(gfx::RectF(gfx::PointF(), gfx::SizeF(15, 15)), implLaye
r->updateRect()); |
560 | 572 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 scoped_refptr<MockLayer> layer(new MockLayer); | 824 scoped_refptr<MockLayer> layer(new MockLayer); |
813 EXPECT_FALSE(layer->needsDisplay()); | 825 EXPECT_FALSE(layer->needsDisplay()); |
814 layer->setBounds(gfx::Size(0, 10)); | 826 layer->setBounds(gfx::Size(0, 10)); |
815 EXPECT_FALSE(layer->needsDisplay()); | 827 EXPECT_FALSE(layer->needsDisplay()); |
816 layer->setBounds(gfx::Size(10, 10)); | 828 layer->setBounds(gfx::Size(10, 10)); |
817 EXPECT_TRUE(layer->needsDisplay()); | 829 EXPECT_TRUE(layer->needsDisplay()); |
818 } | 830 } |
819 | 831 |
820 } // namespace | 832 } // namespace |
821 } // namespace cc | 833 } // namespace cc |
OLD | NEW |