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

Side by Side Diff: ui/compositor/layer_animation_element_unittest.cc

Issue 23531053: ui/base/animation -> ui/gfx/animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge 2 trunk Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/compositor/layer_animation_element.cc ('k') | ui/compositor/layer_animator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/time.h" 10 #include "base/time/time.h"
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 TestLayerAnimationDelegate delegate; 359 TestLayerAnimationDelegate delegate;
360 float start = 0.0; 360 float start = 0.0;
361 float target = 1.0; 361 float target = 1.0;
362 base::TimeTicks start_time; 362 base::TimeTicks start_time;
363 base::TimeTicks effective_start_time; 363 base::TimeTicks effective_start_time;
364 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 364 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
365 scoped_ptr<LayerAnimationElement> element( 365 scoped_ptr<LayerAnimationElement> element(
366 LayerAnimationElement::CreateOpacityElement(target, delta)); 366 LayerAnimationElement::CreateOpacityElement(target, delta));
367 367
368 // Choose a non-linear Tween type. 368 // Choose a non-linear Tween type.
369 Tween::Type tween_type = Tween::EASE_IN; 369 gfx::Tween::Type tween_type = gfx::Tween::EASE_IN;
370 element->set_tween_type(tween_type); 370 element->set_tween_type(tween_type);
371 371
372 delegate.SetOpacityFromAnimation(start); 372 delegate.SetOpacityFromAnimation(start);
373 373
374 // Aborting the element before it has started should not update the delegate. 374 // Aborting the element before it has started should not update the delegate.
375 element->Abort(&delegate); 375 element->Abort(&delegate);
376 EXPECT_FLOAT_EQ(start, delegate.GetOpacityForAnimation()); 376 EXPECT_FLOAT_EQ(start, delegate.GetOpacityForAnimation());
377 377
378 start_time += delta; 378 start_time += delta;
379 element->set_requested_start_time(start_time); 379 element->set_requested_start_time(start_time);
380 element->Start(&delegate, 1); 380 element->Start(&delegate, 1);
381 element->Progress(start_time, &delegate); 381 element->Progress(start_time, &delegate);
382 effective_start_time = start_time + delta; 382 effective_start_time = start_time + delta;
383 element->set_effective_start_time(effective_start_time); 383 element->set_effective_start_time(effective_start_time);
384 element->Progress(effective_start_time, &delegate); 384 element->Progress(effective_start_time, &delegate);
385 element->Progress(effective_start_time + delta/2, &delegate); 385 element->Progress(effective_start_time + delta/2, &delegate);
386 386
387 // Since the element has started, it should update the delegate when 387 // Since the element has started, it should update the delegate when
388 // aborted. 388 // aborted.
389 element->Abort(&delegate); 389 element->Abort(&delegate);
390 EXPECT_FLOAT_EQ(Tween::CalculateValue(tween_type, 0.5), 390 EXPECT_FLOAT_EQ(gfx::Tween::CalculateValue(tween_type, 0.5),
391 delegate.GetOpacityForAnimation()); 391 delegate.GetOpacityForAnimation());
392 } 392 }
393 393
394 // Check that a threaded transform element updates the delegate as expected when 394 // Check that a threaded transform element updates the delegate as expected when
395 // aborted. 395 // aborted.
396 TEST(LayerAnimationElementTest, AbortTransformElement) { 396 TEST(LayerAnimationElementTest, AbortTransformElement) {
397 TestLayerAnimationDelegate delegate; 397 TestLayerAnimationDelegate delegate;
398 gfx::Transform start_transform, target_transform; 398 gfx::Transform start_transform, target_transform;
399 start_transform.Rotate(-30.0); 399 start_transform.Rotate(-30.0);
400 target_transform.Rotate(30.0); 400 target_transform.Rotate(30.0);
401 base::TimeTicks start_time; 401 base::TimeTicks start_time;
402 base::TimeTicks effective_start_time; 402 base::TimeTicks effective_start_time;
403 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 403 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
404 scoped_ptr<LayerAnimationElement> element( 404 scoped_ptr<LayerAnimationElement> element(
405 LayerAnimationElement::CreateTransformElement(target_transform, delta)); 405 LayerAnimationElement::CreateTransformElement(target_transform, delta));
406 406
407 // Choose a non-linear Tween type. 407 // Choose a non-linear Tween type.
408 Tween::Type tween_type = Tween::EASE_IN; 408 gfx::Tween::Type tween_type = gfx::Tween::EASE_IN;
409 element->set_tween_type(tween_type); 409 element->set_tween_type(tween_type);
410 410
411 delegate.SetTransformFromAnimation(start_transform); 411 delegate.SetTransformFromAnimation(start_transform);
412 412
413 // Aborting the element before it has started should not update the delegate. 413 // Aborting the element before it has started should not update the delegate.
414 element->Abort(&delegate); 414 element->Abort(&delegate);
415 CheckApproximatelyEqual(start_transform, delegate.GetTransformForAnimation()); 415 CheckApproximatelyEqual(start_transform, delegate.GetTransformForAnimation());
416 416
417 start_time += delta; 417 start_time += delta;
418 element->set_requested_start_time(start_time); 418 element->set_requested_start_time(start_time);
419 element->Start(&delegate, 1); 419 element->Start(&delegate, 1);
420 element->Progress(start_time, &delegate); 420 element->Progress(start_time, &delegate);
421 effective_start_time = start_time + delta; 421 effective_start_time = start_time + delta;
422 element->set_effective_start_time(effective_start_time); 422 element->set_effective_start_time(effective_start_time);
423 element->Progress(effective_start_time, &delegate); 423 element->Progress(effective_start_time, &delegate);
424 element->Progress(effective_start_time + delta/2, &delegate); 424 element->Progress(effective_start_time + delta/2, &delegate);
425 425
426 // Since the element has started, it should update the delegate when 426 // Since the element has started, it should update the delegate when
427 // aborted. 427 // aborted.
428 element->Abort(&delegate); 428 element->Abort(&delegate);
429 target_transform.Blend(start_transform, 429 target_transform.Blend(start_transform,
430 Tween::CalculateValue(tween_type, 0.5)); 430 gfx::Tween::CalculateValue(tween_type, 0.5));
431 CheckApproximatelyEqual(target_transform, 431 CheckApproximatelyEqual(target_transform,
432 delegate.GetTransformForAnimation()); 432 delegate.GetTransformForAnimation());
433 } 433 }
434 434
435 } // namespace 435 } // namespace
436 436
437 } // namespace ui 437 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer_animation_element.cc ('k') | ui/compositor/layer_animator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698