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

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

Issue 23809002: Revert 220479 "Add support for inverse transform animations." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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
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"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/compositor/layer_animation_delegate.h" 12 #include "ui/compositor/layer_animation_delegate.h"
13 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
14 #include "ui/compositor/test/test_layer_animation_delegate.h" 13 #include "ui/compositor/test/test_layer_animation_delegate.h"
15 #include "ui/compositor/test/test_utils.h" 14 #include "ui/compositor/test/test_utils.h"
16 #include "ui/gfx/rect.h" 15 #include "ui/gfx/rect.h"
17 #include "ui/gfx/transform.h" 16 #include "ui/gfx/transform.h"
18 17
19 namespace ui { 18 namespace ui {
20 19
21 namespace { 20 namespace {
22 21
23 // Check that the transformation element progresses the delegate as expected and 22 // Check that the transformation element progresses the delegate as expected and
24 // that the element can be reused after it completes. 23 // that the element can be reused after it completes.
25 TEST(LayerAnimationElementTest, TransformElement) { 24 TEST(LayerAnimationElementTest, TransformElement) {
26 TestLayerAnimationDelegate delegate; 25 TestLayerAnimationDelegate delegate;
27 gfx::Transform start_transform, target_transform; 26 gfx::Transform start_transform, target_transform, middle_transform;
28 start_transform.Rotate(-30.0); 27 start_transform.Rotate(-30.0);
29 target_transform.Rotate(30.0); 28 target_transform.Rotate(30.0);
30 base::TimeTicks start_time; 29 base::TimeTicks start_time;
31 base::TimeTicks effective_start_time; 30 base::TimeTicks effective_start_time;
32 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 31 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
33 32
34 scoped_ptr<LayerAnimationElement> element( 33 scoped_ptr<LayerAnimationElement> element(
35 LayerAnimationElement::CreateTransformElement(target_transform, delta)); 34 LayerAnimationElement::CreateTransformElement(target_transform, delta));
36 element->set_animation_group_id(1); 35 element->set_animation_group_id(1);
37 36
(...skipping 21 matching lines...) Expand all
59 EXPECT_FLOAT_EQ(1.0, element->last_progressed_fraction()); 58 EXPECT_FLOAT_EQ(1.0, element->last_progressed_fraction());
60 CheckApproximatelyEqual(target_transform, 59 CheckApproximatelyEqual(target_transform,
61 delegate.GetTransformForAnimation()); 60 delegate.GetTransformForAnimation());
62 } 61 }
63 62
64 LayerAnimationElement::TargetValue target_value(&delegate); 63 LayerAnimationElement::TargetValue target_value(&delegate);
65 element->GetTargetValue(&target_value); 64 element->GetTargetValue(&target_value);
66 CheckApproximatelyEqual(target_transform, target_value.transform); 65 CheckApproximatelyEqual(target_transform, target_value.transform);
67 } 66 }
68 67
69 // Ensures that duration is copied correctly.
70 TEST(LayerAnimationElementTest, InverseElementDurationNoScale) {
71 gfx::Transform transform;
72 base::TimeDelta delta;
73
74 scoped_ptr<LayerAnimationElement> base_element(
75 LayerAnimationElement::CreateTransformElement(transform, delta));
76
77 scoped_ptr<LayerAnimationElement> inverse_element(
78 LayerAnimationElement::CreateInverseTransformElement(transform,
79 base_element.get()));
80 EXPECT_EQ(base_element->duration(), inverse_element->duration());
81 }
82
83 // Ensures that duration is copied correctly and not double scaled.
84 TEST(LayerAnimationElementTest, InverseElementDurationScaled) {
85 gfx::Transform transform;
86 base::TimeDelta delta;
87
88 ScopedAnimationDurationScaleMode faster_duration(
89 ScopedAnimationDurationScaleMode::FAST_DURATION);
90 scoped_ptr<LayerAnimationElement> base_element(
91 LayerAnimationElement::CreateTransformElement(transform, delta));
92
93 scoped_ptr<LayerAnimationElement> inverse_element(
94 LayerAnimationElement::CreateInverseTransformElement(transform,
95 base_element.get()));
96 EXPECT_EQ(base_element->duration(), inverse_element->duration());
97 }
98
99 // Check that the bounds element progresses the delegate as expected and 68 // Check that the bounds element progresses the delegate as expected and
100 // that the element can be reused after it completes. 69 // that the element can be reused after it completes.
101 TEST(LayerAnimationElementTest, BoundsElement) { 70 TEST(LayerAnimationElementTest, BoundsElement) {
102 TestLayerAnimationDelegate delegate; 71 TestLayerAnimationDelegate delegate;
103 gfx::Rect start, target, middle; 72 gfx::Rect start, target, middle;
104 start = target = middle = gfx::Rect(0, 0, 50, 50); 73 start = target = middle = gfx::Rect(0, 0, 50, 50);
105 start.set_x(-90); 74 start.set_x(-90);
106 target.set_x(90); 75 target.set_x(90);
107 base::TimeTicks start_time; 76 base::TimeTicks start_time;
108 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 77 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 element->Abort(&delegate); 365 element->Abort(&delegate);
397 target_transform.Blend(start_transform, 366 target_transform.Blend(start_transform,
398 Tween::CalculateValue(tween_type, 0.5)); 367 Tween::CalculateValue(tween_type, 0.5));
399 CheckApproximatelyEqual(target_transform, 368 CheckApproximatelyEqual(target_transform,
400 delegate.GetTransformForAnimation()); 369 delegate.GetTransformForAnimation());
401 } 370 }
402 371
403 } // namespace 372 } // namespace
404 373
405 } // namespace ui 374 } // namespace ui
OLDNEW
« no previous file with comments | « trunk/src/ui/compositor/layer_animation_element.cc ('k') | trunk/src/ui/compositor/test/test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698