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

Unified Diff: cc/layers/layer_unittest.cc

Issue 2251143002: cc: Reland Move data to LayerTree from LayerTreeHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comment Created 4 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/layers/layer_proto_converter.h ('k') | cc/layers/painted_scrollbar_layer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/layer_unittest.cc
diff --git a/cc/layers/layer_unittest.cc b/cc/layers/layer_unittest.cc
index 02768a29925699f5d0ef13bb3176577da0e15f26..32337c93d7c053aadbecab6d60d09bc1e2bec530 100644
--- a/cc/layers/layer_unittest.cc
+++ b/cc/layers/layer_unittest.cc
@@ -49,11 +49,11 @@ using ::testing::Mock;
using ::testing::StrictMock;
using ::testing::_;
-#define EXPECT_SET_NEEDS_FULL_TREE_SYNC(expect, code_to_test) \
- do { \
- EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times((expect)); \
- code_to_test; \
- Mock::VerifyAndClearExpectations(layer_tree_host_.get()); \
+#define EXPECT_SET_NEEDS_FULL_TREE_SYNC(expect, code_to_test) \
+ do { \
+ EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times((expect)); \
+ code_to_test; \
+ Mock::VerifyAndClearExpectations(layer_tree_); \
} while (false)
#define EXECUTE_AND_VERIFY_SUBTREE_CHANGED(code_to_test) \
@@ -888,18 +888,36 @@ class LayerSerializationTest : public testing::Test {
namespace {
+class MockLayerTree : public LayerTree {
+ public:
+ MockLayerTree(AnimationHost* animation_host, LayerTreeHost* layer_tree_host)
+ : LayerTree(base::WrapUnique(animation_host), layer_tree_host) {}
+ ~MockLayerTree() override {}
+
+ MOCK_METHOD0(SetNeedsFullTreeSync, void());
+};
+
class MockLayerTreeHost : public LayerTreeHost {
public:
MockLayerTreeHost(LayerTreeHostSingleThreadClient* single_thread_client,
LayerTreeHost::InitParams* params)
- : LayerTreeHost(params, CompositorMode::SINGLE_THREADED) {
+ // We pass the raw pointer to the AnimationHost to the MockLayerTree here,
Khushal 2016/08/17 18:43:54 Added a comment to explain the weird release and w
+ // which the MockLayerTree will take ownership of. We tried using an
+ // rvalue reference to the unique_ptr of the animation host instead but
+ // StrictMock takes a const& of the arguments for the ctor of the
+ // templated class, so sadly we had to resort to releasing the pointer and
+ // wrapping it in a unique_ptr again later.
+ : LayerTreeHost(params,
+ CompositorMode::SINGLE_THREADED,
+ base::MakeUnique<StrictMock<MockLayerTree>>(
+ params->animation_host.release(),
+ this)) {
InitializeSingleThreaded(single_thread_client,
base::ThreadTaskRunnerHandle::Get(), nullptr);
}
MOCK_METHOD0(SetNeedsCommit, void());
MOCK_METHOD0(SetNeedsUpdateLayers, void());
- MOCK_METHOD0(SetNeedsFullTreeSync, void());
};
class LayerTest : public testing::Test {
@@ -929,11 +947,14 @@ class LayerTest : public testing::Test {
layer_tree_host_.reset(
new StrictMock<MockLayerTreeHost>(&single_thread_client_, &params));
+ layer_tree_ = static_cast<StrictMock<MockLayerTree>*>(
+ layer_tree_host_->GetLayerTree());
}
void TearDown() override {
Mock::VerifyAndClearExpectations(layer_tree_host_.get());
- EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber());
+ Mock::VerifyAndClearExpectations(layer_tree_);
+ EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(AnyNumber());
parent_ = nullptr;
child1_ = nullptr;
child2_ = nullptr;
@@ -942,8 +963,9 @@ class LayerTest : public testing::Test {
grand_child2_ = nullptr;
grand_child3_ = nullptr;
- layer_tree_host_->SetRootLayer(nullptr);
+ layer_tree_->SetRootLayer(nullptr);
layer_tree_host_ = nullptr;
+ layer_tree_ = nullptr;
}
void VerifyTestTreeInitialState() const {
@@ -977,8 +999,8 @@ class LayerTest : public testing::Test {
grand_child2_ = Layer::Create();
grand_child3_ = Layer::Create();
- EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber());
- layer_tree_host_->SetRootLayer(parent_);
+ EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(AnyNumber());
+ layer_tree_->SetRootLayer(parent_);
parent_->AddChild(child1_);
parent_->AddChild(child2_);
@@ -987,7 +1009,7 @@ class LayerTest : public testing::Test {
child1_->AddChild(grand_child2_);
child2_->AddChild(grand_child3_);
- Mock::VerifyAndClearExpectations(layer_tree_host_.get());
+ Mock::VerifyAndClearExpectations(layer_tree_);
VerifyTestTreeInitialState();
}
@@ -1000,6 +1022,7 @@ class LayerTest : public testing::Test {
StubLayerTreeHostSingleThreadClient single_thread_client_;
FakeLayerTreeHostClient fake_client_;
std::unique_ptr<StrictMock<MockLayerTreeHost>> layer_tree_host_;
+ StrictMock<MockLayerTree>* layer_tree_;
scoped_refptr<Layer> parent_;
scoped_refptr<Layer> child1_;
scoped_refptr<Layer> child2_;
@@ -1026,7 +1049,7 @@ TEST_F(LayerTest, BasicCreateAndDestroy) {
}
TEST_F(LayerTest, LayerPropertyChangedForSubtree) {
- EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AtLeast(1));
+ EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(AtLeast(1));
scoped_refptr<Layer> root = Layer::Create();
scoped_refptr<Layer> child = Layer::Create();
scoped_refptr<Layer> child2 = Layer::Create();
@@ -1034,7 +1057,7 @@ TEST_F(LayerTest, LayerPropertyChangedForSubtree) {
scoped_refptr<Layer> dummy_layer1 = Layer::Create();
scoped_refptr<Layer> dummy_layer2 = Layer::Create();
- layer_tree_host_->SetRootLayer(root);
+ layer_tree_->SetRootLayer(root);
root->AddChild(child);
root->AddChild(child2);
child->AddChild(grand_child);
@@ -1056,7 +1079,7 @@ TEST_F(LayerTest, LayerPropertyChangedForSubtree) {
std::unique_ptr<LayerImpl> dummy_layer2_impl =
LayerImpl::Create(host_impl_.active_tree(), dummy_layer2->id());
- EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1);
+ EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(1);
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetMaskLayer(dummy_layer1.get()));
EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
root->PushPropertiesTo(root_impl.get());
@@ -1081,7 +1104,7 @@ TEST_F(LayerTest, LayerPropertyChangedForSubtree) {
child2->PushPropertiesTo(child2_impl.get());
grand_child->PushPropertiesTo(grand_child_impl.get()));
- EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(1);
+ EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(1);
EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->SetReplicaLayer(dummy_layer2.get()));
EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
root->PushPropertiesTo(root_impl.get());
@@ -1161,7 +1184,7 @@ TEST_F(LayerTest, LayerPropertyChangedForSubtree) {
gfx::PointF arbitrary_point_f = gfx::PointF(0.125f, 0.25f);
EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
root->SetPosition(arbitrary_point_f);
- TransformNode* node = layer_tree_host_->property_trees()->transform_tree.Node(
+ TransformNode* node = layer_tree_->property_trees()->transform_tree.Node(
root->transform_tree_index());
EXPECT_TRUE(node->transform_changed);
EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
@@ -1169,33 +1192,33 @@ TEST_F(LayerTest, LayerPropertyChangedForSubtree) {
child->PushPropertiesTo(child_impl.get());
child2->PushPropertiesTo(child2_impl.get());
grand_child->PushPropertiesTo(grand_child_impl.get());
- layer_tree_host_->property_trees()->ResetAllChangeTracking());
+ layer_tree_->property_trees()->ResetAllChangeTracking());
EXPECT_FALSE(node->transform_changed);
EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
child->SetPosition(arbitrary_point_f);
- node = layer_tree_host_->property_trees()->transform_tree.Node(
+ node = layer_tree_->property_trees()->transform_tree.Node(
child->transform_tree_index());
EXPECT_TRUE(node->transform_changed);
// child2 is not in the subtree of child, but its scroll parent is. So, its
// to_screen will be effected by change in position of child2.
- layer_tree_host_->property_trees()->transform_tree.UpdateTransforms(
+ layer_tree_->property_trees()->transform_tree.UpdateTransforms(
child2->transform_tree_index());
- node = layer_tree_host_->property_trees()->transform_tree.Node(
+ node = layer_tree_->property_trees()->transform_tree.Node(
child2->transform_tree_index());
EXPECT_TRUE(node->transform_changed);
EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
child->PushPropertiesTo(child_impl.get());
grand_child->PushPropertiesTo(grand_child_impl.get());
- layer_tree_host_->property_trees()->ResetAllChangeTracking());
- node = layer_tree_host_->property_trees()->transform_tree.Node(
+ layer_tree_->property_trees()->ResetAllChangeTracking());
+ node = layer_tree_->property_trees()->transform_tree.Node(
child->transform_tree_index());
EXPECT_FALSE(node->transform_changed);
gfx::Point3F arbitrary_point_3f = gfx::Point3F(0.125f, 0.25f, 0.f);
EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
root->SetTransformOrigin(arbitrary_point_3f);
- node = layer_tree_host_->property_trees()->transform_tree.Node(
+ node = layer_tree_->property_trees()->transform_tree.Node(
root->transform_tree_index());
EXPECT_TRUE(node->transform_changed);
EXECUTE_AND_VERIFY_SUBTREE_CHANGES_RESET(
@@ -1203,13 +1226,13 @@ TEST_F(LayerTest, LayerPropertyChangedForSubtree) {
child->PushPropertiesTo(child_impl.get());
child2->PushPropertiesTo(child2_impl.get());
grand_child->PushPropertiesTo(grand_child_impl.get());
- layer_tree_host_->property_trees()->ResetAllChangeTracking());
+ layer_tree_->property_trees()->ResetAllChangeTracking());
gfx::Transform arbitrary_transform;
arbitrary_transform.Scale3d(0.1f, 0.2f, 0.3f);
EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
root->SetTransform(arbitrary_transform);
- node = layer_tree_host_->property_trees()->transform_tree.Node(
+ node = layer_tree_->property_trees()->transform_tree.Node(
root->transform_tree_index());
EXPECT_TRUE(node->transform_changed);
}
@@ -1222,7 +1245,7 @@ TEST_F(LayerTest, AddAndRemoveChild) {
ASSERT_EQ(0U, parent->children().size());
EXPECT_FALSE(child->parent());
- EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent));
+ EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(parent));
EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, parent->AddChild(child));
ASSERT_EQ(1U, parent->children().size());
@@ -1234,12 +1257,12 @@ TEST_F(LayerTest, AddAndRemoveChild) {
}
TEST_F(LayerTest, AddSameChildTwice) {
- EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AtLeast(1));
+ EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(AtLeast(1));
scoped_refptr<Layer> parent = Layer::Create();
scoped_refptr<Layer> child = Layer::Create();
- layer_tree_host_->SetRootLayer(parent);
+ layer_tree_->SetRootLayer(parent);
ASSERT_EQ(0u, parent->children().size());
@@ -1259,7 +1282,7 @@ TEST_F(LayerTest, InsertChild) {
scoped_refptr<Layer> child3 = Layer::Create();
scoped_refptr<Layer> child4 = Layer::Create();
- EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent));
+ EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(parent));
ASSERT_EQ(0U, parent->children().size());
@@ -1294,7 +1317,7 @@ TEST_F(LayerTest, InsertChild) {
EXPECT_EQ(child4, parent->children()[3]);
EXPECT_EQ(parent.get(), child4->parent());
- EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr));
+ EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(nullptr));
}
TEST_F(LayerTest, InsertChildPastEndOfList) {
@@ -1323,7 +1346,7 @@ TEST_F(LayerTest, InsertSameChildTwice) {
scoped_refptr<Layer> child1 = Layer::Create();
scoped_refptr<Layer> child2 = Layer::Create();
- EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent));
+ EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(parent));
ASSERT_EQ(0U, parent->children().size());
@@ -1343,7 +1366,7 @@ TEST_F(LayerTest, InsertSameChildTwice) {
EXPECT_EQ(child2, parent->children()[0]);
EXPECT_EQ(child1, parent->children()[1]);
- EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr));
+ EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(nullptr));
}
TEST_F(LayerTest, ReplaceChildWithNewChild) {
@@ -1400,7 +1423,7 @@ TEST_F(LayerTest, DeleteRemovedScrollParent) {
scoped_refptr<Layer> child1 = Layer::Create();
scoped_refptr<Layer> child2 = Layer::Create();
- EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent));
+ EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(parent));
ASSERT_EQ(0U, parent->children().size());
@@ -1419,11 +1442,9 @@ TEST_F(LayerTest, DeleteRemovedScrollParent) {
EXPECT_SET_NEEDS_COMMIT(1, child2 = nullptr);
- EXPECT_TRUE(
- layer_tree_host_->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
- child1.get()));
+ EXPECT_TRUE(layer_tree_->LayerNeedsPushPropertiesForTesting(child1.get()));
- EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr));
+ EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(nullptr));
}
TEST_F(LayerTest, DeleteRemovedScrollChild) {
@@ -1431,7 +1452,7 @@ TEST_F(LayerTest, DeleteRemovedScrollChild) {
scoped_refptr<Layer> child1 = Layer::Create();
scoped_refptr<Layer> child2 = Layer::Create();
- EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(parent));
+ EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(parent));
ASSERT_EQ(0U, parent->children().size());
@@ -1450,11 +1471,9 @@ TEST_F(LayerTest, DeleteRemovedScrollChild) {
EXPECT_SET_NEEDS_COMMIT(1, child1 = nullptr);
- EXPECT_TRUE(
- layer_tree_host_->GetLayerTree()->LayerNeedsPushPropertiesForTesting(
- child2.get()));
+ EXPECT_TRUE(layer_tree_->LayerNeedsPushPropertiesForTesting(child2.get()));
- EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr));
+ EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(nullptr));
}
TEST_F(LayerTest, ReplaceChildWithSameChild) {
@@ -1463,7 +1482,7 @@ TEST_F(LayerTest, ReplaceChildWithSameChild) {
// SetNeedsFullTreeSync / SetNeedsCommit should not be called because its the
// same child.
EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(0);
- EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(0);
+ EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(0);
parent_->ReplaceChild(child2_.get(), child2_);
VerifyTestTreeInitialState();
@@ -1498,8 +1517,7 @@ TEST_F(LayerTest, SetChildren) {
EXPECT_EQ(old_parent.get(), child1->parent());
EXPECT_FALSE(child2->parent());
- EXPECT_SET_NEEDS_FULL_TREE_SYNC(
- 1, layer_tree_host_->SetRootLayer(new_parent));
+ EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(new_parent));
EXPECT_SET_NEEDS_FULL_TREE_SYNC(
AtLeast(1), new_parent->SetChildren(new_children));
@@ -1508,7 +1526,7 @@ TEST_F(LayerTest, SetChildren) {
EXPECT_EQ(new_parent.get(), child1->parent());
EXPECT_EQ(new_parent.get(), child2->parent());
- EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(nullptr));
+ EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(nullptr));
}
TEST_F(LayerTest, HasAncestor) {
@@ -1536,7 +1554,7 @@ TEST_F(LayerTest, GetRootLayerAfterTreeManipulations) {
CreateSimpleTestTree();
// For this test we don't care about SetNeedsFullTreeSync calls.
- EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times(AnyNumber());
+ EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times(AnyNumber());
scoped_refptr<Layer> child4 = Layer::Create();
@@ -1594,8 +1612,7 @@ TEST_F(LayerTest, CheckSetNeedsDisplayCausesCorrectBehavior) {
// SetNeedsDisplay.
scoped_refptr<Layer> test_layer = Layer::Create();
- EXPECT_SET_NEEDS_FULL_TREE_SYNC(
- 1, layer_tree_host_->SetRootLayer(test_layer));
+ EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer));
EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true));
gfx::Size test_bounds = gfx::Size(501, 508);
@@ -1646,8 +1663,7 @@ TEST_F(LayerTest, CheckSetNeedsDisplayCausesCorrectBehavior) {
TEST_F(LayerTest, TestSettingMainThreadScrollingReason) {
scoped_refptr<Layer> test_layer = Layer::Create();
- EXPECT_SET_NEEDS_FULL_TREE_SYNC(1,
- layer_tree_host_->SetRootLayer(test_layer));
+ EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer));
EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true));
// sanity check of initial test condition
@@ -1697,8 +1713,7 @@ TEST_F(LayerTest, TestSettingMainThreadScrollingReason) {
TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) {
scoped_refptr<Layer> test_layer = Layer::Create();
- EXPECT_SET_NEEDS_FULL_TREE_SYNC(
- 1, layer_tree_host_->SetRootLayer(test_layer));
+ EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer));
EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetIsDrawable(true));
scoped_refptr<Layer> dummy_layer1 = Layer::Create();
@@ -1749,7 +1764,7 @@ TEST_F(LayerTest, CheckPropertyChangeCausesCorrectBehavior) {
EXPECT_FALSE(test_layer->NeedsDisplayForTesting());
// As layers are removed from the tree, they will cause a tree sync.
- EXPECT_CALL(*layer_tree_host_, SetNeedsFullTreeSync()).Times((AnyNumber()));
+ EXPECT_CALL(*layer_tree_, SetNeedsFullTreeSync()).Times((AnyNumber()));
}
TEST_F(LayerTest, PushPropertiesAccumulatesUpdateRect) {
@@ -1757,8 +1772,7 @@ TEST_F(LayerTest, PushPropertiesAccumulatesUpdateRect) {
std::unique_ptr<LayerImpl> impl_layer =
LayerImpl::Create(host_impl_.active_tree(), 1);
- EXPECT_SET_NEEDS_FULL_TREE_SYNC(1,
- layer_tree_host_->SetRootLayer(test_layer));
+ EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer));
host_impl_.active_tree()->SetRootLayerForTesting(std::move(impl_layer));
host_impl_.active_tree()->BuildLayerListForTesting();
@@ -1789,8 +1803,7 @@ TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForTransform) {
std::unique_ptr<LayerImpl> impl_layer =
LayerImpl::Create(host_impl_.active_tree(), 1);
- EXPECT_SET_NEEDS_FULL_TREE_SYNC(1,
- layer_tree_host_->SetRootLayer(test_layer));
+ EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer));
gfx::Transform transform;
transform.Rotate(45.0);
@@ -1808,8 +1821,7 @@ TEST_F(LayerTest, PushPropertiesCausesLayerPropertyChangedForOpacity) {
std::unique_ptr<LayerImpl> impl_layer =
LayerImpl::Create(host_impl_.active_tree(), 1);
- EXPECT_SET_NEEDS_FULL_TREE_SYNC(1,
- layer_tree_host_->SetRootLayer(test_layer));
+ EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer));
EXPECT_SET_NEEDS_COMMIT(1, test_layer->SetOpacity(0.5f));
@@ -1915,15 +1927,16 @@ TEST_F(LayerLayerTreeHostTest, EnteringTree) {
LayerTreeHostFactory factory;
std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create();
+ LayerTree* layer_tree = layer_tree_host->GetLayerTree();
// Setting the root layer should set the host pointer for all layers in the
// tree.
- layer_tree_host->SetRootLayer(parent.get());
+ layer_tree->SetRootLayer(parent.get());
AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get());
// Clearing the root layer should also clear out the host pointers for all
// layers in the tree.
- layer_tree_host->SetRootLayer(nullptr);
+ layer_tree->SetRootLayer(nullptr);
AssertLayerTreeHostMatchesForSubtree(parent.get(), nullptr);
}
@@ -1932,8 +1945,9 @@ TEST_F(LayerLayerTreeHostTest, AddingLayerSubtree) {
scoped_refptr<Layer> parent = Layer::Create();
LayerTreeHostFactory factory;
std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create();
+ LayerTree* layer_tree = layer_tree_host->GetLayerTree();
- layer_tree_host->SetRootLayer(parent.get());
+ layer_tree->SetRootLayer(parent.get());
EXPECT_EQ(parent->layer_tree_host(), layer_tree_host.get());
@@ -1954,7 +1968,7 @@ TEST_F(LayerLayerTreeHostTest, AddingLayerSubtree) {
parent->AddChild(child);
AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get());
- layer_tree_host->SetRootLayer(nullptr);
+ layer_tree->SetRootLayer(nullptr);
}
TEST_F(LayerLayerTreeHostTest, ChangeHost) {
@@ -1972,7 +1986,7 @@ TEST_F(LayerLayerTreeHostTest, ChangeHost) {
LayerTreeHostFactory factory;
std::unique_ptr<LayerTreeHost> first_layer_tree_host = factory.Create();
- first_layer_tree_host->SetRootLayer(parent.get());
+ first_layer_tree_host->GetLayerTree()->SetRootLayer(parent.get());
AssertLayerTreeHostMatchesForSubtree(parent.get(),
first_layer_tree_host.get());
@@ -1980,12 +1994,12 @@ TEST_F(LayerLayerTreeHostTest, ChangeHost) {
// Now re-root the tree to a new host (simulating what we do on a context lost
// event). This should update the host pointers for all layers in the tree.
std::unique_ptr<LayerTreeHost> second_layer_tree_host = factory.Create();
- second_layer_tree_host->SetRootLayer(parent.get());
+ second_layer_tree_host->GetLayerTree()->SetRootLayer(parent.get());
AssertLayerTreeHostMatchesForSubtree(parent.get(),
second_layer_tree_host.get());
- second_layer_tree_host->SetRootLayer(nullptr);
+ second_layer_tree_host->GetLayerTree()->SetRootLayer(nullptr);
}
TEST_F(LayerLayerTreeHostTest, ChangeHostInSubtree) {
@@ -2002,7 +2016,7 @@ TEST_F(LayerLayerTreeHostTest, ChangeHostInSubtree) {
LayerTreeHostFactory factory;
std::unique_ptr<LayerTreeHost> first_layer_tree_host = factory.Create();
- first_layer_tree_host->SetRootLayer(first_parent.get());
+ first_layer_tree_host->GetLayerTree()->SetRootLayer(first_parent.get());
AssertLayerTreeHostMatchesForSubtree(first_parent.get(),
first_layer_tree_host.get());
@@ -2010,7 +2024,7 @@ TEST_F(LayerLayerTreeHostTest, ChangeHostInSubtree) {
// Now reparent the subtree starting at second_child to a layer in a different
// tree.
std::unique_ptr<LayerTreeHost> second_layer_tree_host = factory.Create();
- second_layer_tree_host->SetRootLayer(second_parent.get());
+ second_layer_tree_host->GetLayerTree()->SetRootLayer(second_parent.get());
second_parent->AddChild(second_child);
@@ -2020,8 +2034,8 @@ TEST_F(LayerLayerTreeHostTest, ChangeHostInSubtree) {
second_grand_child->layer_tree_host());
// Test over, cleanup time.
- first_layer_tree_host->SetRootLayer(nullptr);
- second_layer_tree_host->SetRootLayer(nullptr);
+ first_layer_tree_host->GetLayerTree()->SetRootLayer(nullptr);
+ second_layer_tree_host->GetLayerTree()->SetRootLayer(nullptr);
}
TEST_F(LayerLayerTreeHostTest, ReplaceMaskAndReplicaLayer) {
@@ -2040,7 +2054,7 @@ TEST_F(LayerLayerTreeHostTest, ReplaceMaskAndReplicaLayer) {
LayerTreeHostFactory factory;
std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create();
- layer_tree_host->SetRootLayer(parent.get());
+ layer_tree_host->GetLayerTree()->SetRootLayer(parent.get());
AssertLayerTreeHostMatchesForSubtree(parent.get(), layer_tree_host.get());
@@ -2055,7 +2069,7 @@ TEST_F(LayerLayerTreeHostTest, ReplaceMaskAndReplicaLayer) {
EXPECT_EQ(nullptr, replica_child->layer_tree_host());
// Test over, cleanup time.
- layer_tree_host->SetRootLayer(nullptr);
+ layer_tree_host->GetLayerTree()->SetRootLayer(nullptr);
}
TEST_F(LayerLayerTreeHostTest, DestroyHostWithNonNullRootLayer) {
@@ -2064,15 +2078,16 @@ TEST_F(LayerLayerTreeHostTest, DestroyHostWithNonNullRootLayer) {
root->AddChild(child);
LayerTreeHostFactory factory;
std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create();
- layer_tree_host->SetRootLayer(root);
+ layer_tree_host->GetLayerTree()->SetRootLayer(root);
}
TEST_F(LayerTest, SafeOpaqueBackgroundColor) {
LayerTreeHostFactory factory;
std::unique_ptr<LayerTreeHost> layer_tree_host = factory.Create();
+ LayerTree* layer_tree = layer_tree_host->GetLayerTree();
scoped_refptr<Layer> layer = Layer::Create();
- layer_tree_host->SetRootLayer(layer);
+ layer_tree->SetRootLayer(layer);
for (int contents_opaque = 0; contents_opaque < 2; ++contents_opaque) {
for (int layer_opaque = 0; layer_opaque < 2; ++layer_opaque) {
@@ -2080,10 +2095,10 @@ TEST_F(LayerTest, SafeOpaqueBackgroundColor) {
layer->SetContentsOpaque(!!contents_opaque);
layer->SetBackgroundColor(layer_opaque ? SK_ColorRED
: SK_ColorTRANSPARENT);
- layer_tree_host->set_background_color(
- host_opaque ? SK_ColorRED : SK_ColorTRANSPARENT);
+ layer_tree->set_background_color(host_opaque ? SK_ColorRED
+ : SK_ColorTRANSPARENT);
- layer_tree_host->property_trees()->needs_rebuild = true;
+ layer_tree->property_trees()->needs_rebuild = true;
layer_tree_host->BuildPropertyTreesForTesting();
SkColor safe_color = layer->SafeOpaqueBackgroundColor();
if (contents_opaque) {
@@ -2216,7 +2231,7 @@ TEST_F(LayerTest, DedupesCopyOutputRequestsBySource) {
TEST_F(LayerTest, AnimationSchedulesLayerUpdate) {
scoped_refptr<Layer> layer = Layer::Create();
- EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_host_->SetRootLayer(layer));
+ EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(layer));
LayerInternalsForTest layer_internals(layer.get());
@@ -2532,8 +2547,7 @@ TEST_F(LayerTest, ElementIdAndMutablePropertiesArePushed) {
std::unique_ptr<LayerImpl> impl_layer =
LayerImpl::Create(host_impl_.active_tree(), 1);
- EXPECT_SET_NEEDS_FULL_TREE_SYNC(1,
- layer_tree_host_->SetRootLayer(test_layer));
+ EXPECT_SET_NEEDS_FULL_TREE_SYNC(1, layer_tree_->SetRootLayer(test_layer));
EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(2);
« no previous file with comments | « cc/layers/layer_proto_converter.h ('k') | cc/layers/painted_scrollbar_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698