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

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: Fix the DCHECK production code and removed k prefix to const transform variable. 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
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 <sstream>
8
9 #include "base/time/time.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/compositor/test/test_utils.h"
12
13 namespace ui {
14
15 namespace {
16
17 // Check that the inverse transform curve gives the gives a transform that when
18 // applied on top of the parent transform gives the original transform
19 TEST(InverseTransformCurveAdapterTest, InversesTransform) {
20 gfx::Transform parent_start, parent_target;
21 parent_start.Scale(0.5, 3.0);
22 parent_start.Translate(-20.0, 30.0);
23 parent_target.Translate(0, 100);
24
25 gfx::Transform child_transform;
26 child_transform.Rotate(-30.0);
27
28 base::TimeDelta duration = base::TimeDelta::FromSeconds(1);
29
30 const gfx::Transform effective_child_transform =
31 parent_start * child_transform;
32
33 TransformAnimationCurveAdapter parent_curve(Tween::LINEAR,
34 parent_start,
35 parent_target,
36 duration);
37
38 InverseTransformCurveAdapter child_curve(parent_curve,
39 child_transform,
40 duration);
41 static const int kSteps = 1000;
42 double step = 1.0 / kSteps;
43 for (int i = 0; i != kSteps + 1; ++i) {
danakj 2013/09/04 15:29:09 nit: i < kSteps + 1 ?
avallee 2013/09/04 15:36:53 I want to exit the loop having done 1001 steps in
danakj 2013/09/04 15:47:40 I'm not sure how < and != differ in this case. The
danakj 2013/09/04 15:48:26 (i <= kSteps) would also work if you preferred.
avallee 2013/09/04 15:50:34 Done.
44 std::ostringstream message;
45 message << "Step " << i << " of " << kSteps;
46 SCOPED_TRACE(message.str());
47 gfx::Transform progress_parent_transform =
48 parent_curve.GetValue(i*step);
49 gfx::Transform progress_child_transform =
50 child_curve.GetValue(i*step);
51 CheckApproximatelyEqual(effective_child_transform,
52 progress_parent_transform *
53 progress_child_transform);
54 }
55 }
56
57 } // namespace
58
59 } // namespace ui
OLDNEW
« ui/compositor/test/test_utils.cc ('K') | « ui/compositor/transform_animation_curve_adapter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698