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

Unified Diff: cc/layers/layer_unittest.cc

Issue 2888483002: Manage registering composited elements in PaintArtifactCompositor. (Closed)
Patch Set: Sync to head and disable flaky animation test. Created 3 years, 7 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.cc ('k') | third_party/WebKit/LayoutTests/FlagExpectations/enable-slimming-paint-v2 » ('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 e6ef4d578fcda4b15003f8f44942b1254bbfee30..652d84e6dee54dbb51c1c8d0a0f9d1000babe06f 100644
--- a/cc/layers/layer_unittest.cc
+++ b/cc/layers/layer_unittest.cc
@@ -1431,5 +1431,62 @@ TEST_F(LayerTest, ElementIdAndMutablePropertiesArePushed) {
EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties());
}
+TEST_F(LayerTest, NotUsingLayerListsManagesElementId) {
+ scoped_refptr<Layer> test_layer = Layer::Create();
+ ElementId element_id = ElementId(2);
+ test_layer->SetElementId(element_id);
+
+ // Expect additional call due to has-animation check.
+ EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(2);
+ scoped_refptr<AnimationTimeline> timeline =
+ AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
+ animation_host_->AddAnimationTimeline(timeline);
+
+ AddOpacityTransitionToElementWithPlayer(element_id, timeline, 10.0, 1.f, 0.f,
+ false);
+ EXPECT_TRUE(animation_host_->HasAnyAnimation(element_id));
+
+ EXPECT_EQ(nullptr, layer_tree_host_->LayerByElementId(element_id));
+ test_layer->SetLayerTreeHost(layer_tree_host_.get());
+ // Layer should now be registered by element id.
+ EXPECT_EQ(test_layer, layer_tree_host_->LayerByElementId(element_id));
+
+ test_layer->SetLayerTreeHost(nullptr);
+ // Layer should have been un-registered.
+ EXPECT_EQ(nullptr, layer_tree_host_->LayerByElementId(element_id));
+}
+
+class LayerTestWithLayerLists : public LayerTest {
+ protected:
+ void SetUp() override {
+ settings_.use_layer_lists = true;
+ LayerTest::SetUp();
+ }
+};
+
+TEST_F(LayerTestWithLayerLists, UsingLayerListsDoesNotManageElementId) {
+ scoped_refptr<Layer> test_layer = Layer::Create();
+ ElementId element_id = ElementId(2);
+ test_layer->SetElementId(element_id);
+
+ // Only one call expected since we should skip the has-animation check.
+ EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
+ scoped_refptr<AnimationTimeline> timeline =
+ AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
+ animation_host_->AddAnimationTimeline(timeline);
+
+ AddOpacityTransitionToElementWithPlayer(element_id, timeline, 10.0, 1.f, 0.f,
+ false);
+ EXPECT_TRUE(animation_host_->HasAnyAnimation(element_id));
+
+ EXPECT_EQ(nullptr, layer_tree_host_->LayerByElementId(element_id));
+ test_layer->SetLayerTreeHost(layer_tree_host_.get());
+ // Layer shouldn't have been registered by element id.
+ EXPECT_EQ(nullptr, layer_tree_host_->LayerByElementId(element_id));
+
+ test_layer->SetLayerTreeHost(nullptr);
+ EXPECT_EQ(nullptr, layer_tree_host_->LayerByElementId(element_id));
+}
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/layers/layer.cc ('k') | third_party/WebKit/LayoutTests/FlagExpectations/enable-slimming-paint-v2 » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698