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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/layer.h" | 7 #include "cc/layer.h" |
8 | 8 |
9 #include "CCKeyframedAnimationCurve.h" | 9 #include "CCKeyframedAnimationCurve.h" |
10 #include "CCLayerImpl.h" | 10 #include "CCLayerImpl.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 using ::testing::AnyNumber; | 27 using ::testing::AnyNumber; |
28 | 28 |
29 #define EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(numTimesExpectedSetNeedsCom
mit, codeToTest) do { \ | 29 #define EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(numTimesExpectedSetNeedsCom
mit, codeToTest) do { \ |
30 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times((numTimesExpectedS
etNeedsCommit)); \ | 30 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times((numTimesExpectedS
etNeedsCommit)); \ |
31 codeToTest;
\ | 31 codeToTest;
\ |
32 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
\ | 32 Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
\ |
33 } while (0) | 33 } while (0) |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 class MockCCLayerTreeHost : public CCLayerTreeHost { | 37 class MockLayerImplTreeHost : public LayerTreeHost { |
38 public: | 38 public: |
39 MockCCLayerTreeHost() | 39 MockLayerImplTreeHost() |
40 : CCLayerTreeHost(&m_fakeClient, CCLayerTreeSettings()) | 40 : LayerTreeHost(&m_fakeClient, LayerTreeSettings()) |
41 { | 41 { |
42 initialize(); | 42 initialize(); |
43 } | 43 } |
44 | 44 |
45 MOCK_METHOD0(setNeedsCommit, void()); | 45 MOCK_METHOD0(setNeedsCommit, void()); |
46 | 46 |
47 private: | 47 private: |
48 FakeCCLayerTreeHostClient m_fakeClient; | 48 FakeLayerImplTreeHostClient m_fakeClient; |
49 }; | 49 }; |
50 | 50 |
51 class MockLayerPainterChromium : public LayerPainterChromium { | 51 class MockLayerPainter : public LayerPainter { |
52 public: | 52 public: |
53 virtual void paint(SkCanvas*, const IntRect&, FloatRect&) OVERRIDE { } | 53 virtual void paint(SkCanvas*, const IntRect&, FloatRect&) OVERRIDE { } |
54 }; | 54 }; |
55 | 55 |
56 | 56 |
57 class LayerChromiumTest : public testing::Test { | 57 class LayerTest : public testing::Test { |
58 public: | 58 public: |
59 LayerChromiumTest() | 59 LayerTest() |
60 : m_compositorInitializer(0) | 60 : m_compositorInitializer(0) |
61 { | 61 { |
62 } | 62 } |
63 | 63 |
64 protected: | 64 protected: |
65 virtual void SetUp() | 65 virtual void SetUp() |
66 { | 66 { |
67 m_layerTreeHost = scoped_ptr<MockCCLayerTreeHost>(new MockCCLayerTreeHos
t); | 67 m_layerTreeHost = scoped_ptr<MockLayerImplTreeHost>(new MockLayerImplTre
eHost); |
68 } | 68 } |
69 | 69 |
70 virtual void TearDown() | 70 virtual void TearDown() |
71 { | 71 { |
72 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); | 72 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |
73 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); | 73 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); |
74 m_parent = NULL; | 74 m_parent = NULL; |
75 m_child1 = NULL; | 75 m_child1 = NULL; |
76 m_child2 = NULL; | 76 m_child2 = NULL; |
77 m_child3 = NULL; | 77 m_child3 = NULL; |
(...skipping 23 matching lines...) Expand all Loading... |
101 | 101 |
102 ASSERT_EQ(static_cast<size_t>(1), m_child2->children().size()); | 102 ASSERT_EQ(static_cast<size_t>(1), m_child2->children().size()); |
103 EXPECT_EQ(m_grandChild3, m_child2->children()[0]); | 103 EXPECT_EQ(m_grandChild3, m_child2->children()[0]); |
104 EXPECT_EQ(m_child2.get(), m_grandChild3->parent()); | 104 EXPECT_EQ(m_child2.get(), m_grandChild3->parent()); |
105 | 105 |
106 ASSERT_EQ(static_cast<size_t>(0), m_child3->children().size()); | 106 ASSERT_EQ(static_cast<size_t>(0), m_child3->children().size()); |
107 } | 107 } |
108 | 108 |
109 void createSimpleTestTree() | 109 void createSimpleTestTree() |
110 { | 110 { |
111 m_parent = LayerChromium::create(); | 111 m_parent = Layer::create(); |
112 m_child1 = LayerChromium::create(); | 112 m_child1 = Layer::create(); |
113 m_child2 = LayerChromium::create(); | 113 m_child2 = Layer::create(); |
114 m_child3 = LayerChromium::create(); | 114 m_child3 = Layer::create(); |
115 m_grandChild1 = LayerChromium::create(); | 115 m_grandChild1 = Layer::create(); |
116 m_grandChild2 = LayerChromium::create(); | 116 m_grandChild2 = Layer::create(); |
117 m_grandChild3 = LayerChromium::create(); | 117 m_grandChild3 = Layer::create(); |
118 | 118 |
119 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); | 119 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AnyNumber()); |
120 m_layerTreeHost->setRootLayer(m_parent); | 120 m_layerTreeHost->setRootLayer(m_parent); |
121 | 121 |
122 m_parent->addChild(m_child1); | 122 m_parent->addChild(m_child1); |
123 m_parent->addChild(m_child2); | 123 m_parent->addChild(m_child2); |
124 m_parent->addChild(m_child3); | 124 m_parent->addChild(m_child3); |
125 m_child1->addChild(m_grandChild1); | 125 m_child1->addChild(m_grandChild1); |
126 m_child1->addChild(m_grandChild2); | 126 m_child1->addChild(m_grandChild2); |
127 m_child2->addChild(m_grandChild3); | 127 m_child2->addChild(m_grandChild3); |
128 | 128 |
129 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); | 129 Mock::VerifyAndClearExpectations(m_layerTreeHost.get()); |
130 | 130 |
131 verifyTestTreeInitialState(); | 131 verifyTestTreeInitialState(); |
132 } | 132 } |
133 | 133 |
134 scoped_ptr<MockCCLayerTreeHost> m_layerTreeHost; | 134 scoped_ptr<MockLayerImplTreeHost> m_layerTreeHost; |
135 scoped_refptr<LayerChromium> m_parent, m_child1, m_child2, m_child3, m_grand
Child1, m_grandChild2, m_grandChild3; | 135 scoped_refptr<Layer> m_parent, m_child1, m_child2, m_child3, m_grandChild1,
m_grandChild2, m_grandChild3; |
136 WebCompositorInitializer m_compositorInitializer; | 136 WebCompositorInitializer m_compositorInitializer; |
137 }; | 137 }; |
138 | 138 |
139 TEST_F(LayerChromiumTest, basicCreateAndDestroy) | 139 TEST_F(LayerTest, basicCreateAndDestroy) |
140 { | 140 { |
141 scoped_refptr<LayerChromium> testLayer = LayerChromium::create(); | 141 scoped_refptr<Layer> testLayer = Layer::create(); |
142 ASSERT_TRUE(testLayer); | 142 ASSERT_TRUE(testLayer); |
143 | 143 |
144 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(0); | 144 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(0); |
145 testLayer->setLayerTreeHost(m_layerTreeHost.get()); | 145 testLayer->setLayerTreeHost(m_layerTreeHost.get()); |
146 } | 146 } |
147 | 147 |
148 TEST_F(LayerChromiumTest, addAndRemoveChild) | 148 TEST_F(LayerTest, addAndRemoveChild) |
149 { | 149 { |
150 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 150 scoped_refptr<Layer> parent = Layer::create(); |
151 scoped_refptr<LayerChromium> child = LayerChromium::create(); | 151 scoped_refptr<Layer> child = Layer::create(); |
152 | 152 |
153 // Upon creation, layers should not have children or parent. | 153 // Upon creation, layers should not have children or parent. |
154 ASSERT_EQ(static_cast<size_t>(0), parent->children().size()); | 154 ASSERT_EQ(static_cast<size_t>(0), parent->children().size()); |
155 EXPECT_FALSE(child->parent()); | 155 EXPECT_FALSE(child->parent()); |
156 | 156 |
157 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, m_layerTreeHost->setRootLaye
r(parent)); | 157 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, m_layerTreeHost->setRootLaye
r(parent)); |
158 | 158 |
159 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->addChild(child)); | 159 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->addChild(child)); |
160 | 160 |
161 ASSERT_EQ(static_cast<size_t>(1), parent->children().size()); | 161 ASSERT_EQ(static_cast<size_t>(1), parent->children().size()); |
162 EXPECT_EQ(child.get(), parent->children()[0]); | 162 EXPECT_EQ(child.get(), parent->children()[0]); |
163 EXPECT_EQ(parent.get(), child->parent()); | 163 EXPECT_EQ(parent.get(), child->parent()); |
164 EXPECT_EQ(parent.get(), child->rootLayer()); | 164 EXPECT_EQ(parent.get(), child->rootLayer()); |
165 | 165 |
166 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), child->removeFromPa
rent()); | 166 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), child->removeFromPa
rent()); |
167 } | 167 } |
168 | 168 |
169 TEST_F(LayerChromiumTest, insertChild) | 169 TEST_F(LayerTest, insertChild) |
170 { | 170 { |
171 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 171 scoped_refptr<Layer> parent = Layer::create(); |
172 scoped_refptr<LayerChromium> child1 = LayerChromium::create(); | 172 scoped_refptr<Layer> child1 = Layer::create(); |
173 scoped_refptr<LayerChromium> child2 = LayerChromium::create(); | 173 scoped_refptr<Layer> child2 = Layer::create(); |
174 scoped_refptr<LayerChromium> child3 = LayerChromium::create(); | 174 scoped_refptr<Layer> child3 = Layer::create(); |
175 scoped_refptr<LayerChromium> child4 = LayerChromium::create(); | 175 scoped_refptr<Layer> child4 = Layer::create(); |
176 | 176 |
177 parent->setLayerTreeHost(m_layerTreeHost.get()); | 177 parent->setLayerTreeHost(m_layerTreeHost.get()); |
178 | 178 |
179 ASSERT_EQ(static_cast<size_t>(0), parent->children().size()); | 179 ASSERT_EQ(static_cast<size_t>(0), parent->children().size()); |
180 | 180 |
181 // Case 1: inserting to empty list. | 181 // Case 1: inserting to empty list. |
182 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child3,
0)); | 182 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child3,
0)); |
183 ASSERT_EQ(static_cast<size_t>(1), parent->children().size()); | 183 ASSERT_EQ(static_cast<size_t>(1), parent->children().size()); |
184 EXPECT_EQ(child3, parent->children()[0]); | 184 EXPECT_EQ(child3, parent->children()[0]); |
185 EXPECT_EQ(parent.get(), child3->parent()); | 185 EXPECT_EQ(parent.get(), child3->parent()); |
(...skipping 19 matching lines...) Expand all Loading... |
205 ASSERT_EQ(static_cast<size_t>(4), parent->children().size()); | 205 ASSERT_EQ(static_cast<size_t>(4), parent->children().size()); |
206 EXPECT_EQ(child1, parent->children()[0]); | 206 EXPECT_EQ(child1, parent->children()[0]); |
207 EXPECT_EQ(child2, parent->children()[1]); | 207 EXPECT_EQ(child2, parent->children()[1]); |
208 EXPECT_EQ(child3, parent->children()[2]); | 208 EXPECT_EQ(child3, parent->children()[2]); |
209 EXPECT_EQ(child4, parent->children()[3]); | 209 EXPECT_EQ(child4, parent->children()[3]); |
210 EXPECT_EQ(parent.get(), child4->parent()); | 210 EXPECT_EQ(parent.get(), child4->parent()); |
211 | 211 |
212 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); | 212 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); |
213 } | 213 } |
214 | 214 |
215 TEST_F(LayerChromiumTest, insertChildPastEndOfList) | 215 TEST_F(LayerTest, insertChildPastEndOfList) |
216 { | 216 { |
217 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 217 scoped_refptr<Layer> parent = Layer::create(); |
218 scoped_refptr<LayerChromium> child1 = LayerChromium::create(); | 218 scoped_refptr<Layer> child1 = Layer::create(); |
219 scoped_refptr<LayerChromium> child2 = LayerChromium::create(); | 219 scoped_refptr<Layer> child2 = Layer::create(); |
220 | 220 |
221 ASSERT_EQ(static_cast<size_t>(0), parent->children().size()); | 221 ASSERT_EQ(static_cast<size_t>(0), parent->children().size()); |
222 | 222 |
223 // insert to an out-of-bounds index | 223 // insert to an out-of-bounds index |
224 parent->insertChild(child1, 53); | 224 parent->insertChild(child1, 53); |
225 | 225 |
226 ASSERT_EQ(static_cast<size_t>(1), parent->children().size()); | 226 ASSERT_EQ(static_cast<size_t>(1), parent->children().size()); |
227 EXPECT_EQ(child1, parent->children()[0]); | 227 EXPECT_EQ(child1, parent->children()[0]); |
228 | 228 |
229 // insert another child to out-of-bounds, when list is not already empty. | 229 // insert another child to out-of-bounds, when list is not already empty. |
230 parent->insertChild(child2, 2459); | 230 parent->insertChild(child2, 2459); |
231 | 231 |
232 ASSERT_EQ(static_cast<size_t>(2), parent->children().size()); | 232 ASSERT_EQ(static_cast<size_t>(2), parent->children().size()); |
233 EXPECT_EQ(child1, parent->children()[0]); | 233 EXPECT_EQ(child1, parent->children()[0]); |
234 EXPECT_EQ(child2, parent->children()[1]); | 234 EXPECT_EQ(child2, parent->children()[1]); |
235 } | 235 } |
236 | 236 |
237 TEST_F(LayerChromiumTest, insertSameChildTwice) | 237 TEST_F(LayerTest, insertSameChildTwice) |
238 { | 238 { |
239 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 239 scoped_refptr<Layer> parent = Layer::create(); |
240 scoped_refptr<LayerChromium> child1 = LayerChromium::create(); | 240 scoped_refptr<Layer> child1 = Layer::create(); |
241 scoped_refptr<LayerChromium> child2 = LayerChromium::create(); | 241 scoped_refptr<Layer> child2 = Layer::create(); |
242 | 242 |
243 parent->setLayerTreeHost(m_layerTreeHost.get()); | 243 parent->setLayerTreeHost(m_layerTreeHost.get()); |
244 | 244 |
245 ASSERT_EQ(static_cast<size_t>(0), parent->children().size()); | 245 ASSERT_EQ(static_cast<size_t>(0), parent->children().size()); |
246 | 246 |
247 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child1,
0)); | 247 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child1,
0)); |
248 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child2,
1)); | 248 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, parent->insertChild(child2,
1)); |
249 | 249 |
250 ASSERT_EQ(static_cast<size_t>(2), parent->children().size()); | 250 ASSERT_EQ(static_cast<size_t>(2), parent->children().size()); |
251 EXPECT_EQ(child1, parent->children()[0]); | 251 EXPECT_EQ(child1, parent->children()[0]); |
252 EXPECT_EQ(child2, parent->children()[1]); | 252 EXPECT_EQ(child2, parent->children()[1]); |
253 | 253 |
254 // Inserting the same child again should cause the child to be removed and r
e-inserted at the new location. | 254 // Inserting the same child again should cause the child to be removed and r
e-inserted at the new location. |
255 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), parent->insertChild
(child1, 1)); | 255 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), parent->insertChild
(child1, 1)); |
256 | 256 |
257 // child1 should now be at the end of the list. | 257 // child1 should now be at the end of the list. |
258 ASSERT_EQ(static_cast<size_t>(2), parent->children().size()); | 258 ASSERT_EQ(static_cast<size_t>(2), parent->children().size()); |
259 EXPECT_EQ(child2, parent->children()[0]); | 259 EXPECT_EQ(child2, parent->children()[0]); |
260 EXPECT_EQ(child1, parent->children()[1]); | 260 EXPECT_EQ(child1, parent->children()[1]); |
261 | 261 |
262 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); | 262 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); |
263 } | 263 } |
264 | 264 |
265 TEST_F(LayerChromiumTest, replaceChildWithNewChild) | 265 TEST_F(LayerTest, replaceChildWithNewChild) |
266 { | 266 { |
267 createSimpleTestTree(); | 267 createSimpleTestTree(); |
268 scoped_refptr<LayerChromium> child4 = LayerChromium::create(); | 268 scoped_refptr<Layer> child4 = Layer::create(); |
269 | 269 |
270 EXPECT_FALSE(child4->parent()); | 270 EXPECT_FALSE(child4->parent()); |
271 | 271 |
272 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), m_parent->replaceCh
ild(m_child2.get(), child4)); | 272 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), m_parent->replaceCh
ild(m_child2.get(), child4)); |
273 | 273 |
274 ASSERT_EQ(static_cast<size_t>(3), m_parent->children().size()); | 274 ASSERT_EQ(static_cast<size_t>(3), m_parent->children().size()); |
275 EXPECT_EQ(m_child1, m_parent->children()[0]); | 275 EXPECT_EQ(m_child1, m_parent->children()[0]); |
276 EXPECT_EQ(child4, m_parent->children()[1]); | 276 EXPECT_EQ(child4, m_parent->children()[1]); |
277 EXPECT_EQ(m_child3, m_parent->children()[2]); | 277 EXPECT_EQ(m_child3, m_parent->children()[2]); |
278 EXPECT_EQ(m_parent.get(), child4->parent()); | 278 EXPECT_EQ(m_parent.get(), child4->parent()); |
279 | 279 |
280 EXPECT_FALSE(m_child2->parent()); | 280 EXPECT_FALSE(m_child2->parent()); |
281 } | 281 } |
282 | 282 |
283 TEST_F(LayerChromiumTest, replaceChildWithNewChildThatHasOtherParent) | 283 TEST_F(LayerTest, replaceChildWithNewChildThatHasOtherParent) |
284 { | 284 { |
285 createSimpleTestTree(); | 285 createSimpleTestTree(); |
286 | 286 |
287 // create another simple tree with testLayer and child4. | 287 // create another simple tree with testLayer and child4. |
288 scoped_refptr<LayerChromium> testLayer = LayerChromium::create(); | 288 scoped_refptr<Layer> testLayer = Layer::create(); |
289 scoped_refptr<LayerChromium> child4 = LayerChromium::create(); | 289 scoped_refptr<Layer> child4 = Layer::create(); |
290 testLayer->addChild(child4); | 290 testLayer->addChild(child4); |
291 ASSERT_EQ(static_cast<size_t>(1), testLayer->children().size()); | 291 ASSERT_EQ(static_cast<size_t>(1), testLayer->children().size()); |
292 EXPECT_EQ(child4, testLayer->children()[0]); | 292 EXPECT_EQ(child4, testLayer->children()[0]); |
293 EXPECT_EQ(testLayer.get(), child4->parent()); | 293 EXPECT_EQ(testLayer.get(), child4->parent()); |
294 | 294 |
295 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), m_parent->replaceCh
ild(m_child2.get(), child4)); | 295 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), m_parent->replaceCh
ild(m_child2.get(), child4)); |
296 | 296 |
297 ASSERT_EQ(static_cast<size_t>(3), m_parent->children().size()); | 297 ASSERT_EQ(static_cast<size_t>(3), m_parent->children().size()); |
298 EXPECT_EQ(m_child1, m_parent->children()[0]); | 298 EXPECT_EQ(m_child1, m_parent->children()[0]); |
299 EXPECT_EQ(child4, m_parent->children()[1]); | 299 EXPECT_EQ(child4, m_parent->children()[1]); |
300 EXPECT_EQ(m_child3, m_parent->children()[2]); | 300 EXPECT_EQ(m_child3, m_parent->children()[2]); |
301 EXPECT_EQ(m_parent.get(), child4->parent()); | 301 EXPECT_EQ(m_parent.get(), child4->parent()); |
302 | 302 |
303 // testLayer should no longer have child4, | 303 // testLayer should no longer have child4, |
304 // and child2 should no longer have a parent. | 304 // and child2 should no longer have a parent. |
305 ASSERT_EQ(static_cast<size_t>(0), testLayer->children().size()); | 305 ASSERT_EQ(static_cast<size_t>(0), testLayer->children().size()); |
306 EXPECT_FALSE(m_child2->parent()); | 306 EXPECT_FALSE(m_child2->parent()); |
307 } | 307 } |
308 | 308 |
309 TEST_F(LayerChromiumTest, replaceChildWithSameChild) | 309 TEST_F(LayerTest, replaceChildWithSameChild) |
310 { | 310 { |
311 createSimpleTestTree(); | 311 createSimpleTestTree(); |
312 | 312 |
313 // setNeedsCommit should not be called because its the same child | 313 // setNeedsCommit should not be called because its the same child |
314 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, m_parent->replaceChild(m_chi
ld2.get(), m_child2)); | 314 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, m_parent->replaceChild(m_chi
ld2.get(), m_child2)); |
315 | 315 |
316 verifyTestTreeInitialState(); | 316 verifyTestTreeInitialState(); |
317 } | 317 } |
318 | 318 |
319 TEST_F(LayerChromiumTest, removeAllChildren) | 319 TEST_F(LayerTest, removeAllChildren) |
320 { | 320 { |
321 createSimpleTestTree(); | 321 createSimpleTestTree(); |
322 | 322 |
323 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(3), m_parent->removeAll
Children()); | 323 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(3), m_parent->removeAll
Children()); |
324 | 324 |
325 ASSERT_EQ(static_cast<size_t>(0), m_parent->children().size()); | 325 ASSERT_EQ(static_cast<size_t>(0), m_parent->children().size()); |
326 EXPECT_FALSE(m_child1->parent()); | 326 EXPECT_FALSE(m_child1->parent()); |
327 EXPECT_FALSE(m_child2->parent()); | 327 EXPECT_FALSE(m_child2->parent()); |
328 EXPECT_FALSE(m_child3->parent()); | 328 EXPECT_FALSE(m_child3->parent()); |
329 } | 329 } |
330 | 330 |
331 TEST_F(LayerChromiumTest, setChildren) | 331 TEST_F(LayerTest, setChildren) |
332 { | 332 { |
333 scoped_refptr<LayerChromium> oldParent = LayerChromium::create(); | 333 scoped_refptr<Layer> oldParent = Layer::create(); |
334 scoped_refptr<LayerChromium> newParent = LayerChromium::create(); | 334 scoped_refptr<Layer> newParent = Layer::create(); |
335 | 335 |
336 scoped_refptr<LayerChromium> child1 = LayerChromium::create(); | 336 scoped_refptr<Layer> child1 = Layer::create(); |
337 scoped_refptr<LayerChromium> child2 = LayerChromium::create(); | 337 scoped_refptr<Layer> child2 = Layer::create(); |
338 | 338 |
339 std::vector<scoped_refptr<LayerChromium> > newChildren; | 339 std::vector<scoped_refptr<Layer> > newChildren; |
340 newChildren.push_back(child1); | 340 newChildren.push_back(child1); |
341 newChildren.push_back(child2); | 341 newChildren.push_back(child2); |
342 | 342 |
343 // Set up and verify initial test conditions: child1 has a parent, child2 ha
s no parent. | 343 // Set up and verify initial test conditions: child1 has a parent, child2 ha
s no parent. |
344 oldParent->addChild(child1); | 344 oldParent->addChild(child1); |
345 ASSERT_EQ(static_cast<size_t>(0), newParent->children().size()); | 345 ASSERT_EQ(static_cast<size_t>(0), newParent->children().size()); |
346 EXPECT_EQ(oldParent.get(), child1->parent()); | 346 EXPECT_EQ(oldParent.get(), child1->parent()); |
347 EXPECT_FALSE(child2->parent()); | 347 EXPECT_FALSE(child2->parent()); |
348 | 348 |
349 newParent->setLayerTreeHost(m_layerTreeHost.get()); | 349 newParent->setLayerTreeHost(m_layerTreeHost.get()); |
350 | 350 |
351 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), newParent->setChild
ren(newChildren)); | 351 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(AtLeast(1), newParent->setChild
ren(newChildren)); |
352 | 352 |
353 ASSERT_EQ(static_cast<size_t>(2), newParent->children().size()); | 353 ASSERT_EQ(static_cast<size_t>(2), newParent->children().size()); |
354 EXPECT_EQ(newParent.get(), child1->parent()); | 354 EXPECT_EQ(newParent.get(), child1->parent()); |
355 EXPECT_EQ(newParent.get(), child2->parent()); | 355 EXPECT_EQ(newParent.get(), child2->parent()); |
356 | 356 |
357 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); | 357 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); |
358 } | 358 } |
359 | 359 |
360 TEST_F(LayerChromiumTest, getRootLayerAfterTreeManipulations) | 360 TEST_F(LayerTest, getRootLayerAfterTreeManipulations) |
361 { | 361 { |
362 createSimpleTestTree(); | 362 createSimpleTestTree(); |
363 | 363 |
364 // For this test we don't care about setNeedsCommit calls. | 364 // For this test we don't care about setNeedsCommit calls. |
365 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); | 365 EXPECT_CALL(*m_layerTreeHost, setNeedsCommit()).Times(AtLeast(1)); |
366 | 366 |
367 scoped_refptr<LayerChromium> child4 = LayerChromium::create(); | 367 scoped_refptr<Layer> child4 = Layer::create(); |
368 | 368 |
369 EXPECT_EQ(m_parent.get(), m_parent->rootLayer()); | 369 EXPECT_EQ(m_parent.get(), m_parent->rootLayer()); |
370 EXPECT_EQ(m_parent.get(), m_child1->rootLayer()); | 370 EXPECT_EQ(m_parent.get(), m_child1->rootLayer()); |
371 EXPECT_EQ(m_parent.get(), m_child2->rootLayer()); | 371 EXPECT_EQ(m_parent.get(), m_child2->rootLayer()); |
372 EXPECT_EQ(m_parent.get(), m_child3->rootLayer()); | 372 EXPECT_EQ(m_parent.get(), m_child3->rootLayer()); |
373 EXPECT_EQ(child4.get(), child4->rootLayer()); | 373 EXPECT_EQ(child4.get(), child4->rootLayer()); |
374 EXPECT_EQ(m_parent.get(), m_grandChild1->rootLayer()); | 374 EXPECT_EQ(m_parent.get(), m_grandChild1->rootLayer()); |
375 EXPECT_EQ(m_parent.get(), m_grandChild2->rootLayer()); | 375 EXPECT_EQ(m_parent.get(), m_grandChild2->rootLayer()); |
376 EXPECT_EQ(m_parent.get(), m_grandChild3->rootLayer()); | 376 EXPECT_EQ(m_parent.get(), m_grandChild3->rootLayer()); |
377 | 377 |
(...skipping 26 matching lines...) Expand all Loading... |
404 EXPECT_EQ(m_parent.get(), m_parent->rootLayer()); | 404 EXPECT_EQ(m_parent.get(), m_parent->rootLayer()); |
405 EXPECT_EQ(m_parent.get(), m_child1->rootLayer()); | 405 EXPECT_EQ(m_parent.get(), m_child1->rootLayer()); |
406 EXPECT_EQ(m_parent.get(), m_child2->rootLayer()); | 406 EXPECT_EQ(m_parent.get(), m_child2->rootLayer()); |
407 EXPECT_EQ(m_parent.get(), m_child3->rootLayer()); | 407 EXPECT_EQ(m_parent.get(), m_child3->rootLayer()); |
408 EXPECT_EQ(m_grandChild3.get(), child4->rootLayer()); | 408 EXPECT_EQ(m_grandChild3.get(), child4->rootLayer()); |
409 EXPECT_EQ(m_parent.get(), m_grandChild1->rootLayer()); | 409 EXPECT_EQ(m_parent.get(), m_grandChild1->rootLayer()); |
410 EXPECT_EQ(m_parent.get(), m_grandChild2->rootLayer()); | 410 EXPECT_EQ(m_parent.get(), m_grandChild2->rootLayer()); |
411 EXPECT_EQ(m_grandChild3.get(), m_grandChild3->rootLayer()); | 411 EXPECT_EQ(m_grandChild3.get(), m_grandChild3->rootLayer()); |
412 } | 412 } |
413 | 413 |
414 TEST_F(LayerChromiumTest, checkSetNeedsDisplayCausesCorrectBehavior) | 414 TEST_F(LayerTest, checkSetNeedsDisplayCausesCorrectBehavior) |
415 { | 415 { |
416 // The semantics for setNeedsDisplay which are tested here: | 416 // The semantics for setNeedsDisplay which are tested here: |
417 // 1. sets needsDisplay flag appropriately. | 417 // 1. sets needsDisplay flag appropriately. |
418 // 2. indirectly calls setNeedsCommit, exactly once for each call to setNe
edsDisplay. | 418 // 2. indirectly calls setNeedsCommit, exactly once for each call to setNe
edsDisplay. |
419 | 419 |
420 scoped_refptr<LayerChromium> testLayer = LayerChromium::create(); | 420 scoped_refptr<Layer> testLayer = Layer::create(); |
421 testLayer->setLayerTreeHost(m_layerTreeHost.get()); | 421 testLayer->setLayerTreeHost(m_layerTreeHost.get()); |
422 | 422 |
423 IntSize testBounds = IntSize(501, 508); | 423 IntSize testBounds = IntSize(501, 508); |
424 | 424 |
425 FloatRect dirty1 = FloatRect(10, 15, 1, 2); | 425 FloatRect dirty1 = FloatRect(10, 15, 1, 2); |
426 FloatRect dirty2 = FloatRect(20, 25, 3, 4); | 426 FloatRect dirty2 = FloatRect(20, 25, 3, 4); |
427 FloatRect emptyDirtyRect = FloatRect(40, 45, 0, 0); | 427 FloatRect emptyDirtyRect = FloatRect(40, 45, 0, 0); |
428 FloatRect outOfBoundsDirtyRect = FloatRect(400, 405, 500, 502); | 428 FloatRect outOfBoundsDirtyRect = FloatRect(400, 405, 500, 502); |
429 | 429 |
430 // Before anything, testLayer should not be dirty. | 430 // Before anything, testLayer should not be dirty. |
431 EXPECT_FALSE(testLayer->needsDisplay()); | 431 EXPECT_FALSE(testLayer->needsDisplay()); |
432 | 432 |
433 // This is just initialization, but setNeedsCommit behavior is verified anyw
ay to avoid warnings. | 433 // This is just initialization, but setNeedsCommit behavior is verified anyw
ay to avoid warnings. |
434 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBou
nds)); | 434 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBou
nds)); |
435 testLayer = LayerChromium::create(); | 435 testLayer = Layer::create(); |
436 testLayer->setLayerTreeHost(m_layerTreeHost.get()); | 436 testLayer->setLayerTreeHost(m_layerTreeHost.get()); |
437 EXPECT_FALSE(testLayer->needsDisplay()); | 437 EXPECT_FALSE(testLayer->needsDisplay()); |
438 | 438 |
439 // The real test begins here. | 439 // The real test begins here. |
440 | 440 |
441 // Case 1: needsDisplay flag should not change because of an empty dirty rec
t. | 441 // Case 1: needsDisplay flag should not change because of an empty dirty rec
t. |
442 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRe
ct(emptyDirtyRect)); | 442 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRe
ct(emptyDirtyRect)); |
443 EXPECT_FALSE(testLayer->needsDisplay()); | 443 EXPECT_FALSE(testLayer->needsDisplay()); |
444 | 444 |
445 // Case 2: basic. | 445 // Case 2: basic. |
446 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRe
ct(dirty1)); | 446 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRe
ct(dirty1)); |
447 EXPECT_TRUE(testLayer->needsDisplay()); | 447 EXPECT_TRUE(testLayer->needsDisplay()); |
448 | 448 |
449 // Case 3: a second dirty rect. | 449 // Case 3: a second dirty rect. |
450 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRe
ct(dirty2)); | 450 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRe
ct(dirty2)); |
451 EXPECT_TRUE(testLayer->needsDisplay()); | 451 EXPECT_TRUE(testLayer->needsDisplay()); |
452 | 452 |
453 // Case 4: LayerChromium should accept dirty rects that go beyond its bounds
. | 453 // Case 4: Layer should accept dirty rects that go beyond its bounds. |
454 testLayer = LayerChromium::create(); | 454 testLayer = Layer::create(); |
455 testLayer->setLayerTreeHost(m_layerTreeHost.get()); | 455 testLayer->setLayerTreeHost(m_layerTreeHost.get()); |
456 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBou
nds)); | 456 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBou
nds)); |
457 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRe
ct(outOfBoundsDirtyRect)); | 457 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplayRe
ct(outOfBoundsDirtyRect)); |
458 EXPECT_TRUE(testLayer->needsDisplay()); | 458 EXPECT_TRUE(testLayer->needsDisplay()); |
459 | 459 |
460 // Case 5: setNeedsDisplay() without the dirty rect arg. | 460 // Case 5: setNeedsDisplay() without the dirty rect arg. |
461 testLayer = LayerChromium::create(); | 461 testLayer = Layer::create(); |
462 testLayer->setLayerTreeHost(m_layerTreeHost.get()); | 462 testLayer->setLayerTreeHost(m_layerTreeHost.get()); |
463 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBou
nds)); | 463 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBou
nds)); |
464 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplay()
); | 464 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setNeedsDisplay()
); |
465 EXPECT_TRUE(testLayer->needsDisplay()); | 465 EXPECT_TRUE(testLayer->needsDisplay()); |
466 } | 466 } |
467 | 467 |
468 TEST_F(LayerChromiumTest, checkPropertyChangeCausesCorrectBehavior) | 468 TEST_F(LayerTest, checkPropertyChangeCausesCorrectBehavior) |
469 { | 469 { |
470 scoped_refptr<LayerChromium> testLayer = LayerChromium::create(); | 470 scoped_refptr<Layer> testLayer = Layer::create(); |
471 testLayer->setLayerTreeHost(m_layerTreeHost.get()); | 471 testLayer->setLayerTreeHost(m_layerTreeHost.get()); |
472 | 472 |
473 scoped_refptr<LayerChromium> dummyLayer = LayerChromium::create(); // just a
dummy layer for this test case. | 473 scoped_refptr<Layer> dummyLayer = Layer::create(); // just a dummy layer for
this test case. |
474 | 474 |
475 // sanity check of initial test condition | 475 // sanity check of initial test condition |
476 EXPECT_FALSE(testLayer->needsDisplay()); | 476 EXPECT_FALSE(testLayer->needsDisplay()); |
477 | 477 |
478 // Test properties that should not call needsDisplay and needsCommit when ch
anged. | 478 // Test properties that should not call needsDisplay and needsCommit when ch
anged. |
479 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setVisibleContent
Rect(IntRect(0, 0, 40, 50))); | 479 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setVisibleContent
Rect(IntRect(0, 0, 40, 50))); |
480 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setUseLCDText(tru
e)); | 480 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setUseLCDText(tru
e)); |
481 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawOpacity(0.
5)); | 481 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawOpacity(0.
5)); |
482 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setRenderTarget(0
)); | 482 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setRenderTarget(0
)); |
483 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawTransform(
WebTransformationMatrix())); | 483 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawTransform(
WebTransformationMatrix())); |
(...skipping 25 matching lines...) Expand all Loading... |
509 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setForceRenderSur
face(true)); | 509 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setForceRenderSur
face(true)); |
510 | 510 |
511 // The above tests should not have caused a change to the needsDisplay flag. | 511 // The above tests should not have caused a change to the needsDisplay flag. |
512 EXPECT_FALSE(testLayer->needsDisplay()); | 512 EXPECT_FALSE(testLayer->needsDisplay()); |
513 | 513 |
514 // Test properties that should call setNeedsDisplay and setNeedsCommit | 514 // Test properties that should call setNeedsDisplay and setNeedsCommit |
515 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(IntSize
(5, 10))); | 515 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(IntSize
(5, 10))); |
516 EXPECT_TRUE(testLayer->needsDisplay()); | 516 EXPECT_TRUE(testLayer->needsDisplay()); |
517 } | 517 } |
518 | 518 |
519 TEST_F(LayerChromiumTest, verifyPushPropertiesAccumulatesUpdateRect) | 519 TEST_F(LayerTest, verifyPushPropertiesAccumulatesUpdateRect) |
520 { | 520 { |
521 DebugScopedSetImplThread setImplThread; | 521 DebugScopedSetImplThread setImplThread; |
522 | 522 |
523 scoped_refptr<LayerChromium> testLayer = LayerChromium::create(); | 523 scoped_refptr<Layer> testLayer = Layer::create(); |
524 scoped_ptr<CCLayerImpl> implLayer = CCLayerImpl::create(1); | 524 scoped_ptr<LayerImpl> implLayer = LayerImpl::create(1); |
525 | 525 |
526 testLayer->setNeedsDisplayRect(FloatRect(FloatPoint::zero(), FloatSize(5, 5)
)); | 526 testLayer->setNeedsDisplayRect(FloatRect(FloatPoint::zero(), FloatSize(5, 5)
)); |
527 testLayer->pushPropertiesTo(implLayer.get()); | 527 testLayer->pushPropertiesTo(implLayer.get()); |
528 EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint::zero(), FloatSize(5, 5)), implLay
er->updateRect()); | 528 EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint::zero(), FloatSize(5, 5)), implLay
er->updateRect()); |
529 | 529 |
530 // The CCLayerImpl's updateRect should be accumulated here, since we did not
do anything to clear it. | 530 // The LayerImpl's updateRect should be accumulated here, since we did not d
o anything to clear it. |
531 testLayer->setNeedsDisplayRect(FloatRect(FloatPoint(10, 10), FloatSize(5, 5)
)); | 531 testLayer->setNeedsDisplayRect(FloatRect(FloatPoint(10, 10), FloatSize(5, 5)
)); |
532 testLayer->pushPropertiesTo(implLayer.get()); | 532 testLayer->pushPropertiesTo(implLayer.get()); |
533 EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint::zero(), FloatSize(15, 15)), implL
ayer->updateRect()); | 533 EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint::zero(), FloatSize(15, 15)), implL
ayer->updateRect()); |
534 | 534 |
535 // If we do clear the CCLayerImpl side, then the next updateRect should be f
resh without accumulation. | 535 // If we do clear the LayerImpl side, then the next updateRect should be fre
sh without accumulation. |
536 implLayer->resetAllChangeTrackingForSubtree(); | 536 implLayer->resetAllChangeTrackingForSubtree(); |
537 testLayer->setNeedsDisplayRect(FloatRect(FloatPoint(10, 10), FloatSize(5, 5)
)); | 537 testLayer->setNeedsDisplayRect(FloatRect(FloatPoint(10, 10), FloatSize(5, 5)
)); |
538 testLayer->pushPropertiesTo(implLayer.get()); | 538 testLayer->pushPropertiesTo(implLayer.get()); |
539 EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint(10, 10), FloatSize(5, 5)), implLay
er->updateRect()); | 539 EXPECT_FLOAT_RECT_EQ(FloatRect(FloatPoint(10, 10), FloatSize(5, 5)), implLay
er->updateRect()); |
540 } | 540 } |
541 | 541 |
542 class LayerChromiumWithContentScaling : public LayerChromium { | 542 class LayerWithContentScaling : public Layer { |
543 public: | 543 public: |
544 explicit LayerChromiumWithContentScaling() | 544 explicit LayerWithContentScaling() |
545 : LayerChromium() | 545 : Layer() |
546 { | 546 { |
547 } | 547 } |
548 | 548 |
549 virtual bool needsContentsScale() const OVERRIDE | 549 virtual bool needsContentsScale() const OVERRIDE |
550 { | 550 { |
551 return true; | 551 return true; |
552 } | 552 } |
553 | 553 |
554 virtual void setNeedsDisplayRect(const FloatRect& dirtyRect) OVERRIDE | 554 virtual void setNeedsDisplayRect(const FloatRect& dirtyRect) OVERRIDE |
555 { | 555 { |
556 m_lastNeedsDisplayRect = dirtyRect; | 556 m_lastNeedsDisplayRect = dirtyRect; |
557 LayerChromium::setNeedsDisplayRect(dirtyRect); | 557 Layer::setNeedsDisplayRect(dirtyRect); |
558 } | 558 } |
559 | 559 |
560 void resetNeedsDisplay() | 560 void resetNeedsDisplay() |
561 { | 561 { |
562 m_needsDisplay = false; | 562 m_needsDisplay = false; |
563 } | 563 } |
564 | 564 |
565 const FloatRect& lastNeedsDisplayRect() const { return m_lastNeedsDisplayRec
t; } | 565 const FloatRect& lastNeedsDisplayRect() const { return m_lastNeedsDisplayRec
t; } |
566 | 566 |
567 private: | 567 private: |
568 virtual ~LayerChromiumWithContentScaling() | 568 virtual ~LayerWithContentScaling() |
569 { | 569 { |
570 } | 570 } |
571 | 571 |
572 FloatRect m_lastNeedsDisplayRect; | 572 FloatRect m_lastNeedsDisplayRect; |
573 }; | 573 }; |
574 | 574 |
575 TEST_F(LayerChromiumTest, checkContentsScaleChangeTriggersNeedsDisplay) | 575 TEST_F(LayerTest, checkContentsScaleChangeTriggersNeedsDisplay) |
576 { | 576 { |
577 scoped_refptr<LayerChromiumWithContentScaling> testLayer = make_scoped_refpt
r(new LayerChromiumWithContentScaling()); | 577 scoped_refptr<LayerWithContentScaling> testLayer = make_scoped_refptr(new La
yerWithContentScaling()); |
578 testLayer->setLayerTreeHost(m_layerTreeHost.get()); | 578 testLayer->setLayerTreeHost(m_layerTreeHost.get()); |
579 | 579 |
580 IntSize testBounds = IntSize(320, 240); | 580 IntSize testBounds = IntSize(320, 240); |
581 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBou
nds)); | 581 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setBounds(testBou
nds)); |
582 | 582 |
583 testLayer->resetNeedsDisplay(); | 583 testLayer->resetNeedsDisplay(); |
584 EXPECT_FALSE(testLayer->needsDisplay()); | 584 EXPECT_FALSE(testLayer->needsDisplay()); |
585 | 585 |
586 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setContentsScale(
testLayer->contentsScale() + 1.f)); | 586 EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setContentsScale(
testLayer->contentsScale() + 1.f)); |
587 EXPECT_TRUE(testLayer->needsDisplay()); | 587 EXPECT_TRUE(testLayer->needsDisplay()); |
588 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 320, 240), testLayer->lastNeedsDisplayR
ect()); | 588 EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 320, 240), testLayer->lastNeedsDisplayR
ect()); |
589 } | 589 } |
590 | 590 |
591 class FakeCCLayerTreeHost : public CCLayerTreeHost { | 591 class FakeLayerImplTreeHost : public LayerTreeHost { |
592 public: | 592 public: |
593 static scoped_ptr<FakeCCLayerTreeHost> create() | 593 static scoped_ptr<FakeLayerImplTreeHost> create() |
594 { | 594 { |
595 scoped_ptr<FakeCCLayerTreeHost> host(new FakeCCLayerTreeHost); | 595 scoped_ptr<FakeLayerImplTreeHost> host(new FakeLayerImplTreeHost); |
596 // The initialize call will fail, since our client doesn't provide a val
id GraphicsContext3D, but it doesn't matter in the tests that use this fake so i
gnore the return value. | 596 // The initialize call will fail, since our client doesn't provide a val
id GraphicsContext3D, but it doesn't matter in the tests that use this fake so i
gnore the return value. |
597 host->initialize(); | 597 host->initialize(); |
598 return host.Pass(); | 598 return host.Pass(); |
599 } | 599 } |
600 | 600 |
601 private: | 601 private: |
602 FakeCCLayerTreeHost() | 602 FakeLayerImplTreeHost() |
603 : CCLayerTreeHost(&m_client, CCLayerTreeSettings()) | 603 : LayerTreeHost(&m_client, LayerTreeSettings()) |
604 { | 604 { |
605 } | 605 } |
606 | 606 |
607 FakeCCLayerTreeHostClient m_client; | 607 FakeLayerImplTreeHostClient m_client; |
608 }; | 608 }; |
609 | 609 |
610 void assertLayerTreeHostMatchesForSubtree(LayerChromium* layer, CCLayerTreeHost*
host) | 610 void assertLayerTreeHostMatchesForSubtree(Layer* layer, LayerTreeHost* host) |
611 { | 611 { |
612 EXPECT_EQ(host, layer->layerTreeHost()); | 612 EXPECT_EQ(host, layer->layerTreeHost()); |
613 | 613 |
614 for (size_t i = 0; i < layer->children().size(); ++i) | 614 for (size_t i = 0; i < layer->children().size(); ++i) |
615 assertLayerTreeHostMatchesForSubtree(layer->children()[i].get(), host); | 615 assertLayerTreeHostMatchesForSubtree(layer->children()[i].get(), host); |
616 | 616 |
617 if (layer->maskLayer()) | 617 if (layer->maskLayer()) |
618 assertLayerTreeHostMatchesForSubtree(layer->maskLayer(), host); | 618 assertLayerTreeHostMatchesForSubtree(layer->maskLayer(), host); |
619 | 619 |
620 if (layer->replicaLayer()) | 620 if (layer->replicaLayer()) |
621 assertLayerTreeHostMatchesForSubtree(layer->replicaLayer(), host); | 621 assertLayerTreeHostMatchesForSubtree(layer->replicaLayer(), host); |
622 } | 622 } |
623 | 623 |
624 | 624 |
625 TEST(LayerChromiumLayerTreeHostTest, enteringTree) | 625 TEST(LayerLayerTreeHostTest, enteringTree) |
626 { | 626 { |
627 WebCompositorInitializer compositorInitializer(0); | 627 WebCompositorInitializer compositorInitializer(0); |
628 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 628 scoped_refptr<Layer> parent = Layer::create(); |
629 scoped_refptr<LayerChromium> child = LayerChromium::create(); | 629 scoped_refptr<Layer> child = Layer::create(); |
630 scoped_refptr<LayerChromium> mask = LayerChromium::create(); | 630 scoped_refptr<Layer> mask = Layer::create(); |
631 scoped_refptr<LayerChromium> replica = LayerChromium::create(); | 631 scoped_refptr<Layer> replica = Layer::create(); |
632 scoped_refptr<LayerChromium> replicaMask = LayerChromium::create(); | 632 scoped_refptr<Layer> replicaMask = Layer::create(); |
633 | 633 |
634 // Set up a detached tree of layers. The host pointer should be nil for thes
e layers. | 634 // Set up a detached tree of layers. The host pointer should be nil for thes
e layers. |
635 parent->addChild(child); | 635 parent->addChild(child); |
636 child->setMaskLayer(mask.get()); | 636 child->setMaskLayer(mask.get()); |
637 child->setReplicaLayer(replica.get()); | 637 child->setReplicaLayer(replica.get()); |
638 replica->setMaskLayer(mask.get()); | 638 replica->setMaskLayer(mask.get()); |
639 | 639 |
640 assertLayerTreeHostMatchesForSubtree(parent.get(), 0); | 640 assertLayerTreeHostMatchesForSubtree(parent.get(), 0); |
641 | 641 |
642 scoped_ptr<FakeCCLayerTreeHost> layerTreeHost(FakeCCLayerTreeHost::create())
; | 642 scoped_ptr<FakeLayerImplTreeHost> layerTreeHost(FakeLayerImplTreeHost::creat
e()); |
643 // Setting the root layer should set the host pointer for all layers in the
tree. | 643 // Setting the root layer should set the host pointer for all layers in the
tree. |
644 layerTreeHost->setRootLayer(parent.get()); | 644 layerTreeHost->setRootLayer(parent.get()); |
645 | 645 |
646 assertLayerTreeHostMatchesForSubtree(parent.get(), layerTreeHost.get()); | 646 assertLayerTreeHostMatchesForSubtree(parent.get(), layerTreeHost.get()); |
647 | 647 |
648 // Clearing the root layer should also clear out the host pointers for all l
ayers in the tree. | 648 // Clearing the root layer should also clear out the host pointers for all l
ayers in the tree. |
649 layerTreeHost->setRootLayer(0); | 649 layerTreeHost->setRootLayer(0); |
650 | 650 |
651 assertLayerTreeHostMatchesForSubtree(parent.get(), 0); | 651 assertLayerTreeHostMatchesForSubtree(parent.get(), 0); |
652 } | 652 } |
653 | 653 |
654 TEST(LayerChromiumLayerTreeHostTest, addingLayerSubtree) | 654 TEST(LayerLayerTreeHostTest, addingLayerSubtree) |
655 { | 655 { |
656 WebCompositorInitializer compositorInitializer(0); | 656 WebCompositorInitializer compositorInitializer(0); |
657 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 657 scoped_refptr<Layer> parent = Layer::create(); |
658 scoped_ptr<FakeCCLayerTreeHost> layerTreeHost(FakeCCLayerTreeHost::create())
; | 658 scoped_ptr<FakeLayerImplTreeHost> layerTreeHost(FakeLayerImplTreeHost::creat
e()); |
659 | 659 |
660 layerTreeHost->setRootLayer(parent.get()); | 660 layerTreeHost->setRootLayer(parent.get()); |
661 | 661 |
662 EXPECT_EQ(parent->layerTreeHost(), layerTreeHost.get()); | 662 EXPECT_EQ(parent->layerTreeHost(), layerTreeHost.get()); |
663 | 663 |
664 // Adding a subtree to a layer already associated with a host should set the
host pointer on all layers in that subtree. | 664 // Adding a subtree to a layer already associated with a host should set the
host pointer on all layers in that subtree. |
665 scoped_refptr<LayerChromium> child = LayerChromium::create(); | 665 scoped_refptr<Layer> child = Layer::create(); |
666 scoped_refptr<LayerChromium> grandChild = LayerChromium::create(); | 666 scoped_refptr<Layer> grandChild = Layer::create(); |
667 child->addChild(grandChild); | 667 child->addChild(grandChild); |
668 | 668 |
669 // Masks, replicas, and replica masks should pick up the new host too. | 669 // Masks, replicas, and replica masks should pick up the new host too. |
670 scoped_refptr<LayerChromium> childMask = LayerChromium::create(); | 670 scoped_refptr<Layer> childMask = Layer::create(); |
671 child->setMaskLayer(childMask.get()); | 671 child->setMaskLayer(childMask.get()); |
672 scoped_refptr<LayerChromium> childReplica = LayerChromium::create(); | 672 scoped_refptr<Layer> childReplica = Layer::create(); |
673 child->setReplicaLayer(childReplica.get()); | 673 child->setReplicaLayer(childReplica.get()); |
674 scoped_refptr<LayerChromium> childReplicaMask = LayerChromium::create(); | 674 scoped_refptr<Layer> childReplicaMask = Layer::create(); |
675 childReplica->setMaskLayer(childReplicaMask.get()); | 675 childReplica->setMaskLayer(childReplicaMask.get()); |
676 | 676 |
677 parent->addChild(child); | 677 parent->addChild(child); |
678 assertLayerTreeHostMatchesForSubtree(parent.get(), layerTreeHost.get()); | 678 assertLayerTreeHostMatchesForSubtree(parent.get(), layerTreeHost.get()); |
679 | 679 |
680 layerTreeHost->setRootLayer(0); | 680 layerTreeHost->setRootLayer(0); |
681 } | 681 } |
682 | 682 |
683 TEST(LayerChromiumLayerTreeHostTest, changeHost) | 683 TEST(LayerLayerTreeHostTest, changeHost) |
684 { | 684 { |
685 WebCompositorInitializer compositorInitializer(0); | 685 WebCompositorInitializer compositorInitializer(0); |
686 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 686 scoped_refptr<Layer> parent = Layer::create(); |
687 scoped_refptr<LayerChromium> child = LayerChromium::create(); | 687 scoped_refptr<Layer> child = Layer::create(); |
688 scoped_refptr<LayerChromium> mask = LayerChromium::create(); | 688 scoped_refptr<Layer> mask = Layer::create(); |
689 scoped_refptr<LayerChromium> replica = LayerChromium::create(); | 689 scoped_refptr<Layer> replica = Layer::create(); |
690 scoped_refptr<LayerChromium> replicaMask = LayerChromium::create(); | 690 scoped_refptr<Layer> replicaMask = Layer::create(); |
691 | 691 |
692 // Same setup as the previous test. | 692 // Same setup as the previous test. |
693 parent->addChild(child); | 693 parent->addChild(child); |
694 child->setMaskLayer(mask.get()); | 694 child->setMaskLayer(mask.get()); |
695 child->setReplicaLayer(replica.get()); | 695 child->setReplicaLayer(replica.get()); |
696 replica->setMaskLayer(mask.get()); | 696 replica->setMaskLayer(mask.get()); |
697 | 697 |
698 scoped_ptr<FakeCCLayerTreeHost> firstLayerTreeHost(FakeCCLayerTreeHost::crea
te()); | 698 scoped_ptr<FakeLayerImplTreeHost> firstLayerTreeHost(FakeLayerImplTreeHost::
create()); |
699 firstLayerTreeHost->setRootLayer(parent.get()); | 699 firstLayerTreeHost->setRootLayer(parent.get()); |
700 | 700 |
701 assertLayerTreeHostMatchesForSubtree(parent.get(), firstLayerTreeHost.get())
; | 701 assertLayerTreeHostMatchesForSubtree(parent.get(), firstLayerTreeHost.get())
; |
702 | 702 |
703 // Now re-root the tree to a new host (simulating what we do on a context lo
st event). | 703 // Now re-root the tree to a new host (simulating what we do on a context lo
st event). |
704 // This should update the host pointers for all layers in the tree. | 704 // This should update the host pointers for all layers in the tree. |
705 scoped_ptr<FakeCCLayerTreeHost> secondLayerTreeHost(FakeCCLayerTreeHost::cre
ate()); | 705 scoped_ptr<FakeLayerImplTreeHost> secondLayerTreeHost(FakeLayerImplTreeHost:
:create()); |
706 secondLayerTreeHost->setRootLayer(parent.get()); | 706 secondLayerTreeHost->setRootLayer(parent.get()); |
707 | 707 |
708 assertLayerTreeHostMatchesForSubtree(parent.get(), secondLayerTreeHost.get()
); | 708 assertLayerTreeHostMatchesForSubtree(parent.get(), secondLayerTreeHost.get()
); |
709 | 709 |
710 secondLayerTreeHost->setRootLayer(0); | 710 secondLayerTreeHost->setRootLayer(0); |
711 } | 711 } |
712 | 712 |
713 TEST(LayerChromiumLayerTreeHostTest, changeHostInSubtree) | 713 TEST(LayerLayerTreeHostTest, changeHostInSubtree) |
714 { | 714 { |
715 WebCompositorInitializer compositorInitializer(0); | 715 WebCompositorInitializer compositorInitializer(0); |
716 scoped_refptr<LayerChromium> firstParent = LayerChromium::create(); | 716 scoped_refptr<Layer> firstParent = Layer::create(); |
717 scoped_refptr<LayerChromium> firstChild = LayerChromium::create(); | 717 scoped_refptr<Layer> firstChild = Layer::create(); |
718 scoped_refptr<LayerChromium> secondParent = LayerChromium::create(); | 718 scoped_refptr<Layer> secondParent = Layer::create(); |
719 scoped_refptr<LayerChromium> secondChild = LayerChromium::create(); | 719 scoped_refptr<Layer> secondChild = Layer::create(); |
720 scoped_refptr<LayerChromium> secondGrandChild = LayerChromium::create(); | 720 scoped_refptr<Layer> secondGrandChild = Layer::create(); |
721 | 721 |
722 // First put all children under the first parent and set the first host. | 722 // First put all children under the first parent and set the first host. |
723 firstParent->addChild(firstChild); | 723 firstParent->addChild(firstChild); |
724 secondChild->addChild(secondGrandChild); | 724 secondChild->addChild(secondGrandChild); |
725 firstParent->addChild(secondChild); | 725 firstParent->addChild(secondChild); |
726 | 726 |
727 scoped_ptr<FakeCCLayerTreeHost> firstLayerTreeHost(FakeCCLayerTreeHost::crea
te()); | 727 scoped_ptr<FakeLayerImplTreeHost> firstLayerTreeHost(FakeLayerImplTreeHost::
create()); |
728 firstLayerTreeHost->setRootLayer(firstParent.get()); | 728 firstLayerTreeHost->setRootLayer(firstParent.get()); |
729 | 729 |
730 assertLayerTreeHostMatchesForSubtree(firstParent.get(), firstLayerTreeHost.g
et()); | 730 assertLayerTreeHostMatchesForSubtree(firstParent.get(), firstLayerTreeHost.g
et()); |
731 | 731 |
732 // Now reparent the subtree starting at secondChild to a layer in a differen
t tree. | 732 // Now reparent the subtree starting at secondChild to a layer in a differen
t tree. |
733 scoped_ptr<FakeCCLayerTreeHost> secondLayerTreeHost(FakeCCLayerTreeHost::cre
ate()); | 733 scoped_ptr<FakeLayerImplTreeHost> secondLayerTreeHost(FakeLayerImplTreeHost:
:create()); |
734 secondLayerTreeHost->setRootLayer(secondParent.get()); | 734 secondLayerTreeHost->setRootLayer(secondParent.get()); |
735 | 735 |
736 secondParent->addChild(secondChild); | 736 secondParent->addChild(secondChild); |
737 | 737 |
738 // The moved layer and its children should point to the new host. | 738 // The moved layer and its children should point to the new host. |
739 EXPECT_EQ(secondLayerTreeHost.get(), secondChild->layerTreeHost()); | 739 EXPECT_EQ(secondLayerTreeHost.get(), secondChild->layerTreeHost()); |
740 EXPECT_EQ(secondLayerTreeHost.get(), secondGrandChild->layerTreeHost()); | 740 EXPECT_EQ(secondLayerTreeHost.get(), secondGrandChild->layerTreeHost()); |
741 | 741 |
742 // Test over, cleanup time. | 742 // Test over, cleanup time. |
743 firstLayerTreeHost->setRootLayer(0); | 743 firstLayerTreeHost->setRootLayer(0); |
744 secondLayerTreeHost->setRootLayer(0); | 744 secondLayerTreeHost->setRootLayer(0); |
745 } | 745 } |
746 | 746 |
747 TEST(LayerChromiumLayerTreeHostTest, replaceMaskAndReplicaLayer) | 747 TEST(LayerLayerTreeHostTest, replaceMaskAndReplicaLayer) |
748 { | 748 { |
749 WebCompositorInitializer compositorInitializer(0); | 749 WebCompositorInitializer compositorInitializer(0); |
750 scoped_refptr<LayerChromium> parent = LayerChromium::create(); | 750 scoped_refptr<Layer> parent = Layer::create(); |
751 scoped_refptr<LayerChromium> mask = LayerChromium::create(); | 751 scoped_refptr<Layer> mask = Layer::create(); |
752 scoped_refptr<LayerChromium> replica = LayerChromium::create(); | 752 scoped_refptr<Layer> replica = Layer::create(); |
753 scoped_refptr<LayerChromium> maskChild = LayerChromium::create(); | 753 scoped_refptr<Layer> maskChild = Layer::create(); |
754 scoped_refptr<LayerChromium> replicaChild = LayerChromium::create(); | 754 scoped_refptr<Layer> replicaChild = Layer::create(); |
755 scoped_refptr<LayerChromium> maskReplacement = LayerChromium::create(); | 755 scoped_refptr<Layer> maskReplacement = Layer::create(); |
756 scoped_refptr<LayerChromium> replicaReplacement = LayerChromium::create(); | 756 scoped_refptr<Layer> replicaReplacement = Layer::create(); |
757 | 757 |
758 parent->setMaskLayer(mask.get()); | 758 parent->setMaskLayer(mask.get()); |
759 parent->setReplicaLayer(replica.get()); | 759 parent->setReplicaLayer(replica.get()); |
760 mask->addChild(maskChild); | 760 mask->addChild(maskChild); |
761 replica->addChild(replicaChild); | 761 replica->addChild(replicaChild); |
762 | 762 |
763 scoped_ptr<FakeCCLayerTreeHost> layerTreeHost(FakeCCLayerTreeHost::create())
; | 763 scoped_ptr<FakeLayerImplTreeHost> layerTreeHost(FakeLayerImplTreeHost::creat
e()); |
764 layerTreeHost->setRootLayer(parent.get()); | 764 layerTreeHost->setRootLayer(parent.get()); |
765 | 765 |
766 assertLayerTreeHostMatchesForSubtree(parent.get(), layerTreeHost.get()); | 766 assertLayerTreeHostMatchesForSubtree(parent.get(), layerTreeHost.get()); |
767 | 767 |
768 // Replacing the mask should clear out the old mask's subtree's host pointer
s. | 768 // Replacing the mask should clear out the old mask's subtree's host pointer
s. |
769 parent->setMaskLayer(maskReplacement.get()); | 769 parent->setMaskLayer(maskReplacement.get()); |
770 EXPECT_EQ(0, mask->layerTreeHost()); | 770 EXPECT_EQ(0, mask->layerTreeHost()); |
771 EXPECT_EQ(0, maskChild->layerTreeHost()); | 771 EXPECT_EQ(0, maskChild->layerTreeHost()); |
772 | 772 |
773 // Same for replacing a replica layer. | 773 // Same for replacing a replica layer. |
774 parent->setReplicaLayer(replicaReplacement.get()); | 774 parent->setReplicaLayer(replicaReplacement.get()); |
775 EXPECT_EQ(0, replica->layerTreeHost()); | 775 EXPECT_EQ(0, replica->layerTreeHost()); |
776 EXPECT_EQ(0, replicaChild->layerTreeHost()); | 776 EXPECT_EQ(0, replicaChild->layerTreeHost()); |
777 | 777 |
778 // Test over, cleanup time. | 778 // Test over, cleanup time. |
779 layerTreeHost->setRootLayer(0); | 779 layerTreeHost->setRootLayer(0); |
780 } | 780 } |
781 | 781 |
782 TEST(LayerChromiumLayerTreeHostTest, destroyHostWithNonNullRootLayer) | 782 TEST(LayerLayerTreeHostTest, destroyHostWithNonNullRootLayer) |
783 { | 783 { |
784 WebCompositorInitializer compositorInitializer(0); | 784 WebCompositorInitializer compositorInitializer(0); |
785 scoped_refptr<LayerChromium> root = LayerChromium::create(); | 785 scoped_refptr<Layer> root = Layer::create(); |
786 scoped_refptr<LayerChromium> child = LayerChromium::create(); | 786 scoped_refptr<Layer> child = Layer::create(); |
787 root->addChild(child); | 787 root->addChild(child); |
788 scoped_ptr<FakeCCLayerTreeHost> layerTreeHost(FakeCCLayerTreeHost::create())
; | 788 scoped_ptr<FakeLayerImplTreeHost> layerTreeHost(FakeLayerImplTreeHost::creat
e()); |
789 layerTreeHost->setRootLayer(root); | 789 layerTreeHost->setRootLayer(root); |
790 } | 790 } |
791 | 791 |
792 static bool addTestAnimation(LayerChromium* layer) | 792 static bool addTestAnimation(Layer* layer) |
793 { | 793 { |
794 scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCu
rve::create()); | 794 scoped_ptr<KeyframedFloatAnimationCurve> curve(KeyframedFloatAnimationCurve:
:create()); |
795 curve->addKeyframe(CCFloatKeyframe::create(0, 0.3f, scoped_ptr<CCTimingFunct
ion>())); | 795 curve->addKeyframe(FloatKeyframe::create(0, 0.3f, scoped_ptr<TimingFunction>
())); |
796 curve->addKeyframe(CCFloatKeyframe::create(1, 0.7f, scoped_ptr<CCTimingFunct
ion>())); | 796 curve->addKeyframe(FloatKeyframe::create(1, 0.7f, scoped_ptr<TimingFunction>
())); |
797 scoped_ptr<CCActiveAnimation> animation(CCActiveAnimation::create(curve.Pass
As<CCAnimationCurve>(), 0, 0, CCActiveAnimation::Opacity)); | 797 scoped_ptr<ActiveAnimation> animation(ActiveAnimation::create(curve.PassAs<A
nimationCurve>(), 0, 0, ActiveAnimation::Opacity)); |
798 | 798 |
799 return layer->addAnimation(animation.Pass()); | 799 return layer->addAnimation(animation.Pass()); |
800 } | 800 } |
801 | 801 |
802 TEST(LayerChromiumLayerTreeHostTest, shouldNotAddAnimationWithoutLayerTreeHost) | 802 TEST(LayerLayerTreeHostTest, shouldNotAddAnimationWithoutLayerTreeHost) |
803 { | 803 { |
804 // Currently, WebCore assumes that animations will be started immediately /
very soon | 804 // Currently, WebCore assumes that animations will be started immediately /
very soon |
805 // if a composited layer's addAnimation() returns true. However, without a l
ayerTreeHost, | 805 // if a composited layer's addAnimation() returns true. However, without a l
ayerTreeHost, |
806 // layers cannot actually animate yet. So, to prevent violating this WebCore
assumption, | 806 // layers cannot actually animate yet. So, to prevent violating this WebCore
assumption, |
807 // the animation should not be accepted if the layer doesn't already have a
layerTreeHost. | 807 // the animation should not be accepted if the layer doesn't already have a
layerTreeHost. |
808 | 808 |
809 WebKit::Platform::current()->compositorSupport()->setAcceleratedAnimationEna
bled(true); | 809 WebKit::Platform::current()->compositorSupport()->setAcceleratedAnimationEna
bled(true); |
810 | 810 |
811 WebCompositorInitializer compositorInitializer(0); | 811 WebCompositorInitializer compositorInitializer(0); |
812 scoped_refptr<LayerChromium> layer = LayerChromium::create(); | 812 scoped_refptr<Layer> layer = Layer::create(); |
813 | 813 |
814 // Case 1: without a layerTreeHost, the animation should not be accepted. | 814 // Case 1: without a layerTreeHost, the animation should not be accepted. |
815 EXPECT_FALSE(addTestAnimation(layer.get())); | 815 EXPECT_FALSE(addTestAnimation(layer.get())); |
816 | 816 |
817 scoped_ptr<FakeCCLayerTreeHost> layerTreeHost(FakeCCLayerTreeHost::create())
; | 817 scoped_ptr<FakeLayerImplTreeHost> layerTreeHost(FakeLayerImplTreeHost::creat
e()); |
818 layerTreeHost->setRootLayer(layer.get()); | 818 layerTreeHost->setRootLayer(layer.get()); |
819 layer->setLayerTreeHost(layerTreeHost.get()); | 819 layer->setLayerTreeHost(layerTreeHost.get()); |
820 assertLayerTreeHostMatchesForSubtree(layer.get(), layerTreeHost.get()); | 820 assertLayerTreeHostMatchesForSubtree(layer.get(), layerTreeHost.get()); |
821 | 821 |
822 // Case 2: with a layerTreeHost, the animation should be accepted. | 822 // Case 2: with a layerTreeHost, the animation should be accepted. |
823 EXPECT_TRUE(addTestAnimation(layer.get())); | 823 EXPECT_TRUE(addTestAnimation(layer.get())); |
824 } | 824 } |
825 | 825 |
826 class MockLayerChromium : public LayerChromium { | 826 class MockLayer : public Layer { |
827 public: | 827 public: |
828 bool needsDisplay() const { return m_needsDisplay; } | 828 bool needsDisplay() const { return m_needsDisplay; } |
829 | 829 |
830 private: | 830 private: |
831 virtual ~MockLayerChromium() | 831 virtual ~MockLayer() |
832 { | 832 { |
833 } | 833 } |
834 }; | 834 }; |
835 | 835 |
836 TEST(LayerChromiumTestWithoutFixture, setBoundsTriggersSetNeedsRedrawAfterGettin
gNonEmptyBounds) | 836 TEST(LayerTestWithoutFixture, setBoundsTriggersSetNeedsRedrawAfterGettingNonEmpt
yBounds) |
837 { | 837 { |
838 scoped_refptr<MockLayerChromium> layer(new MockLayerChromium); | 838 scoped_refptr<MockLayer> layer(new MockLayer); |
839 EXPECT_FALSE(layer->needsDisplay()); | 839 EXPECT_FALSE(layer->needsDisplay()); |
840 layer->setBounds(IntSize(0, 10)); | 840 layer->setBounds(IntSize(0, 10)); |
841 EXPECT_FALSE(layer->needsDisplay()); | 841 EXPECT_FALSE(layer->needsDisplay()); |
842 layer->setBounds(IntSize(10, 10)); | 842 layer->setBounds(IntSize(10, 10)); |
843 EXPECT_TRUE(layer->needsDisplay()); | 843 EXPECT_TRUE(layer->needsDisplay()); |
844 } | 844 } |
845 | 845 |
846 | 846 |
847 } // namespace | 847 } // namespace |
OLD | NEW |