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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/resources/geometry-interfaces-test-helpers.js

Issue 2370623003: [GeometryInterface] Clean-up layout tests for geometry interfaces. (Closed)
Patch Set: [GeometryInterface] Fix a indentation and clean up. Created 4 years, 2 months 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 | « third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-translate.html ('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 function assert_identity_2d_matrix(actual, description) { 1 function assert_identity_2d_matrix(actual) {
2 assert_matrix_equals(actual, { 2 assert_true(actual instanceof DOMMatrixReadOnly);
3 m11: 1, m12: 0, m13: 0, m14: 0, 3 assert_true(actual.is2D, "is2D");
4 m21: 0, m22: 1, m23: 0, m24: 0, 4 assert_true(actual.isIdentity, "isIdentity");
5 m31: 0, m32: 0, m33: 1, m34: 0, 5 assert_identity_matrix(actual);
6 m41: 0, m42: 0, m43: 0, m44: 1,
7 is2D: true, isIdentity: true
8 }, description);
9 } 6 }
10 7
11 function assert_identity_3d_matrix(actual, description) { 8 function assert_identity_3d_matrix(actual) {
12 assert_matrix_equals(actual, { 9 assert_true(actual instanceof DOMMatrixReadOnly);
13 m11: 1, m12: 0, m13: 0, m14: 0, 10 assert_false(actual.is2D, "is2D");
14 m21: 0, m22: 1, m23: 0, m24: 0, 11 assert_true(actual.isIdentity, "isIdentity");
15 m31: 0, m32: 0, m33: 1, m34: 0, 12 assert_identity_matrix(actual);
16 m41: 0, m42: 0, m43: 0, m44: 1,
17 is2D: false, isIdentity: true
18 }, description);
19 } 13 }
20 14
21 function assert_2d_matrix_equals(actual, expected, description) { 15 function assert_identity_matrix(actual) {
22 if (Array.isArray(expected)) { 16 assert_array_equals(actual.toFloat64Array(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
23 assert_equals(6, expected.length);
24 var full_expected = {
25 m11: expected[0], m12: expected[1], m13: 0, m14: 0,
26 m21: expected[2], m22: expected[3], m23: 0, m24: 0,
27 m31: 0, m32: 0, m33: 1, m34: 0,
28 m41: expected[4], m42: expected[5], m43: 0, m44: 1,
29 is2D: true, isIdentity: false
30 };
31 assert_matrix_equals(actual, full_expected, description);
32 } else {
33 var full_expected = {
34 m11: expected.m11, m12: expected.m12, m13: 0, m14: 0,
35 m21: expected.m21, m22: expected.m22, m23: 0, m24: 0,
36 m31: 0, m32: 0, m33: 1, m34: 0,
37 m41: expected.m41, m42: expected.m42, m43: 0, m44: 1,
38 is2D: true, isIdentity: false
39 };
40 assert_matrix_equals(actual, full_expected, description);
41 }
42 } 17 }
43 18
44 function assert_3d_matrix_equals(actual, expected, description){ 19 function toArray(actual) {
45 if (Array.isArray(expected)) { 20 var array = actual.toFloat64Array();
46 assert_equals(16, expected.length); 21 // Do not care negative zero for testing accomodation.
47 var full_expected = { 22 for (var i = 0; i < array.length; i++) {
48 m11: expected[0], m12: expected[1], m13: expected[2], m14: expected[3], 23 if (array[i] === -0)
49 m21: expected[4], m22: expected[5], m23: expected[6], m24: expected[7], 24 array[i] = 0;
50 m31: expected[8], m32: expected[9], m33: expected[10], m34: expected[11] ,
51 m41: expected[12], m42: expected[13], m43: expected[14], m44: expected[1 5],
52 is2D: false, isIdentity: false
53 };
54 assert_matrix_equals(actual, full_expected, description);
55 } else {
56 expected['is2D'] = false;
57 expected['isIdentity'] = false;
58 assert_matrix_equals(actual, expected, description);
59 } 25 }
26 return array;
60 } 27 }
61 28
62 function assert_matrix_equals(actual, expected, description) { 29 function assert_2d_matrix_equals(actual, expected) {
63 assert_equals(actual.isIdentity, expected.isIdentity, description); 30 assert_true(actual instanceof DOMMatrixReadOnly);
64 assert_equals(actual.is2D, expected.is2D, description); 31 assert_true(Array.isArray(expected));
65 assert_equals(actual.m11, expected.m11, description); 32 assert_equals(6, expected.length, "expected.length");
66 assert_equals(actual.m12, expected.m12, description); 33 assert_true(actual.is2D, "is2D");
67 assert_equals(actual.m13, expected.m13, description); 34 assert_false(actual.isIdentity, "isIdentity");
68 assert_equals(actual.m14, expected.m14, description); 35 assert_array_equals(toArray(actual), [
69 assert_equals(actual.m21, expected.m21, description); 36 expected[0], expected[1], 0, 0,
70 assert_equals(actual.m22, expected.m22, description); 37 expected[2], expected[3], 0, 0,
71 assert_equals(actual.m23, expected.m23, description); 38 0, 0, 1, 0,
72 assert_equals(actual.m24, expected.m24, description); 39 expected[4], expected[5], 0, 1
73 assert_equals(actual.m31, expected.m31, description); 40 ]);
74 assert_equals(actual.m32, expected.m32, description);
75 assert_equals(actual.m33, expected.m33, description);
76 assert_equals(actual.m34, expected.m34, description);
77 assert_equals(actual.m41, expected.m41, description);
78 assert_equals(actual.m42, expected.m42, description);
79 assert_equals(actual.m43, expected.m43, description);
80 assert_equals(actual.m44, expected.m44, description);
81 assert_equals(actual.m11, actual.a, description);
82 assert_equals(actual.m12, actual.b, description);
83 assert_equals(actual.m21, actual.c, description);
84 assert_equals(actual.m22, actual.d, description);
85 assert_equals(actual.m41, actual.e, description);
86 assert_equals(actual.m42, actual.f, description);
87 } 41 }
42
43 function assert_3d_matrix_equals(actual, expected) {
44 assert_true(actual instanceof DOMMatrixReadOnly);
45 assert_true(Array.isArray(expected) );
46 assert_equals(16, expected.length, "expected.length");
47 assert_false(actual.is2D, "is2D");
48 assert_false(actual.isIdentity, "isIdentity");
49 assert_array_equals(toArray(actual), [
50 expected[0], expected[1], expected[2], expected[3],
51 expected[4], expected[5], expected[6], expected[7],
52 expected[8], expected[9], expected[10], expected[11],
53 expected[12], expected[13], expected[14], expected[15],
54 ]);
55 }
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-translate.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698