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

Side by Side Diff: third_party/WebKit/Source/platform/animation/AnimationTranslationUtilTest.cpp

Issue 2357633003: Move buildFilterOperations to FilterEffectBuilder (Closed)
Patch Set: Fold toCompositorFilterOperations Created 4 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
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24 24
25 #include "platform/animation/AnimationTranslationUtil.h" 25 #include "platform/animation/AnimationTranslationUtil.h"
26 26
27 #include "platform/animation/CompositorTransformOperations.h" 27 #include "platform/animation/CompositorTransformOperations.h"
28 #include "platform/graphics/CompositorFilterOperations.h"
29 #include "platform/graphics/filters/FilterOperations.h"
30 #include "platform/transforms/Matrix3DTransformOperation.h" 28 #include "platform/transforms/Matrix3DTransformOperation.h"
31 #include "platform/transforms/RotateTransformOperation.h" 29 #include "platform/transforms/RotateTransformOperation.h"
32 #include "platform/transforms/ScaleTransformOperation.h" 30 #include "platform/transforms/ScaleTransformOperation.h"
33 #include "platform/transforms/TransformOperations.h" 31 #include "platform/transforms/TransformOperations.h"
34 #include "platform/transforms/TranslateTransformOperation.h" 32 #include "platform/transforms/TranslateTransformOperation.h"
35 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
36 #include "wtf/RefPtr.h"
37 #include <memory> 34 #include <memory>
38 35
39 namespace blink { 36 namespace blink {
40 37
41 TEST(AnimationTranslationUtilTest, transformsWork) 38 TEST(AnimationTranslationUtilTest, transformsWork)
42 { 39 {
43 TransformOperations ops; 40 TransformOperations ops;
44 CompositorTransformOperations outOps; 41 CompositorTransformOperations outOps;
45 42
46 ops.operations().append(TranslateTransformOperation::create(Length(2, Fixed) , Length(0, Fixed), TransformOperation::TranslateX)); 43 ops.operations().append(TranslateTransformOperation::create(Length(2, Fixed) , Length(0, Fixed), TransformOperation::TranslateX));
(...skipping 17 matching lines...) Expand all
64 EXPECT_NEAR(op1.rotate.axis.z, 0.3f, err); 61 EXPECT_NEAR(op1.rotate.axis.z, 0.3f, err);
65 EXPECT_NEAR(op1.rotate.angle, 200000.4f, 0.01f); 62 EXPECT_NEAR(op1.rotate.angle, 200000.4f, 0.01f);
66 63
67 auto& op2 = outOps.asCcTransformOperations().at(2); 64 auto& op2 = outOps.asCcTransformOperations().at(2);
68 EXPECT_EQ(cc::TransformOperation::TRANSFORM_OPERATION_SCALE, op2.type); 65 EXPECT_EQ(cc::TransformOperation::TRANSFORM_OPERATION_SCALE, op2.type);
69 EXPECT_NEAR(op2.scale.x, 50.2f, err); 66 EXPECT_NEAR(op2.scale.x, 50.2f, err);
70 EXPECT_NEAR(op2.scale.y, 100.0f, err); 67 EXPECT_NEAR(op2.scale.y, 100.0f, err);
71 EXPECT_NEAR(op2.scale.z, -4.0f, err); 68 EXPECT_NEAR(op2.scale.z, -4.0f, err);
72 } 69 }
73 70
74 TEST(AnimationTranslationUtilTest, filtersWork)
75 {
76 FilterOperations ops;
77 ops.operations().append(BasicColorMatrixFilterOperation::create(0.5, FilterO peration::SATURATE));
78 ops.operations().append(BasicColorMatrixFilterOperation::create(0.2, FilterO peration::GRAYSCALE));
79 ops.operations().append(BasicColorMatrixFilterOperation::create(0.8, FilterO peration::SEPIA));
80 ops.operations().append(BasicComponentTransferFilterOperation::create(0.1, F ilterOperation::OPACITY));
81
82 CompositorFilterOperations outOps = toCompositorFilterOperations(ops);
83
84 EXPECT_EQ(4UL, outOps.asCcFilterOperations().size());
85 const float err = 0.0001;
86
87 auto& op0 = outOps.asCcFilterOperations().at(0);
88 EXPECT_EQ(cc::FilterOperation::SATURATE, op0.type());
89 EXPECT_NEAR(op0.amount(), 0.5f, err);
90
91 auto& op1 = outOps.asCcFilterOperations().at(1);
92 EXPECT_EQ(cc::FilterOperation::GRAYSCALE, op1.type());
93 EXPECT_NEAR(op1.amount(), 0.2f, err);
94
95 auto& op2 = outOps.asCcFilterOperations().at(2);
96 EXPECT_EQ(cc::FilterOperation::SEPIA, op2.type());
97 EXPECT_NEAR(op2.amount(), 0.8f, err);
98
99 auto& op3 = outOps.asCcFilterOperations().at(3);
100 EXPECT_EQ(cc::FilterOperation::OPACITY, op3.type());
101 EXPECT_NEAR(op3.amount(), 0.1f, err);
102 }
103
104 } // namespace blink 71 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698