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

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

Issue 12226080: Thread ui transform animations (Closed) Base URL: http://git.chromium.org/chromium/src.git@DefineThreadedLayerAnimationElements
Patch Set: Speed up animations in WebContentsViewAuraTest.QuickOverscrollDirectionChange Created 7 years, 9 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
« no previous file with comments | « ui/compositor/layer_animation_element.cc ('k') | ui/compositor/layer_animation_sequence.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.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/test/test_layer_animation_delegate.h" 13 #include "ui/compositor/test/test_layer_animation_delegate.h"
14 #include "ui/compositor/test/test_utils.h" 14 #include "ui/compositor/test/test_utils.h"
15 #include "ui/gfx/rect.h" 15 #include "ui/gfx/rect.h"
16 #include "ui/gfx/transform.h" 16 #include "ui/gfx/transform.h"
17 17
18 namespace ui { 18 namespace ui {
19 19
20 namespace { 20 namespace {
21 21
22 // Check that the transformation element progresses the delegate as expected and 22 // Check that the transformation element progresses the delegate as expected and
23 // that the element can be reused after it completes. 23 // that the element can be reused after it completes.
24 TEST(LayerAnimationElementTest, TransformElement) { 24 TEST(LayerAnimationElementTest, TransformElement) {
25 TestLayerAnimationDelegate delegate; 25 TestLayerAnimationDelegate delegate;
26 gfx::Transform start_transform, target_transform, middle_transform; 26 gfx::Transform start_transform, target_transform, middle_transform;
27 start_transform.Rotate(-30.0); 27 start_transform.Rotate(-30.0);
28 target_transform.Rotate(30.0); 28 target_transform.Rotate(30.0);
29 base::TimeTicks start_time; 29 base::TimeTicks start_time;
30 base::TimeTicks effective_start_time;
30 base::TimeDelta delta = base::TimeDelta::FromSeconds(1); 31 base::TimeDelta delta = base::TimeDelta::FromSeconds(1);
31 32
32 scoped_ptr<LayerAnimationElement> element( 33 scoped_ptr<LayerAnimationElement> element(
33 LayerAnimationElement::CreateTransformElement(target_transform, delta)); 34 LayerAnimationElement::CreateTransformElement(target_transform, delta));
35 element->set_animation_group_id(1);
34 36
35 for (int i = 0; i < 2; ++i) { 37 for (int i = 0; i < 2; ++i) {
36 start_time += delta; 38 start_time = effective_start_time + delta;
37 element->set_requested_start_time(start_time); 39 element->set_requested_start_time(start_time);
38 delegate.SetTransformFromAnimation(start_transform); 40 delegate.SetTransformFromAnimation(start_transform);
39 element->Start(&delegate, 1); 41 element->Start(&delegate, 1);
40 element->Progress(start_time, &delegate); 42 element->Progress(start_time, &delegate);
41 CheckApproximatelyEqual(start_transform, 43 CheckApproximatelyEqual(start_transform,
42 delegate.GetTransformForAnimation()); 44 delegate.GetTransformForAnimation());
43 element->Progress(start_time + delta/2, &delegate); 45 effective_start_time = start_time + delta;
44 CheckApproximatelyEqual(middle_transform, 46 element->set_effective_start_time(effective_start_time);
45 delegate.GetTransformForAnimation()); 47 element->Progress(effective_start_time, &delegate);
48 EXPECT_FLOAT_EQ(0.0, element->last_progressed_fraction());
49 element->Progress(effective_start_time + delta/2, &delegate);
50 EXPECT_FLOAT_EQ(0.5, element->last_progressed_fraction());
46 51
47 base::TimeDelta element_duration; 52 base::TimeDelta element_duration;
48 EXPECT_TRUE(element->IsFinished(start_time + delta, &element_duration)); 53 EXPECT_TRUE(element->IsFinished(effective_start_time + delta,
49 EXPECT_EQ(delta, element_duration); 54 &element_duration));
55 EXPECT_EQ(2 * delta, element_duration);
50 56
51 element->Progress(start_time + delta, &delegate); 57 element->Progress(effective_start_time + delta, &delegate);
58 EXPECT_FLOAT_EQ(1.0, element->last_progressed_fraction());
52 CheckApproximatelyEqual(target_transform, 59 CheckApproximatelyEqual(target_transform,
53 delegate.GetTransformForAnimation()); 60 delegate.GetTransformForAnimation());
54 } 61 }
55 62
56 LayerAnimationElement::TargetValue target_value(&delegate); 63 LayerAnimationElement::TargetValue target_value(&delegate);
57 element->GetTargetValue(&target_value); 64 element->GetTargetValue(&target_value);
58 CheckApproximatelyEqual(target_transform, target_value.transform); 65 CheckApproximatelyEqual(target_transform, target_value.transform);
59 } 66 }
60 67
61 // Check that the bounds element progresses the delegate as expected and 68 // Check that the bounds element progresses the delegate as expected and
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 element->Progress(effective_start_time + delta/2, &delegate); 316 element->Progress(effective_start_time + delta/2, &delegate);
310 317
311 element->Abort(&delegate); 318 element->Abort(&delegate);
312 EXPECT_FLOAT_EQ(Tween::CalculateValue(tween_type, 0.5), 319 EXPECT_FLOAT_EQ(Tween::CalculateValue(tween_type, 0.5),
313 delegate.GetOpacityForAnimation()); 320 delegate.GetOpacityForAnimation());
314 } 321 }
315 322
316 } // namespace 323 } // namespace
317 324
318 } // namespace ui 325 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer_animation_element.cc ('k') | ui/compositor/layer_animation_sequence.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698