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

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

Issue 11316315: Remove ui::LayerAnimationSequence::duration and ui::LayerAnimationElement::duration. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Make unit tests use IsFinished() instead of duration() Created 8 years 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
« no previous file with comments | « ui/compositor/layer_animation_sequence.cc ('k') | ui/compositor/layer_animator.cc » ('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_sequence.h" 5 #include "ui/compositor/layer_animation_sequence.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"
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/layer_animation_element.h" 13 #include "ui/compositor/layer_animation_element.h"
14 #include "ui/compositor/test/test_layer_animation_delegate.h" 14 #include "ui/compositor/test/test_layer_animation_delegate.h"
15 #include "ui/compositor/test/test_layer_animation_observer.h" 15 #include "ui/compositor/test/test_layer_animation_observer.h"
16 #include "ui/compositor/test/test_utils.h" 16 #include "ui/compositor/test/test_utils.h"
17 #include "ui/gfx/rect.h" 17 #include "ui/gfx/rect.h"
18 #include "ui/gfx/transform.h" 18 #include "ui/gfx/transform.h"
19 19
20 namespace ui { 20 namespace ui {
21 21
22 namespace { 22 namespace {
23 23
24 // Check that the sequence behaves sanely when it contains no elements. 24 // Check that the sequence behaves sanely when it contains no elements.
25 TEST(LayerAnimationSequenceTest, NoElement) { 25 TEST(LayerAnimationSequenceTest, NoElement) {
26 LayerAnimationSequence sequence; 26 LayerAnimationSequence sequence;
27 EXPECT_EQ(sequence.duration(), base::TimeDelta()); 27 EXPECT_TRUE(sequence.IsFinished(base::TimeDelta()));
28 EXPECT_TRUE(sequence.properties().size() == 0); 28 EXPECT_TRUE(sequence.properties().size() == 0);
29 LayerAnimationElement::AnimatableProperties properties; 29 LayerAnimationElement::AnimatableProperties properties;
30 EXPECT_FALSE(sequence.HasCommonProperty(properties)); 30 EXPECT_FALSE(sequence.HasCommonProperty(properties));
31 } 31 }
32 32
33 // Check that the sequences progresses the delegate as expected when it contains 33 // Check that the sequences progresses the delegate as expected when it contains
34 // a single element. 34 // a single element.
35 TEST(LayerAnimationSequenceTest, SingleElement) { 35 TEST(LayerAnimationSequenceTest, SingleElement) {
36 LayerAnimationSequence sequence; 36 LayerAnimationSequence sequence;
37 TestLayerAnimationDelegate delegate; 37 TestLayerAnimationDelegate delegate;
(...skipping 10 matching lines...) Expand all
48 EXPECT_FLOAT_EQ(start, delegate.GetOpacityForAnimation()); 48 EXPECT_FLOAT_EQ(start, delegate.GetOpacityForAnimation());
49 sequence.Progress(base::TimeDelta::FromMilliseconds(500), &delegate); 49 sequence.Progress(base::TimeDelta::FromMilliseconds(500), &delegate);
50 EXPECT_FLOAT_EQ(middle, delegate.GetOpacityForAnimation()); 50 EXPECT_FLOAT_EQ(middle, delegate.GetOpacityForAnimation());
51 sequence.Progress(base::TimeDelta::FromMilliseconds(1000), &delegate); 51 sequence.Progress(base::TimeDelta::FromMilliseconds(1000), &delegate);
52 EXPECT_FLOAT_EQ(target, delegate.GetOpacityForAnimation()); 52 EXPECT_FLOAT_EQ(target, delegate.GetOpacityForAnimation());
53 } 53 }
54 54
55 EXPECT_TRUE(sequence.properties().size() == 1); 55 EXPECT_TRUE(sequence.properties().size() == 1);
56 EXPECT_TRUE(sequence.properties().find(LayerAnimationElement::OPACITY) != 56 EXPECT_TRUE(sequence.properties().find(LayerAnimationElement::OPACITY) !=
57 sequence.properties().end()); 57 sequence.properties().end());
58 EXPECT_EQ(delta, sequence.duration()); 58 EXPECT_TRUE(sequence.IsFinished(delta));
59 } 59 }
60 60
61 // Check that the sequences progresses the delegate as expected when it contains 61 // Check that the sequences progresses the delegate as expected when it contains
62 // multiple elements. Note, see the layer animator tests for cyclic sequences. 62 // multiple elements. Note, see the layer animator tests for cyclic sequences.
63 TEST(LayerAnimationSequenceTest, MultipleElement) { 63 TEST(LayerAnimationSequenceTest, MultipleElement) {
64 LayerAnimationSequence sequence; 64 LayerAnimationSequence sequence;
65 TestLayerAnimationDelegate delegate; 65 TestLayerAnimationDelegate delegate;
66 float start_opacity = 0.0f; 66 float start_opacity = 0.0f;
67 float middle_opacity = 0.5f; 67 float middle_opacity = 0.5f;
68 float target_opacity = 1.0f; 68 float target_opacity = 1.0f;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 delegate.GetTransformForAnimation()); 117 delegate.GetTransformForAnimation());
118 } 118 }
119 119
120 EXPECT_TRUE(sequence.properties().size() == 3); 120 EXPECT_TRUE(sequence.properties().size() == 3);
121 EXPECT_TRUE(sequence.properties().find(LayerAnimationElement::OPACITY) != 121 EXPECT_TRUE(sequence.properties().find(LayerAnimationElement::OPACITY) !=
122 sequence.properties().end()); 122 sequence.properties().end());
123 EXPECT_TRUE(sequence.properties().find(LayerAnimationElement::TRANSFORM) != 123 EXPECT_TRUE(sequence.properties().find(LayerAnimationElement::TRANSFORM) !=
124 sequence.properties().end()); 124 sequence.properties().end());
125 EXPECT_TRUE(sequence.properties().find(LayerAnimationElement::BOUNDS) != 125 EXPECT_TRUE(sequence.properties().find(LayerAnimationElement::BOUNDS) !=
126 sequence.properties().end()); 126 sequence.properties().end());
127 EXPECT_EQ(delta + delta + delta, sequence.duration()); 127 EXPECT_TRUE(sequence.IsFinished(delta + delta + delta));
128 } 128 }
129 129
130 // Check that a sequence can still be aborted if it has cycled many times. 130 // Check that a sequence can still be aborted if it has cycled many times.
131 TEST(LayerAnimationSequenceTest, AbortingCyclicSequence) { 131 TEST(LayerAnimationSequenceTest, AbortingCyclicSequence) {
132 LayerAnimationSequence sequence; 132 LayerAnimationSequence sequence;
133 TestLayerAnimationDelegate delegate; 133 TestLayerAnimationDelegate delegate;
134 float start_opacity = 0.0f; 134 float start_opacity = 0.0f;
135 float target_opacity = 1.0f; 135 float target_opacity = 1.0f;
136 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 136 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
137 sequence.AddElement( 137 sequence.AddElement(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 EXPECT_TRUE(!observer.last_ended_sequence()); 188 EXPECT_TRUE(!observer.last_ended_sequence());
189 sequence.Progress(delta, &delegate); 189 sequence.Progress(delta, &delegate);
190 EXPECT_EQ(observer.last_ended_sequence(), &sequence); 190 EXPECT_EQ(observer.last_ended_sequence(), &sequence);
191 sequence.RemoveObserver(&observer); 191 sequence.RemoveObserver(&observer);
192 } 192 }
193 } 193 }
194 194
195 } // namespace 195 } // namespace
196 196
197 } // namespace ui 197 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer_animation_sequence.cc ('k') | ui/compositor/layer_animator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698