Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: cc/tree_synchronizer_unittest.cc

Issue 11232051: Remove static thread pointers from CC (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Address code review comments and fix all cc_unittests Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/tree_synchronizer.h" 7 #include "cc/tree_synchronizer.h"
8 8
9 #include "Region.h" 9 #include "Region.h"
10 #include "cc/layer.h" 10 #include "cc/layer.h"
11 #include "cc/layer_animation_controller.h" 11 #include "cc/layer_animation_controller.h"
12 #include "cc/layer_impl.h" 12 #include "cc/layer_impl.h"
13 #include "cc/proxy.h" 13 #include "cc/proxy.h"
14 #include "cc/single_thread_proxy.h" 14 #include "cc/single_thread_proxy.h"
15 #include "cc/test/animation_test_common.h" 15 #include "cc/test/animation_test_common.h"
16 #include "cc/test/fake_proxy.h"
16 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
17 18
18 using namespace cc; 19 using namespace cc;
19 using namespace WebKitTests; 20 using namespace WebKitTests;
20 21
21 namespace { 22 namespace {
22 23
23 class MockLayerImpl : public LayerImpl { 24 class MockLayerImpl : public LayerImpl {
24 public: 25 public:
25 static scoped_ptr<MockLayerImpl> create(int layerId) 26 static scoped_ptr<MockLayerImpl> create(int layerId)
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 ASSERT_EQ(layerChildren.size(), layerImplChildren.size()); 125 ASSERT_EQ(layerChildren.size(), layerImplChildren.size());
125 126
126 for (size_t i = 0; i < layerChildren.size(); ++i) 127 for (size_t i = 0; i < layerChildren.size(); ++i)
127 expectTreesAreIdentical(layerChildren[i].get(), layerImplChildren[i], ho stImpl); 128 expectTreesAreIdentical(layerChildren[i].get(), layerImplChildren[i], ho stImpl);
128 } 129 }
129 130
130 // Attempts to synchronizes a null tree. This should not crash, and should 131 // Attempts to synchronizes a null tree. This should not crash, and should
131 // return a null tree. 132 // return a null tree.
132 TEST(TreeSynchronizerTest, syncNullTree) 133 TEST(TreeSynchronizerTest, syncNullTree)
133 { 134 {
134 DebugScopedSetImplThread impl;
135
136 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (0, scoped_ptr<LayerImpl>(), 0); 135 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (0, scoped_ptr<LayerImpl>(), 0);
137 136
138 EXPECT_TRUE(!layerImplTreeRoot.get()); 137 EXPECT_TRUE(!layerImplTreeRoot.get());
139 } 138 }
140 139
141 // Constructs a very simple tree and synchronizes it without trying to reuse any preexisting layers. 140 // Constructs a very simple tree and synchronizes it without trying to reuse any preexisting layers.
142 TEST(TreeSynchronizerTest, syncSimpleTreeFromEmpty) 141 TEST(TreeSynchronizerTest, syncSimpleTreeFromEmpty)
143 { 142 {
144 DebugScopedSetImplThread impl;
145
146 LayerTreeSettings settings; 143 LayerTreeSettings settings;
147 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0); 144 FakeProxy proxy(0);
145 DebugScopedSetImplThread impl(&proxy);
danakj 2012/10/25 05:06:06 Why do we need to be impl thread for these tests?
aelias_OOO_until_Jul13 2012/10/25 06:11:06 LTHI constructor asserts that it's on the impl thr
146 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy);
148 147
149 scoped_refptr<Layer> layerTreeRoot = Layer::create(); 148 scoped_refptr<Layer> layerTreeRoot = Layer::create();
150 layerTreeRoot->addChild(Layer::create()); 149 layerTreeRoot->addChild(Layer::create());
151 layerTreeRoot->addChild(Layer::create()); 150 layerTreeRoot->addChild(Layer::create());
152 151
153 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get()); 152 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get());
154 153
155 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm pl.get()); 154 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm pl.get());
156 } 155 }
157 156
158 // Constructs a very simple tree and synchronizes it attempting to reuse some la yers 157 // Constructs a very simple tree and synchronizes it attempting to reuse some la yers
159 TEST(TreeSynchronizerTest, syncSimpleTreeReusingLayers) 158 TEST(TreeSynchronizerTest, syncSimpleTreeReusingLayers)
160 { 159 {
161 DebugScopedSetImplThread impl;
162 Vector<int> layerImplDestructionList; 160 Vector<int> layerImplDestructionList;
163 161
164 LayerTreeSettings settings; 162 LayerTreeSettings settings;
165 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0); 163 FakeProxy proxy(0);
164 DebugScopedSetImplThread impl(&proxy);
165 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy);
166 166
167 scoped_refptr<Layer> layerTreeRoot = MockLayer::create(&layerImplDestruction List); 167 scoped_refptr<Layer> layerTreeRoot = MockLayer::create(&layerImplDestruction List);
168 layerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); 168 layerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList));
169 layerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); 169 layerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList));
170 170
171 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get()); 171 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get());
172 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm pl.get()); 172 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm pl.get());
173 173
174 // Add a new layer to the Layer side 174 // Add a new layer to the Layer side
175 layerTreeRoot->children()[0]->addChild(MockLayer::create(&layerImplDestructi onList)); 175 layerTreeRoot->children()[0]->addChild(MockLayer::create(&layerImplDestructi onList));
176 // Remove one. 176 // Remove one.
177 layerTreeRoot->children()[1]->removeFromParent(); 177 layerTreeRoot->children()[1]->removeFromParent();
178 int secondLayerImplId = layerImplTreeRoot->children()[1]->id(); 178 int secondLayerImplId = layerImplTreeRoot->children()[1]->id();
179 179
180 // Synchronize again. After the sync the trees should be equivalent and we s hould have created and destroyed one LayerImpl. 180 // Synchronize again. After the sync the trees should be equivalent and we s hould have created and destroyed one LayerImpl.
181 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl.get()); 181 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl.get());
182 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm pl.get()); 182 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm pl.get());
183 183
184 ASSERT_EQ(1u, layerImplDestructionList.size()); 184 ASSERT_EQ(1u, layerImplDestructionList.size());
185 EXPECT_EQ(secondLayerImplId, layerImplDestructionList[0]); 185 EXPECT_EQ(secondLayerImplId, layerImplDestructionList[0]);
186 } 186 }
187 187
188 // Constructs a very simple tree and checks that a stacking-order change is trac ked properly. 188 // Constructs a very simple tree and checks that a stacking-order change is trac ked properly.
189 TEST(TreeSynchronizerTest, syncSimpleTreeAndTrackStackingOrderChange) 189 TEST(TreeSynchronizerTest, syncSimpleTreeAndTrackStackingOrderChange)
190 { 190 {
191 DebugScopedSetImplThread impl;
192 Vector<int> layerImplDestructionList; 191 Vector<int> layerImplDestructionList;
193 192
194 LayerTreeSettings settings; 193 LayerTreeSettings settings;
195 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0); 194 FakeProxy proxy(0);
195 DebugScopedSetImplThread impl(&proxy);
196 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy);
196 197
197 // Set up the tree and sync once. child2 needs to be synced here, too, even though we 198 // Set up the tree and sync once. child2 needs to be synced here, too, even though we
198 // remove it to set up the intended scenario. 199 // remove it to set up the intended scenario.
199 scoped_refptr<Layer> layerTreeRoot = MockLayer::create(&layerImplDestruction List); 200 scoped_refptr<Layer> layerTreeRoot = MockLayer::create(&layerImplDestruction List);
200 scoped_refptr<Layer> child2 = MockLayer::create(&layerImplDestructionList); 201 scoped_refptr<Layer> child2 = MockLayer::create(&layerImplDestructionList);
201 layerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); 202 layerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList));
202 layerTreeRoot->addChild(child2); 203 layerTreeRoot->addChild(child2);
203 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get()); 204 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get());
204 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm pl.get()); 205 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm pl.get());
205 layerImplTreeRoot->resetAllChangeTrackingForSubtree(); 206 layerImplTreeRoot->resetAllChangeTrackingForSubtree();
206 207
207 // re-insert the layer and sync again. 208 // re-insert the layer and sync again.
208 child2->removeFromParent(); 209 child2->removeFromParent();
209 layerTreeRoot->addChild(child2); 210 layerTreeRoot->addChild(child2);
210 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl.get()); 211 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl.get());
211 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm pl.get()); 212 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm pl.get());
212 213
213 // Check that the impl thread properly tracked the change. 214 // Check that the impl thread properly tracked the change.
214 EXPECT_FALSE(layerImplTreeRoot->layerPropertyChanged()); 215 EXPECT_FALSE(layerImplTreeRoot->layerPropertyChanged());
215 EXPECT_FALSE(layerImplTreeRoot->children()[0]->layerPropertyChanged()); 216 EXPECT_FALSE(layerImplTreeRoot->children()[0]->layerPropertyChanged());
216 EXPECT_TRUE(layerImplTreeRoot->children()[1]->layerPropertyChanged()); 217 EXPECT_TRUE(layerImplTreeRoot->children()[1]->layerPropertyChanged());
217 } 218 }
218 219
219 TEST(TreeSynchronizerTest, syncSimpleTreeAndProperties) 220 TEST(TreeSynchronizerTest, syncSimpleTreeAndProperties)
220 { 221 {
221 DebugScopedSetImplThread impl;
222
223 LayerTreeSettings settings; 222 LayerTreeSettings settings;
224 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0); 223 FakeProxy proxy(0);
224 DebugScopedSetImplThread impl(&proxy);
225 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy);
225 226
226 scoped_refptr<Layer> layerTreeRoot = Layer::create(); 227 scoped_refptr<Layer> layerTreeRoot = Layer::create();
227 layerTreeRoot->addChild(Layer::create()); 228 layerTreeRoot->addChild(Layer::create());
228 layerTreeRoot->addChild(Layer::create()); 229 layerTreeRoot->addChild(Layer::create());
229 230
230 // Pick some random properties to set. The values are not important, we're j ust testing that at least some properties are making it through. 231 // Pick some random properties to set. The values are not important, we're j ust testing that at least some properties are making it through.
231 FloatPoint rootPosition = FloatPoint(2.3f, 7.4f); 232 FloatPoint rootPosition = FloatPoint(2.3f, 7.4f);
232 layerTreeRoot->setPosition(rootPosition); 233 layerTreeRoot->setPosition(rootPosition);
233 234
234 float firstChildOpacity = 0.25f; 235 float firstChildOpacity = 0.25f;
(...skipping 12 matching lines...) Expand all
247 248
248 EXPECT_EQ(firstChildOpacity, layerImplTreeRoot->children()[0]->opacity()); 249 EXPECT_EQ(firstChildOpacity, layerImplTreeRoot->children()[0]->opacity());
249 250
250 IntSize secondLayerImplChildBounds = layerImplTreeRoot->children()[1]->bound s(); 251 IntSize secondLayerImplChildBounds = layerImplTreeRoot->children()[1]->bound s();
251 EXPECT_EQ(secondChildBounds.width(), secondLayerImplChildBounds.width()); 252 EXPECT_EQ(secondChildBounds.width(), secondLayerImplChildBounds.width());
252 EXPECT_EQ(secondChildBounds.height(), secondLayerImplChildBounds.height()); 253 EXPECT_EQ(secondChildBounds.height(), secondLayerImplChildBounds.height());
253 } 254 }
254 255
255 TEST(TreeSynchronizerTest, reuseLayerImplsAfterStructuralChange) 256 TEST(TreeSynchronizerTest, reuseLayerImplsAfterStructuralChange)
256 { 257 {
257 DebugScopedSetImplThread impl;
258 Vector<int> layerImplDestructionList; 258 Vector<int> layerImplDestructionList;
259 259
260 LayerTreeSettings settings; 260 LayerTreeSettings settings;
261 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0); 261 FakeProxy proxy(0);
262 DebugScopedSetImplThread impl(&proxy);
263 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy);
262 264
263 // Set up a tree with this sort of structure: 265 // Set up a tree with this sort of structure:
264 // root --- A --- B ---+--- C 266 // root --- A --- B ---+--- C
265 // | 267 // |
266 // +--- D 268 // +--- D
267 scoped_refptr<Layer> layerTreeRoot = MockLayer::create(&layerImplDestruction List); 269 scoped_refptr<Layer> layerTreeRoot = MockLayer::create(&layerImplDestruction List);
268 layerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); 270 layerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList));
269 271
270 scoped_refptr<Layer> layerA = layerTreeRoot->children()[0].get(); 272 scoped_refptr<Layer> layerA = layerTreeRoot->children()[0].get();
271 layerA->addChild(MockLayer::create(&layerImplDestructionList)); 273 layerA->addChild(MockLayer::create(&layerImplDestructionList));
(...skipping 25 matching lines...) Expand all
297 // After another synchronize our trees should match and we should not have d estroyed any LayerImpls 299 // After another synchronize our trees should match and we should not have d estroyed any LayerImpls
298 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl.get()); 300 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl.get());
299 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm pl.get()); 301 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm pl.get());
300 302
301 EXPECT_EQ(0u, layerImplDestructionList.size()); 303 EXPECT_EQ(0u, layerImplDestructionList.size());
302 } 304 }
303 305
304 // Constructs a very simple tree, synchronizes it, then synchronizes to a totall y new tree. All layers from the old tree should be deleted. 306 // Constructs a very simple tree, synchronizes it, then synchronizes to a totall y new tree. All layers from the old tree should be deleted.
305 TEST(TreeSynchronizerTest, syncSimpleTreeThenDestroy) 307 TEST(TreeSynchronizerTest, syncSimpleTreeThenDestroy)
306 { 308 {
307 DebugScopedSetImplThread impl;
308 Vector<int> layerImplDestructionList; 309 Vector<int> layerImplDestructionList;
309 310
310 LayerTreeSettings settings; 311 LayerTreeSettings settings;
311 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0); 312 FakeProxy proxy(0);
313 DebugScopedSetImplThread impl(&proxy);
314 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy);
312 315
313 scoped_refptr<Layer> oldLayerTreeRoot = MockLayer::create(&layerImplDestruct ionList); 316 scoped_refptr<Layer> oldLayerTreeRoot = MockLayer::create(&layerImplDestruct ionList);
314 oldLayerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); 317 oldLayerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList));
315 oldLayerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); 318 oldLayerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList));
316 319
317 int oldTreeRootLayerId = oldLayerTreeRoot->id(); 320 int oldTreeRootLayerId = oldLayerTreeRoot->id();
318 int oldTreeFirstChildLayerId = oldLayerTreeRoot->children()[0]->id(); 321 int oldTreeFirstChildLayerId = oldLayerTreeRoot->children()[0]->id();
319 int oldTreeSecondChildLayerId = oldLayerTreeRoot->children()[1]->id(); 322 int oldTreeSecondChildLayerId = oldLayerTreeRoot->children()[1]->id();
320 323
321 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (oldLayerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get()); 324 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (oldLayerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get());
322 expectTreesAreIdentical(oldLayerTreeRoot.get(), layerImplTreeRoot.get(), hos tImpl.get()); 325 expectTreesAreIdentical(oldLayerTreeRoot.get(), layerImplTreeRoot.get(), hos tImpl.get());
323 326
324 // Remove all children on the Layer side. 327 // Remove all children on the Layer side.
325 oldLayerTreeRoot->removeAllChildren(); 328 oldLayerTreeRoot->removeAllChildren();
326 329
327 // Synchronize again. After the sync all LayerImpls from the old tree should be deleted. 330 // Synchronize again. After the sync all LayerImpls from the old tree should be deleted.
328 scoped_refptr<Layer> newLayerTreeRoot = Layer::create(); 331 scoped_refptr<Layer> newLayerTreeRoot = Layer::create();
329 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(newLayerTreeRoot.get( ), layerImplTreeRoot.Pass(), hostImpl.get()); 332 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(newLayerTreeRoot.get( ), layerImplTreeRoot.Pass(), hostImpl.get());
330 expectTreesAreIdentical(newLayerTreeRoot.get(), layerImplTreeRoot.get(), hos tImpl.get()); 333 expectTreesAreIdentical(newLayerTreeRoot.get(), layerImplTreeRoot.get(), hos tImpl.get());
331 334
332 ASSERT_EQ(3u, layerImplDestructionList.size()); 335 ASSERT_EQ(3u, layerImplDestructionList.size());
333 EXPECT_TRUE(layerImplDestructionList.contains(oldTreeRootLayerId)); 336 EXPECT_TRUE(layerImplDestructionList.contains(oldTreeRootLayerId));
334 EXPECT_TRUE(layerImplDestructionList.contains(oldTreeFirstChildLayerId)); 337 EXPECT_TRUE(layerImplDestructionList.contains(oldTreeFirstChildLayerId));
335 EXPECT_TRUE(layerImplDestructionList.contains(oldTreeSecondChildLayerId)); 338 EXPECT_TRUE(layerImplDestructionList.contains(oldTreeSecondChildLayerId));
336 } 339 }
337 340
338 // Constructs+syncs a tree with mask, replica, and replica mask layers. 341 // Constructs+syncs a tree with mask, replica, and replica mask layers.
339 TEST(TreeSynchronizerTest, syncMaskReplicaAndReplicaMaskLayers) 342 TEST(TreeSynchronizerTest, syncMaskReplicaAndReplicaMaskLayers)
340 { 343 {
341 DebugScopedSetImplThread impl;
342
343 LayerTreeSettings settings; 344 LayerTreeSettings settings;
344 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0); 345 FakeProxy proxy(0);
346 DebugScopedSetImplThread impl(&proxy);
347 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy);
345 348
346 scoped_refptr<Layer> layerTreeRoot = Layer::create(); 349 scoped_refptr<Layer> layerTreeRoot = Layer::create();
347 layerTreeRoot->addChild(Layer::create()); 350 layerTreeRoot->addChild(Layer::create());
348 layerTreeRoot->addChild(Layer::create()); 351 layerTreeRoot->addChild(Layer::create());
349 layerTreeRoot->addChild(Layer::create()); 352 layerTreeRoot->addChild(Layer::create());
350 353
351 // First child gets a mask layer. 354 // First child gets a mask layer.
352 scoped_refptr<Layer> maskLayer = Layer::create(); 355 scoped_refptr<Layer> maskLayer = Layer::create();
353 layerTreeRoot->children()[0]->setMaskLayer(maskLayer.get()); 356 layerTreeRoot->children()[0]->setMaskLayer(maskLayer.get());
354 357
(...skipping 22 matching lines...) Expand all
377 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm pl.get()); 380 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm pl.get());
378 381
379 // Remove the replica mask. 382 // Remove the replica mask.
380 replicaLayerWithMask->setMaskLayer(0); 383 replicaLayerWithMask->setMaskLayer(0);
381 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl.get()); 384 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl.get());
382 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm pl.get()); 385 expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostIm pl.get());
383 } 386 }
384 387
385 TEST(TreeSynchronizerTest, synchronizeAnimations) 388 TEST(TreeSynchronizerTest, synchronizeAnimations)
386 { 389 {
387 DebugScopedSetImplThread impl;
388
389 LayerTreeSettings settings; 390 LayerTreeSettings settings;
390 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0); 391 FakeProxy proxy(0);
392 DebugScopedSetImplThread impl(&proxy);
393 scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy);
391 394
392 scoped_refptr<Layer> layerTreeRoot = Layer::create(); 395 scoped_refptr<Layer> layerTreeRoot = Layer::create();
393 396
394 FakeLayerAnimationControllerClient dummy; 397 FakeLayerAnimationControllerClient dummy;
395 layerTreeRoot->setLayerAnimationController(FakeLayerAnimationController::cre ate(&dummy).PassAs<LayerAnimationController>()); 398 layerTreeRoot->setLayerAnimationController(FakeLayerAnimationController::cre ate(&dummy).PassAs<LayerAnimationController>());
396 399
397 EXPECT_FALSE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layer AnimationController())->synchronizedAnimations()); 400 EXPECT_FALSE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layer AnimationController())->synchronizedAnimations());
398 401
399 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get()); 402 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.get());
400 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl.get()); 403 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl.get());
401 404
402 EXPECT_TRUE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layerA nimationController())->synchronizedAnimations()); 405 EXPECT_TRUE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layerA nimationController())->synchronizedAnimations());
403 } 406 }
404 407
405 } // namespace 408 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698