Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1789)

Side by Side Diff: webkit/compositor_bindings/web_transformation_matrix_unittest.cc

Issue 11316043: Implement unit tests and temporary MathUtil wrappers for transform functionality (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: patch for landing Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/math_util_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #define _USE_MATH_DEFINES 5 #define _USE_MATH_DEFINES
6 #include <math.h> 6 #include <math.h>
7 7
8 #include "cc/test/geometry_test_utils.h" 8 #include "cc/test/geometry_test_utils.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMa trix.h" 10 #include "third_party/WebKit/Source/Platform/chromium/public/WebTransformationMa trix.h"
(...skipping 13 matching lines...) Expand all
24 #define EXPECT_ROW3_EQ(a, b, c, d, matrix) \ 24 #define EXPECT_ROW3_EQ(a, b, c, d, matrix) \
25 EXPECT_FLOAT_EQ((a), (matrix).m13()); \ 25 EXPECT_FLOAT_EQ((a), (matrix).m13()); \
26 EXPECT_FLOAT_EQ((b), (matrix).m23()); \ 26 EXPECT_FLOAT_EQ((b), (matrix).m23()); \
27 EXPECT_FLOAT_EQ((c), (matrix).m33()); \ 27 EXPECT_FLOAT_EQ((c), (matrix).m33()); \
28 EXPECT_FLOAT_EQ((d), (matrix).m43()); 28 EXPECT_FLOAT_EQ((d), (matrix).m43());
29 29
30 #define EXPECT_ROW4_EQ(a, b, c, d, matrix) \ 30 #define EXPECT_ROW4_EQ(a, b, c, d, matrix) \
31 EXPECT_FLOAT_EQ((a), (matrix).m14()); \ 31 EXPECT_FLOAT_EQ((a), (matrix).m14()); \
32 EXPECT_FLOAT_EQ((b), (matrix).m24()); \ 32 EXPECT_FLOAT_EQ((b), (matrix).m24()); \
33 EXPECT_FLOAT_EQ((c), (matrix).m34()); \ 33 EXPECT_FLOAT_EQ((c), (matrix).m34()); \
34 EXPECT_FLOAT_EQ((d), (matrix).m44()); \ 34 EXPECT_FLOAT_EQ((d), (matrix).m44());
35 35
36 // Checking float values for equality close to zero is not robust using EXPECT_F LOAT_EQ 36 // Checking float values for equality close to zero is not robust using EXPECT_F LOAT_EQ
37 // (see gtest documentation). So, to verify rotation matrices, we must use a loo ser 37 // (see gtest documentation). So, to verify rotation matrices, we must use a loo ser
38 // absolute error threshold in some places. 38 // absolute error threshold in some places.
39 #define EXPECT_ROW1_NEAR(a, b, c, d, matrix, errorThreshold) \ 39 #define EXPECT_ROW1_NEAR(a, b, c, d, matrix, errorThreshold) \
40 EXPECT_NEAR((a), (matrix).m11(), (errorThreshold)); \ 40 EXPECT_NEAR((a), (matrix).m11(), (errorThreshold)); \
41 EXPECT_NEAR((b), (matrix).m21(), (errorThreshold)); \ 41 EXPECT_NEAR((b), (matrix).m21(), (errorThreshold)); \
42 EXPECT_NEAR((c), (matrix).m31(), (errorThreshold)); \ 42 EXPECT_NEAR((c), (matrix).m31(), (errorThreshold)); \
43 EXPECT_NEAR((d), (matrix).m41(), (errorThreshold)); 43 EXPECT_NEAR((d), (matrix).m41(), (errorThreshold));
44 44
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 0.3333333333333334258519187, 625 0.3333333333333334258519187,
626 -0.2440169358562924717404030, 626 -0.2440169358562924717404030,
627 0, A, ERROR_THRESHOLD); 627 0, A, ERROR_THRESHOLD);
628 EXPECT_ROW3_NEAR(-0.2440169358562924717404030, 628 EXPECT_ROW3_NEAR(-0.2440169358562924717404030,
629 0.9106836025229592124219380, 629 0.9106836025229592124219380,
630 0.3333333333333334258519187, 630 0.3333333333333334258519187,
631 0, A, ERROR_THRESHOLD); 631 0, A, ERROR_THRESHOLD);
632 EXPECT_ROW4_EQ(0, 0, 0, 1, A); 632 EXPECT_ROW4_EQ(0, 0, 0, 1, A);
633 } 633 }
634 634
635 // Test failing as of webkit 132872:132896. http://crbug.com/158553
636 TEST(WebTransformationMatrixTest, verifyRotateAxisAngle3dForDegenerateAxis) 635 TEST(WebTransformationMatrixTest, verifyRotateAxisAngle3dForDegenerateAxis)
637 { 636 {
638 // Check rotation about a degenerate zero vector. 637 // Check rotation about a degenerate zero vector.
639 // It is expected to skip applying the rotation. 638 // It is expected to skip applying the rotation.
640 WebTransformationMatrix A; 639 WebTransformationMatrix A;
641 640
642 A.rotate3d(0, 0, 0, 45); 641 A.rotate3d(0, 0, 0, 45);
643 // Verify that A remains unchanged. 642 // Verify that A remains unchanged.
644 EXPECT_TRUE(A.isIdentity()); 643 EXPECT_TRUE(A.isIdentity());
645 644
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 normalizationMatrix.setM11(1 / expectedEndOfAnimation.m44()); 1303 normalizationMatrix.setM11(1 / expectedEndOfAnimation.m44());
1305 normalizationMatrix.setM22(1 / expectedEndOfAnimation.m44()); 1304 normalizationMatrix.setM22(1 / expectedEndOfAnimation.m44());
1306 normalizationMatrix.setM33(1 / expectedEndOfAnimation.m44()); 1305 normalizationMatrix.setM33(1 / expectedEndOfAnimation.m44());
1307 normalizationMatrix.setM44(1 / expectedEndOfAnimation.m44()); 1306 normalizationMatrix.setM44(1 / expectedEndOfAnimation.m44());
1308 normalizedExpectedEndOfAnimation.multiply(normalizationMatrix); 1307 normalizedExpectedEndOfAnimation.multiply(normalizationMatrix);
1309 1308
1310 EXPECT_TRANSFORMATION_MATRIX_EQ(normalizedExpectedEndOfAnimation, to); 1309 EXPECT_TRANSFORMATION_MATRIX_EQ(normalizedExpectedEndOfAnimation, to);
1311 } 1310 }
1312 1311
1313 } // namespace 1312 } // namespace
OLDNEW
« no previous file with comments | « cc/math_util_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698