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/layers/layer.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include "base/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.h" |
8 #include "cc/animation/keyframed_animation_curve.h" | 8 #include "cc/animation/keyframed_animation_curve.h" |
9 #include "cc/base/math_util.h" | 9 #include "cc/base/math_util.h" |
10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 EXPECT_EQ(child1_.get(), grand_child2_->parent()); | 108 EXPECT_EQ(child1_.get(), grand_child2_->parent()); |
109 | 109 |
110 ASSERT_EQ(1U, child2_->children().size()); | 110 ASSERT_EQ(1U, child2_->children().size()); |
111 EXPECT_EQ(grand_child3_, child2_->children()[0]); | 111 EXPECT_EQ(grand_child3_, child2_->children()[0]); |
112 EXPECT_EQ(child2_.get(), grand_child3_->parent()); | 112 EXPECT_EQ(child2_.get(), grand_child3_->parent()); |
113 | 113 |
114 ASSERT_EQ(0U, child3_->children().size()); | 114 ASSERT_EQ(0U, child3_->children().size()); |
115 } | 115 } |
116 | 116 |
117 void CreateSimpleTestTree() { | 117 void CreateSimpleTestTree() { |
118 parent_ = Layer::Create(); | 118 parent_ = Layer::Create(layer_settings_); |
119 child1_ = Layer::Create(); | 119 child1_ = Layer::Create(layer_settings_); |
120 child2_ = Layer::Create(); | 120 child2_ = Layer::Create(layer_settings_); |
121 child3_ = Layer::Create(); | 121 child3_ = Layer::Create(layer_settings_); |
122 grand_child1_ = Layer::Create(); | 122 grand_child1_ = Layer::Create(layer_settings_); |
123 grand_child2_ = Layer::Create(); | 123 grand_child2_ = Layer::Create(layer_settings_); |
124 grand_child3_ = Layer::Create(); | 124 grand_child3_ = Layer::Create(layer_settings_); |
125 | 125 |
126 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber()); | 126 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber()); |
127 layer_tree_host_->SetRootLayer(parent_); | 127 layer_tree_host_->SetRootLayer(parent_); |
128 | 128 |
129 parent_->AddChild(child1_); | 129 parent_->AddChild(child1_); |
130 parent_->AddChild(child2_); | 130 parent_->AddChild(child2_); |
131 parent_->AddChild(child3_); | 131 parent_->AddChild(child3_); |
132 child1_->AddChild(grand_child1_); | 132 child1_->AddChild(grand_child1_); |
133 child1_->AddChild(grand_child2_); | 133 child1_->AddChild(grand_child2_); |
134 child2_->AddChild(grand_child3_); | 134 child2_->AddChild(grand_child3_); |
(...skipping 10 matching lines...) Expand all Loading... |
145 | 145 |
146 FakeLayerTreeHostClient fake_client_; | 146 FakeLayerTreeHostClient fake_client_; |
147 scoped_ptr<StrictMock<MockLayerTreeHost>> layer_tree_host_; | 147 scoped_ptr<StrictMock<MockLayerTreeHost>> layer_tree_host_; |
148 scoped_refptr<Layer> parent_; | 148 scoped_refptr<Layer> parent_; |
149 scoped_refptr<Layer> child1_; | 149 scoped_refptr<Layer> child1_; |
150 scoped_refptr<Layer> child2_; | 150 scoped_refptr<Layer> child2_; |
151 scoped_refptr<Layer> child3_; | 151 scoped_refptr<Layer> child3_; |
152 scoped_refptr<Layer> grand_child1_; | 152 scoped_refptr<Layer> grand_child1_; |
153 scoped_refptr<Layer> grand_child2_; | 153 scoped_refptr<Layer> grand_child2_; |
154 scoped_refptr<Layer> grand_child3_; | 154 scoped_refptr<Layer> grand_child3_; |
| 155 |
| 156 LayerSettings layer_settings_; |
155 }; | 157 }; |
156 | 158 |
157 TEST_F(LayerTest, BasicCreateAndDestroy) { | 159 TEST_F(LayerTest, BasicCreateAndDestroy) { |
158 scoped_refptr<Layer> test_layer = Layer::Create(); | 160 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_); |
159 ASSERT_TRUE(test_layer.get()); | 161 ASSERT_TRUE(test_layer.get()); |
160 | 162 |
161 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); | 163 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); |
162 test_layer->SetLayerTreeHost(layer_tree_host_.get()); | 164 test_layer->SetLayerTreeHost(layer_tree_host_.get()); |
163 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 165 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
164 | 166 |
165 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); | 167 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0); |
166 test_layer->SetLayerTreeHost(nullptr); | 168 test_layer->SetLayerTreeHost(nullptr); |
167 } | 169 } |
168 | 170 |
169 TEST_F(LayerTest, AddAndRemoveChild) { | 171 TEST_F(LayerTest, AddAndRemoveChild) { |
170 scoped_refptr<Layer> parent = Layer::Create(); | 172 scoped_refptr<Layer> parent = Layer::Create(layer_settings_); |
171 scoped_refptr<Layer> child = Layer::Create(); | 173 scoped_refptr<Layer> child = Layer::Create(layer_settings_); |
172 | 174 |
173 // Upon creation, layers should not have children or parent. | 175 // Upon creation, layers should not have children or parent. |
174 ASSERT_EQ(0U, parent->children().size()); | 176 ASSERT_EQ(0U, parent->children().size()); |
175 EXPECT_FALSE(child->parent()); | 177 EXPECT_FALSE(child->parent()); |
176 | 178 |
177 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); | 179 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); |
178 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->AddChild(child)); | 180 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->AddChild(child)); |
179 | 181 |
180 ASSERT_EQ(1U, parent->children().size()); | 182 ASSERT_EQ(1U, parent->children().size()); |
181 EXPECT_EQ(child.get(), parent->children()[0].get()); | 183 EXPECT_EQ(child.get(), parent->children()[0].get()); |
182 EXPECT_EQ(parent.get(), child->parent()); | 184 EXPECT_EQ(parent.get(), child->parent()); |
183 EXPECT_EQ(parent.get(), child->RootLayer()); | 185 EXPECT_EQ(parent.get(), child->RootLayer()); |
184 | 186 |
185 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(1), child->RemoveFromParent()); | 187 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(1), child->RemoveFromParent()); |
186 } | 188 } |
187 | 189 |
188 TEST_F(LayerTest, AddSameChildTwice) { | 190 TEST_F(LayerTest, AddSameChildTwice) { |
189 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AtLeast(1)); | 191 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AtLeast(1)); |
190 | 192 |
191 scoped_refptr<Layer> parent = Layer::Create(); | 193 scoped_refptr<Layer> parent = Layer::Create(layer_settings_); |
192 scoped_refptr<Layer> child = Layer::Create(); | 194 scoped_refptr<Layer> child = Layer::Create(layer_settings_); |
193 | 195 |
194 layer_tree_host_->SetRootLayer(parent); | 196 layer_tree_host_->SetRootLayer(parent); |
195 | 197 |
196 ASSERT_EQ(0u, parent->children().size()); | 198 ASSERT_EQ(0u, parent->children().size()); |
197 | 199 |
198 parent->AddChild(child); | 200 parent->AddChild(child); |
199 ASSERT_EQ(1u, parent->children().size()); | 201 ASSERT_EQ(1u, parent->children().size()); |
200 EXPECT_EQ(parent.get(), child->parent()); | 202 EXPECT_EQ(parent.get(), child->parent()); |
201 | 203 |
202 parent->AddChild(child); | 204 parent->AddChild(child); |
203 ASSERT_EQ(1u, parent->children().size()); | 205 ASSERT_EQ(1u, parent->children().size()); |
204 EXPECT_EQ(parent.get(), child->parent()); | 206 EXPECT_EQ(parent.get(), child->parent()); |
205 } | 207 } |
206 | 208 |
207 TEST_F(LayerTest, InsertChild) { | 209 TEST_F(LayerTest, InsertChild) { |
208 scoped_refptr<Layer> parent = Layer::Create(); | 210 scoped_refptr<Layer> parent = Layer::Create(layer_settings_); |
209 scoped_refptr<Layer> child1 = Layer::Create(); | 211 scoped_refptr<Layer> child1 = Layer::Create(layer_settings_); |
210 scoped_refptr<Layer> child2 = Layer::Create(); | 212 scoped_refptr<Layer> child2 = Layer::Create(layer_settings_); |
211 scoped_refptr<Layer> child3 = Layer::Create(); | 213 scoped_refptr<Layer> child3 = Layer::Create(layer_settings_); |
212 scoped_refptr<Layer> child4 = Layer::Create(); | 214 scoped_refptr<Layer> child4 = Layer::Create(layer_settings_); |
213 | 215 |
214 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); | 216 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); |
215 | 217 |
216 ASSERT_EQ(0U, parent->children().size()); | 218 ASSERT_EQ(0U, parent->children().size()); |
217 | 219 |
218 // Case 1: inserting to empty list. | 220 // Case 1: inserting to empty list. |
219 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child3, 0)); | 221 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child3, 0)); |
220 ASSERT_EQ(1U, parent->children().size()); | 222 ASSERT_EQ(1U, parent->children().size()); |
221 EXPECT_EQ(child3, parent->children()[0]); | 223 EXPECT_EQ(child3, parent->children()[0]); |
222 EXPECT_EQ(parent.get(), child3->parent()); | 224 EXPECT_EQ(parent.get(), child3->parent()); |
(...skipping 20 matching lines...) Expand all Loading... |
243 EXPECT_EQ(child1, parent->children()[0]); | 245 EXPECT_EQ(child1, parent->children()[0]); |
244 EXPECT_EQ(child2, parent->children()[1]); | 246 EXPECT_EQ(child2, parent->children()[1]); |
245 EXPECT_EQ(child3, parent->children()[2]); | 247 EXPECT_EQ(child3, parent->children()[2]); |
246 EXPECT_EQ(child4, parent->children()[3]); | 248 EXPECT_EQ(child4, parent->children()[3]); |
247 EXPECT_EQ(parent.get(), child4->parent()); | 249 EXPECT_EQ(parent.get(), child4->parent()); |
248 | 250 |
249 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); | 251 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); |
250 } | 252 } |
251 | 253 |
252 TEST_F(LayerTest, InsertChildPastEndOfList) { | 254 TEST_F(LayerTest, InsertChildPastEndOfList) { |
253 scoped_refptr<Layer> parent = Layer::Create(); | 255 scoped_refptr<Layer> parent = Layer::Create(layer_settings_); |
254 scoped_refptr<Layer> child1 = Layer::Create(); | 256 scoped_refptr<Layer> child1 = Layer::Create(layer_settings_); |
255 scoped_refptr<Layer> child2 = Layer::Create(); | 257 scoped_refptr<Layer> child2 = Layer::Create(layer_settings_); |
256 | 258 |
257 ASSERT_EQ(0U, parent->children().size()); | 259 ASSERT_EQ(0U, parent->children().size()); |
258 | 260 |
259 // insert to an out-of-bounds index | 261 // insert to an out-of-bounds index |
260 parent->InsertChild(child1, 53); | 262 parent->InsertChild(child1, 53); |
261 | 263 |
262 ASSERT_EQ(1U, parent->children().size()); | 264 ASSERT_EQ(1U, parent->children().size()); |
263 EXPECT_EQ(child1, parent->children()[0]); | 265 EXPECT_EQ(child1, parent->children()[0]); |
264 | 266 |
265 // insert another child to out-of-bounds, when list is not already empty. | 267 // insert another child to out-of-bounds, when list is not already empty. |
266 parent->InsertChild(child2, 2459); | 268 parent->InsertChild(child2, 2459); |
267 | 269 |
268 ASSERT_EQ(2U, parent->children().size()); | 270 ASSERT_EQ(2U, parent->children().size()); |
269 EXPECT_EQ(child1, parent->children()[0]); | 271 EXPECT_EQ(child1, parent->children()[0]); |
270 EXPECT_EQ(child2, parent->children()[1]); | 272 EXPECT_EQ(child2, parent->children()[1]); |
271 } | 273 } |
272 | 274 |
273 TEST_F(LayerTest, InsertSameChildTwice) { | 275 TEST_F(LayerTest, InsertSameChildTwice) { |
274 scoped_refptr<Layer> parent = Layer::Create(); | 276 scoped_refptr<Layer> parent = Layer::Create(layer_settings_); |
275 scoped_refptr<Layer> child1 = Layer::Create(); | 277 scoped_refptr<Layer> child1 = Layer::Create(layer_settings_); |
276 scoped_refptr<Layer> child2 = Layer::Create(); | 278 scoped_refptr<Layer> child2 = Layer::Create(layer_settings_); |
277 | 279 |
278 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); | 280 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); |
279 | 281 |
280 ASSERT_EQ(0U, parent->children().size()); | 282 ASSERT_EQ(0U, parent->children().size()); |
281 | 283 |
282 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); | 284 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); |
283 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); | 285 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); |
284 | 286 |
285 ASSERT_EQ(2U, parent->children().size()); | 287 ASSERT_EQ(2U, parent->children().size()); |
286 EXPECT_EQ(child1, parent->children()[0]); | 288 EXPECT_EQ(child1, parent->children()[0]); |
287 EXPECT_EQ(child2, parent->children()[1]); | 289 EXPECT_EQ(child2, parent->children()[1]); |
288 | 290 |
289 // Inserting the same child again should cause the child to be removed and | 291 // Inserting the same child again should cause the child to be removed and |
290 // re-inserted at the new location. | 292 // re-inserted at the new location. |
291 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(1), parent->InsertChild(child1, 1)); | 293 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(1), parent->InsertChild(child1, 1)); |
292 | 294 |
293 // child1 should now be at the end of the list. | 295 // child1 should now be at the end of the list. |
294 ASSERT_EQ(2U, parent->children().size()); | 296 ASSERT_EQ(2U, parent->children().size()); |
295 EXPECT_EQ(child2, parent->children()[0]); | 297 EXPECT_EQ(child2, parent->children()[0]); |
296 EXPECT_EQ(child1, parent->children()[1]); | 298 EXPECT_EQ(child1, parent->children()[1]); |
297 | 299 |
298 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); | 300 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); |
299 } | 301 } |
300 | 302 |
301 TEST_F(LayerTest, ReplaceChildWithNewChild) { | 303 TEST_F(LayerTest, ReplaceChildWithNewChild) { |
302 CreateSimpleTestTree(); | 304 CreateSimpleTestTree(); |
303 scoped_refptr<Layer> child4 = Layer::Create(); | 305 scoped_refptr<Layer> child4 = Layer::Create(layer_settings_); |
304 | 306 |
305 EXPECT_FALSE(child4->parent()); | 307 EXPECT_FALSE(child4->parent()); |
306 | 308 |
307 EXPECT_SET_NEEDS_FULL_TREE_SYNC( | 309 EXPECT_SET_NEEDS_FULL_TREE_SYNC( |
308 AtLeast(1), parent_->ReplaceChild(child2_.get(), child4)); | 310 AtLeast(1), parent_->ReplaceChild(child2_.get(), child4)); |
309 EXPECT_FALSE(parent_->NeedsDisplayForTesting()); | 311 EXPECT_FALSE(parent_->NeedsDisplayForTesting()); |
310 EXPECT_FALSE(child1_->NeedsDisplayForTesting()); | 312 EXPECT_FALSE(child1_->NeedsDisplayForTesting()); |
311 EXPECT_FALSE(child2_->NeedsDisplayForTesting()); | 313 EXPECT_FALSE(child2_->NeedsDisplayForTesting()); |
312 EXPECT_FALSE(child3_->NeedsDisplayForTesting()); | 314 EXPECT_FALSE(child3_->NeedsDisplayForTesting()); |
313 EXPECT_FALSE(child4->NeedsDisplayForTesting()); | 315 EXPECT_FALSE(child4->NeedsDisplayForTesting()); |
314 | 316 |
315 ASSERT_EQ(static_cast<size_t>(3), parent_->children().size()); | 317 ASSERT_EQ(static_cast<size_t>(3), parent_->children().size()); |
316 EXPECT_EQ(child1_, parent_->children()[0]); | 318 EXPECT_EQ(child1_, parent_->children()[0]); |
317 EXPECT_EQ(child4, parent_->children()[1]); | 319 EXPECT_EQ(child4, parent_->children()[1]); |
318 EXPECT_EQ(child3_, parent_->children()[2]); | 320 EXPECT_EQ(child3_, parent_->children()[2]); |
319 EXPECT_EQ(parent_.get(), child4->parent()); | 321 EXPECT_EQ(parent_.get(), child4->parent()); |
320 | 322 |
321 EXPECT_FALSE(child2_->parent()); | 323 EXPECT_FALSE(child2_->parent()); |
322 } | 324 } |
323 | 325 |
324 TEST_F(LayerTest, ReplaceChildWithNewChildThatHasOtherParent) { | 326 TEST_F(LayerTest, ReplaceChildWithNewChildThatHasOtherParent) { |
325 CreateSimpleTestTree(); | 327 CreateSimpleTestTree(); |
326 | 328 |
327 // create another simple tree with test_layer and child4. | 329 // create another simple tree with test_layer and child4. |
328 scoped_refptr<Layer> test_layer = Layer::Create(); | 330 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_); |
329 scoped_refptr<Layer> child4 = Layer::Create(); | 331 scoped_refptr<Layer> child4 = Layer::Create(layer_settings_); |
330 test_layer->AddChild(child4); | 332 test_layer->AddChild(child4); |
331 ASSERT_EQ(1U, test_layer->children().size()); | 333 ASSERT_EQ(1U, test_layer->children().size()); |
332 EXPECT_EQ(child4, test_layer->children()[0]); | 334 EXPECT_EQ(child4, test_layer->children()[0]); |
333 EXPECT_EQ(test_layer.get(), child4->parent()); | 335 EXPECT_EQ(test_layer.get(), child4->parent()); |
334 | 336 |
335 EXPECT_SET_NEEDS_FULL_TREE_SYNC( | 337 EXPECT_SET_NEEDS_FULL_TREE_SYNC( |
336 AtLeast(1), parent_->ReplaceChild(child2_.get(), child4)); | 338 AtLeast(1), parent_->ReplaceChild(child2_.get(), child4)); |
337 | 339 |
338 ASSERT_EQ(3U, parent_->children().size()); | 340 ASSERT_EQ(3U, parent_->children().size()); |
339 EXPECT_EQ(child1_, parent_->children()[0]); | 341 EXPECT_EQ(child1_, parent_->children()[0]); |
340 EXPECT_EQ(child4, parent_->children()[1]); | 342 EXPECT_EQ(child4, parent_->children()[1]); |
341 EXPECT_EQ(child3_, parent_->children()[2]); | 343 EXPECT_EQ(child3_, parent_->children()[2]); |
342 EXPECT_EQ(parent_.get(), child4->parent()); | 344 EXPECT_EQ(parent_.get(), child4->parent()); |
343 | 345 |
344 // test_layer should no longer have child4, | 346 // test_layer should no longer have child4, |
345 // and child2 should no longer have a parent. | 347 // and child2 should no longer have a parent. |
346 ASSERT_EQ(0U, test_layer->children().size()); | 348 ASSERT_EQ(0U, test_layer->children().size()); |
347 EXPECT_FALSE(child2_->parent()); | 349 EXPECT_FALSE(child2_->parent()); |
348 } | 350 } |
349 | 351 |
350 TEST_F(LayerTest, DeleteRemovedScrollParent) { | 352 TEST_F(LayerTest, DeleteRemovedScrollParent) { |
351 scoped_refptr<Layer> parent = Layer::Create(); | 353 scoped_refptr<Layer> parent = Layer::Create(layer_settings_); |
352 scoped_refptr<Layer> child1 = Layer::Create(); | 354 scoped_refptr<Layer> child1 = Layer::Create(layer_settings_); |
353 scoped_refptr<Layer> child2 = Layer::Create(); | 355 scoped_refptr<Layer> child2 = Layer::Create(layer_settings_); |
354 | 356 |
355 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); | 357 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); |
356 | 358 |
357 ASSERT_EQ(0U, parent->children().size()); | 359 ASSERT_EQ(0U, parent->children().size()); |
358 | 360 |
359 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); | 361 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); |
360 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); | 362 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); |
361 | 363 |
362 ASSERT_EQ(2U, parent->children().size()); | 364 ASSERT_EQ(2U, parent->children().size()); |
363 EXPECT_EQ(child1, parent->children()[0]); | 365 EXPECT_EQ(child1, parent->children()[0]); |
364 EXPECT_EQ(child2, parent->children()[1]); | 366 EXPECT_EQ(child2, parent->children()[1]); |
365 | 367 |
366 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); | 368 EXPECT_SET_NEEDS_COMMIT(2, child1->SetScrollParent(child2.get())); |
367 | 369 |
368 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child2->RemoveFromParent()); | 370 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, child2->RemoveFromParent()); |
369 | 371 |
370 child1->reset_needs_push_properties_for_testing(); | 372 child1->reset_needs_push_properties_for_testing(); |
371 | 373 |
372 EXPECT_SET_NEEDS_COMMIT(1, child2 = nullptr); | 374 EXPECT_SET_NEEDS_COMMIT(1, child2 = nullptr); |
373 | 375 |
374 EXPECT_TRUE(child1->needs_push_properties()); | 376 EXPECT_TRUE(child1->needs_push_properties()); |
375 | 377 |
376 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); | 378 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); |
377 } | 379 } |
378 | 380 |
379 TEST_F(LayerTest, DeleteRemovedScrollChild) { | 381 TEST_F(LayerTest, DeleteRemovedScrollChild) { |
380 scoped_refptr<Layer> parent = Layer::Create(); | 382 scoped_refptr<Layer> parent = Layer::Create(layer_settings_); |
381 scoped_refptr<Layer> child1 = Layer::Create(); | 383 scoped_refptr<Layer> child1 = Layer::Create(layer_settings_); |
382 scoped_refptr<Layer> child2 = Layer::Create(); | 384 scoped_refptr<Layer> child2 = Layer::Create(layer_settings_); |
383 | 385 |
384 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); | 386 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent)); |
385 | 387 |
386 ASSERT_EQ(0U, parent->children().size()); | 388 ASSERT_EQ(0U, parent->children().size()); |
387 | 389 |
388 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); | 390 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child1, 0)); |
389 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); | 391 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->InsertChild(child2, 1)); |
390 | 392 |
391 ASSERT_EQ(2U, parent->children().size()); | 393 ASSERT_EQ(2U, parent->children().size()); |
392 EXPECT_EQ(child1, parent->children()[0]); | 394 EXPECT_EQ(child1, parent->children()[0]); |
(...skipping 29 matching lines...) Expand all Loading... |
422 | 424 |
423 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(3), parent_->RemoveAllChildren()); | 425 EXPECT_SET_NEEDS_FULL_TREE_SYNC(AtLeast(3), parent_->RemoveAllChildren()); |
424 | 426 |
425 ASSERT_EQ(0U, parent_->children().size()); | 427 ASSERT_EQ(0U, parent_->children().size()); |
426 EXPECT_FALSE(child1_->parent()); | 428 EXPECT_FALSE(child1_->parent()); |
427 EXPECT_FALSE(child2_->parent()); | 429 EXPECT_FALSE(child2_->parent()); |
428 EXPECT_FALSE(child3_->parent()); | 430 EXPECT_FALSE(child3_->parent()); |
429 } | 431 } |
430 | 432 |
431 TEST_F(LayerTest, SetChildren) { | 433 TEST_F(LayerTest, SetChildren) { |
432 scoped_refptr<Layer> old_parent = Layer::Create(); | 434 scoped_refptr<Layer> old_parent = Layer::Create(layer_settings_); |
433 scoped_refptr<Layer> new_parent = Layer::Create(); | 435 scoped_refptr<Layer> new_parent = Layer::Create(layer_settings_); |
434 | 436 |
435 scoped_refptr<Layer> child1 = Layer::Create(); | 437 scoped_refptr<Layer> child1 = Layer::Create(layer_settings_); |
436 scoped_refptr<Layer> child2 = Layer::Create(); | 438 scoped_refptr<Layer> child2 = Layer::Create(layer_settings_); |
437 | 439 |
438 LayerList new_children; | 440 LayerList new_children; |
439 new_children.push_back(child1); | 441 new_children.push_back(child1); |
440 new_children.push_back(child2); | 442 new_children.push_back(child2); |
441 | 443 |
442 // Set up and verify initial test conditions: child1 has a parent, child2 has | 444 // Set up and verify initial test conditions: child1 has a parent, child2 has |
443 // no parent. | 445 // no parent. |
444 old_parent->AddChild(child1); | 446 old_parent->AddChild(child1); |
445 ASSERT_EQ(0U, new_parent->children().size()); | 447 ASSERT_EQ(0U, new_parent->children().size()); |
446 EXPECT_EQ(old_parent.get(), child1->parent()); | 448 EXPECT_EQ(old_parent.get(), child1->parent()); |
447 EXPECT_FALSE(child2->parent()); | 449 EXPECT_FALSE(child2->parent()); |
448 | 450 |
449 EXPECT_SET_NEEDS_FULL_TREE_SYNC( | 451 EXPECT_SET_NEEDS_FULL_TREE_SYNC( |
450 1, layer_tree_host_->SetRootLayer(new_parent)); | 452 1, layer_tree_host_->SetRootLayer(new_parent)); |
451 | 453 |
452 EXPECT_SET_NEEDS_FULL_TREE_SYNC( | 454 EXPECT_SET_NEEDS_FULL_TREE_SYNC( |
453 AtLeast(1), new_parent->SetChildren(new_children)); | 455 AtLeast(1), new_parent->SetChildren(new_children)); |
454 | 456 |
455 ASSERT_EQ(2U, new_parent->children().size()); | 457 ASSERT_EQ(2U, new_parent->children().size()); |
456 EXPECT_EQ(new_parent.get(), child1->parent()); | 458 EXPECT_EQ(new_parent.get(), child1->parent()); |
457 EXPECT_EQ(new_parent.get(), child2->parent()); | 459 EXPECT_EQ(new_parent.get(), child2->parent()); |
458 | 460 |
459 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); | 461 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr)); |
460 } | 462 } |
461 | 463 |
462 TEST_F(LayerTest, HasAncestor) { | 464 TEST_F(LayerTest, HasAncestor) { |
463 scoped_refptr<Layer> parent = Layer::Create(); | 465 scoped_refptr<Layer> parent = Layer::Create(layer_settings_); |
464 EXPECT_FALSE(parent->HasAncestor(parent.get())); | 466 EXPECT_FALSE(parent->HasAncestor(parent.get())); |
465 | 467 |
466 scoped_refptr<Layer> child = Layer::Create(); | 468 scoped_refptr<Layer> child = Layer::Create(layer_settings_); |
467 parent->AddChild(child); | 469 parent->AddChild(child); |
468 | 470 |
469 EXPECT_FALSE(child->HasAncestor(child.get())); | 471 EXPECT_FALSE(child->HasAncestor(child.get())); |
470 EXPECT_TRUE(child->HasAncestor(parent.get())); | 472 EXPECT_TRUE(child->HasAncestor(parent.get())); |
471 EXPECT_FALSE(parent->HasAncestor(child.get())); | 473 EXPECT_FALSE(parent->HasAncestor(child.get())); |
472 | 474 |
473 scoped_refptr<Layer> child_child = Layer::Create(); | 475 scoped_refptr<Layer> child_child = Layer::Create(layer_settings_); |
474 child->AddChild(child_child); | 476 child->AddChild(child_child); |
475 | 477 |
476 EXPECT_FALSE(child_child->HasAncestor(child_child.get())); | 478 EXPECT_FALSE(child_child->HasAncestor(child_child.get())); |
477 EXPECT_TRUE(child_child->HasAncestor(parent.get())); | 479 EXPECT_TRUE(child_child->HasAncestor(parent.get())); |
478 EXPECT_TRUE(child_child->HasAncestor(child.get())); | 480 EXPECT_TRUE(child_child->HasAncestor(child.get())); |
479 EXPECT_FALSE(parent->HasAncestor(child.get())); | 481 EXPECT_FALSE(parent->HasAncestor(child.get())); |
480 EXPECT_FALSE(parent->HasAncestor(child_child.get())); | 482 EXPECT_FALSE(parent->HasAncestor(child_child.get())); |
481 } | 483 } |
482 | 484 |
483 TEST_F(LayerTest, GetRootLayerAfterTreeManipulations) { | 485 TEST_F(LayerTest, GetRootLayerAfterTreeManipulations) { |
484 CreateSimpleTestTree(); | 486 CreateSimpleTestTree(); |
485 | 487 |
486 // For this test we don't care about SetNeedsFullTreeSync calls. | 488 // For this test we don't care about SetNeedsFullTreeSync calls. |
487 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber()); | 489 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber()); |
488 | 490 |
489 scoped_refptr<Layer> child4 = Layer::Create(); | 491 scoped_refptr<Layer> child4 = Layer::Create(layer_settings_); |
490 | 492 |
491 EXPECT_EQ(parent_.get(), parent_->RootLayer()); | 493 EXPECT_EQ(parent_.get(), parent_->RootLayer()); |
492 EXPECT_EQ(parent_.get(), child1_->RootLayer()); | 494 EXPECT_EQ(parent_.get(), child1_->RootLayer()); |
493 EXPECT_EQ(parent_.get(), child2_->RootLayer()); | 495 EXPECT_EQ(parent_.get(), child2_->RootLayer()); |
494 EXPECT_EQ(parent_.get(), child3_->RootLayer()); | 496 EXPECT_EQ(parent_.get(), child3_->RootLayer()); |
495 EXPECT_EQ(child4.get(), child4->RootLayer()); | 497 EXPECT_EQ(child4.get(), child4->RootLayer()); |
496 EXPECT_EQ(parent_.get(), grand_child1_->RootLayer()); | 498 EXPECT_EQ(parent_.get(), grand_child1_->RootLayer()); |
497 EXPECT_EQ(parent_.get(), grand_child2_->RootLayer()); | 499 EXPECT_EQ(parent_.get(), grand_child2_->RootLayer()); |
498 EXPECT_EQ(parent_.get(), grand_child3_->RootLayer()); | 500 EXPECT_EQ(parent_.get(), grand_child3_->RootLayer()); |
499 | 501 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 EXPECT_EQ(parent_.get(), grand_child2_->RootLayer()); | 536 EXPECT_EQ(parent_.get(), grand_child2_->RootLayer()); |
535 EXPECT_EQ(grand_child3_.get(), grand_child3_->RootLayer()); | 537 EXPECT_EQ(grand_child3_.get(), grand_child3_->RootLayer()); |
536 } | 538 } |
537 | 539 |
538 TEST_F(LayerTest, CheckSetNeedsDisplayCausesCorrectBehavior) { | 540 TEST_F(LayerTest, CheckSetNeedsDisplayCausesCorrectBehavior) { |
539 // The semantics for SetNeedsDisplay which are tested here: | 541 // The semantics for SetNeedsDisplay which are tested here: |
540 // 1. sets NeedsDisplay flag appropriately. | 542 // 1. sets NeedsDisplay flag appropriately. |
541 // 2. indirectly calls SetNeedsUpdate, exactly once for each call to | 543 // 2. indirectly calls SetNeedsUpdate, exactly once for each call to |
542 // SetNeedsDisplay. | 544 // SetNeedsDisplay. |
543 | 545 |
544 scoped_refptr<Layer> test_layer = Layer::Create(); | 546 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_); |
545 EXPECT_SET_NEEDS_FULL_TREE_SYNC( | 547 EXPECT_SET_NEEDS_FULL_TREE_SYNC( |
546 1, layer_tree_host_->SetRootLayer(test_layer)); | 548 1, layer_tree_host_->SetRootLayer(test_layer)); |
547 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); | 549 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); |
548 | 550 |
549 gfx::Size test_bounds = gfx::Size(501, 508); | 551 gfx::Size test_bounds = gfx::Size(501, 508); |
550 | 552 |
551 gfx::Rect dirty1 = gfx::Rect(10, 15, 1, 2); | 553 gfx::Rect dirty1 = gfx::Rect(10, 15, 1, 2); |
552 gfx::Rect dirty2 = gfx::Rect(20, 25, 3, 4); | 554 gfx::Rect dirty2 = gfx::Rect(20, 25, 3, 4); |
553 gfx::Rect out_of_bounds_dirty_rect = gfx::Rect(400, 405, 500, 502); | 555 gfx::Rect out_of_bounds_dirty_rect = gfx::Rect(400, 405, 500, 502); |
554 | 556 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 | 589 |
588 // Case 4: SetNeedsDisplay() with a non-drawable layer | 590 // Case 4: SetNeedsDisplay() with a non-drawable layer |
589 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(false)); | 591 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(false)); |
590 test_layer->ResetNeedsDisplayForTesting(); | 592 test_layer->ResetNeedsDisplayForTesting(); |
591 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 593 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
592 EXPECT_SET_NEEDS_UPDATE(0, test_layer->SetNeedsDisplayRect(dirty1)); | 594 EXPECT_SET_NEEDS_UPDATE(0, test_layer->SetNeedsDisplayRect(dirty1)); |
593 EXPECT_TRUE(test_layer->NeedsDisplayForTesting()); | 595 EXPECT_TRUE(test_layer->NeedsDisplayForTesting()); |
594 } | 596 } |
595 | 597 |
596 TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) { | 598 TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) { |
597 scoped_refptr<Layer> test_layer = Layer::Create(); | 599 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_); |
598 EXPECT_SET_NEEDS_FULL_TREE_SYNC( | 600 EXPECT_SET_NEEDS_FULL_TREE_SYNC( |
599 1, layer_tree_host_->SetRootLayer(test_layer)); | 601 1, layer_tree_host_->SetRootLayer(test_layer)); |
600 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); | 602 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true)); |
601 | 603 |
602 scoped_refptr<Layer> dummy_layer1 = Layer::Create(); | 604 scoped_refptr<Layer> dummy_layer1 = Layer::Create(layer_settings_); |
603 scoped_refptr<Layer> dummy_layer2 = Layer::Create(); | 605 scoped_refptr<Layer> dummy_layer2 = Layer::Create(layer_settings_); |
604 | 606 |
605 // sanity check of initial test condition | 607 // sanity check of initial test condition |
606 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 608 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
607 | 609 |
608 // Next, test properties that should call SetNeedsCommit (but not | 610 // Next, test properties that should call SetNeedsCommit (but not |
609 // SetNeedsDisplay). All properties need to be set to new values in order for | 611 // SetNeedsDisplay). All properties need to be set to new values in order for |
610 // SetNeedsCommit to be called. | 612 // SetNeedsCommit to be called. |
611 EXPECT_SET_NEEDS_COMMIT( | 613 EXPECT_SET_NEEDS_COMMIT( |
612 1, test_layer->SetTransformOrigin(gfx::Point3F(1.23f, 4.56f, 0.f))); | 614 1, test_layer->SetTransformOrigin(gfx::Point3F(1.23f, 4.56f, 0.f))); |
613 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBackgroundColor(SK_ColorLTGRAY)); | 615 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetBackgroundColor(SK_ColorLTGRAY)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 dummy_layer2.get())); | 648 dummy_layer2.get())); |
647 | 649 |
648 // The above tests should not have caused a change to the needs_display flag. | 650 // The above tests should not have caused a change to the needs_display flag. |
649 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); | 651 EXPECT_FALSE(test_layer->NeedsDisplayForTesting()); |
650 | 652 |
651 // As layers are removed from the tree, they will cause a tree sync. | 653 // As layers are removed from the tree, they will cause a tree sync. |
652 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times((AnyNumber())); | 654 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times((AnyNumber())); |
653 } | 655 } |
654 | 656 |
655 TEST_F(LayerTest, PushPropertiesAccumulatesUpdateRect) { | 657 TEST_F(LayerTest, PushPropertiesAccumulatesUpdateRect) { |
656 scoped_refptr<Layer> test_layer = Layer::Create(); | 658 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_); |
657 scoped_ptr<LayerImpl> impl_layer = | 659 scoped_ptr<LayerImpl> impl_layer = |
658 LayerImpl::Create(host_impl_.active_tree(), 1); | 660 LayerImpl::Create(host_impl_.active_tree(), 1); |
659 | 661 |
660 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, | 662 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
661 layer_tree_host_->SetRootLayer(test_layer)); | 663 layer_tree_host_->SetRootLayer(test_layer)); |
662 | 664 |
663 test_layer->SetNeedsDisplayRect(gfx::Rect(5, 5)); | 665 test_layer->SetNeedsDisplayRect(gfx::Rect(5, 5)); |
664 test_layer->PushPropertiesTo(impl_layer.get()); | 666 test_layer->PushPropertiesTo(impl_layer.get()); |
665 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 5.f, 5.f), | 667 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 5.f, 5.f), |
666 impl_layer->update_rect()); | 668 impl_layer->update_rect()); |
667 | 669 |
668 // The LayerImpl's update_rect() should be accumulated here, since we did not | 670 // The LayerImpl's update_rect() should be accumulated here, since we did not |
669 // do anything to clear it. | 671 // do anything to clear it. |
670 test_layer->SetNeedsDisplayRect(gfx::Rect(10, 10, 5, 5)); | 672 test_layer->SetNeedsDisplayRect(gfx::Rect(10, 10, 5, 5)); |
671 test_layer->PushPropertiesTo(impl_layer.get()); | 673 test_layer->PushPropertiesTo(impl_layer.get()); |
672 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 15.f, 15.f), | 674 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0.f, 0.f, 15.f, 15.f), |
673 impl_layer->update_rect()); | 675 impl_layer->update_rect()); |
674 | 676 |
675 // If we do clear the LayerImpl side, then the next update_rect() should be | 677 // If we do clear the LayerImpl side, then the next update_rect() should be |
676 // fresh without accumulation. | 678 // fresh without accumulation. |
677 impl_layer->ResetAllChangeTrackingForSubtree(); | 679 impl_layer->ResetAllChangeTrackingForSubtree(); |
678 test_layer->SetNeedsDisplayRect(gfx::Rect(10, 10, 5, 5)); | 680 test_layer->SetNeedsDisplayRect(gfx::Rect(10, 10, 5, 5)); |
679 test_layer->PushPropertiesTo(impl_layer.get()); | 681 test_layer->PushPropertiesTo(impl_layer.get()); |
680 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10.f, 10.f, 5.f, 5.f), | 682 EXPECT_FLOAT_RECT_EQ(gfx::RectF(10.f, 10.f, 5.f, 5.f), |
681 impl_layer->update_rect()); | 683 impl_layer->update_rect()); |
682 } | 684 } |
683 | 685 |
684 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForTransform) { | 686 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForTransform) { |
685 scoped_refptr<Layer> test_layer = Layer::Create(); | 687 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_); |
686 scoped_ptr<LayerImpl> impl_layer = | 688 scoped_ptr<LayerImpl> impl_layer = |
687 LayerImpl::Create(host_impl_.active_tree(), 1); | 689 LayerImpl::Create(host_impl_.active_tree(), 1); |
688 | 690 |
689 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, | 691 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
690 layer_tree_host_->SetRootLayer(test_layer)); | 692 layer_tree_host_->SetRootLayer(test_layer)); |
691 | 693 |
692 gfx::Transform transform; | 694 gfx::Transform transform; |
693 transform.Rotate(45.0); | 695 transform.Rotate(45.0); |
694 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTransform(transform)); | 696 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTransform(transform)); |
695 | 697 |
696 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); | 698 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); |
697 | 699 |
698 test_layer->PushPropertiesTo(impl_layer.get()); | 700 test_layer->PushPropertiesTo(impl_layer.get()); |
699 | 701 |
700 EXPECT_TRUE(impl_layer->LayerPropertyChanged()); | 702 EXPECT_TRUE(impl_layer->LayerPropertyChanged()); |
701 } | 703 } |
702 | 704 |
703 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForOpacity) { | 705 TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForOpacity) { |
704 scoped_refptr<Layer> test_layer = Layer::Create(); | 706 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_); |
705 scoped_ptr<LayerImpl> impl_layer = | 707 scoped_ptr<LayerImpl> impl_layer = |
706 LayerImpl::Create(host_impl_.active_tree(), 1); | 708 LayerImpl::Create(host_impl_.active_tree(), 1); |
707 | 709 |
708 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, | 710 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
709 layer_tree_host_->SetRootLayer(test_layer)); | 711 layer_tree_host_->SetRootLayer(test_layer)); |
710 | 712 |
711 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetOpacity(0.5f)); | 713 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetOpacity(0.5f)); |
712 | 714 |
713 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); | 715 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); |
714 | 716 |
715 test_layer->PushPropertiesTo(impl_layer.get()); | 717 test_layer->PushPropertiesTo(impl_layer.get()); |
716 | 718 |
717 EXPECT_TRUE(impl_layer->LayerPropertyChanged()); | 719 EXPECT_TRUE(impl_layer->LayerPropertyChanged()); |
718 } | 720 } |
719 | 721 |
720 TEST_F(LayerTest, | 722 TEST_F(LayerTest, |
721 PushPropsDoesntCauseLayerPropertyChangedDuringImplOnlyTransformAnim) { | 723 PushPropsDoesntCauseLayerPropertyChangedDuringImplOnlyTransformAnim) { |
722 scoped_refptr<Layer> test_layer = Layer::Create(); | 724 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_); |
723 scoped_ptr<LayerImpl> impl_layer = | 725 scoped_ptr<LayerImpl> impl_layer = |
724 LayerImpl::Create(host_impl_.active_tree(), 1); | 726 LayerImpl::Create(host_impl_.active_tree(), 1); |
725 | 727 |
726 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, | 728 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
727 layer_tree_host_->SetRootLayer(test_layer)); | 729 layer_tree_host_->SetRootLayer(test_layer)); |
728 | 730 |
729 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::Create(); | 731 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::Create(); |
730 impl_layer->layer_animation_controller()->SetAnimationRegistrar( | 732 impl_layer->layer_animation_controller()->SetAnimationRegistrar( |
731 registrar.get()); | 733 registrar.get()); |
732 | 734 |
(...skipping 21 matching lines...) Expand all Loading... |
754 transform.Rotate(45.0); | 756 transform.Rotate(45.0); |
755 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTransform(transform)); | 757 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetTransform(transform)); |
756 | 758 |
757 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); | 759 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); |
758 test_layer->PushPropertiesTo(impl_layer.get()); | 760 test_layer->PushPropertiesTo(impl_layer.get()); |
759 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); | 761 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); |
760 } | 762 } |
761 | 763 |
762 TEST_F(LayerTest, | 764 TEST_F(LayerTest, |
763 PushPropsDoesntCauseLayerPropertyChangedDuringImplOnlyOpacityAnim) { | 765 PushPropsDoesntCauseLayerPropertyChangedDuringImplOnlyOpacityAnim) { |
764 scoped_refptr<Layer> test_layer = Layer::Create(); | 766 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_); |
765 scoped_ptr<LayerImpl> impl_layer = | 767 scoped_ptr<LayerImpl> impl_layer = |
766 LayerImpl::Create(host_impl_.active_tree(), 1); | 768 LayerImpl::Create(host_impl_.active_tree(), 1); |
767 | 769 |
768 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, | 770 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
769 layer_tree_host_->SetRootLayer(test_layer)); | 771 layer_tree_host_->SetRootLayer(test_layer)); |
770 | 772 |
771 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::Create(); | 773 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::Create(); |
772 impl_layer->layer_animation_controller()->SetAnimationRegistrar( | 774 impl_layer->layer_animation_controller()->SetAnimationRegistrar( |
773 registrar.get()); | 775 registrar.get()); |
774 | 776 |
(...skipping 20 matching lines...) Expand all Loading... |
795 ->set_is_impl_only(true); | 797 ->set_is_impl_only(true); |
796 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetOpacity(0.75f)); | 798 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetOpacity(0.75f)); |
797 | 799 |
798 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); | 800 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); |
799 test_layer->PushPropertiesTo(impl_layer.get()); | 801 test_layer->PushPropertiesTo(impl_layer.get()); |
800 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); | 802 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); |
801 } | 803 } |
802 | 804 |
803 TEST_F(LayerTest, | 805 TEST_F(LayerTest, |
804 PushPropsDoesntCauseLayerPropertyChangedDuringImplOnlyFilterAnim) { | 806 PushPropsDoesntCauseLayerPropertyChangedDuringImplOnlyFilterAnim) { |
805 scoped_refptr<Layer> test_layer = Layer::Create(); | 807 scoped_refptr<Layer> test_layer = Layer::Create(layer_settings_); |
806 scoped_ptr<LayerImpl> impl_layer = | 808 scoped_ptr<LayerImpl> impl_layer = |
807 LayerImpl::Create(host_impl_.active_tree(), 1); | 809 LayerImpl::Create(host_impl_.active_tree(), 1); |
808 | 810 |
809 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, | 811 EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, |
810 layer_tree_host_->SetRootLayer(test_layer)); | 812 layer_tree_host_->SetRootLayer(test_layer)); |
811 | 813 |
812 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::Create(); | 814 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::Create(); |
813 impl_layer->layer_animation_controller()->SetAnimationRegistrar( | 815 impl_layer->layer_animation_controller()->SetAnimationRegistrar( |
814 registrar.get()); | 816 registrar.get()); |
815 | 817 |
(...skipping 16 matching lines...) Expand all Loading... |
832 ->set_is_impl_only(true); | 834 ->set_is_impl_only(true); |
833 filters.Append(FilterOperation::CreateSepiaFilter(0.5f)); | 835 filters.Append(FilterOperation::CreateSepiaFilter(0.5f)); |
834 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFilters(filters)); | 836 EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetFilters(filters)); |
835 | 837 |
836 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); | 838 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); |
837 test_layer->PushPropertiesTo(impl_layer.get()); | 839 test_layer->PushPropertiesTo(impl_layer.get()); |
838 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); | 840 EXPECT_FALSE(impl_layer->LayerPropertyChanged()); |
839 } | 841 } |
840 | 842 |
841 TEST_F(LayerTest, MaskAndReplicaHasParent) { | 843 TEST_F(LayerTest, MaskAndReplicaHasParent) { |
842 scoped_refptr<Layer> parent = Layer::Create(); | 844 scoped_refptr<Layer> parent = Layer::Create(layer_settings_); |
843 scoped_refptr<Layer> child = Layer::Create(); | 845 scoped_refptr<Layer> child = Layer::Create(layer_settings_); |
844 scoped_refptr<Layer> mask = Layer::Create(); | 846 scoped_refptr<Layer> mask = Layer::Create(layer_settings_); |
845 scoped_refptr<Layer> replica = Layer::Create(); | 847 scoped_refptr<Layer> replica = Layer::Create(layer_settings_); |
846 scoped_refptr<Layer> replica_mask = Layer::Create(); | 848 scoped_refptr<Layer> replica_mask = Layer::Create(layer_settings_); |
847 scoped_refptr<Layer> mask_replacement = Layer::Create(); | 849 scoped_refptr<Layer> mask_replacement = Layer::Create(layer_settings_); |
848 scoped_refptr<Layer> replica_replacement = Layer::Create(); | 850 scoped_refptr<Layer> replica_replacement = Layer::Create(layer_settings_); |
849 scoped_refptr<Layer> replica_mask_replacement = Layer::Create(); | 851 scoped_refptr<Layer> replica_mask_replacement = |
| 852 Layer::Create(layer_settings_); |
850 | 853 |
851 parent->AddChild(child); | 854 parent->AddChild(child); |
852 child->SetMaskLayer(mask.get()); | 855 child->SetMaskLayer(mask.get()); |
853 child->SetReplicaLayer(replica.get()); | 856 child->SetReplicaLayer(replica.get()); |
854 replica->SetMaskLayer(replica_mask.get()); | 857 replica->SetMaskLayer(replica_mask.get()); |
855 | 858 |
856 EXPECT_EQ(parent.get(), child->parent()); | 859 EXPECT_EQ(parent.get(), child->parent()); |
857 EXPECT_EQ(child.get(), mask->parent()); | 860 EXPECT_EQ(child.get(), mask->parent()); |
858 EXPECT_EQ(child.get(), replica->parent()); | 861 EXPECT_EQ(child.get(), replica->parent()); |
859 EXPECT_EQ(replica.get(), replica_mask->parent()); | 862 EXPECT_EQ(replica.get(), replica_mask->parent()); |
860 | 863 |
861 replica->SetMaskLayer(replica_mask_replacement.get()); | 864 replica->SetMaskLayer(replica_mask_replacement.get()); |
862 EXPECT_EQ(nullptr, replica_mask->parent()); | 865 EXPECT_EQ(nullptr, replica_mask->parent()); |
863 EXPECT_EQ(replica.get(), replica_mask_replacement->parent()); | 866 EXPECT_EQ(replica.get(), replica_mask_replacement->parent()); |
864 | 867 |
865 child->SetMaskLayer(mask_replacement.get()); | 868 child->SetMaskLayer(mask_replacement.get()); |
866 EXPECT_EQ(nullptr, mask->parent()); | 869 EXPECT_EQ(nullptr, mask->parent()); |
867 EXPECT_EQ(child.get(), mask_replacement->parent()); | 870 EXPECT_EQ(child.get(), mask_replacement->parent()); |
868 | 871 |
869 child->SetReplicaLayer(replica_replacement.get()); | 872 child->SetReplicaLayer(replica_replacement.get()); |
870 EXPECT_EQ(nullptr, replica->parent()); | 873 EXPECT_EQ(nullptr, replica->parent()); |
871 EXPECT_EQ(child.get(), replica_replacement->parent()); | 874 EXPECT_EQ(child.get(), replica_replacement->parent()); |
872 | 875 |
873 EXPECT_EQ(replica.get(), replica->mask_layer()->parent()); | 876 EXPECT_EQ(replica.get(), replica->mask_layer()->parent()); |
874 } | 877 } |
875 | 878 |
876 TEST_F(LayerTest, CheckTranformIsInvertible) { | 879 TEST_F(LayerTest, CheckTranformIsInvertible) { |
877 scoped_refptr<Layer> layer = Layer::Create(); | 880 scoped_refptr<Layer> layer = Layer::Create(layer_settings_); |
878 scoped_ptr<LayerImpl> impl_layer = | 881 scoped_ptr<LayerImpl> impl_layer = |
879 LayerImpl::Create(host_impl_.active_tree(), 1); | 882 LayerImpl::Create(host_impl_.active_tree(), 1); |
880 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1); | 883 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1); |
881 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 884 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
882 layer_tree_host_->SetRootLayer(layer); | 885 layer_tree_host_->SetRootLayer(layer); |
883 | 886 |
884 EXPECT_TRUE(layer->transform_is_invertible()); | 887 EXPECT_TRUE(layer->transform_is_invertible()); |
885 | 888 |
886 gfx::Transform singular_transform; | 889 gfx::Transform singular_transform; |
887 singular_transform.Scale3d( | 890 singular_transform.Scale3d( |
(...skipping 10 matching lines...) Expand all Loading... |
898 | 901 |
899 layer->SetTransform(rotation_transform); | 902 layer->SetTransform(rotation_transform); |
900 layer->PushPropertiesTo(impl_layer.get()); | 903 layer->PushPropertiesTo(impl_layer.get()); |
901 EXPECT_TRUE(layer->transform_is_invertible()); | 904 EXPECT_TRUE(layer->transform_is_invertible()); |
902 EXPECT_TRUE(impl_layer->transform_is_invertible()); | 905 EXPECT_TRUE(impl_layer->transform_is_invertible()); |
903 | 906 |
904 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 907 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
905 } | 908 } |
906 | 909 |
907 TEST_F(LayerTest, TranformIsInvertibleAnimation) { | 910 TEST_F(LayerTest, TranformIsInvertibleAnimation) { |
908 scoped_refptr<Layer> layer = Layer::Create(); | 911 scoped_refptr<Layer> layer = Layer::Create(layer_settings_); |
909 scoped_ptr<LayerImpl> impl_layer = | 912 scoped_ptr<LayerImpl> impl_layer = |
910 LayerImpl::Create(host_impl_.active_tree(), 1); | 913 LayerImpl::Create(host_impl_.active_tree(), 1); |
911 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1); | 914 EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1); |
912 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); | 915 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(AnyNumber()); |
913 layer_tree_host_->SetRootLayer(layer); | 916 layer_tree_host_->SetRootLayer(layer); |
914 | 917 |
915 EXPECT_TRUE(layer->transform_is_invertible()); | 918 EXPECT_TRUE(layer->transform_is_invertible()); |
916 | 919 |
917 gfx::Transform singular_transform; | 920 gfx::Transform singular_transform; |
918 singular_transform.Scale3d( | 921 singular_transform.Scale3d( |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 for (size_t i = 0; i < layer->children().size(); ++i) | 970 for (size_t i = 0; i < layer->children().size(); ++i) |
968 AssertLayerTreeHostMatchesForSubtree(layer->children()[i].get(), host); | 971 AssertLayerTreeHostMatchesForSubtree(layer->children()[i].get(), host); |
969 | 972 |
970 if (layer->mask_layer()) | 973 if (layer->mask_layer()) |
971 AssertLayerTreeHostMatchesForSubtree(layer->mask_layer(), host); | 974 AssertLayerTreeHostMatchesForSubtree(layer->mask_layer(), host); |
972 | 975 |
973 if (layer->replica_layer()) | 976 if (layer->replica_layer()) |
974 AssertLayerTreeHostMatchesForSubtree(layer->replica_layer(), host); | 977 AssertLayerTreeHostMatchesForSubtree(layer->replica_layer(), host); |
975 } | 978 } |
976 | 979 |
977 TEST(LayerLayerTreeHostTest, EnteringTree) { | 980 class LayerLayerTreeHostTest : public testing::Test { |
978 scoped_refptr<Layer> parent = Layer::Create(); | 981 public: |
979 scoped_refptr<Layer> child = Layer::Create(); | 982 protected: |
980 scoped_refptr<Layer> mask = Layer::Create(); | 983 LayerSettings layer_settings_; |
981 scoped_refptr<Layer> replica = Layer::Create(); | 984 }; |
982 scoped_refptr<Layer> replica_mask = Layer::Create(); | 985 |
| 986 TEST_F(LayerLayerTreeHostTest, EnteringTree) { |
| 987 scoped_refptr<Layer> parent = Layer::Create(layer_settings_); |
| 988 scoped_refptr<Layer> child = Layer::Create(layer_settings_); |
| 989 scoped_refptr<Layer> mask = Layer::Create(layer_settings_); |
| 990 scoped_refptr<Layer> replica = Layer::Create(layer_settings_); |
| 991 scoped_refptr<Layer> replica_mask = Layer::Create(layer_settings_); |
983 | 992 |
984 // Set up a detached tree of layers. The host pointer should be nil for these | 993 // Set up a detached tree of layers. The host pointer should be nil for these |
985 // layers. | 994 // layers. |
986 parent->AddChild(child); | 995 parent->AddChild(child); |
987 child->SetMaskLayer(mask.get()); | 996 child->SetMaskLayer(mask.get()); |
988 child->SetReplicaLayer(replica.get()); | 997 child->SetReplicaLayer(replica.get()); |
989 replica->SetMaskLayer(replica_mask.get()); | 998 replica->SetMaskLayer(replica_mask.get()); |
990 | 999 |
991 AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr); | 1000 AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr); |
992 | 1001 |
993 LayerTreeHostFactory factory; | 1002 LayerTreeHostFactory factory; |
994 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); | 1003 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); |
995 // Setting the root layer should set the host pointer for all layers in the | 1004 // Setting the root layer should set the host pointer for all layers in the |
996 // tree. | 1005 // tree. |
997 layer_tree_host->SetRootLayer(parent.get()); | 1006 layer_tree_host->SetRootLayer(parent.get()); |
998 | 1007 |
999 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); | 1008 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); |
1000 | 1009 |
1001 // Clearing the root layer should also clear out the host pointers for all | 1010 // Clearing the root layer should also clear out the host pointers for all |
1002 // layers in the tree. | 1011 // layers in the tree. |
1003 layer_tree_host->SetRootLayer(nullptr); | 1012 layer_tree_host->SetRootLayer(nullptr); |
1004 | 1013 |
1005 AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr); | 1014 AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr); |
1006 } | 1015 } |
1007 | 1016 |
1008 TEST(LayerLayerTreeHostTest, AddingLayerSubtree) { | 1017 TEST_F(LayerLayerTreeHostTest, AddingLayerSubtree) { |
1009 scoped_refptr<Layer> parent = Layer::Create(); | 1018 scoped_refptr<Layer> parent = Layer::Create(layer_settings_); |
1010 LayerTreeHostFactory factory; | 1019 LayerTreeHostFactory factory; |
1011 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); | 1020 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); |
1012 | 1021 |
1013 layer_tree_host->SetRootLayer(parent.get()); | 1022 layer_tree_host->SetRootLayer(parent.get()); |
1014 | 1023 |
1015 EXPECT_EQ(parent->layer_tree_host(), layer_tree_host.get()); | 1024 EXPECT_EQ(parent->layer_tree_host(), layer_tree_host.get()); |
1016 | 1025 |
1017 // Adding a subtree to a layer already associated with a host should set the | 1026 // Adding a subtree to a layer already associated with a host should set the |
1018 // host pointer on all layers in that subtree. | 1027 // host pointer on all layers in that subtree. |
1019 scoped_refptr<Layer> child = Layer::Create(); | 1028 scoped_refptr<Layer> child = Layer::Create(layer_settings_); |
1020 scoped_refptr<Layer> grand_child = Layer::Create(); | 1029 scoped_refptr<Layer> grand_child = Layer::Create(layer_settings_); |
1021 child->AddChild(grand_child); | 1030 child->AddChild(grand_child); |
1022 | 1031 |
1023 // Masks, replicas, and replica masks should pick up the new host too. | 1032 // Masks, replicas, and replica masks should pick up the new host too. |
1024 scoped_refptr<Layer> child_mask = Layer::Create(); | 1033 scoped_refptr<Layer> child_mask = Layer::Create(layer_settings_); |
1025 child->SetMaskLayer(child_mask.get()); | 1034 child->SetMaskLayer(child_mask.get()); |
1026 scoped_refptr<Layer> child_replica = Layer::Create(); | 1035 scoped_refptr<Layer> child_replica = Layer::Create(layer_settings_); |
1027 child->SetReplicaLayer(child_replica.get()); | 1036 child->SetReplicaLayer(child_replica.get()); |
1028 scoped_refptr<Layer> child_replica_mask = Layer::Create(); | 1037 scoped_refptr<Layer> child_replica_mask = Layer::Create(layer_settings_); |
1029 child_replica->SetMaskLayer(child_replica_mask.get()); | 1038 child_replica->SetMaskLayer(child_replica_mask.get()); |
1030 | 1039 |
1031 parent->AddChild(child); | 1040 parent->AddChild(child); |
1032 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); | 1041 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); |
1033 | 1042 |
1034 layer_tree_host->SetRootLayer(nullptr); | 1043 layer_tree_host->SetRootLayer(nullptr); |
1035 } | 1044 } |
1036 | 1045 |
1037 TEST(LayerLayerTreeHostTest, ChangeHost) { | 1046 TEST_F(LayerLayerTreeHostTest, ChangeHost) { |
1038 scoped_refptr<Layer> parent = Layer::Create(); | 1047 scoped_refptr<Layer> parent = Layer::Create(layer_settings_); |
1039 scoped_refptr<Layer> child = Layer::Create(); | 1048 scoped_refptr<Layer> child = Layer::Create(layer_settings_); |
1040 scoped_refptr<Layer> mask = Layer::Create(); | 1049 scoped_refptr<Layer> mask = Layer::Create(layer_settings_); |
1041 scoped_refptr<Layer> replica = Layer::Create(); | 1050 scoped_refptr<Layer> replica = Layer::Create(layer_settings_); |
1042 scoped_refptr<Layer> replica_mask = Layer::Create(); | 1051 scoped_refptr<Layer> replica_mask = Layer::Create(layer_settings_); |
1043 | 1052 |
1044 // Same setup as the previous test. | 1053 // Same setup as the previous test. |
1045 parent->AddChild(child); | 1054 parent->AddChild(child); |
1046 child->SetMaskLayer(mask.get()); | 1055 child->SetMaskLayer(mask.get()); |
1047 child->SetReplicaLayer(replica.get()); | 1056 child->SetReplicaLayer(replica.get()); |
1048 replica->SetMaskLayer(replica_mask.get()); | 1057 replica->SetMaskLayer(replica_mask.get()); |
1049 | 1058 |
1050 LayerTreeHostFactory factory; | 1059 LayerTreeHostFactory factory; |
1051 scoped_ptr<LayerTreeHost> first_layer_tree_host = factory.Create(); | 1060 scoped_ptr<LayerTreeHost> first_layer_tree_host = factory.Create(); |
1052 first_layer_tree_host->SetRootLayer(parent.get()); | 1061 first_layer_tree_host->SetRootLayer(parent.get()); |
1053 | 1062 |
1054 AssertLayerTreeHostMatchesForSubtree(parent.get(), | 1063 AssertLayerTreeHostMatchesForSubtree(parent.get(), |
1055 first_layer_tree_host.get()); | 1064 first_layer_tree_host.get()); |
1056 | 1065 |
1057 // Now re-root the tree to a new host (simulating what we do on a context lost | 1066 // Now re-root the tree to a new host (simulating what we do on a context lost |
1058 // event). This should update the host pointers for all layers in the tree. | 1067 // event). This should update the host pointers for all layers in the tree. |
1059 scoped_ptr<LayerTreeHost> second_layer_tree_host = factory.Create(); | 1068 scoped_ptr<LayerTreeHost> second_layer_tree_host = factory.Create(); |
1060 second_layer_tree_host->SetRootLayer(parent.get()); | 1069 second_layer_tree_host->SetRootLayer(parent.get()); |
1061 | 1070 |
1062 AssertLayerTreeHostMatchesForSubtree(parent.get(), | 1071 AssertLayerTreeHostMatchesForSubtree(parent.get(), |
1063 second_layer_tree_host.get()); | 1072 second_layer_tree_host.get()); |
1064 | 1073 |
1065 second_layer_tree_host->SetRootLayer(nullptr); | 1074 second_layer_tree_host->SetRootLayer(nullptr); |
1066 } | 1075 } |
1067 | 1076 |
1068 TEST(LayerLayerTreeHostTest, ChangeHostInSubtree) { | 1077 TEST_F(LayerLayerTreeHostTest, ChangeHostInSubtree) { |
1069 scoped_refptr<Layer> first_parent = Layer::Create(); | 1078 scoped_refptr<Layer> first_parent = Layer::Create(layer_settings_); |
1070 scoped_refptr<Layer> first_child = Layer::Create(); | 1079 scoped_refptr<Layer> first_child = Layer::Create(layer_settings_); |
1071 scoped_refptr<Layer> second_parent = Layer::Create(); | 1080 scoped_refptr<Layer> second_parent = Layer::Create(layer_settings_); |
1072 scoped_refptr<Layer> second_child = Layer::Create(); | 1081 scoped_refptr<Layer> second_child = Layer::Create(layer_settings_); |
1073 scoped_refptr<Layer> second_grand_child = Layer::Create(); | 1082 scoped_refptr<Layer> second_grand_child = Layer::Create(layer_settings_); |
1074 | 1083 |
1075 // First put all children under the first parent and set the first host. | 1084 // First put all children under the first parent and set the first host. |
1076 first_parent->AddChild(first_child); | 1085 first_parent->AddChild(first_child); |
1077 second_child->AddChild(second_grand_child); | 1086 second_child->AddChild(second_grand_child); |
1078 first_parent->AddChild(second_child); | 1087 first_parent->AddChild(second_child); |
1079 | 1088 |
1080 LayerTreeHostFactory factory; | 1089 LayerTreeHostFactory factory; |
1081 scoped_ptr<LayerTreeHost> first_layer_tree_host = factory.Create(); | 1090 scoped_ptr<LayerTreeHost> first_layer_tree_host = factory.Create(); |
1082 first_layer_tree_host->SetRootLayer(first_parent.get()); | 1091 first_layer_tree_host->SetRootLayer(first_parent.get()); |
1083 | 1092 |
(...skipping 10 matching lines...) Expand all Loading... |
1094 // The moved layer and its children should point to the new host. | 1103 // The moved layer and its children should point to the new host. |
1095 EXPECT_EQ(second_layer_tree_host.get(), second_child->layer_tree_host()); | 1104 EXPECT_EQ(second_layer_tree_host.get(), second_child->layer_tree_host()); |
1096 EXPECT_EQ(second_layer_tree_host.get(), | 1105 EXPECT_EQ(second_layer_tree_host.get(), |
1097 second_grand_child->layer_tree_host()); | 1106 second_grand_child->layer_tree_host()); |
1098 | 1107 |
1099 // Test over, cleanup time. | 1108 // Test over, cleanup time. |
1100 first_layer_tree_host->SetRootLayer(nullptr); | 1109 first_layer_tree_host->SetRootLayer(nullptr); |
1101 second_layer_tree_host->SetRootLayer(nullptr); | 1110 second_layer_tree_host->SetRootLayer(nullptr); |
1102 } | 1111 } |
1103 | 1112 |
1104 TEST(LayerLayerTreeHostTest, ReplaceMaskAndReplicaLayer) { | 1113 TEST_F(LayerLayerTreeHostTest, ReplaceMaskAndReplicaLayer) { |
1105 scoped_refptr<Layer> parent = Layer::Create(); | 1114 scoped_refptr<Layer> parent = Layer::Create(layer_settings_); |
1106 scoped_refptr<Layer> mask = Layer::Create(); | 1115 scoped_refptr<Layer> mask = Layer::Create(layer_settings_); |
1107 scoped_refptr<Layer> replica = Layer::Create(); | 1116 scoped_refptr<Layer> replica = Layer::Create(layer_settings_); |
1108 scoped_refptr<Layer> mask_child = Layer::Create(); | 1117 scoped_refptr<Layer> mask_child = Layer::Create(layer_settings_); |
1109 scoped_refptr<Layer> replica_child = Layer::Create(); | 1118 scoped_refptr<Layer> replica_child = Layer::Create(layer_settings_); |
1110 scoped_refptr<Layer> mask_replacement = Layer::Create(); | 1119 scoped_refptr<Layer> mask_replacement = Layer::Create(layer_settings_); |
1111 scoped_refptr<Layer> replica_replacement = Layer::Create(); | 1120 scoped_refptr<Layer> replica_replacement = Layer::Create(layer_settings_); |
1112 | 1121 |
1113 parent->SetMaskLayer(mask.get()); | 1122 parent->SetMaskLayer(mask.get()); |
1114 parent->SetReplicaLayer(replica.get()); | 1123 parent->SetReplicaLayer(replica.get()); |
1115 mask->AddChild(mask_child); | 1124 mask->AddChild(mask_child); |
1116 replica->AddChild(replica_child); | 1125 replica->AddChild(replica_child); |
1117 | 1126 |
1118 LayerTreeHostFactory factory; | 1127 LayerTreeHostFactory factory; |
1119 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); | 1128 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); |
1120 layer_tree_host->SetRootLayer(parent.get()); | 1129 layer_tree_host->SetRootLayer(parent.get()); |
1121 | 1130 |
1122 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); | 1131 AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get()); |
1123 | 1132 |
1124 // Replacing the mask should clear out the old mask's subtree's host pointers. | 1133 // Replacing the mask should clear out the old mask's subtree's host pointers. |
1125 parent->SetMaskLayer(mask_replacement.get()); | 1134 parent->SetMaskLayer(mask_replacement.get()); |
1126 EXPECT_EQ(nullptr, mask->layer_tree_host()); | 1135 EXPECT_EQ(nullptr, mask->layer_tree_host()); |
1127 EXPECT_EQ(nullptr, mask_child->layer_tree_host()); | 1136 EXPECT_EQ(nullptr, mask_child->layer_tree_host()); |
1128 | 1137 |
1129 // Same for replacing a replica layer. | 1138 // Same for replacing a replica layer. |
1130 parent->SetReplicaLayer(replica_replacement.get()); | 1139 parent->SetReplicaLayer(replica_replacement.get()); |
1131 EXPECT_EQ(nullptr, replica->layer_tree_host()); | 1140 EXPECT_EQ(nullptr, replica->layer_tree_host()); |
1132 EXPECT_EQ(nullptr, replica_child->layer_tree_host()); | 1141 EXPECT_EQ(nullptr, replica_child->layer_tree_host()); |
1133 | 1142 |
1134 // Test over, cleanup time. | 1143 // Test over, cleanup time. |
1135 layer_tree_host->SetRootLayer(nullptr); | 1144 layer_tree_host->SetRootLayer(nullptr); |
1136 } | 1145 } |
1137 | 1146 |
1138 TEST(LayerLayerTreeHostTest, DestroyHostWithNonNullRootLayer) { | 1147 TEST_F(LayerLayerTreeHostTest, DestroyHostWithNonNullRootLayer) { |
1139 scoped_refptr<Layer> root = Layer::Create(); | 1148 scoped_refptr<Layer> root = Layer::Create(layer_settings_); |
1140 scoped_refptr<Layer> child = Layer::Create(); | 1149 scoped_refptr<Layer> child = Layer::Create(layer_settings_); |
1141 root->AddChild(child); | 1150 root->AddChild(child); |
1142 LayerTreeHostFactory factory; | 1151 LayerTreeHostFactory factory; |
1143 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); | 1152 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); |
1144 layer_tree_host->SetRootLayer(root); | 1153 layer_tree_host->SetRootLayer(root); |
1145 } | 1154 } |
1146 | 1155 |
1147 static bool AddTestAnimation(Layer* layer) { | 1156 static bool AddTestAnimation(Layer* layer) { |
1148 scoped_ptr<KeyframedFloatAnimationCurve> curve = | 1157 scoped_ptr<KeyframedFloatAnimationCurve> curve = |
1149 KeyframedFloatAnimationCurve::Create(); | 1158 KeyframedFloatAnimationCurve::Create(); |
1150 curve->AddKeyframe(FloatKeyframe::Create(base::TimeDelta(), 0.3f, nullptr)); | 1159 curve->AddKeyframe(FloatKeyframe::Create(base::TimeDelta(), 0.3f, nullptr)); |
1151 curve->AddKeyframe( | 1160 curve->AddKeyframe( |
1152 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.7f, nullptr)); | 1161 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), 0.7f, nullptr)); |
1153 scoped_ptr<Animation> animation = | 1162 scoped_ptr<Animation> animation = |
1154 Animation::Create(curve.Pass(), 0, 0, Animation::OPACITY); | 1163 Animation::Create(curve.Pass(), 0, 0, Animation::OPACITY); |
1155 | 1164 |
1156 return layer->AddAnimation(animation.Pass()); | 1165 return layer->AddAnimation(animation.Pass()); |
1157 } | 1166 } |
1158 | 1167 |
1159 TEST(LayerLayerTreeHostTest, ShouldNotAddAnimationWithoutAnimationRegistrar) { | 1168 TEST_F(LayerLayerTreeHostTest, ShouldNotAddAnimationWithoutAnimationRegistrar) { |
1160 scoped_refptr<Layer> layer = Layer::Create(); | 1169 scoped_refptr<Layer> layer = Layer::Create(layer_settings_); |
1161 | 1170 |
1162 // Case 1: without a LayerTreeHost and without an AnimationRegistrar, the | 1171 // Case 1: without a LayerTreeHost and without an AnimationRegistrar, the |
1163 // animation should not be accepted. | 1172 // animation should not be accepted. |
1164 EXPECT_FALSE(AddTestAnimation(layer.get())); | 1173 EXPECT_FALSE(AddTestAnimation(layer.get())); |
1165 | 1174 |
1166 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::Create(); | 1175 scoped_ptr<AnimationRegistrar> registrar = AnimationRegistrar::Create(); |
1167 layer->layer_animation_controller()->SetAnimationRegistrar(registrar.get()); | 1176 layer->layer_animation_controller()->SetAnimationRegistrar(registrar.get()); |
1168 | 1177 |
1169 // Case 2: with an AnimationRegistrar, the animation should be accepted. | 1178 // Case 2: with an AnimationRegistrar, the animation should be accepted. |
1170 EXPECT_TRUE(AddTestAnimation(layer.get())); | 1179 EXPECT_TRUE(AddTestAnimation(layer.get())); |
1171 | 1180 |
1172 LayerTreeSettings settings; | 1181 LayerTreeSettings settings; |
1173 settings.accelerated_animation_enabled = false; | 1182 settings.accelerated_animation_enabled = false; |
1174 LayerTreeHostFactory factory; | 1183 LayerTreeHostFactory factory; |
1175 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(settings); | 1184 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(settings); |
1176 layer_tree_host->SetRootLayer(layer); | 1185 layer_tree_host->SetRootLayer(layer); |
1177 AssertLayerTreeHostMatchesForSubtree(layer.get(), layer_tree_host.get()); | 1186 AssertLayerTreeHostMatchesForSubtree(layer.get(), layer_tree_host.get()); |
1178 | 1187 |
1179 // Case 3: with a LayerTreeHost where accelerated animation is disabled, the | 1188 // Case 3: with a LayerTreeHost where accelerated animation is disabled, the |
1180 // animation should be rejected. | 1189 // animation should be rejected. |
1181 EXPECT_FALSE(AddTestAnimation(layer.get())); | 1190 EXPECT_FALSE(AddTestAnimation(layer.get())); |
1182 } | 1191 } |
1183 | 1192 |
1184 TEST_F(LayerTest, SafeOpaqueBackgroundColor) { | 1193 TEST_F(LayerTest, SafeOpaqueBackgroundColor) { |
1185 LayerTreeHostFactory factory; | 1194 LayerTreeHostFactory factory; |
1186 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); | 1195 scoped_ptr<LayerTreeHost> layer_tree_host = factory.Create(); |
1187 | 1196 |
1188 scoped_refptr<Layer> layer = Layer::Create(); | 1197 scoped_refptr<Layer> layer = Layer::Create(layer_settings_); |
1189 layer_tree_host->SetRootLayer(layer); | 1198 layer_tree_host->SetRootLayer(layer); |
1190 | 1199 |
1191 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { | 1200 for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) { |
1192 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { | 1201 for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) { |
1193 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { | 1202 for (int host_opaque = 0; host_opaque < 2; ++host_opaque) { |
1194 layer->SetContentsOpaque(!!contents_opaque); | 1203 layer->SetContentsOpaque(!!contents_opaque); |
1195 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED | 1204 layer->SetBackgroundColor(layer_opaque ? SK_ColorRED |
1196 : SK_ColorTRANSPARENT); | 1205 : SK_ColorTRANSPARENT); |
1197 layer_tree_host->set_background_color( | 1206 layer_tree_host->set_background_color( |
1198 host_opaque ? SK_ColorRED : SK_ColorTRANSPARENT); | 1207 host_opaque ? SK_ColorRED : SK_ColorTRANSPARENT); |
1199 | 1208 |
1200 SkColor safe_color = layer->SafeOpaqueBackgroundColor(); | 1209 SkColor safe_color = layer->SafeOpaqueBackgroundColor(); |
1201 if (contents_opaque) { | 1210 if (contents_opaque) { |
1202 EXPECT_EQ(SkColorGetA(safe_color), 255u) | 1211 EXPECT_EQ(SkColorGetA(safe_color), 255u) |
1203 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " | 1212 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " |
1204 << host_opaque << "\n"; | 1213 << host_opaque << "\n"; |
1205 } else { | 1214 } else { |
1206 EXPECT_NE(SkColorGetA(safe_color), 255u) | 1215 EXPECT_NE(SkColorGetA(safe_color), 255u) |
1207 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " | 1216 << "Flags: " << contents_opaque << ", " << layer_opaque << ", " |
1208 << host_opaque << "\n"; | 1217 << host_opaque << "\n"; |
1209 } | 1218 } |
1210 } | 1219 } |
1211 } | 1220 } |
1212 } | 1221 } |
1213 } | 1222 } |
1214 | 1223 |
1215 class DrawsContentChangeLayer : public Layer { | 1224 class DrawsContentChangeLayer : public Layer { |
1216 public: | 1225 public: |
1217 static scoped_refptr<DrawsContentChangeLayer> Create() { | 1226 static scoped_refptr<DrawsContentChangeLayer> Create( |
1218 return make_scoped_refptr(new DrawsContentChangeLayer()); | 1227 const LayerSettings& settings) { |
| 1228 return make_scoped_refptr(new DrawsContentChangeLayer(settings)); |
1219 } | 1229 } |
1220 | 1230 |
1221 void SetLayerTreeHost(LayerTreeHost* host) override { | 1231 void SetLayerTreeHost(LayerTreeHost* host) override { |
1222 Layer::SetLayerTreeHost(host); | 1232 Layer::SetLayerTreeHost(host); |
1223 SetFakeDrawsContent(!fake_draws_content_); | 1233 SetFakeDrawsContent(!fake_draws_content_); |
1224 } | 1234 } |
1225 | 1235 |
1226 bool HasDrawableContent() const override { | 1236 bool HasDrawableContent() const override { |
1227 return fake_draws_content_ && Layer::HasDrawableContent(); | 1237 return fake_draws_content_ && Layer::HasDrawableContent(); |
1228 } | 1238 } |
1229 | 1239 |
1230 void SetFakeDrawsContent(bool fake_draws_content) { | 1240 void SetFakeDrawsContent(bool fake_draws_content) { |
1231 fake_draws_content_ = fake_draws_content; | 1241 fake_draws_content_ = fake_draws_content; |
1232 UpdateDrawsContent(HasDrawableContent()); | 1242 UpdateDrawsContent(HasDrawableContent()); |
1233 } | 1243 } |
1234 | 1244 |
1235 private: | 1245 private: |
1236 DrawsContentChangeLayer() : Layer(), fake_draws_content_(false) {} | 1246 explicit DrawsContentChangeLayer(const LayerSettings& settings) |
| 1247 : Layer(settings), fake_draws_content_(false) {} |
1237 ~DrawsContentChangeLayer() override {} | 1248 ~DrawsContentChangeLayer() override {} |
1238 | 1249 |
1239 bool fake_draws_content_; | 1250 bool fake_draws_content_; |
1240 }; | 1251 }; |
1241 | 1252 |
1242 TEST_F(LayerTest, DrawsContentChangedInSetLayerTreeHost) { | 1253 TEST_F(LayerTest, DrawsContentChangedInSetLayerTreeHost) { |
1243 scoped_refptr<Layer> root_layer = Layer::Create(); | 1254 scoped_refptr<Layer> root_layer = Layer::Create(layer_settings_); |
1244 scoped_refptr<DrawsContentChangeLayer> becomes_not_draws_content = | 1255 scoped_refptr<DrawsContentChangeLayer> becomes_not_draws_content = |
1245 DrawsContentChangeLayer::Create(); | 1256 DrawsContentChangeLayer::Create(layer_settings_); |
1246 scoped_refptr<DrawsContentChangeLayer> becomes_draws_content = | 1257 scoped_refptr<DrawsContentChangeLayer> becomes_draws_content = |
1247 DrawsContentChangeLayer::Create(); | 1258 DrawsContentChangeLayer::Create(layer_settings_); |
1248 root_layer->SetIsDrawable(true); | 1259 root_layer->SetIsDrawable(true); |
1249 becomes_not_draws_content->SetIsDrawable(true); | 1260 becomes_not_draws_content->SetIsDrawable(true); |
1250 becomes_not_draws_content->SetFakeDrawsContent(true); | 1261 becomes_not_draws_content->SetFakeDrawsContent(true); |
1251 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); | 1262 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); |
1252 root_layer->AddChild(becomes_not_draws_content); | 1263 root_layer->AddChild(becomes_not_draws_content); |
1253 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); | 1264 EXPECT_EQ(0, root_layer->NumDescendantsThatDrawContent()); |
1254 | 1265 |
1255 becomes_draws_content->SetIsDrawable(true); | 1266 becomes_draws_content->SetIsDrawable(true); |
1256 root_layer->AddChild(becomes_draws_content); | 1267 root_layer->AddChild(becomes_draws_content); |
1257 EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent()); | 1268 EXPECT_EQ(1, root_layer->NumDescendantsThatDrawContent()); |
1258 } | 1269 } |
1259 | 1270 |
1260 void ReceiveCopyOutputResult(int* result_count, | 1271 void ReceiveCopyOutputResult(int* result_count, |
1261 scoped_ptr<CopyOutputResult> result) { | 1272 scoped_ptr<CopyOutputResult> result) { |
1262 ++(*result_count); | 1273 ++(*result_count); |
1263 } | 1274 } |
1264 | 1275 |
1265 TEST_F(LayerTest, DedupesCopyOutputRequestsBySource) { | 1276 TEST_F(LayerTest, DedupesCopyOutputRequestsBySource) { |
1266 scoped_refptr<Layer> layer = Layer::Create(); | 1277 scoped_refptr<Layer> layer = Layer::Create(layer_settings_); |
1267 int result_count = 0; | 1278 int result_count = 0; |
1268 | 1279 |
1269 // Create identical requests without the source being set, and expect the | 1280 // Create identical requests without the source being set, and expect the |
1270 // layer does not abort either one. | 1281 // layer does not abort either one. |
1271 scoped_ptr<CopyOutputRequest> request = CopyOutputRequest::CreateRequest( | 1282 scoped_ptr<CopyOutputRequest> request = CopyOutputRequest::CreateRequest( |
1272 base::Bind(&ReceiveCopyOutputResult, &result_count)); | 1283 base::Bind(&ReceiveCopyOutputResult, &result_count)); |
1273 layer->RequestCopyOfOutput(request.Pass()); | 1284 layer->RequestCopyOfOutput(request.Pass()); |
1274 EXPECT_EQ(0, result_count); | 1285 EXPECT_EQ(0, result_count); |
1275 request = CopyOutputRequest::CreateRequest( | 1286 request = CopyOutputRequest::CreateRequest( |
1276 base::Bind(&ReceiveCopyOutputResult, &result_count)); | 1287 base::Bind(&ReceiveCopyOutputResult, &result_count)); |
1277 layer->RequestCopyOfOutput(request.Pass()); | 1288 layer->RequestCopyOfOutput(request.Pass()); |
1278 EXPECT_EQ(0, result_count); | 1289 EXPECT_EQ(0, result_count); |
1279 | 1290 |
1280 // When the layer is destroyed, expect both requests to be aborted. | 1291 // When the layer is destroyed, expect both requests to be aborted. |
1281 layer = nullptr; | 1292 layer = nullptr; |
1282 EXPECT_EQ(2, result_count); | 1293 EXPECT_EQ(2, result_count); |
1283 | 1294 |
1284 layer = Layer::Create(); | 1295 layer = Layer::Create(layer_settings_); |
1285 result_count = 0; | 1296 result_count = 0; |
1286 | 1297 |
1287 // Create identical requests, but this time the source is being set. Expect | 1298 // Create identical requests, but this time the source is being set. Expect |
1288 // the first request from |this| source aborts immediately when the second | 1299 // the first request from |this| source aborts immediately when the second |
1289 // request from |this| source is made. | 1300 // request from |this| source is made. |
1290 int did_receive_first_result_from_this_source = 0; | 1301 int did_receive_first_result_from_this_source = 0; |
1291 request = CopyOutputRequest::CreateRequest(base::Bind( | 1302 request = CopyOutputRequest::CreateRequest(base::Bind( |
1292 &ReceiveCopyOutputResult, &did_receive_first_result_from_this_source)); | 1303 &ReceiveCopyOutputResult, &did_receive_first_result_from_this_source)); |
1293 request->set_source(this); | 1304 request->set_source(this); |
1294 layer->RequestCopyOfOutput(request.Pass()); | 1305 layer->RequestCopyOfOutput(request.Pass()); |
(...skipping 25 matching lines...) Expand all Loading... |
1320 // When the layer is destroyed, the other three requests should be aborted. | 1331 // When the layer is destroyed, the other three requests should be aborted. |
1321 layer = nullptr; | 1332 layer = nullptr; |
1322 EXPECT_EQ(1, did_receive_first_result_from_this_source); | 1333 EXPECT_EQ(1, did_receive_first_result_from_this_source); |
1323 EXPECT_EQ(1, did_receive_result_from_different_source); | 1334 EXPECT_EQ(1, did_receive_result_from_different_source); |
1324 EXPECT_EQ(1, did_receive_result_from_anonymous_source); | 1335 EXPECT_EQ(1, did_receive_result_from_anonymous_source); |
1325 EXPECT_EQ(1, did_receive_second_result_from_this_source); | 1336 EXPECT_EQ(1, did_receive_second_result_from_this_source); |
1326 } | 1337 } |
1327 | 1338 |
1328 } // namespace | 1339 } // namespace |
1329 } // namespace cc | 1340 } // namespace cc |
OLD | NEW |