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