OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/compositor/layer_animation_element.h" | 5 #include "ui/compositor/layer_animation_element.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 CheckApproximatelyEqual(delegate.GetTransformForAnimation(), | 276 CheckApproximatelyEqual(delegate.GetTransformForAnimation(), |
277 copy.GetTransformForAnimation()); | 277 copy.GetTransformForAnimation()); |
278 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), | 278 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), |
279 copy.GetOpacityForAnimation()); | 279 copy.GetOpacityForAnimation()); |
280 EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), | 280 EXPECT_FLOAT_EQ(delegate.GetBrightnessForAnimation(), |
281 copy.GetBrightnessForAnimation()); | 281 copy.GetBrightnessForAnimation()); |
282 EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), | 282 EXPECT_FLOAT_EQ(delegate.GetGrayscaleForAnimation(), |
283 copy.GetGrayscaleForAnimation()); | 283 copy.GetGrayscaleForAnimation()); |
284 } | 284 } |
285 | 285 |
| 286 // Check that a threaded element updates the delegate as expected when aborted. |
| 287 TEST(LayerAnimationElementTest, AbortOpacityElement) { |
| 288 TestLayerAnimationDelegate delegate; |
| 289 float start = 0.0; |
| 290 float target = 1.0; |
| 291 base::TimeTicks start_time; |
| 292 base::TimeTicks effective_start_time; |
| 293 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); |
| 294 scoped_ptr<LayerAnimationElement> element( |
| 295 LayerAnimationElement::CreateOpacityElement(target, delta)); |
| 296 |
| 297 // Choose a non-linear Tween type. |
| 298 Tween::Type tween_type = Tween::EASE_IN; |
| 299 element->set_tween_type(tween_type); |
| 300 |
| 301 start_time += delta; |
| 302 element->set_requested_start_time(start_time); |
| 303 delegate.SetOpacityFromAnimation(start); |
| 304 element->Start(&delegate, 1); |
| 305 element->Progress(start_time, &delegate); |
| 306 effective_start_time = start_time + delta; |
| 307 element->set_effective_start_time(effective_start_time); |
| 308 element->Progress(effective_start_time, &delegate); |
| 309 element->Progress(effective_start_time + delta/2, &delegate); |
| 310 |
| 311 element->Abort(&delegate); |
| 312 EXPECT_FLOAT_EQ(Tween::CalculateValue(tween_type, 0.5), |
| 313 delegate.GetOpacityForAnimation()); |
| 314 } |
| 315 |
286 } // namespace | 316 } // namespace |
287 | 317 |
288 } // namespace ui | 318 } // namespace ui |
OLD | NEW |