| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 | |
| 7 #include "base/memory/scoped_vector.h" | |
| 8 #include "cc/test/geometry_test_utils.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformOperati
ons.h" | |
| 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMa
trix.h" | |
| 12 | |
| 13 using namespace WebKit; | |
| 14 | |
| 15 TEST(WebTransformOperationTest, transformTypesAreUnique) | |
| 16 { | |
| 17 ScopedVector<WebTransformOperations> transforms; | |
| 18 | |
| 19 WebTransformOperations* toAdd = new WebTransformOperations(); | |
| 20 toAdd->appendTranslate(1, 0, 0); | |
| 21 transforms.push_back(toAdd); | |
| 22 | |
| 23 toAdd = new WebTransformOperations(); | |
| 24 toAdd->appendRotate(0, 0, 1, 2); | |
| 25 transforms.push_back(toAdd); | |
| 26 | |
| 27 toAdd = new WebTransformOperations(); | |
| 28 toAdd->appendScale(2, 2, 2); | |
| 29 transforms.push_back(toAdd); | |
| 30 | |
| 31 toAdd = new WebTransformOperations(); | |
| 32 toAdd->appendSkew(1, 0); | |
| 33 transforms.push_back(toAdd); | |
| 34 | |
| 35 toAdd = new WebTransformOperations(); | |
| 36 toAdd->appendPerspective(800); | |
| 37 transforms.push_back(toAdd); | |
| 38 | |
| 39 for (size_t i = 0; i < transforms.size(); ++i) { | |
| 40 for (size_t j = 0; j < transforms.size(); ++j) { | |
| 41 bool matchesType = transforms[i]->matchesTypes(*transforms[j]); | |
| 42 EXPECT_TRUE((i == j && matchesType) || !matchesType); | |
| 43 } | |
| 44 } | |
| 45 } | |
| 46 | |
| 47 TEST(WebTransformOperationTest, matchTypesSameLength) | |
| 48 { | |
| 49 WebTransformOperations translates; | |
| 50 translates.appendTranslate(1, 0, 0); | |
| 51 translates.appendTranslate(1, 0, 0); | |
| 52 translates.appendTranslate(1, 0, 0); | |
| 53 | |
| 54 WebTransformOperations skews; | |
| 55 skews.appendSkew(0, 2); | |
| 56 skews.appendSkew(0, 2); | |
| 57 skews.appendSkew(0, 2); | |
| 58 | |
| 59 WebTransformOperations translates2; | |
| 60 translates2.appendTranslate(0, 2, 0); | |
| 61 translates2.appendTranslate(0, 2, 0); | |
| 62 translates2.appendTranslate(0, 2, 0); | |
| 63 | |
| 64 WebTransformOperations translates3 = translates2; | |
| 65 | |
| 66 EXPECT_FALSE(translates.matchesTypes(skews)); | |
| 67 EXPECT_TRUE(translates.matchesTypes(translates2)); | |
| 68 EXPECT_TRUE(translates.matchesTypes(translates3)); | |
| 69 } | |
| 70 | |
| 71 TEST(WebTransformOperationTest, matchTypesDifferentLength) | |
| 72 { | |
| 73 WebTransformOperations translates; | |
| 74 translates.appendTranslate(1, 0, 0); | |
| 75 translates.appendTranslate(1, 0, 0); | |
| 76 translates.appendTranslate(1, 0, 0); | |
| 77 | |
| 78 WebTransformOperations skews; | |
| 79 skews.appendSkew(2, 0); | |
| 80 skews.appendSkew(2, 0); | |
| 81 | |
| 82 WebTransformOperations translates2; | |
| 83 translates2.appendTranslate(0, 2, 0); | |
| 84 translates2.appendTranslate(0, 2, 0); | |
| 85 | |
| 86 EXPECT_FALSE(translates.matchesTypes(skews)); | |
| 87 EXPECT_FALSE(translates.matchesTypes(translates2)); | |
| 88 } | |
| 89 | |
| 90 void getIdentityOperations(ScopedVector<WebTransformOperations>* operations) | |
| 91 { | |
| 92 WebTransformOperations* toAdd = new WebTransformOperations(); | |
| 93 operations->push_back(toAdd); | |
| 94 | |
| 95 toAdd = new WebTransformOperations(); | |
| 96 toAdd->appendTranslate(0, 0, 0); | |
| 97 operations->push_back(toAdd); | |
| 98 | |
| 99 toAdd = new WebTransformOperations(); | |
| 100 toAdd->appendTranslate(0, 0, 0); | |
| 101 toAdd->appendTranslate(0, 0, 0); | |
| 102 operations->push_back(toAdd); | |
| 103 | |
| 104 toAdd = new WebTransformOperations(); | |
| 105 toAdd->appendScale(1, 1, 1); | |
| 106 operations->push_back(toAdd); | |
| 107 | |
| 108 toAdd = new WebTransformOperations(); | |
| 109 toAdd->appendScale(1, 1, 1); | |
| 110 toAdd->appendScale(1, 1, 1); | |
| 111 operations->push_back(toAdd); | |
| 112 | |
| 113 toAdd = new WebTransformOperations(); | |
| 114 toAdd->appendSkew(0, 0); | |
| 115 operations->push_back(toAdd); | |
| 116 | |
| 117 toAdd = new WebTransformOperations(); | |
| 118 toAdd->appendSkew(0, 0); | |
| 119 toAdd->appendSkew(0, 0); | |
| 120 operations->push_back(toAdd); | |
| 121 | |
| 122 toAdd = new WebTransformOperations(); | |
| 123 toAdd->appendRotate(0, 0, 1, 0); | |
| 124 operations->push_back(toAdd); | |
| 125 | |
| 126 toAdd = new WebTransformOperations(); | |
| 127 toAdd->appendRotate(0, 0, 1, 0); | |
| 128 toAdd->appendRotate(0, 0, 1, 0); | |
| 129 operations->push_back(toAdd); | |
| 130 | |
| 131 toAdd = new WebTransformOperations(); | |
| 132 toAdd->appendMatrix(WebTransformationMatrix()); | |
| 133 operations->push_back(toAdd); | |
| 134 | |
| 135 toAdd = new WebTransformOperations(); | |
| 136 toAdd->appendMatrix(WebTransformationMatrix()); | |
| 137 toAdd->appendMatrix(WebTransformationMatrix()); | |
| 138 operations->push_back(toAdd); | |
| 139 } | |
| 140 | |
| 141 TEST(WebTransformOperationTest, identityAlwaysMatches) | |
| 142 { | |
| 143 ScopedVector<WebTransformOperations> operations; | |
| 144 getIdentityOperations(&operations); | |
| 145 | |
| 146 for (size_t i = 0; i < operations.size(); ++i) { | |
| 147 for (size_t j = 0; j < operations.size(); ++j) | |
| 148 EXPECT_TRUE(operations[i]->matchesTypes(*operations[j])); | |
| 149 } | |
| 150 } | |
| 151 | |
| 152 TEST(WebTransformOperationTest, applyTranslate) | |
| 153 { | |
| 154 double x = 1; | |
| 155 double y = 2; | |
| 156 double z = 3; | |
| 157 WebTransformOperations operations; | |
| 158 operations.appendTranslate(x, y, z); | |
| 159 WebTransformationMatrix expected; | |
| 160 expected.translate3d(x, y, z); | |
| 161 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.apply()); | |
| 162 } | |
| 163 | |
| 164 TEST(WebTransformOperationTest, applyRotate) | |
| 165 { | |
| 166 double x = 1; | |
| 167 double y = 2; | |
| 168 double z = 3; | |
| 169 double degrees = 80; | |
| 170 WebTransformOperations operations; | |
| 171 operations.appendRotate(x, y, z, degrees); | |
| 172 WebTransformationMatrix expected; | |
| 173 expected.rotate3d(x, y, z, degrees); | |
| 174 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.apply()); | |
| 175 } | |
| 176 | |
| 177 TEST(WebTransformOperationTest, applyScale) | |
| 178 { | |
| 179 double x = 1; | |
| 180 double y = 2; | |
| 181 double z = 3; | |
| 182 WebTransformOperations operations; | |
| 183 operations.appendScale(x, y, z); | |
| 184 WebTransformationMatrix expected; | |
| 185 expected.scale3d(x, y, z); | |
| 186 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.apply()); | |
| 187 } | |
| 188 | |
| 189 TEST(WebTransformOperationTest, applySkew) | |
| 190 { | |
| 191 double x = 1; | |
| 192 double y = 2; | |
| 193 WebTransformOperations operations; | |
| 194 operations.appendSkew(x, y); | |
| 195 WebTransformationMatrix expected; | |
| 196 expected.skewX(x); | |
| 197 expected.skewY(y); | |
| 198 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.apply()); | |
| 199 } | |
| 200 | |
| 201 TEST(WebTransformOperationTest, applyPerspective) | |
| 202 { | |
| 203 double depth = 800; | |
| 204 WebTransformOperations operations; | |
| 205 operations.appendPerspective(depth); | |
| 206 WebTransformationMatrix expected; | |
| 207 expected.applyPerspective(depth); | |
| 208 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.apply()); | |
| 209 } | |
| 210 | |
| 211 TEST(WebTransformOperationTest, applyMatrix) | |
| 212 { | |
| 213 double dx = 1; | |
| 214 double dy = 2; | |
| 215 double dz = 3; | |
| 216 WebTransformationMatrix expectedMatrix; | |
| 217 expectedMatrix.translate3d(dx, dy, dz); | |
| 218 WebTransformOperations matrixTransform; | |
| 219 matrixTransform.appendMatrix(expectedMatrix); | |
| 220 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedMatrix, matrixTransform.apply()); | |
| 221 } | |
| 222 | |
| 223 TEST(WebTransformOperationTest, applyOrder) | |
| 224 { | |
| 225 double sx = 2; | |
| 226 double sy = 4; | |
| 227 double sz = 8; | |
| 228 | |
| 229 double dx = 1; | |
| 230 double dy = 2; | |
| 231 double dz = 3; | |
| 232 | |
| 233 WebTransformOperations operations; | |
| 234 operations.appendScale(sx, sy, sz); | |
| 235 operations.appendTranslate(dx, dy, dz); | |
| 236 | |
| 237 WebTransformationMatrix expectedScaleMatrix; | |
| 238 expectedScaleMatrix.scale3d(sx, sy, sz); | |
| 239 | |
| 240 WebTransformationMatrix expectedTranslateMatrix; | |
| 241 expectedTranslateMatrix.translate3d(dx, dy, dz); | |
| 242 | |
| 243 WebTransformationMatrix expectedCombinedMatrix = expectedScaleMatrix; | |
| 244 expectedCombinedMatrix.multiply(expectedTranslateMatrix); | |
| 245 | |
| 246 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedCombinedMatrix, operations.apply()); | |
| 247 } | |
| 248 | |
| 249 TEST(WebTransformOperationTest, blendOrder) | |
| 250 { | |
| 251 double sx1 = 2; | |
| 252 double sy1 = 4; | |
| 253 double sz1 = 8; | |
| 254 | |
| 255 double dx1 = 1; | |
| 256 double dy1 = 2; | |
| 257 double dz1 = 3; | |
| 258 | |
| 259 double sx2 = 4; | |
| 260 double sy2 = 8; | |
| 261 double sz2 = 16; | |
| 262 | |
| 263 double dx2 = 10; | |
| 264 double dy2 = 20; | |
| 265 double dz2 = 30; | |
| 266 | |
| 267 WebTransformOperations operationsFrom; | |
| 268 operationsFrom.appendScale(sx1, sy1, sz1); | |
| 269 operationsFrom.appendTranslate(dx1, dy1, dz1); | |
| 270 | |
| 271 WebTransformOperations operationsTo; | |
| 272 operationsTo.appendScale(sx2, sy2, sz2); | |
| 273 operationsTo.appendTranslate(dx2, dy2, dz2); | |
| 274 | |
| 275 WebTransformationMatrix scaleFrom; | |
| 276 scaleFrom.scale3d(sx1, sy1, sz1); | |
| 277 WebTransformationMatrix translateFrom; | |
| 278 translateFrom.translate3d(dx1, dy1, dz1); | |
| 279 | |
| 280 WebTransformationMatrix scaleTo; | |
| 281 scaleTo.scale3d(sx2, sy2, sz2); | |
| 282 WebTransformationMatrix translateTo; | |
| 283 translateTo.translate3d(dx2, dy2, dz2); | |
| 284 | |
| 285 double progress = 0.25; | |
| 286 | |
| 287 WebTransformationMatrix blendedScale = scaleTo; | |
| 288 blendedScale.blend(scaleFrom, progress); | |
| 289 | |
| 290 WebTransformationMatrix blendedTranslate = translateTo; | |
| 291 blendedTranslate.blend(translateFrom, progress); | |
| 292 | |
| 293 WebTransformationMatrix expected = blendedScale; | |
| 294 expected.multiply(blendedTranslate); | |
| 295 | |
| 296 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operationsTo.blend(operationsFrom,
progress)); | |
| 297 } | |
| 298 | |
| 299 static void checkProgress(double progress, | |
| 300 const WebTransformationMatrix& fromMatrix, | |
| 301 const WebTransformationMatrix& toMatrix, | |
| 302 const WebTransformOperations& fromTransform, | |
| 303 const WebTransformOperations& toTransform) | |
| 304 { | |
| 305 WebTransformationMatrix expectedMatrix = toMatrix; | |
| 306 expectedMatrix.blend(fromMatrix, progress); | |
| 307 EXPECT_TRANSFORMATION_MATRIX_EQ(expectedMatrix, toTransform.blend(fromTransf
orm, progress)); | |
| 308 } | |
| 309 | |
| 310 TEST(WebTransformOperationTest, blendProgress) | |
| 311 { | |
| 312 double sx = 2; | |
| 313 double sy = 4; | |
| 314 double sz = 8; | |
| 315 WebTransformOperations operationsFrom; | |
| 316 operationsFrom.appendScale(sx, sy, sz); | |
| 317 | |
| 318 WebTransformationMatrix matrixFrom; | |
| 319 matrixFrom.scale3d(sx, sy, sz); | |
| 320 | |
| 321 sx = 4; | |
| 322 sy = 8; | |
| 323 sz = 16; | |
| 324 WebTransformOperations operationsTo; | |
| 325 operationsTo.appendScale(sx, sy, sz); | |
| 326 | |
| 327 WebTransformationMatrix matrixTo; | |
| 328 matrixTo.scale3d(sx, sy, sz); | |
| 329 | |
| 330 checkProgress(-1, matrixFrom, matrixTo, operationsFrom, operationsTo); | |
| 331 checkProgress(0, matrixFrom, matrixTo, operationsFrom, operationsTo); | |
| 332 checkProgress(0.25, matrixFrom, matrixTo, operationsFrom, operationsTo); | |
| 333 checkProgress(0.5, matrixFrom, matrixTo, operationsFrom, operationsTo); | |
| 334 checkProgress(1, matrixFrom, matrixTo, operationsFrom, operationsTo); | |
| 335 checkProgress(2, matrixFrom, matrixTo, operationsFrom, operationsTo); | |
| 336 } | |
| 337 | |
| 338 TEST(WebTransformOperationTest, blendWhenTypesDoNotMatch) | |
| 339 { | |
| 340 double sx1 = 2; | |
| 341 double sy1 = 4; | |
| 342 double sz1 = 8; | |
| 343 | |
| 344 double dx1 = 1; | |
| 345 double dy1 = 2; | |
| 346 double dz1 = 3; | |
| 347 | |
| 348 double sx2 = 4; | |
| 349 double sy2 = 8; | |
| 350 double sz2 = 16; | |
| 351 | |
| 352 double dx2 = 10; | |
| 353 double dy2 = 20; | |
| 354 double dz2 = 30; | |
| 355 | |
| 356 WebTransformOperations operationsFrom; | |
| 357 operationsFrom.appendScale(sx1, sy1, sz1); | |
| 358 operationsFrom.appendTranslate(dx1, dy1, dz1); | |
| 359 | |
| 360 WebTransformOperations operationsTo; | |
| 361 operationsTo.appendTranslate(dx2, dy2, dz2); | |
| 362 operationsTo.appendScale(sx2, sy2, sz2); | |
| 363 | |
| 364 WebTransformationMatrix from; | |
| 365 from.scale3d(sx1, sy1, sz1); | |
| 366 from.translate3d(dx1, dy1, dz1); | |
| 367 | |
| 368 WebTransformationMatrix to; | |
| 369 to.translate3d(dx2, dy2, dz2); | |
| 370 to.scale3d(sx2, sy2, sz2); | |
| 371 | |
| 372 double progress = 0.25; | |
| 373 | |
| 374 WebTransformationMatrix expected = to; | |
| 375 expected.blend(from, progress); | |
| 376 | |
| 377 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operationsTo.blend(operationsFrom,
progress)); | |
| 378 } | |
| 379 | |
| 380 TEST(WebTransformOperationTest, largeRotationsWithSameAxis) | |
| 381 { | |
| 382 WebTransformOperations operationsFrom; | |
| 383 operationsFrom.appendRotate(0, 0, 1, 0); | |
| 384 | |
| 385 WebTransformOperations operationsTo; | |
| 386 operationsTo.appendRotate(0, 0, 2, 360); | |
| 387 | |
| 388 double progress = 0.5; | |
| 389 | |
| 390 WebTransformationMatrix expected; | |
| 391 expected.rotate3d(0, 0, 1, 180); | |
| 392 | |
| 393 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operationsTo.blend(operationsFrom,
progress)); | |
| 394 } | |
| 395 | |
| 396 TEST(WebTransformOperationTest, largeRotationsWithSameAxisInDifferentDirection) | |
| 397 { | |
| 398 WebTransformOperations operationsFrom; | |
| 399 operationsFrom.appendRotate(0, 0, 1, 180); | |
| 400 | |
| 401 WebTransformOperations operationsTo; | |
| 402 operationsTo.appendRotate(0, 0, -1, 180); | |
| 403 | |
| 404 double progress = 0.5; | |
| 405 | |
| 406 WebTransformationMatrix expected; | |
| 407 | |
| 408 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operationsTo.blend(operationsFrom,
progress)); | |
| 409 } | |
| 410 | |
| 411 TEST(WebTransformOperationTest, largeRotationsWithDifferentAxes) | |
| 412 { | |
| 413 WebTransformOperations operationsFrom; | |
| 414 operationsFrom.appendRotate(0, 0, 1, 180); | |
| 415 | |
| 416 WebTransformOperations operationsTo; | |
| 417 operationsTo.appendRotate(0, 1, 0, 180); | |
| 418 | |
| 419 double progress = 0.5; | |
| 420 WebTransformationMatrix matrixFrom; | |
| 421 matrixFrom.rotate3d(0, 0, 1, 180); | |
| 422 | |
| 423 WebTransformationMatrix matrixTo; | |
| 424 matrixTo.rotate3d(0, 1, 0, 180); | |
| 425 | |
| 426 WebTransformationMatrix expected = matrixTo; | |
| 427 expected.blend(matrixFrom, progress); | |
| 428 | |
| 429 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operationsTo.blend(operationsFrom,
progress)); | |
| 430 } | |
| 431 | |
| 432 TEST(WebTransformOperationTest, blendRotationFromIdentity) | |
| 433 { | |
| 434 ScopedVector<WebTransformOperations> identityOperations; | |
| 435 getIdentityOperations(&identityOperations); | |
| 436 | |
| 437 for (size_t i = 0; i < identityOperations.size(); ++i) { | |
| 438 WebTransformOperations operations; | |
| 439 operations.appendRotate(0, 0, 1, 360); | |
| 440 | |
| 441 double progress = 0.5; | |
| 442 | |
| 443 WebTransformationMatrix expected; | |
| 444 expected.rotate3d(0, 0, 1, 180); | |
| 445 | |
| 446 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.blend(*identityOper
ations[i], progress)); | |
| 447 } | |
| 448 } | |
| 449 | |
| 450 TEST(WebTransformOperationTest, blendTranslationFromIdentity) | |
| 451 { | |
| 452 ScopedVector<WebTransformOperations> identityOperations; | |
| 453 getIdentityOperations(&identityOperations); | |
| 454 | |
| 455 for (size_t i = 0; i < identityOperations.size(); ++i) { | |
| 456 WebTransformOperations operations; | |
| 457 operations.appendTranslate(2, 2, 2); | |
| 458 | |
| 459 double progress = 0.5; | |
| 460 | |
| 461 WebTransformationMatrix expected; | |
| 462 expected.translate3d(1, 1, 1); | |
| 463 | |
| 464 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.blend(*identityOper
ations[i], progress)); | |
| 465 } | |
| 466 } | |
| 467 | |
| 468 TEST(WebTransformOperationTest, blendScaleFromIdentity) | |
| 469 { | |
| 470 ScopedVector<WebTransformOperations> identityOperations; | |
| 471 getIdentityOperations(&identityOperations); | |
| 472 | |
| 473 for (size_t i = 0; i < identityOperations.size(); ++i) { | |
| 474 WebTransformOperations operations; | |
| 475 operations.appendScale(3, 3, 3); | |
| 476 | |
| 477 double progress = 0.5; | |
| 478 | |
| 479 WebTransformationMatrix expected; | |
| 480 expected.scale3d(2, 2, 2); | |
| 481 | |
| 482 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.blend(*identityOper
ations[i], progress)); | |
| 483 } | |
| 484 } | |
| 485 | |
| 486 TEST(WebTransformOperationTest, blendSkewFromIdentity) | |
| 487 { | |
| 488 ScopedVector<WebTransformOperations> identityOperations; | |
| 489 getIdentityOperations(&identityOperations); | |
| 490 | |
| 491 for (size_t i = 0; i < identityOperations.size(); ++i) { | |
| 492 WebTransformOperations operations; | |
| 493 operations.appendSkew(2, 2); | |
| 494 | |
| 495 double progress = 0.5; | |
| 496 | |
| 497 WebTransformationMatrix expected; | |
| 498 expected.skewX(1); | |
| 499 expected.skewY(1); | |
| 500 | |
| 501 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.blend(*identityOper
ations[i], progress)); | |
| 502 } | |
| 503 } | |
| 504 | |
| 505 TEST(WebTransformOperationTest, blendPerspectiveFromIdentity) | |
| 506 { | |
| 507 ScopedVector<WebTransformOperations> identityOperations; | |
| 508 getIdentityOperations(&identityOperations); | |
| 509 | |
| 510 for (size_t i = 0; i < identityOperations.size(); ++i) { | |
| 511 WebTransformOperations operations; | |
| 512 operations.appendPerspective(1000); | |
| 513 | |
| 514 double progress = 0.5; | |
| 515 | |
| 516 WebTransformationMatrix expected; | |
| 517 expected.applyPerspective(500 + 0.5 * std::numeric_limits<double>::max()
); | |
| 518 | |
| 519 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, operations.blend(*identityOper
ations[i], progress)); | |
| 520 } | |
| 521 } | |
| 522 | |
| 523 TEST(WebTransformOperationTest, blendRotationToIdentity) | |
| 524 { | |
| 525 ScopedVector<WebTransformOperations> identityOperations; | |
| 526 getIdentityOperations(&identityOperations); | |
| 527 | |
| 528 for (size_t i = 0; i < identityOperations.size(); ++i) { | |
| 529 WebTransformOperations operations; | |
| 530 operations.appendRotate(0, 0, 1, 360); | |
| 531 | |
| 532 double progress = 0.5; | |
| 533 | |
| 534 WebTransformationMatrix expected; | |
| 535 expected.rotate3d(0, 0, 1, 180); | |
| 536 | |
| 537 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, identityOperations[i]->blend(o
perations, progress)); | |
| 538 } | |
| 539 } | |
| 540 | |
| 541 TEST(WebTransformOperationTest, blendTranslationToIdentity) | |
| 542 { | |
| 543 ScopedVector<WebTransformOperations> identityOperations; | |
| 544 getIdentityOperations(&identityOperations); | |
| 545 | |
| 546 for (size_t i = 0; i < identityOperations.size(); ++i) { | |
| 547 WebTransformOperations operations; | |
| 548 operations.appendTranslate(2, 2, 2); | |
| 549 | |
| 550 double progress = 0.5; | |
| 551 | |
| 552 WebTransformationMatrix expected; | |
| 553 expected.translate3d(1, 1, 1); | |
| 554 | |
| 555 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, identityOperations[i]->blend(o
perations, progress)); | |
| 556 } | |
| 557 } | |
| 558 | |
| 559 TEST(WebTransformOperationTest, blendScaleToIdentity) | |
| 560 { | |
| 561 ScopedVector<WebTransformOperations> identityOperations; | |
| 562 getIdentityOperations(&identityOperations); | |
| 563 | |
| 564 for (size_t i = 0; i < identityOperations.size(); ++i) { | |
| 565 WebTransformOperations operations; | |
| 566 operations.appendScale(3, 3, 3); | |
| 567 | |
| 568 double progress = 0.5; | |
| 569 | |
| 570 WebTransformationMatrix expected; | |
| 571 expected.scale3d(2, 2, 2); | |
| 572 | |
| 573 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, identityOperations[i]->blend(o
perations, progress)); | |
| 574 } | |
| 575 } | |
| 576 | |
| 577 TEST(WebTransformOperationTest, blendSkewToIdentity) | |
| 578 { | |
| 579 ScopedVector<WebTransformOperations> identityOperations; | |
| 580 getIdentityOperations(&identityOperations); | |
| 581 | |
| 582 for (size_t i = 0; i < identityOperations.size(); ++i) { | |
| 583 WebTransformOperations operations; | |
| 584 operations.appendSkew(2, 2); | |
| 585 | |
| 586 double progress = 0.5; | |
| 587 | |
| 588 WebTransformationMatrix expected; | |
| 589 expected.skewX(1); | |
| 590 expected.skewY(1); | |
| 591 | |
| 592 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, identityOperations[i]->blend(o
perations, progress)); | |
| 593 } | |
| 594 } | |
| 595 | |
| 596 TEST(WebTransformOperationTest, blendPerspectiveToIdentity) | |
| 597 { | |
| 598 ScopedVector<WebTransformOperations> identityOperations; | |
| 599 getIdentityOperations(&identityOperations); | |
| 600 | |
| 601 for (size_t i = 0; i < identityOperations.size(); ++i) { | |
| 602 WebTransformOperations operations; | |
| 603 operations.appendPerspective(1000); | |
| 604 | |
| 605 double progress = 0.5; | |
| 606 | |
| 607 WebTransformationMatrix expected; | |
| 608 expected.applyPerspective(500 + 0.5 * std::numeric_limits<double>::max()
); | |
| 609 | |
| 610 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, identityOperations[i]->blend(o
perations, progress)); | |
| 611 } | |
| 612 } | |
| 613 | |
| OLD | NEW |