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

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 1973083002: Use element id's for animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: get element id's from scroll node data directly. Created 4 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
Index: cc/trees/layer_tree_host_impl_unittest.cc
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 72b431a63100516e18878d1195291782b1f6d7da..d1029f368708d6ea9c802a4df33e582aa20a4a15 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -378,6 +378,8 @@ class LayerTreeHostImplTest : public testing::Test,
host_impl_->InnerViewportScrollLayer()->SetBounds(viewport_size);
host_impl_->active_tree()->BuildPropertyTreesForTesting();
+ host_impl_->active_tree()->SetElementIdsForTesting();
+
host_impl_->SetViewportSize(viewport_size);
host_impl_->active_tree()->DidBecomeActive();
@@ -1314,7 +1316,11 @@ TEST_F(LayerTreeHostImplTest, AnimationSchedulingPendingTree) {
child->SetBounds(gfx::Size(10, 10));
child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
child->SetDrawsContent(true);
- AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0);
+
+ host_impl_->pending_tree()->SetElementIdsForTesting();
+
+ AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 10.0,
+ 3, 0);
EXPECT_FALSE(did_request_next_frame_);
EXPECT_FALSE(did_request_redraw_);
@@ -1365,13 +1371,15 @@ TEST_F(LayerTreeHostImplTest, AnimationSchedulingActiveTree) {
child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
child->SetDrawsContent(true);
+ host_impl_->active_tree()->SetElementIdsForTesting();
+
// Add a translate from 6,7 to 8,9.
TransformOperations start;
start.AppendTranslate(6.f, 7.f, 0.f);
TransformOperations end;
end.AppendTranslate(8.f, 9.f, 0.f);
- AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 4.0, start,
- end);
+ AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 4.0,
+ start, end);
base::TimeTicks now = base::TimeTicks::Now();
host_impl_->WillBeginImplFrame(
@@ -1428,7 +1436,11 @@ TEST_F(LayerTreeHostImplTest, AnimationSchedulingCommitToActiveTree) {
child->SetBounds(gfx::Size(10, 10));
child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
child->SetDrawsContent(true);
- AddAnimatedTransformToLayerWithPlayer(child->id(), timeline(), 10.0, 3, 0);
+
+ host_impl_->active_tree()->SetElementIdsForTesting();
+
+ AddAnimatedTransformToElementWithPlayer(child->element_id(), timeline(), 10.0,
+ 3, 0);
// Set up the property trees so that UpdateDrawProperties will work in
// CommitComplete below.
@@ -1488,6 +1500,8 @@ TEST_F(LayerTreeHostImplTest, AnimationMarksLayerNotReady) {
child->draw_properties().visible_layer_rect = gfx::Rect(10, 10);
child->SetDrawsContent(true);
+ host_impl_->active_tree()->SetElementIdsForTesting();
+
EXPECT_TRUE(child->was_ever_ready_since_last_transform_animation());
// Add a translate from 6,7 to 8,9.
@@ -1495,8 +1509,8 @@ TEST_F(LayerTreeHostImplTest, AnimationMarksLayerNotReady) {
start.AppendTranslate(6.f, 7.f, 0.f);
TransformOperations end;
end.AppendTranslate(8.f, 9.f, 0.f);
- int animation_id = AddAnimatedTransformToLayerWithPlayer(
- child->id(), timeline(), 4.0, start, end);
+ int animation_id = AddAnimatedTransformToElementWithPlayer(
+ child->element_id(), timeline(), 4.0, start, end);
base::TimeTicks now = base::TimeTicks::Now();
host_impl_->WillBeginImplFrame(
@@ -1527,8 +1541,8 @@ TEST_F(LayerTreeHostImplTest, AnimationMarksLayerNotReady) {
// Remove the animation.
child->set_has_missing_tiles(true);
- RemoveAnimationFromLayerWithExistingPlayer(child->id(), timeline(),
- animation_id);
+ RemoveAnimationFromElementWithExistingPlayer(child->element_id(), timeline(),
+ animation_id);
child->draw_properties().screen_space_transform_is_animating = false;
// Child layer doesn't have an animation, but was never ready since the last
@@ -3527,8 +3541,11 @@ class MissingTextureAnimatingLayer : public DidDrawCheckLayer {
: DidDrawCheckLayer(tree_impl, id),
tile_missing_(tile_missing),
had_incomplete_tile_(had_incomplete_tile) {
- if (animating)
- AddAnimatedTransformToLayerWithPlayer(this->id(), timeline, 10.0, 3, 0);
+ if (animating) {
+ this->SetElementId(LayerIdToElementIdForTesting(id));
+ AddAnimatedTransformToElementWithPlayer(this->element_id(), timeline,
+ 10.0, 3, 0);
+ }
}
bool tile_missing_;
@@ -9692,7 +9709,7 @@ TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedAborted) {
host_impl_->UpdateAnimationState(true);
EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty(
- scrolling_layer->id(), TargetProperty::SCROLL_OFFSET));
+ scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET));
EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
host_impl_->DidFinishImplFrame();
@@ -9725,7 +9742,7 @@ TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimatedAborted) {
// The instant scroll should have marked the smooth scroll animation as
// aborted.
EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting(
- scrolling_layer->id()));
+ scrolling_layer->element_id()));
EXPECT_VECTOR2DF_EQ(gfx::ScrollOffset(0, y + 50),
scrolling_layer->CurrentScrollOffset());
@@ -9763,7 +9780,7 @@ TEST_F(LayerTreeHostImplTimelinesTest,
host_impl_->UpdateAnimationState(true);
EXPECT_TRUE(host_impl_->animation_host()->HasAnyAnimationTargetingProperty(
- scrolling_layer->id(), TargetProperty::SCROLL_OFFSET));
+ scrolling_layer->element_id(), TargetProperty::SCROLL_OFFSET));
EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
host_impl_->DidFinishImplFrame();
@@ -9784,7 +9801,7 @@ TEST_F(LayerTreeHostImplTimelinesTest,
// Aborting with the needs completion param should have marked the smooth
// scroll animation as finished.
EXPECT_FALSE(host_impl_->animation_host()->HasActiveAnimationForTesting(
- scrolling_layer->id()));
+ scrolling_layer->element_id()));
EXPECT_TRUE(y > 1 && y < 49);
EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
host_impl_->DidFinishImplFrame();

Powered by Google App Engine
This is Rietveld 408576698