| OLD | NEW |
| (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 |
| 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 |
| OLD | NEW |