| OLD | NEW |
| (Empty) |
| 1 // Copyright 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(gfx::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 ; ++i) { | |
| 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 | |
| OLD | NEW |