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

Side by Side Diff: cc/animation/keyframed_animation_curve_unittest.cc

Issue 2971503002: Transform animations should not collapse by default when interpolating (Closed)
Patch Set: . Created 3 years, 5 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
« no previous file with comments | « cc/animation/keyframed_animation_curve.cc ('k') | cc/animation/transform_operation.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/animation/keyframed_animation_curve.h" 5 #include "cc/animation/keyframed_animation_curve.h"
6 6
7 #include "cc/animation/transform_operations.h" 7 #include "cc/animation/transform_operations.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/gfx/animation/tween.h" 10 #include "ui/gfx/animation/tween.h"
11 #include "ui/gfx/geometry/box_f.h" 11 #include "ui/gfx/geometry/box_f.h"
12 #include "ui/gfx/test/gfx_util.h" 12 #include "ui/gfx/test/gfx_util.h"
13 13
14 namespace cc { 14 namespace cc {
15 namespace { 15 namespace {
16 16
17 void ExpectTranslateX(SkMScalar translate_x, const gfx::Transform& transform) { 17 void ExpectTranslateX(SkMScalar translate_x,
18 EXPECT_FLOAT_EQ(translate_x, transform.matrix().get(0, 3)); 18 const TransformOperations& operations) {
19 EXPECT_FLOAT_EQ(translate_x, operations.Apply().matrix().get(0, 3));
19 } 20 }
20 21
21 void ExpectBrightness(double brightness, const FilterOperations& filter) { 22 void ExpectBrightness(double brightness, const FilterOperations& filter) {
22 EXPECT_EQ(1u, filter.size()); 23 EXPECT_EQ(1u, filter.size());
23 EXPECT_EQ(FilterOperation::BRIGHTNESS, filter.at(0).type()); 24 EXPECT_EQ(FilterOperation::BRIGHTNESS, filter.at(0).type());
24 EXPECT_FLOAT_EQ(brightness, filter.at(0).amount()); 25 EXPECT_FLOAT_EQ(brightness, filter.at(0).amount());
25 } 26 }
26 27
27 // Tests that a color animation with one keyframe works as expected. 28 // Tests that a color animation with one keyframe works as expected.
28 TEST(KeyframedAnimationCurveTest, OneColorKeyFrame) { 29 TEST(KeyframedAnimationCurveTest, OneColorKeyFrame) {
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 curve->AddKeyframe(TransformKeyframe::Create( 287 curve->AddKeyframe(TransformKeyframe::Create(
287 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); 288 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr));
288 curve->AddKeyframe(TransformKeyframe::Create( 289 curve->AddKeyframe(TransformKeyframe::Create(
289 base::TimeDelta::FromSecondsD(2.0), operations4, nullptr)); 290 base::TimeDelta::FromSecondsD(2.0), operations4, nullptr));
290 291
291 ExpectTranslateX(4.f, curve->GetValue(base::TimeDelta::FromSecondsD(-1.f))); 292 ExpectTranslateX(4.f, curve->GetValue(base::TimeDelta::FromSecondsD(-1.f)));
292 ExpectTranslateX(4.f, curve->GetValue(base::TimeDelta::FromSecondsD(0.f))); 293 ExpectTranslateX(4.f, curve->GetValue(base::TimeDelta::FromSecondsD(0.f)));
293 ExpectTranslateX(4.f, curve->GetValue(base::TimeDelta::FromSecondsD(0.5f))); 294 ExpectTranslateX(4.f, curve->GetValue(base::TimeDelta::FromSecondsD(0.5f)));
294 295
295 // There is a discontinuity at 1. Any value between 4 and 6 is valid. 296 // There is a discontinuity at 1. Any value between 4 and 6 is valid.
296 gfx::Transform value = curve->GetValue(base::TimeDelta::FromSecondsD(1.f)); 297 gfx::Transform value =
298 curve->GetValue(base::TimeDelta::FromSecondsD(1.f)).Apply();
297 EXPECT_GE(value.matrix().get(0, 3), 4.f); 299 EXPECT_GE(value.matrix().get(0, 3), 4.f);
298 EXPECT_LE(value.matrix().get(0, 3), 6.f); 300 EXPECT_LE(value.matrix().get(0, 3), 6.f);
299 301
300 ExpectTranslateX(6.f, curve->GetValue(base::TimeDelta::FromSecondsD(1.5f))); 302 ExpectTranslateX(6.f, curve->GetValue(base::TimeDelta::FromSecondsD(1.5f)));
301 ExpectTranslateX(6.f, curve->GetValue(base::TimeDelta::FromSecondsD(2.f))); 303 ExpectTranslateX(6.f, curve->GetValue(base::TimeDelta::FromSecondsD(2.f)));
302 ExpectTranslateX(6.f, curve->GetValue(base::TimeDelta::FromSecondsD(3.f))); 304 ExpectTranslateX(6.f, curve->GetValue(base::TimeDelta::FromSecondsD(3.f)));
303 } 305 }
304 306
305 // Tests that a filter animation with one keyframe works as expected. 307 // Tests that a filter animation with one keyframe works as expected.
306 TEST(KeyframedAnimationCurveTest, OneFilterKeyframe) { 308 TEST(KeyframedAnimationCurveTest, OneFilterKeyframe) {
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 EXPECT_LE(64.0f, value.height()); 1071 EXPECT_LE(64.0f, value.height());
1070 EXPECT_GE(192.0f, value.height()); 1072 EXPECT_GE(192.0f, value.height());
1071 1073
1072 EXPECT_SIZEF_EQ(size_b, curve->GetValue(base::TimeDelta::FromSecondsD(1.5f))); 1074 EXPECT_SIZEF_EQ(size_b, curve->GetValue(base::TimeDelta::FromSecondsD(1.5f)));
1073 EXPECT_SIZEF_EQ(size_b, curve->GetValue(base::TimeDelta::FromSecondsD(2.f))); 1075 EXPECT_SIZEF_EQ(size_b, curve->GetValue(base::TimeDelta::FromSecondsD(2.f)));
1074 EXPECT_SIZEF_EQ(size_b, curve->GetValue(base::TimeDelta::FromSecondsD(3.f))); 1076 EXPECT_SIZEF_EQ(size_b, curve->GetValue(base::TimeDelta::FromSecondsD(3.f)));
1075 } 1077 }
1076 1078
1077 } // namespace 1079 } // namespace
1078 } // namespace cc 1080 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/keyframed_animation_curve.cc ('k') | cc/animation/transform_operation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698