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