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

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

Issue 22861008: Add support for inverse transform animations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved the logic into a new curve adapter and did miminal work in the counter transform element. Created 7 years, 4 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
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/compositor/transform_animation_curve_adapter.h"
6
7 #include "base/time/time.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/compositor/test/test_utils.h"
10
11 namespace ui {
12
13 namespace {
14
15 // Check that the counter transform curve gives the gives a transform that when
16 // applied on top of the parent transform gives the original transform
Ian Vollick 2013/08/23 12:45:19 Nice test!
avallee 2013/08/23 15:01:19 Thanks.
17 TEST(CounterTransformCurveAdapterTest, InversesTransform) {
18 gfx::Transform parent_start, parent_target;
19 parent_start.Scale(0.5, 3);
20 parent_start.Translate(-20, 30);
21 parent_target.Translate(0, 100);
22
23 gfx::Transform child_transform;
24 child_transform.Rotate(-30.0);
25
26 base::TimeDelta duration = base::TimeDelta::FromSeconds(1);
27
28 const gfx::Transform effective_child_transform =
29 parent_start * child_transform;
30
31 TransformAnimationCurveAdapter parent_curve(Tween::LINEAR,
32 parent_start,
33 parent_target,
34 duration);
35
36 CounterTransformCurveAdapter child_curve(parent_curve,
37 child_transform,
38 duration);
39 const int steps = 1000;
40 double step = 1.0/steps;
41 for (int i = 0; i != steps; ++i) {
42 gfx::Transform progress_parent_transform =
43 parent_curve.GetValue(i*step);
44 gfx::Transform progress_child_transform =
45 child_curve.GetValue(i*step);
46 CheckApproximatelyEqual(effective_child_transform,
47 progress_parent_transform *
48 progress_child_transform);
49 }
50 }
51
52 } // namespace
53
54 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698