Index: cc/animation/animation_player_unittest.cc |
diff --git a/cc/animation/animation_player_unittest.cc b/cc/animation/animation_player_unittest.cc |
index 466964f6d7741bf898e8133b07254e6a1373d495..d8030b3ec804a5da9239f5bc2de660ce8c5fcf15 100644 |
--- a/cc/animation/animation_player_unittest.cc |
+++ b/cc/animation/animation_player_unittest.cc |
@@ -332,5 +332,39 @@ TEST_F(AnimationPlayerTest, AddRemoveAnimationCausesSetNeedsCommit) { |
client_.set_mutators_need_commit(false); |
} |
+// If main-thread player switches to another layer within one frame then |
+// impl-thread player must be switched as well. |
+TEST_F(AnimationPlayerTest, SwitchToLayer) { |
+ host_->AddAnimationTimeline(timeline_); |
+ timeline_->AttachPlayer(player_); |
+ player_->AttachLayer(layer_id_); |
+ |
+ host_->PushPropertiesTo(host_impl_); |
+ |
+ GetImplTimelineAndPlayerByID(); |
+ |
+ EXPECT_EQ(player_, GetPlayerForLayerId(layer_id_)); |
+ EXPECT_TRUE(player_->element_animations()); |
+ EXPECT_EQ(player_->layer_id(), layer_id_); |
+ |
+ EXPECT_EQ(player_impl_, GetImplPlayerForLayerId(layer_id_)); |
+ EXPECT_TRUE(player_impl_->element_animations()); |
+ EXPECT_EQ(player_impl_->layer_id(), layer_id_); |
+ |
+ const int new_layer_id = NextTestLayerId(); |
+ player_->DetachLayer(); |
+ player_->AttachLayer(new_layer_id); |
+ |
+ EXPECT_EQ(player_, GetPlayerForLayerId(new_layer_id)); |
+ EXPECT_TRUE(player_->element_animations()); |
+ EXPECT_EQ(player_->layer_id(), new_layer_id); |
+ |
+ host_->PushPropertiesTo(host_impl_); |
+ |
+ EXPECT_EQ(player_impl_, GetImplPlayerForLayerId(new_layer_id)); |
+ EXPECT_TRUE(player_impl_->element_animations()); |
+ EXPECT_EQ(player_impl_->layer_id(), new_layer_id); |
+} |
+ |
} // namespace |
} // namespace cc |