Index: cc/tree_synchronizer_unittest.cc |
diff --git a/cc/tree_synchronizer_unittest.cc b/cc/tree_synchronizer_unittest.cc |
index 94aadf3d96195fe68172060a5efa3123e060957c..585db8f7865ffd8fdfc4a38b1dbc1f05b75a52c8 100644 |
--- a/cc/tree_synchronizer_unittest.cc |
+++ b/cc/tree_synchronizer_unittest.cc |
@@ -12,7 +12,8 @@ |
#include "cc/proxy.h" |
#include "cc/single_thread_proxy.h" |
#include "cc/test/animation_test_common.h" |
-#include "cc/test/fake_proxy.h" |
+#include "cc/test/fake_impl_proxy.h" |
+#include "cc/test/fake_layer_tree_host_impl.h" |
#include "testing/gtest/include/gtest/gtest.h" |
namespace cc { |
@@ -125,48 +126,50 @@ void expectTreesAreIdentical(Layer* layer, LayerImpl* layerImpl, LayerTreeImpl* |
expectTreesAreIdentical(layerChildren[i].get(), layerImplChildren[i], treeImpl); |
} |
+class TreeSynchronizerTest : public testing::Test { |
+public: |
+ TreeSynchronizerTest() |
+ : m_hostImpl(&m_proxy) |
+ { |
+ } |
+ |
+protected: |
+ FakeImplProxy m_proxy; |
+ FakeLayerTreeHostImpl m_hostImpl; |
+}; |
+ |
// Attempts to synchronizes a null tree. This should not crash, and should |
// return a null tree. |
-TEST(TreeSynchronizerTest, syncNullTree) |
+TEST_F(TreeSynchronizerTest, syncNullTree) |
{ |
- scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(0, scoped_ptr<LayerImpl>(), 0); |
+ scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(0, scoped_ptr<LayerImpl>(), m_hostImpl.activeTree()); |
EXPECT_TRUE(!layerImplTreeRoot.get()); |
} |
// Constructs a very simple tree and synchronizes it without trying to reuse any preexisting layers. |
-TEST(TreeSynchronizerTest, syncSimpleTreeFromEmpty) |
+TEST_F(TreeSynchronizerTest, syncSimpleTreeFromEmpty) |
{ |
- LayerTreeSettings settings; |
- FakeProxy proxy(scoped_ptr<Thread>(NULL)); |
- DebugScopedSetImplThread impl(&proxy); |
- scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy); |
- |
scoped_refptr<Layer> layerTreeRoot = Layer::create(); |
layerTreeRoot->addChild(Layer::create()); |
layerTreeRoot->addChild(Layer::create()); |
- scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl->activeTree()); |
+ scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.activeTree()); |
- expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostImpl->activeTree()); |
+ expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_hostImpl.activeTree()); |
} |
// Constructs a very simple tree and synchronizes it attempting to reuse some layers |
-TEST(TreeSynchronizerTest, syncSimpleTreeReusingLayers) |
+TEST_F(TreeSynchronizerTest, syncSimpleTreeReusingLayers) |
{ |
std::vector<int> layerImplDestructionList; |
- LayerTreeSettings settings; |
- FakeProxy proxy(scoped_ptr<Thread>(NULL)); |
- DebugScopedSetImplThread impl(&proxy); |
- scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy); |
- |
scoped_refptr<Layer> layerTreeRoot = MockLayer::create(&layerImplDestructionList); |
layerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); |
layerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); |
- scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl->activeTree()); |
- expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostImpl->activeTree()); |
+ scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.activeTree()); |
+ expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_hostImpl.activeTree()); |
// Add a new layer to the Layer side |
layerTreeRoot->children()[0]->addChild(MockLayer::create(&layerImplDestructionList)); |
@@ -175,38 +178,33 @@ TEST(TreeSynchronizerTest, syncSimpleTreeReusingLayers) |
int secondLayerImplId = layerImplTreeRoot->children()[1]->id(); |
// Synchronize again. After the sync the trees should be equivalent and we should have created and destroyed one LayerImpl. |
- layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl->activeTree()); |
- expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostImpl->activeTree()); |
+ layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.activeTree()); |
+ expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_hostImpl.activeTree()); |
ASSERT_EQ(1u, layerImplDestructionList.size()); |
EXPECT_EQ(secondLayerImplId, layerImplDestructionList[0]); |
} |
// Constructs a very simple tree and checks that a stacking-order change is tracked properly. |
-TEST(TreeSynchronizerTest, syncSimpleTreeAndTrackStackingOrderChange) |
+TEST_F(TreeSynchronizerTest, syncSimpleTreeAndTrackStackingOrderChange) |
{ |
std::vector<int> layerImplDestructionList; |
- LayerTreeSettings settings; |
- FakeProxy proxy(scoped_ptr<Thread>(NULL)); |
- DebugScopedSetImplThread impl(&proxy); |
- scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy); |
- |
// Set up the tree and sync once. child2 needs to be synced here, too, even though we |
// remove it to set up the intended scenario. |
scoped_refptr<Layer> layerTreeRoot = MockLayer::create(&layerImplDestructionList); |
scoped_refptr<Layer> child2 = MockLayer::create(&layerImplDestructionList); |
layerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); |
layerTreeRoot->addChild(child2); |
- scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl->activeTree()); |
- expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostImpl->activeTree()); |
+ scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.activeTree()); |
+ expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_hostImpl.activeTree()); |
layerImplTreeRoot->resetAllChangeTrackingForSubtree(); |
// re-insert the layer and sync again. |
child2->removeFromParent(); |
layerTreeRoot->addChild(child2); |
- layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl->activeTree()); |
- expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostImpl->activeTree()); |
+ layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.activeTree()); |
+ expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_hostImpl.activeTree()); |
// Check that the impl thread properly tracked the change. |
EXPECT_FALSE(layerImplTreeRoot->layerPropertyChanged()); |
@@ -214,13 +212,8 @@ TEST(TreeSynchronizerTest, syncSimpleTreeAndTrackStackingOrderChange) |
EXPECT_TRUE(layerImplTreeRoot->children()[1]->layerPropertyChanged()); |
} |
-TEST(TreeSynchronizerTest, syncSimpleTreeAndProperties) |
+TEST_F(TreeSynchronizerTest, syncSimpleTreeAndProperties) |
{ |
- LayerTreeSettings settings; |
- FakeProxy proxy(scoped_ptr<Thread>(NULL)); |
- DebugScopedSetImplThread impl(&proxy); |
- scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy); |
- |
scoped_refptr<Layer> layerTreeRoot = Layer::create(); |
layerTreeRoot->addChild(Layer::create()); |
layerTreeRoot->addChild(Layer::create()); |
@@ -235,8 +228,8 @@ TEST(TreeSynchronizerTest, syncSimpleTreeAndProperties) |
gfx::Size secondChildBounds = gfx::Size(25, 53); |
layerTreeRoot->children()[1]->setBounds(secondChildBounds); |
- scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl->activeTree()); |
- expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostImpl->activeTree()); |
+ scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.activeTree()); |
+ expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_hostImpl.activeTree()); |
// Check that the property values we set on the Layer tree are reflected in the LayerImpl tree. |
gfx::PointF rootLayerImplPosition = layerImplTreeRoot->position(); |
@@ -250,15 +243,10 @@ TEST(TreeSynchronizerTest, syncSimpleTreeAndProperties) |
EXPECT_EQ(secondChildBounds.height(), secondLayerImplChildBounds.height()); |
} |
-TEST(TreeSynchronizerTest, reuseLayerImplsAfterStructuralChange) |
+TEST_F(TreeSynchronizerTest, reuseLayerImplsAfterStructuralChange) |
{ |
std::vector<int> layerImplDestructionList; |
- LayerTreeSettings settings; |
- FakeProxy proxy(scoped_ptr<Thread>(NULL)); |
- DebugScopedSetImplThread impl(&proxy); |
- scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy); |
- |
// Set up a tree with this sort of structure: |
// root --- A --- B ---+--- C |
// | |
@@ -276,8 +264,8 @@ TEST(TreeSynchronizerTest, reuseLayerImplsAfterStructuralChange) |
layerB->addChild(MockLayer::create(&layerImplDestructionList)); |
scoped_refptr<Layer> layerD = layerB->children()[1].get(); |
- scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl->activeTree()); |
- expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostImpl->activeTree()); |
+ scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.activeTree()); |
+ expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_hostImpl.activeTree()); |
// Now restructure the tree to look like this: |
// root --- D ---+--- A |
@@ -294,22 +282,17 @@ TEST(TreeSynchronizerTest, reuseLayerImplsAfterStructuralChange) |
layerC->addChild(layerB); |
// After another synchronize our trees should match and we should not have destroyed any LayerImpls |
- layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl->activeTree()); |
- expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostImpl->activeTree()); |
+ layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.activeTree()); |
+ expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_hostImpl.activeTree()); |
EXPECT_EQ(0u, layerImplDestructionList.size()); |
} |
// Constructs a very simple tree, synchronizes it, then synchronizes to a totally new tree. All layers from the old tree should be deleted. |
-TEST(TreeSynchronizerTest, syncSimpleTreeThenDestroy) |
+TEST_F(TreeSynchronizerTest, syncSimpleTreeThenDestroy) |
{ |
std::vector<int> layerImplDestructionList; |
- LayerTreeSettings settings; |
- FakeProxy proxy(scoped_ptr<Thread>(NULL)); |
- DebugScopedSetImplThread impl(&proxy); |
- scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy); |
- |
scoped_refptr<Layer> oldLayerTreeRoot = MockLayer::create(&layerImplDestructionList); |
oldLayerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); |
oldLayerTreeRoot->addChild(MockLayer::create(&layerImplDestructionList)); |
@@ -318,16 +301,16 @@ TEST(TreeSynchronizerTest, syncSimpleTreeThenDestroy) |
int oldTreeFirstChildLayerId = oldLayerTreeRoot->children()[0]->id(); |
int oldTreeSecondChildLayerId = oldLayerTreeRoot->children()[1]->id(); |
- scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(oldLayerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl->activeTree()); |
- expectTreesAreIdentical(oldLayerTreeRoot.get(), layerImplTreeRoot.get(), hostImpl->activeTree()); |
+ scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(oldLayerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.activeTree()); |
+ expectTreesAreIdentical(oldLayerTreeRoot.get(), layerImplTreeRoot.get(), m_hostImpl.activeTree()); |
// Remove all children on the Layer side. |
oldLayerTreeRoot->removeAllChildren(); |
// Synchronize again. After the sync all LayerImpls from the old tree should be deleted. |
scoped_refptr<Layer> newLayerTreeRoot = Layer::create(); |
- layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(newLayerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl->activeTree()); |
- expectTreesAreIdentical(newLayerTreeRoot.get(), layerImplTreeRoot.get(), hostImpl->activeTree()); |
+ layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(newLayerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.activeTree()); |
+ expectTreesAreIdentical(newLayerTreeRoot.get(), layerImplTreeRoot.get(), m_hostImpl.activeTree()); |
ASSERT_EQ(3u, layerImplDestructionList.size()); |
@@ -337,13 +320,8 @@ TEST(TreeSynchronizerTest, syncSimpleTreeThenDestroy) |
} |
// Constructs+syncs a tree with mask, replica, and replica mask layers. |
-TEST(TreeSynchronizerTest, syncMaskReplicaAndReplicaMaskLayers) |
+TEST_F(TreeSynchronizerTest, syncMaskReplicaAndReplicaMaskLayers) |
{ |
- LayerTreeSettings settings; |
- FakeProxy proxy(scoped_ptr<Thread>(NULL)); |
- DebugScopedSetImplThread impl(&proxy); |
- scoped_ptr<LayerTreeHostImpl> hostImpl = LayerTreeHostImpl::create(settings, 0, &proxy); |
- |
scoped_refptr<Layer> layerTreeRoot = Layer::create(); |
layerTreeRoot->addChild(Layer::create()); |
layerTreeRoot->addChild(Layer::create()); |
@@ -363,27 +341,27 @@ TEST(TreeSynchronizerTest, syncMaskReplicaAndReplicaMaskLayers) |
replicaLayerWithMask->setMaskLayer(replicaMaskLayer.get()); |
layerTreeRoot->children()[2]->setReplicaLayer(replicaLayerWithMask.get()); |
- scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl->activeTree()); |
+ scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.activeTree()); |
- expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostImpl->activeTree()); |
+ expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_hostImpl.activeTree()); |
// Remove the mask layer. |
layerTreeRoot->children()[0]->setMaskLayer(0); |
- layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl->activeTree()); |
- expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostImpl->activeTree()); |
+ layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.activeTree()); |
+ expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_hostImpl.activeTree()); |
// Remove the replica layer. |
layerTreeRoot->children()[1]->setReplicaLayer(0); |
- layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl->activeTree()); |
- expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostImpl->activeTree()); |
+ layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.activeTree()); |
+ expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_hostImpl.activeTree()); |
// Remove the replica mask. |
replicaLayerWithMask->setMaskLayer(0); |
- layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl->activeTree()); |
- expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), hostImpl->activeTree()); |
+ layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.activeTree()); |
+ expectTreesAreIdentical(layerTreeRoot.get(), layerImplTreeRoot.get(), m_hostImpl.activeTree()); |
} |
-TEST(TreeSynchronizerTest, synchronizeAnimations) |
+TEST_F(TreeSynchronizerTest, synchronizeAnimations) |
{ |
LayerTreeSettings settings; |
FakeProxy proxy(scoped_ptr<Thread>(NULL)); |
@@ -397,8 +375,8 @@ TEST(TreeSynchronizerTest, synchronizeAnimations) |
EXPECT_FALSE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layerAnimationController())->synchronizedAnimations()); |
- scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl->activeTree()); |
- layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl->activeTree()); |
+ scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), m_hostImpl.activeTree()); |
+ layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), m_hostImpl.activeTree()); |
EXPECT_TRUE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layerAnimationController())->synchronizedAnimations()); |
} |