| OLD | NEW |
| 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 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "platform/animation/CompositorTransformOperations.h" | 27 #include "platform/animation/CompositorTransformOperations.h" |
| 28 #include "platform/graphics/CompositorFilterOperations.h" | 28 #include "platform/graphics/CompositorFilterOperations.h" |
| 29 #include "platform/graphics/filters/FilterOperations.h" | 29 #include "platform/graphics/filters/FilterOperations.h" |
| 30 #include "platform/transforms/Matrix3DTransformOperation.h" | 30 #include "platform/transforms/Matrix3DTransformOperation.h" |
| 31 #include "platform/transforms/RotateTransformOperation.h" | 31 #include "platform/transforms/RotateTransformOperation.h" |
| 32 #include "platform/transforms/ScaleTransformOperation.h" | 32 #include "platform/transforms/ScaleTransformOperation.h" |
| 33 #include "platform/transforms/TransformOperations.h" | 33 #include "platform/transforms/TransformOperations.h" |
| 34 #include "platform/transforms/TranslateTransformOperation.h" | 34 #include "platform/transforms/TranslateTransformOperation.h" |
| 35 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
| 36 #include "wtf/RefPtr.h" | 36 #include "wtf/RefPtr.h" |
| 37 #include <memory> | |
| 38 | 37 |
| 39 namespace blink { | 38 namespace blink { |
| 40 | 39 |
| 41 TEST(AnimationTranslationUtilTest, transformsWork) | 40 TEST(AnimationTranslationUtilTest, transformsWork) |
| 42 { | 41 { |
| 43 TransformOperations ops; | 42 TransformOperations ops; |
| 44 std::unique_ptr<CompositorTransformOperations> outOps = CompositorTransformO
perations::create(); | 43 OwnPtr<CompositorTransformOperations> outOps = CompositorTransformOperations
::create(); |
| 45 | 44 |
| 46 ops.operations().append(TranslateTransformOperation::create(Length(2, Fixed)
, Length(0, Fixed), TransformOperation::TranslateX)); | 45 ops.operations().append(TranslateTransformOperation::create(Length(2, Fixed)
, Length(0, Fixed), TransformOperation::TranslateX)); |
| 47 ops.operations().append(RotateTransformOperation::create(0.1, 0.2, 0.3, 2000
00.4, TransformOperation::Rotate3D)); | 46 ops.operations().append(RotateTransformOperation::create(0.1, 0.2, 0.3, 2000
00.4, TransformOperation::Rotate3D)); |
| 48 ops.operations().append(ScaleTransformOperation::create(50.2, 100, -4, Trans
formOperation::Scale3D)); | 47 ops.operations().append(ScaleTransformOperation::create(50.2, 100, -4, Trans
formOperation::Scale3D)); |
| 49 toCompositorTransformOperations(ops, outOps.get()); | 48 toCompositorTransformOperations(ops, outOps.get()); |
| 50 | 49 |
| 51 EXPECT_EQ(3UL, outOps->asTransformOperations().size()); | 50 EXPECT_EQ(3UL, outOps->asTransformOperations().size()); |
| 52 const float err = 0.0001; | 51 const float err = 0.0001; |
| 53 | 52 |
| 54 auto& op0 = outOps->asTransformOperations().at(0); | 53 auto& op0 = outOps->asTransformOperations().at(0); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 67 auto& op2 = outOps->asTransformOperations().at(2); | 66 auto& op2 = outOps->asTransformOperations().at(2); |
| 68 EXPECT_EQ(cc::TransformOperation::TRANSFORM_OPERATION_SCALE, op2.type); | 67 EXPECT_EQ(cc::TransformOperation::TRANSFORM_OPERATION_SCALE, op2.type); |
| 69 EXPECT_NEAR(op2.scale.x, 50.2f, err); | 68 EXPECT_NEAR(op2.scale.x, 50.2f, err); |
| 70 EXPECT_NEAR(op2.scale.y, 100.0f, err); | 69 EXPECT_NEAR(op2.scale.y, 100.0f, err); |
| 71 EXPECT_NEAR(op2.scale.z, -4.0f, err); | 70 EXPECT_NEAR(op2.scale.z, -4.0f, err); |
| 72 } | 71 } |
| 73 | 72 |
| 74 TEST(AnimationTranslationUtilTest, filtersWork) | 73 TEST(AnimationTranslationUtilTest, filtersWork) |
| 75 { | 74 { |
| 76 FilterOperations ops; | 75 FilterOperations ops; |
| 77 std::unique_ptr<CompositorFilterOperations> outOps = CompositorFilterOperati
ons::create(); | 76 OwnPtr<CompositorFilterOperations> outOps = CompositorFilterOperations::crea
te(); |
| 78 | 77 |
| 79 ops.operations().append(BasicColorMatrixFilterOperation::create(0.5, FilterO
peration::SATURATE)); | 78 ops.operations().append(BasicColorMatrixFilterOperation::create(0.5, FilterO
peration::SATURATE)); |
| 80 ops.operations().append(BasicColorMatrixFilterOperation::create(0.2, FilterO
peration::GRAYSCALE)); | 79 ops.operations().append(BasicColorMatrixFilterOperation::create(0.2, FilterO
peration::GRAYSCALE)); |
| 81 ops.operations().append(BasicColorMatrixFilterOperation::create(0.8, FilterO
peration::SEPIA)); | 80 ops.operations().append(BasicColorMatrixFilterOperation::create(0.8, FilterO
peration::SEPIA)); |
| 82 ops.operations().append(BasicComponentTransferFilterOperation::create(0.1, F
ilterOperation::OPACITY)); | 81 ops.operations().append(BasicComponentTransferFilterOperation::create(0.1, F
ilterOperation::OPACITY)); |
| 83 toCompositorFilterOperations(ops, outOps.get()); | 82 toCompositorFilterOperations(ops, outOps.get()); |
| 84 | 83 |
| 85 EXPECT_EQ(4UL, outOps->asFilterOperations().size()); | 84 EXPECT_EQ(4UL, outOps->asFilterOperations().size()); |
| 86 const float err = 0.0001; | 85 const float err = 0.0001; |
| 87 | 86 |
| 88 auto& op0 = outOps->asFilterOperations().at(0); | 87 auto& op0 = outOps->asFilterOperations().at(0); |
| 89 EXPECT_EQ(cc::FilterOperation::SATURATE, op0.type()); | 88 EXPECT_EQ(cc::FilterOperation::SATURATE, op0.type()); |
| 90 EXPECT_NEAR(op0.amount(), 0.5f, err); | 89 EXPECT_NEAR(op0.amount(), 0.5f, err); |
| 91 | 90 |
| 92 auto& op1 = outOps->asFilterOperations().at(1); | 91 auto& op1 = outOps->asFilterOperations().at(1); |
| 93 EXPECT_EQ(cc::FilterOperation::GRAYSCALE, op1.type()); | 92 EXPECT_EQ(cc::FilterOperation::GRAYSCALE, op1.type()); |
| 94 EXPECT_NEAR(op1.amount(), 0.2f, err); | 93 EXPECT_NEAR(op1.amount(), 0.2f, err); |
| 95 | 94 |
| 96 auto& op2 = outOps->asFilterOperations().at(2); | 95 auto& op2 = outOps->asFilterOperations().at(2); |
| 97 EXPECT_EQ(cc::FilterOperation::SEPIA, op2.type()); | 96 EXPECT_EQ(cc::FilterOperation::SEPIA, op2.type()); |
| 98 EXPECT_NEAR(op2.amount(), 0.8f, err); | 97 EXPECT_NEAR(op2.amount(), 0.8f, err); |
| 99 | 98 |
| 100 auto& op3 = outOps->asFilterOperations().at(3); | 99 auto& op3 = outOps->asFilterOperations().at(3); |
| 101 EXPECT_EQ(cc::FilterOperation::OPACITY, op3.type()); | 100 EXPECT_EQ(cc::FilterOperation::OPACITY, op3.type()); |
| 102 EXPECT_NEAR(op3.amount(), 0.1f, err); | 101 EXPECT_NEAR(op3.amount(), 0.1f, err); |
| 103 } | 102 } |
| 104 | 103 |
| 105 } // namespace blink | 104 } // namespace blink |
| OLD | NEW |