| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 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 20 matching lines...) Expand all Loading... |
| 31 #include "platform/transforms/Matrix3DTransformOperation.h" | 31 #include "platform/transforms/Matrix3DTransformOperation.h" |
| 32 #include "platform/transforms/MatrixTransformOperation.h" | 32 #include "platform/transforms/MatrixTransformOperation.h" |
| 33 #include "platform/transforms/PerspectiveTransformOperation.h" | 33 #include "platform/transforms/PerspectiveTransformOperation.h" |
| 34 #include "platform/transforms/RotateTransformOperation.h" | 34 #include "platform/transforms/RotateTransformOperation.h" |
| 35 #include "platform/transforms/ScaleTransformOperation.h" | 35 #include "platform/transforms/ScaleTransformOperation.h" |
| 36 #include "platform/transforms/SkewTransformOperation.h" | 36 #include "platform/transforms/SkewTransformOperation.h" |
| 37 #include "platform/transforms/TranslateTransformOperation.h" | 37 #include "platform/transforms/TranslateTransformOperation.h" |
| 38 | 38 |
| 39 #include <gtest/gtest.h> | 39 #include <gtest/gtest.h> |
| 40 | 40 |
| 41 using namespace WebCore; | 41 using namespace blink; |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 static const TransformOperations identityOperations; | 44 static const TransformOperations identityOperations; |
| 45 | 45 |
| 46 static void EmpiricallyTestBounds(const TransformOperations& from, | 46 static void EmpiricallyTestBounds(const TransformOperations& from, |
| 47 const TransformOperations& to, | 47 const TransformOperations& to, |
| 48 const double& minProgress, | 48 const double& minProgress, |
| 49 const double& maxProgress) | 49 const double& maxProgress) |
| 50 { | 50 { |
| 51 FloatBox box(200, 500, 100, 100, 300, 200); | 51 FloatBox box(200, 500, 100, 100, 300, 200); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 72 firstTime = false; | 72 firstTime = false; |
| 73 } | 73 } |
| 74 | 74 |
| 75 ASSERT_PRED_FORMAT2(FloatBoxTest::AssertContains, bounds, empiricalBounds); | 75 ASSERT_PRED_FORMAT2(FloatBoxTest::AssertContains, bounds, empiricalBounds); |
| 76 } | 76 } |
| 77 | 77 |
| 78 TEST(TransformOperationsTest, AbsoluteAnimatedTranslatedBoundsTest) | 78 TEST(TransformOperationsTest, AbsoluteAnimatedTranslatedBoundsTest) |
| 79 { | 79 { |
| 80 TransformOperations fromOps; | 80 TransformOperations fromOps; |
| 81 TransformOperations toOps; | 81 TransformOperations toOps; |
| 82 fromOps.operations().append(TranslateTransformOperation::create(Length(-30,
WebCore::Fixed), Length(20, WebCore::Fixed), 15, TransformOperation::Translate3D
)); | 82 fromOps.operations().append(TranslateTransformOperation::create(Length(-30,
blink::Fixed), Length(20, blink::Fixed), 15, TransformOperation::Translate3D)); |
| 83 toOps.operations().append(TranslateTransformOperation::create(Length(10, Web
Core::Fixed), Length(10, WebCore::Fixed), 200, TransformOperation::Translate3D))
; | 83 toOps.operations().append(TranslateTransformOperation::create(Length(10, bli
nk::Fixed), Length(10, blink::Fixed), 200, TransformOperation::Translate3D)); |
| 84 FloatBox box(0, 0, 0, 10, 10, 10); | 84 FloatBox box(0, 0, 0, 10, 10, 10); |
| 85 FloatBox bounds; | 85 FloatBox bounds; |
| 86 | 86 |
| 87 EXPECT_TRUE(toOps.blendedBoundsForBox(box, identityOperations, 0, 1, &bounds
)); | 87 EXPECT_TRUE(toOps.blendedBoundsForBox(box, identityOperations, 0, 1, &bounds
)); |
| 88 EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual, FloatBox(0, 0, 0, 20, 2
0, 210), bounds); | 88 EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual, FloatBox(0, 0, 0, 20, 2
0, 210), bounds); |
| 89 | 89 |
| 90 EXPECT_TRUE(identityOperations.blendedBoundsForBox(box, toOps, 0, 1, &bounds
)); | 90 EXPECT_TRUE(identityOperations.blendedBoundsForBox(box, toOps, 0, 1, &bounds
)); |
| 91 EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual, FloatBox(0, 0, 0, 20, 2
0, 210), bounds); | 91 EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual, FloatBox(0, 0, 0, 20, 2
0, 210), bounds); |
| 92 | 92 |
| 93 EXPECT_TRUE(identityOperations.blendedBoundsForBox(box, fromOps, 0, 1, &boun
ds)); | 93 EXPECT_TRUE(identityOperations.blendedBoundsForBox(box, fromOps, 0, 1, &boun
ds)); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 113 // [0,1]. | 113 // [0,1]. |
| 114 float progress[][2] = { | 114 float progress[][2] = { |
| 115 { 0, 1 }, | 115 { 0, 1 }, |
| 116 { -.25, 1.25 } | 116 { -.25, 1.25 } |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 for (size_t i = 0; i < WTF_ARRAY_LENGTH(testTransforms); ++i) { | 119 for (size_t i = 0; i < WTF_ARRAY_LENGTH(testTransforms); ++i) { |
| 120 for (size_t j = 0; j < WTF_ARRAY_LENGTH(progress); ++j) { | 120 for (size_t j = 0; j < WTF_ARRAY_LENGTH(progress); ++j) { |
| 121 TransformOperations fromOps; | 121 TransformOperations fromOps; |
| 122 TransformOperations toOps; | 122 TransformOperations toOps; |
| 123 fromOps.operations().append(TranslateTransformOperation::create(Leng
th(testTransforms[i][0][0], WebCore::Fixed), Length(testTransforms[i][0][1], Web
Core::Fixed), testTransforms[i][0][2], TransformOperation::Translate3D)); | 123 fromOps.operations().append(TranslateTransformOperation::create(Leng
th(testTransforms[i][0][0], blink::Fixed), Length(testTransforms[i][0][1], blink
::Fixed), testTransforms[i][0][2], TransformOperation::Translate3D)); |
| 124 toOps.operations().append(TranslateTransformOperation::create(Length
(testTransforms[i][1][0], WebCore::Fixed), Length(testTransforms[i][1][1], WebCo
re::Fixed), testTransforms[i][1][2], TransformOperation::Translate3D)); | 124 toOps.operations().append(TranslateTransformOperation::create(Length
(testTransforms[i][1][0], blink::Fixed), Length(testTransforms[i][1][1], blink::
Fixed), testTransforms[i][1][2], TransformOperation::Translate3D)); |
| 125 EmpiricallyTestBounds(fromOps, toOps, 0, 1); | 125 EmpiricallyTestBounds(fromOps, toOps, 0, 1); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 | 129 |
| 130 TEST(TransformOperationsTest, AbsoluteAnimatedScaleBoundsTest) | 130 TEST(TransformOperationsTest, AbsoluteAnimatedScaleBoundsTest) |
| 131 { | 131 { |
| 132 TransformOperations fromOps; | 132 TransformOperations fromOps; |
| 133 TransformOperations toOps; | 133 TransformOperations toOps; |
| 134 fromOps.operations().append(ScaleTransformOperation::create(4, -3, Transform
Operation::Scale)); | 134 fromOps.operations().append(ScaleTransformOperation::create(4, -3, Transform
Operation::Scale)); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // [0,1]. | 168 // [0,1]. |
| 169 float progress[][2] = { | 169 float progress[][2] = { |
| 170 { 0, 1 }, | 170 { 0, 1 }, |
| 171 { -.25f, 1.25f } | 171 { -.25f, 1.25f } |
| 172 }; | 172 }; |
| 173 | 173 |
| 174 for (size_t i = 0; i < WTF_ARRAY_LENGTH(testTransforms); ++i) { | 174 for (size_t i = 0; i < WTF_ARRAY_LENGTH(testTransforms); ++i) { |
| 175 for (size_t j = 0; j < WTF_ARRAY_LENGTH(progress); ++j) { | 175 for (size_t j = 0; j < WTF_ARRAY_LENGTH(progress); ++j) { |
| 176 TransformOperations fromOps; | 176 TransformOperations fromOps; |
| 177 TransformOperations toOps; | 177 TransformOperations toOps; |
| 178 fromOps.operations().append(TranslateTransformOperation::create(Leng
th(testTransforms[i][0][0], WebCore::Fixed), Length(testTransforms[i][0][1], Web
Core::Fixed), testTransforms[i][0][2], TransformOperation::Translate3D)); | 178 fromOps.operations().append(TranslateTransformOperation::create(Leng
th(testTransforms[i][0][0], blink::Fixed), Length(testTransforms[i][0][1], blink
::Fixed), testTransforms[i][0][2], TransformOperation::Translate3D)); |
| 179 toOps.operations().append(TranslateTransformOperation::create(Length
(testTransforms[i][1][0], WebCore::Fixed), Length(testTransforms[i][1][1], WebCo
re::Fixed), testTransforms[i][1][2], TransformOperation::Translate3D)); | 179 toOps.operations().append(TranslateTransformOperation::create(Length
(testTransforms[i][1][0], blink::Fixed), Length(testTransforms[i][1][1], blink::
Fixed), testTransforms[i][1][2], TransformOperation::Translate3D)); |
| 180 EmpiricallyTestBounds(fromOps, toOps, 0, 1); | 180 EmpiricallyTestBounds(fromOps, toOps, 0, 1); |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 } | 183 } |
| 184 | 184 |
| 185 TEST(TransformOperationsTest, AbsoluteAnimatedRotationBounds) | 185 TEST(TransformOperationsTest, AbsoluteAnimatedRotationBounds) |
| 186 { | 186 { |
| 187 TransformOperations fromOps; | 187 TransformOperations fromOps; |
| 188 TransformOperations toOps; | 188 TransformOperations toOps; |
| 189 fromOps.operations().append(RotateTransformOperation::create(0, TransformOpe
ration::Rotate)); | 189 fromOps.operations().append(RotateTransformOperation::create(0, TransformOpe
ration::Rotate)); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual, FloatBox(-32, -25, 7, 4
2, 44, 48), bounds); | 484 EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual, FloatBox(-32, -25, 7, 4
2, 44, 48), bounds); |
| 485 | 485 |
| 486 EXPECT_TRUE(toOps.blendedBoundsForBox(box, identityOperations, 0, 1, &bounds
)); | 486 EXPECT_TRUE(toOps.blendedBoundsForBox(box, identityOperations, 0, 1, &bounds
)); |
| 487 EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual, FloatBox(-33, -13, 3, 5
7, 19, 52), bounds); | 487 EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual, FloatBox(-33, -13, 3, 5
7, 19, 52), bounds); |
| 488 | 488 |
| 489 EXPECT_TRUE(identityOperations.blendedBoundsForBox(box, fromOps, 0, 1, &boun
ds)); | 489 EXPECT_TRUE(identityOperations.blendedBoundsForBox(box, fromOps, 0, 1, &boun
ds)); |
| 490 EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual, FloatBox(-7, -3, 2, 15,
23, 20), bounds); | 490 EXPECT_PRED_FORMAT2(FloatBoxTest::AssertAlmostEqual, FloatBox(-7, -3, 2, 15,
23, 20), bounds); |
| 491 } | 491 } |
| 492 | 492 |
| 493 } // namespace | 493 } // namespace |
| OLD | NEW |