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

Side by Side 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 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 "cc/layers/layer.h" 5 #include "cc/layers/layer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 1424
1425 EXPECT_FALSE(impl_layer->element_id()); 1425 EXPECT_FALSE(impl_layer->element_id());
1426 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties()); 1426 EXPECT_EQ(MutableProperty::kNone, impl_layer->mutable_properties());
1427 1427
1428 test_layer->PushPropertiesTo(impl_layer.get()); 1428 test_layer->PushPropertiesTo(impl_layer.get());
1429 1429
1430 EXPECT_EQ(ElementId(2), impl_layer->element_id()); 1430 EXPECT_EQ(ElementId(2), impl_layer->element_id());
1431 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties()); 1431 EXPECT_EQ(MutableProperty::kTransform, impl_layer->mutable_properties());
1432 } 1432 }
1433 1433
1434 TEST_F(LayerTest, NotUsingLayerListsManagesElementId) {
1435 scoped_refptr<Layer> test_layer = Layer::Create();
1436 ElementId element_id = ElementId(2);
1437 test_layer->SetElementId(element_id);
1438
1439 // Expect additional call due to has-animation check.
1440 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(2);
1441 scoped_refptr<AnimationTimeline> timeline =
1442 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
1443 animation_host_->AddAnimationTimeline(timeline);
1444
1445 AddOpacityTransitionToElementWithPlayer(element_id, timeline, 10.0, 1.f, 0.f,
1446 false);
1447 EXPECT_TRUE(animation_host_->HasAnyAnimation(element_id));
1448
1449 EXPECT_EQ(nullptr, layer_tree_host_->LayerByElementId(element_id));
1450 test_layer->SetLayerTreeHost(layer_tree_host_.get());
1451 // Layer should now be registered by element id.
1452 EXPECT_EQ(test_layer, layer_tree_host_->LayerByElementId(element_id));
1453
1454 test_layer->SetLayerTreeHost(nullptr);
1455 // Layer should have been un-registered.
1456 EXPECT_EQ(nullptr, layer_tree_host_->LayerByElementId(element_id));
1457 }
1458
1459 class LayerTestWithLayerLists : public LayerTest {
1460 protected:
1461 void SetUp() override {
1462 settings_.use_layer_lists = true;
1463 LayerTest::SetUp();
1464 }
1465 };
1466
1467 TEST_F(LayerTestWithLayerLists, UsingLayerListsDoesNotManageElementId) {
1468 scoped_refptr<Layer> test_layer = Layer::Create();
1469 ElementId element_id = ElementId(2);
1470 test_layer->SetElementId(element_id);
1471
1472 // Only one call expected since we should skip the has-animation check.
1473 EXPECT_CALL(*layer_tree_host_, SetNeedsCommit()).Times(1);
1474 scoped_refptr<AnimationTimeline> timeline =
1475 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId());
1476 animation_host_->AddAnimationTimeline(timeline);
1477
1478 AddOpacityTransitionToElementWithPlayer(element_id, timeline, 10.0, 1.f, 0.f,
1479 false);
1480 EXPECT_TRUE(animation_host_->HasAnyAnimation(element_id));
1481
1482 EXPECT_EQ(nullptr, layer_tree_host_->LayerByElementId(element_id));
1483 test_layer->SetLayerTreeHost(layer_tree_host_.get());
1484 // Layer shouldn't have been registered by element id.
1485 EXPECT_EQ(nullptr, layer_tree_host_->LayerByElementId(element_id));
1486
1487 test_layer->SetLayerTreeHost(nullptr);
1488 EXPECT_EQ(nullptr, layer_tree_host_->LayerByElementId(element_id));
1489 }
1490
1434 } // namespace 1491 } // namespace
1435 } // namespace cc 1492 } // namespace cc
OLDNEW
« 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