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

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: fix a typo. 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) {
zino 2016/09/27 16:31:18 assert_true(actual instanceof DOMMatrixReadOnly);
Hwanseung Lee 2016/09/27 16:44:31 Done.
2 assert_matrix_equals(actual, { 2 assert_true(actual.is2D);
3 m11: 1, m12: 0, m13: 0, m14: 0, 3 assert_true(actual.isIdentity);
4 m21: 0, m22: 1, m23: 0, m24: 0, 4 assert_array_equals(actual.toFloat64Array(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
zino 2016/09/27 16:31:19 Let's make assert_identity_matrix(actual)
Hwanseung Lee 2016/09/27 16:44:31 Done.
5 m31: 0, m32: 0, m33: 1, m34: 0,
6 m41: 0, m42: 0, m43: 0, m44: 1,
7 is2D: true, isIdentity: true
8 }, description);
9 } 5 }
10 6
11 function assert_identity_3d_matrix(actual, description) { 7 function assert_identity_3d_matrix(actual) {
12 assert_matrix_equals(actual, { 8 assert_false(actual.is2D);
zino 2016/09/27 16:31:19 These assert functions should have description?
Hwanseung Lee 2016/09/27 16:44:31 Done.
13 m11: 1, m12: 0, m13: 0, m14: 0, 9 assert_true(actual.isIdentity);
14 m21: 0, m22: 1, m23: 0, m24: 0, 10 assert_array_equals(actual.toFloat64Array(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
15 m31: 0, m32: 0, m33: 1, m34: 0,
16 m41: 0, m42: 0, m43: 0, m44: 1,
17 is2D: false, isIdentity: true
18 }, description);
19 } 11 }
20 12
21 function assert_2d_matrix_equals(actual, expected, description) { 13 function toArray(actual) {
14 var array = actual.toFloat64Array();
15 for (var i = array.length - 1; i >= 0; i--) {
zino 2016/09/27 16:31:19 // Do not care negative zero for testing accomodat
Hwanseung Lee 2016/09/27 16:44:31 Done.
16 // do not care negative zero.
17 if(array[i] == -0)
18 array[i] = 0;
19 }
20 return array;
21 }
22
23 function assert_2d_matrix_equals(actual, expected) {
zino 2016/09/27 16:31:19 assert_true(actual instanceof DOMMatrixReadOnly);
Hwanseung Lee 2016/09/27 16:44:31 Done.
22 if (Array.isArray(expected)) { 24 if (Array.isArray(expected)) {
zino 2016/09/27 16:31:18 assert_true(Array.isArray(expected));
23 assert_equals(6, expected.length); 25 assert_equals(6, expected.length);
24 var full_expected = { 26 assert_true(actual.is2D);
25 m11: expected[0], m12: expected[1], m13: 0, m14: 0, 27 assert_false(actual.isIdentity);
26 m21: expected[2], m22: expected[3], m23: 0, m24: 0, 28 assert_array_equals(toArray(actual), [
27 m31: 0, m32: 0, m33: 1, m34: 0, 29 expected[0], expected[1], 0, 0,
28 m41: expected[4], m42: expected[5], m43: 0, m44: 1, 30 expected[2], expected[3], 0, 0,
29 is2D: true, isIdentity: false 31 0, 0, 1, 0,
30 }; 32 expected[4], expected[5], 0, 1
31 assert_matrix_equals(actual, full_expected, description); 33 ]);
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 } 34 }
42 } 35 }
43 36
44 function assert_3d_matrix_equals(actual, expected, description){ 37 function assert_3d_matrix_equals(actual, expected) {
zino 2016/09/27 16:31:18 assert_true(actual instanceof DOMMatrixReadOnly);
Hwanseung Lee 2016/09/27 16:44:31 Done.
45 if (Array.isArray(expected)) { 38 if (Array.isArray(expected)) {
zino 2016/09/27 16:31:18 assert_true(Array.isArray(expected));
46 assert_equals(16, expected.length); 39 assert_equals(16, expected.length);
47 var full_expected = { 40 assert_false(actual.is2D);
48 m11: expected[0], m12: expected[1], m13: expected[2], m14: expected[3], 41 assert_false(actual.isIdentity);
49 m21: expected[4], m22: expected[5], m23: expected[6], m24: expected[7], 42 assert_array_equals(toArray(actual), [
50 m31: expected[8], m32: expected[9], m33: expected[10], m34: expected[11] , 43 expected[0], expected[1], expected[2], expected[3],
51 m41: expected[12], m42: expected[13], m43: expected[14], m44: expected[1 5], 44 expected[4], expected[5], expected[6], expected[7],
52 is2D: false, isIdentity: false 45 expected[8], expected[9], expected[10], expected[11],
53 }; 46 expected[12], expected[13], expected[14], expected[15],
54 assert_matrix_equals(actual, full_expected, description); 47 ]);
55 } else {
56 expected['is2D'] = false;
57 expected['isIdentity'] = false;
58 assert_matrix_equals(actual, expected, description);
59 } 48 }
60 } 49 }
61
62 function assert_matrix_equals(actual, expected, description) {
63 assert_equals(actual.isIdentity, expected.isIdentity, description);
64 assert_equals(actual.is2D, expected.is2D, description);
65 assert_equals(actual.m11, expected.m11, description);
66 assert_equals(actual.m12, expected.m12, description);
67 assert_equals(actual.m13, expected.m13, description);
68 assert_equals(actual.m14, expected.m14, description);
69 assert_equals(actual.m21, expected.m21, description);
70 assert_equals(actual.m22, expected.m22, description);
71 assert_equals(actual.m23, expected.m23, description);
72 assert_equals(actual.m24, expected.m24, description);
73 assert_equals(actual.m31, expected.m31, description);
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 }
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