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