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/test/animation_timelines_test_common.h" | 5 #include "cc/test/animation_timelines_test_common.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "cc/animation/animation_events.h" | 8 #include "cc/animation/animation_events.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 12 matching lines...) Expand all Loading... |
23 TestLayer::TestLayer() { | 23 TestLayer::TestLayer() { |
24 ClearMutatedProperties(); | 24 ClearMutatedProperties(); |
25 } | 25 } |
26 | 26 |
27 void TestLayer::ClearMutatedProperties() { | 27 void TestLayer::ClearMutatedProperties() { |
28 transform_ = gfx::Transform(); | 28 transform_ = gfx::Transform(); |
29 opacity_ = 0; | 29 opacity_ = 0; |
30 filters_ = FilterOperations(); | 30 filters_ = FilterOperations(); |
31 scroll_offset_ = gfx::ScrollOffset(); | 31 scroll_offset_ = gfx::ScrollOffset(); |
32 transform_is_animating_ = false; | 32 transform_is_animating_ = false; |
| 33 has_potential_opacity_animation_ = false; |
| 34 opacity_is_currently_animating_ = false; |
33 | 35 |
34 for (int i = 0; i <= TargetProperty::LAST_TARGET_PROPERTY; ++i) | 36 for (int i = 0; i <= TargetProperty::LAST_TARGET_PROPERTY; ++i) |
35 mutated_properties_[i] = false; | 37 mutated_properties_[i] = false; |
36 } | 38 } |
37 | 39 |
38 int TestLayer::transform_x() const { | 40 int TestLayer::transform_x() const { |
39 gfx::Vector2dF vec = transform_.To2dTranslation(); | 41 gfx::Vector2dF vec = transform_.To2dTranslation(); |
40 return static_cast<int>(vec.x()); | 42 return static_cast<int>(vec.x()); |
41 } | 43 } |
42 | 44 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 125 |
124 void TestHostClient::ElementTransformIsPotentiallyAnimatingChanged( | 126 void TestHostClient::ElementTransformIsPotentiallyAnimatingChanged( |
125 ElementId element_id, | 127 ElementId element_id, |
126 ElementListType list_type, | 128 ElementListType list_type, |
127 bool is_animating) { | 129 bool is_animating) { |
128 TestLayer* layer = FindTestLayer(element_id, list_type); | 130 TestLayer* layer = FindTestLayer(element_id, list_type); |
129 if (layer) | 131 if (layer) |
130 layer->set_transform_is_animating(is_animating); | 132 layer->set_transform_is_animating(is_animating); |
131 } | 133 } |
132 | 134 |
| 135 void TestHostClient::ElementOpacityIsAnimatingChanged( |
| 136 ElementId element_id, |
| 137 ElementListType list_type, |
| 138 AnimationChangeType change_type, |
| 139 bool is_animating) { |
| 140 TestLayer* layer = FindTestLayer(element_id, list_type); |
| 141 if (layer) { |
| 142 switch (change_type) { |
| 143 case AnimationChangeType::POTENTIAL: |
| 144 layer->set_has_potential_opacity_animation(is_animating); |
| 145 break; |
| 146 case AnimationChangeType::RUNNING: |
| 147 layer->set_opacity_is_currently_animating(is_animating); |
| 148 break; |
| 149 case AnimationChangeType::BOTH: |
| 150 layer->set_has_potential_opacity_animation(is_animating); |
| 151 layer->set_opacity_is_currently_animating(is_animating); |
| 152 break; |
| 153 } |
| 154 } |
| 155 } |
| 156 |
133 void TestHostClient::SetScrollOffsetForAnimation( | 157 void TestHostClient::SetScrollOffsetForAnimation( |
134 const gfx::ScrollOffset& scroll_offset) { | 158 const gfx::ScrollOffset& scroll_offset) { |
135 scroll_offset_ = scroll_offset; | 159 scroll_offset_ = scroll_offset; |
136 } | 160 } |
137 | 161 |
138 gfx::ScrollOffset TestHostClient::GetScrollOffsetForAnimation( | 162 gfx::ScrollOffset TestHostClient::GetScrollOffsetForAnimation( |
139 ElementId element_id) const { | 163 ElementId element_id) const { |
140 return scroll_offset_; | 164 return scroll_offset_; |
141 } | 165 } |
142 | 166 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 return layer->scroll_offset(); | 226 return layer->scroll_offset(); |
203 } | 227 } |
204 | 228 |
205 bool TestHostClient::GetTransformIsAnimating(ElementId element_id, | 229 bool TestHostClient::GetTransformIsAnimating(ElementId element_id, |
206 ElementListType list_type) const { | 230 ElementListType list_type) const { |
207 TestLayer* layer = FindTestLayer(element_id, list_type); | 231 TestLayer* layer = FindTestLayer(element_id, list_type); |
208 EXPECT_TRUE(layer); | 232 EXPECT_TRUE(layer); |
209 return layer->transform_is_animating(); | 233 return layer->transform_is_animating(); |
210 } | 234 } |
211 | 235 |
| 236 bool TestHostClient::GetOpacityIsCurrentlyAnimating( |
| 237 ElementId element_id, |
| 238 ElementListType list_type) const { |
| 239 TestLayer* layer = FindTestLayer(element_id, list_type); |
| 240 EXPECT_TRUE(layer); |
| 241 return layer->opacity_is_currently_animating(); |
| 242 } |
| 243 |
| 244 bool TestHostClient::GetHasPotentialOpacityAnimation( |
| 245 ElementId element_id, |
| 246 ElementListType list_type) const { |
| 247 TestLayer* layer = FindTestLayer(element_id, list_type); |
| 248 EXPECT_TRUE(layer); |
| 249 return layer->has_potential_opacity_animation(); |
| 250 } |
| 251 |
212 void TestHostClient::ExpectFilterPropertyMutated(ElementId element_id, | 252 void TestHostClient::ExpectFilterPropertyMutated(ElementId element_id, |
213 ElementListType list_type, | 253 ElementListType list_type, |
214 float brightness) const { | 254 float brightness) const { |
215 TestLayer* layer = FindTestLayer(element_id, list_type); | 255 TestLayer* layer = FindTestLayer(element_id, list_type); |
216 EXPECT_TRUE(layer); | 256 EXPECT_TRUE(layer); |
217 EXPECT_TRUE(layer->is_property_mutated(TargetProperty::FILTER)); | 257 EXPECT_TRUE(layer->is_property_mutated(TargetProperty::FILTER)); |
218 EXPECT_EQ(brightness, layer->brightness()); | 258 EXPECT_EQ(brightness, layer->brightness()); |
219 } | 259 } |
220 | 260 |
221 void TestHostClient::ExpectOpacityPropertyMutated(ElementId element_id, | 261 void TestHostClient::ExpectOpacityPropertyMutated(ElementId element_id, |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 return element_animations ? element_animations->players_list().head()->value() | 443 return element_animations ? element_animations->players_list().head()->value() |
404 : nullptr; | 444 : nullptr; |
405 } | 445 } |
406 | 446 |
407 int AnimationTimelinesTest::NextTestLayerId() { | 447 int AnimationTimelinesTest::NextTestLayerId() { |
408 next_test_layer_id_++; | 448 next_test_layer_id_++; |
409 return next_test_layer_id_; | 449 return next_test_layer_id_; |
410 } | 450 } |
411 | 451 |
412 } // namespace cc | 452 } // namespace cc |
OLD | NEW |