Update {virtual,override,final} for content/ to follow C++11 style.
[chromium-blink-merge.git] / ui / compositor / transform_animation_curve_adapter_unittest.cc
blob10ee66811f318b9a5585849c5065c7316ef447cc
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.
5 #include "ui/compositor/transform_animation_curve_adapter.h"
7 #include <sstream>
9 #include "base/time/time.h"
10 #include "cc/base/time_util.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/compositor/test/test_utils.h"
14 namespace ui {
16 namespace {
18 // Check that the inverse transform curve gives the gives a transform that when
19 // applied on top of the parent transform gives the original transform
20 TEST(InverseTransformCurveAdapterTest, InversesTransform) {
21 gfx::Transform parent_start, parent_target;
22 parent_start.Scale(0.5, 3.0);
23 parent_start.Translate(-20.0, 30.0);
24 parent_target.Translate(0, 100);
26 gfx::Transform child_transform;
27 child_transform.Rotate(-30.0);
29 base::TimeDelta duration = base::TimeDelta::FromSeconds(1);
31 const gfx::Transform effective_child_transform =
32 parent_start * child_transform;
34 TransformAnimationCurveAdapter parent_curve(gfx::Tween::LINEAR,
35 parent_start,
36 parent_target,
37 duration);
39 InverseTransformCurveAdapter child_curve(parent_curve,
40 child_transform,
41 duration);
42 static const int kSteps = 1000;
43 double step = 1.0 / kSteps;
44 for (int i = 0; i <= kSteps ; ++i) {
45 base::TimeDelta time_step = cc::TimeUtil::Scale(duration, i * step);
46 std::ostringstream message;
47 message << "Step " << i << " of " << kSteps;
48 SCOPED_TRACE(message.str());
49 gfx::Transform progress_parent_transform = parent_curve.GetValue(time_step);
50 gfx::Transform progress_child_transform = child_curve.GetValue(time_step);
51 CheckApproximatelyEqual(effective_child_transform,
52 progress_parent_transform *
53 progress_child_transform);
57 } // namespace
59 } // namespace ui