| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/animation/element_animations.h" | 5 #include "cc/animation/element_animations.h" |
| 6 | 6 |
| 7 #include "cc/animation/animation_delegate.h" | 7 #include "cc/animation/animation_delegate.h" |
| 8 #include "cc/animation/animation_host.h" | 8 #include "cc/animation/animation_host.h" |
| 9 #include "cc/animation/animation_id_provider.h" | 9 #include "cc/animation/animation_id_provider.h" |
| 10 #include "cc/animation/animation_player.h" | 10 #include "cc/animation/animation_player.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 client_impl_.RegisterLayer(layer_id_, LayerTreeType::PENDING); | 30 client_impl_.RegisterLayer(layer_id_, LayerTreeType::PENDING); |
| 31 | 31 |
| 32 EXPECT_TRUE(client_.IsLayerInTree(layer_id_, LayerTreeType::ACTIVE)); | 32 EXPECT_TRUE(client_.IsLayerInTree(layer_id_, LayerTreeType::ACTIVE)); |
| 33 EXPECT_FALSE(client_.IsLayerInTree(layer_id_, LayerTreeType::PENDING)); | 33 EXPECT_FALSE(client_.IsLayerInTree(layer_id_, LayerTreeType::PENDING)); |
| 34 | 34 |
| 35 host_->AddAnimationTimeline(timeline_); | 35 host_->AddAnimationTimeline(timeline_); |
| 36 | 36 |
| 37 timeline_->AttachPlayer(player_); | 37 timeline_->AttachPlayer(player_); |
| 38 player_->AttachLayer(layer_id_); | 38 player_->AttachLayer(layer_id_); |
| 39 | 39 |
| 40 ElementAnimations* element_animations = player_->element_animations(); | 40 scoped_refptr<ElementAnimations> element_animations = |
| 41 player_->element_animations(); |
| 41 EXPECT_TRUE(element_animations); | 42 EXPECT_TRUE(element_animations); |
| 42 | 43 |
| 43 EXPECT_TRUE(element_animations->needs_active_value_observations()); | 44 EXPECT_TRUE(element_animations->needs_active_value_observations()); |
| 44 EXPECT_FALSE(element_animations->needs_pending_value_observations()); | 45 EXPECT_FALSE(element_animations->needs_pending_value_observations()); |
| 45 | 46 |
| 46 host_->PushPropertiesTo(host_impl_); | 47 host_->PushPropertiesTo(host_impl_); |
| 47 | 48 |
| 48 GetImplTimelineAndPlayerByID(); | 49 GetImplTimelineAndPlayerByID(); |
| 49 | 50 |
| 50 ElementAnimations* element_animations_impl = | 51 scoped_refptr<ElementAnimations> element_animations_impl = |
| 51 player_impl_->element_animations(); | 52 player_impl_->element_animations(); |
| 52 EXPECT_TRUE(element_animations_impl); | 53 EXPECT_TRUE(element_animations_impl); |
| 53 | 54 |
| 54 EXPECT_FALSE(element_animations_impl->needs_active_value_observations()); | 55 EXPECT_FALSE(element_animations_impl->needs_active_value_observations()); |
| 55 EXPECT_TRUE(element_animations_impl->needs_pending_value_observations()); | 56 EXPECT_TRUE(element_animations_impl->needs_pending_value_observations()); |
| 56 | 57 |
| 57 // Create the layer in the impl active tree. | 58 // Create the layer in the impl active tree. |
| 58 client_impl_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); | 59 client_impl_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); |
| 59 EXPECT_TRUE(element_animations_impl->needs_active_value_observations()); | 60 EXPECT_TRUE(element_animations_impl->needs_active_value_observations()); |
| 60 EXPECT_TRUE(element_animations_impl->needs_pending_value_observations()); | 61 EXPECT_TRUE(element_animations_impl->needs_pending_value_observations()); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 TEST_F(ElementAnimationsTest, AttachToNotYetCreatedLayer) { | 103 TEST_F(ElementAnimationsTest, AttachToNotYetCreatedLayer) { |
| 103 host_->AddAnimationTimeline(timeline_); | 104 host_->AddAnimationTimeline(timeline_); |
| 104 timeline_->AttachPlayer(player_); | 105 timeline_->AttachPlayer(player_); |
| 105 | 106 |
| 106 host_->PushPropertiesTo(host_impl_); | 107 host_->PushPropertiesTo(host_impl_); |
| 107 | 108 |
| 108 GetImplTimelineAndPlayerByID(); | 109 GetImplTimelineAndPlayerByID(); |
| 109 | 110 |
| 110 player_->AttachLayer(layer_id_); | 111 player_->AttachLayer(layer_id_); |
| 111 | 112 |
| 112 ElementAnimations* element_animations = player_->element_animations(); | 113 scoped_refptr<ElementAnimations> element_animations = |
| 114 player_->element_animations(); |
| 113 EXPECT_TRUE(element_animations); | 115 EXPECT_TRUE(element_animations); |
| 114 | 116 |
| 115 EXPECT_FALSE(element_animations->needs_active_value_observations()); | 117 EXPECT_FALSE(element_animations->needs_active_value_observations()); |
| 116 EXPECT_FALSE(element_animations->needs_pending_value_observations()); | 118 EXPECT_FALSE(element_animations->needs_pending_value_observations()); |
| 117 | 119 |
| 118 host_->PushPropertiesTo(host_impl_); | 120 host_->PushPropertiesTo(host_impl_); |
| 119 | 121 |
| 120 ElementAnimations* element_animations_impl = | 122 scoped_refptr<ElementAnimations> element_animations_impl = |
| 121 player_impl_->element_animations(); | 123 player_impl_->element_animations(); |
| 122 EXPECT_TRUE(element_animations_impl); | 124 EXPECT_TRUE(element_animations_impl); |
| 123 | 125 |
| 124 EXPECT_FALSE(element_animations_impl->needs_active_value_observations()); | 126 EXPECT_FALSE(element_animations_impl->needs_active_value_observations()); |
| 125 EXPECT_FALSE(element_animations_impl->needs_pending_value_observations()); | 127 EXPECT_FALSE(element_animations_impl->needs_pending_value_observations()); |
| 126 | 128 |
| 127 // Create layer. | 129 // Create layer. |
| 128 client_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); | 130 client_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); |
| 129 EXPECT_TRUE(element_animations->needs_active_value_observations()); | 131 EXPECT_TRUE(element_animations->needs_active_value_observations()); |
| 130 EXPECT_FALSE(element_animations->needs_pending_value_observations()); | 132 EXPECT_FALSE(element_animations->needs_pending_value_observations()); |
| 131 | 133 |
| 132 client_impl_.RegisterLayer(layer_id_, LayerTreeType::PENDING); | 134 client_impl_.RegisterLayer(layer_id_, LayerTreeType::PENDING); |
| 133 EXPECT_FALSE(element_animations_impl->needs_active_value_observations()); | 135 EXPECT_FALSE(element_animations_impl->needs_active_value_observations()); |
| 134 EXPECT_TRUE(element_animations_impl->needs_pending_value_observations()); | 136 EXPECT_TRUE(element_animations_impl->needs_pending_value_observations()); |
| 135 | 137 |
| 136 client_impl_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); | 138 client_impl_.RegisterLayer(layer_id_, LayerTreeType::ACTIVE); |
| 137 EXPECT_TRUE(element_animations_impl->needs_active_value_observations()); | 139 EXPECT_TRUE(element_animations_impl->needs_active_value_observations()); |
| 138 EXPECT_TRUE(element_animations_impl->needs_pending_value_observations()); | 140 EXPECT_TRUE(element_animations_impl->needs_pending_value_observations()); |
| 139 } | 141 } |
| 140 | 142 |
| 141 TEST_F(ElementAnimationsTest, AddRemovePlayers) { | 143 TEST_F(ElementAnimationsTest, AddRemovePlayers) { |
| 142 host_->AddAnimationTimeline(timeline_); | 144 host_->AddAnimationTimeline(timeline_); |
| 143 timeline_->AttachPlayer(player_); | 145 timeline_->AttachPlayer(player_); |
| 144 player_->AttachLayer(layer_id_); | 146 player_->AttachLayer(layer_id_); |
| 145 | 147 |
| 146 ElementAnimations* element_animations = player_->element_animations(); | 148 scoped_refptr<ElementAnimations> element_animations = |
| 149 player_->element_animations(); |
| 147 EXPECT_TRUE(element_animations); | 150 EXPECT_TRUE(element_animations); |
| 148 | 151 |
| 149 scoped_refptr<AnimationPlayer> player1 = | 152 scoped_refptr<AnimationPlayer> player1 = |
| 150 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 153 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
| 151 scoped_refptr<AnimationPlayer> player2 = | 154 scoped_refptr<AnimationPlayer> player2 = |
| 152 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); | 155 AnimationPlayer::Create(AnimationIdProvider::NextPlayerId()); |
| 153 | 156 |
| 154 timeline_->AttachPlayer(player1); | 157 timeline_->AttachPlayer(player1); |
| 155 timeline_->AttachPlayer(player2); | 158 timeline_->AttachPlayer(player2); |
| 156 | 159 |
| 157 // Attach players to the same layer. | 160 // Attach players to the same layer. |
| 158 player1->AttachLayer(layer_id_); | 161 player1->AttachLayer(layer_id_); |
| 159 player2->AttachLayer(layer_id_); | 162 player2->AttachLayer(layer_id_); |
| 160 | 163 |
| 161 EXPECT_EQ(element_animations, player1->element_animations()); | 164 EXPECT_EQ(element_animations, player1->element_animations()); |
| 162 EXPECT_EQ(element_animations, player2->element_animations()); | 165 EXPECT_EQ(element_animations, player2->element_animations()); |
| 163 | 166 |
| 164 host_->PushPropertiesTo(host_impl_); | 167 host_->PushPropertiesTo(host_impl_); |
| 165 GetImplTimelineAndPlayerByID(); | 168 GetImplTimelineAndPlayerByID(); |
| 166 | 169 |
| 167 ElementAnimations* element_animations_impl = | 170 scoped_refptr<ElementAnimations> element_animations_impl = |
| 168 player_impl_->element_animations(); | 171 player_impl_->element_animations(); |
| 169 EXPECT_TRUE(element_animations_impl); | 172 EXPECT_TRUE(element_animations_impl); |
| 170 | 173 |
| 171 int list_size_before = 0; | 174 int list_size_before = 0; |
| 172 for (const ElementAnimations::PlayersListNode* node = | 175 for (const ElementAnimations::PlayersListNode* node = |
| 173 element_animations_impl->players_list().head(); | 176 element_animations_impl->players_list().head(); |
| 174 node != element_animations_impl->players_list().end(); | 177 node != element_animations_impl->players_list().end(); |
| 175 node = node->next()) { | 178 node = node->next()) { |
| 176 const AnimationPlayer* player_impl = node->value(); | 179 const AnimationPlayer* player_impl = node->value(); |
| 177 EXPECT_TRUE(timeline_->GetPlayerById(player_impl->id())); | 180 EXPECT_TRUE(timeline_->GetPlayerById(player_impl->id())); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 194 node = node->next()) { | 197 node = node->next()) { |
| 195 const AnimationPlayer* player_impl = node->value(); | 198 const AnimationPlayer* player_impl = node->value(); |
| 196 EXPECT_TRUE(timeline_->GetPlayerById(player_impl->id())); | 199 EXPECT_TRUE(timeline_->GetPlayerById(player_impl->id())); |
| 197 ++list_size_after; | 200 ++list_size_after; |
| 198 } | 201 } |
| 199 EXPECT_EQ(2, list_size_after); | 202 EXPECT_EQ(2, list_size_after); |
| 200 } | 203 } |
| 201 | 204 |
| 202 } // namespace | 205 } // namespace |
| 203 } // namespace cc | 206 } // namespace cc |
| OLD | NEW |