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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix.html

Issue 2364393002: assert_*d_matrix_equals fuction can accept array as expected parameter. (Closed)
Patch Set: assert_*d_matrix_equals fuction can accept array as expected parameter. 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 | « no previous file | third_party/WebKit/LayoutTests/fast/dom/resources/geometry-interfaces-test-helpers.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Geometry Interfaces: DOMMatrix</title> 4 <title>Geometry Interfaces: DOMMatrix</title>
5 <script src="../../resources/testharness.js"></script> 5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script> 6 <script src="../../resources/testharnessreport.js"></script>
7 <script src="./resources/geometry-interfaces-test-helpers.js"></script> 7 <script src="./resources/geometry-interfaces-test-helpers.js"></script>
8 </head> 8 </head>
9 <body> 9 <body>
10 <script> 10 <script>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 assert_equals(matrix.m42, 3); 57 assert_equals(matrix.m42, 3);
58 assert_equals(matrix.m43, 0); 58 assert_equals(matrix.m43, 0);
59 assert_equals(matrix.m44, 9); 59 assert_equals(matrix.m44, 9);
60 assert_false(matrix.is2D); 60 assert_false(matrix.is2D);
61 assert_false(matrix.isIdentity); 61 assert_false(matrix.isIdentity);
62 }, "DOMMatrix(other) constructor"); 62 }, "DOMMatrix(other) constructor");
63 63
64 test(() => { 64 test(() => {
65 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6]); 65 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6]);
66 var matrix2d = DOMMatrix.fromFloat32Array(float32Array); 66 var matrix2d = DOMMatrix.fromFloat32Array(float32Array);
67 assert_true(matrix2d.is2D); 67 assert_2d_matrix_equals(matrix2d, [1, 2, 3, 4, 5, 6])
68 assert_equals(matrix2d.a, 1);
69 assert_equals(matrix2d.b, 2);
70 assert_equals(matrix2d.c, 3);
71 assert_equals(matrix2d.d, 4);
72 assert_equals(matrix2d.e, 5);
73 assert_equals(matrix2d.f, 6);
74 }, "DOMMatrix fromFloat32Array - 2D matrix"); 68 }, "DOMMatrix fromFloat32Array - 2D matrix");
75 69
76 test(() => { 70 test(() => {
77 // 3.1 is not representable as a 32-bit float 71 // 3.1 is not representable as a 32-bit float
78 var float64Array = new Float64Array([1, 2, 3, 3.1, 4, 5]); 72 var float64Array = new Float64Array([1, 2, 3, 3.1, 4, 5]);
79 var matrix2d = DOMMatrix.fromFloat64Array(float64Array); 73 var matrix2d = DOMMatrix.fromFloat64Array(float64Array);
80 assert_true(matrix2d.is2D); 74 assert_2d_matrix_equals(matrix2d, [1, 2, 3, 3.1, 4, 5])
81 assert_equals(matrix2d.a, 1);
82 assert_equals(matrix2d.b, 2);
83 assert_equals(matrix2d.c, 3);
84 assert_equals(matrix2d.d, 3.1);
85 assert_equals(matrix2d.e, 4);
86 assert_equals(matrix2d.f, 5);
87 }, "DOMMatrix fromFloat64Array - 2D matrix"); 75 }, "DOMMatrix fromFloat64Array - 2D matrix");
88 76
89 test(() => { 77 test(() => {
90 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 , 14, 15, 16]); 78 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 , 14, 15, 16]);
91 var matrix3d = DOMMatrix.fromFloat32Array(float32Array); 79 var matrix3d = DOMMatrix.fromFloat32Array(float32Array);
92 assert_false(matrix3d.is2D); 80 assert_3d_matrix_equals(matrix3d, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])
93 assert_equals(matrix3d.m11, 1);
94 assert_equals(matrix3d.m12, 2);
95 assert_equals(matrix3d.m13, 3);
96 assert_equals(matrix3d.m14, 4);
97 assert_equals(matrix3d.m21, 5);
98 assert_equals(matrix3d.m22, 6);
99 assert_equals(matrix3d.m23, 7);
100 assert_equals(matrix3d.m24, 8);
101 assert_equals(matrix3d.m31, 9);
102 assert_equals(matrix3d.m32, 10);
103 assert_equals(matrix3d.m33, 11);
104 assert_equals(matrix3d.m34, 12);
105 assert_equals(matrix3d.m41, 13);
106 assert_equals(matrix3d.m42, 14);
107 assert_equals(matrix3d.m43, 15);
108 assert_equals(matrix3d.m44, 16);
109 }, "DOMMatrix fromFloat32Array - 3D matrix"); 81 }, "DOMMatrix fromFloat32Array - 3D matrix");
110 82
111 test(() => { 83 test(() => {
112 // 10.1 and 16.6 are not representable as a 32-bit float 84 // 10.1 and 16.6 are not representable as a 32-bit float
113 var float64Array = new Float64Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12, 13, 14, 15, 16.6]); 85 var float64Array = new Float64Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12, 13, 14, 15, 16.6]);
114 var matrix3d = DOMMatrix.fromFloat64Array(float64Array); 86 var matrix3d = DOMMatrix.fromFloat64Array(float64Array);
115 assert_false(matrix3d.is2D); 87 assert_3d_matrix_equals(matrix3d, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12, 13 , 14, 15, 16.6])
116 assert_equals(matrix3d.m11, 1);
117 assert_equals(matrix3d.m12, 2);
118 assert_equals(matrix3d.m13, 3);
119 assert_equals(matrix3d.m14, 4);
120 assert_equals(matrix3d.m21, 5);
121 assert_equals(matrix3d.m22, 6);
122 assert_equals(matrix3d.m23, 7);
123 assert_equals(matrix3d.m24, 8);
124 assert_equals(matrix3d.m31, 9);
125 assert_equals(matrix3d.m32, 10.1);
126 assert_equals(matrix3d.m33, 11);
127 assert_equals(matrix3d.m34, 12);
128 assert_equals(matrix3d.m41, 13);
129 assert_equals(matrix3d.m42, 14);
130 assert_equals(matrix3d.m43, 15);
131 assert_equals(matrix3d.m44, 16.6);
132 }, "DOMMatrix fromFloat64Array - 3D matrix"); 88 }, "DOMMatrix fromFloat64Array - 3D matrix");
133 89
134 test(() => { 90 test(() => {
135 var matrix = new DOMMatrix(); 91 var matrix = new DOMMatrix();
136 matrix.a = 10; 92 matrix.a = 10;
137 matrix.b = 20; 93 matrix.b = 20;
138 matrix.m24 = 2; 94 matrix.m24 = 2;
139 matrix.m33 = 3; 95 matrix.m33 = 3;
140 matrix.m42 = 3; 96 matrix.m42 = 3;
141 matrix.m44 = 9; 97 matrix.m44 = 9;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 186
231 test(() => { 187 test(() => {
232 assert_identity_2d_matrix(DOMMatrix.fromMatrix({})); 188 assert_identity_2d_matrix(DOMMatrix.fromMatrix({}));
233 }, "DOMMatrix.fromMatrix() with empty object."); 189 }, "DOMMatrix.fromMatrix() with empty object.");
234 190
235 test(() => { 191 test(() => {
236 var matrix = DOMMatrix.fromMatrix({a: 1, b: 2, c: 3, d: 4, e: 5, f: 6}); 192 var matrix = DOMMatrix.fromMatrix({a: 1, b: 2, c: 3, d: 4, e: 5, f: 6});
237 assert_2d_matrix_equals(matrix, { 193 assert_2d_matrix_equals(matrix, {
238 m11: 1, m12: 2, 194 m11: 1, m12: 2,
239 m21: 3, m22: 4, 195 m21: 3, m22: 4,
240 m41: 5, m42: 6, 196 m41: 5, m42: 6
241 isIdentity: false
242 }); 197 });
243 }, "DOMMatrix.fromMatrix({a: 1, b: 2, c: 3, d: 4, e: 5, f: 6}) should create a 2 D DOMMatrix."); 198 }, "DOMMatrix.fromMatrix({a: 1, b: 2, c: 3, d: 4, e: 5, f: 6}) should create a 2 D DOMMatrix.");
244 199
245 test(() => { 200 test(() => {
246 var matrix = DOMMatrix.fromMatrix({m11: 1, m22: 2, m33: 3, m44: 4, m23: 5, m43 : 6}); 201 var matrix = DOMMatrix.fromMatrix({m11: 1, m22: 2, m33: 3, m44: 4, m23: 5, m43 : 6});
247 assert_3d_matrix_equals(matrix, { 202 assert_3d_matrix_equals(matrix, {
248 m11: 1, m12: 0, m13: 0, m14: 0, 203 m11: 1, m12: 0, m13: 0, m14: 0,
249 m21: 0, m22: 2, m23: 5, m24: 0, 204 m21: 0, m22: 2, m23: 5, m24: 0,
250 m31: 0, m32: 0, m33: 3, m34: 0, 205 m31: 0, m32: 0, m33: 3, m34: 0,
251 m41: 0, m42: 0, m43: 6, m44: 4, 206 m41: 0, m42: 0, m43: 6, m44: 4
252 isIdentity: false
253 }); 207 });
254 }, "DOMMatrix.fromMatrix({m11: 1, m22: 2, m33: 3, m44: 4, m23: 5, m43: 6}) shoul d create a 3D DOMMatrix."); 208 }, "DOMMatrix.fromMatrix({m11: 1, m22: 2, m33: 3, m44: 4, m23: 5, m43: 6}) shoul d create a 3D DOMMatrix.");
255 209
256 test(() => { 210 test(() => {
257 var matrix = DOMMatrix.fromMatrix({a: 7, c: 9}); 211 var matrix = DOMMatrix.fromMatrix({a: 7, c: 9});
258 assert_2d_matrix_equals(matrix, { 212 assert_2d_matrix_equals(matrix, {
259 m11: 7, m12: 0, 213 m11: 7, m12: 0,
260 m21: 9, m22: 1, 214 m21: 9, m22: 1,
261 m41: 0, m42: 0, 215 m41: 0, m42: 0
262 isIdentity: false
263 }); 216 });
264 }, "If 2d related properties don't be set, should set to fallback."); 217 }, "If 2d related properties don't be set, should set to fallback.");
265 218
266 test(() => { 219 test(() => {
267 var matrix = DOMMatrix.fromMatrix({ 220 var matrix = DOMMatrix.fromMatrix({
268 m11: NaN, m12: NaN, m13: NaN, m14: NaN, 221 m11: NaN, m12: NaN, m13: NaN, m14: NaN,
269 m21: NaN, m22: NaN, m23: NaN, m24: NaN, 222 m21: NaN, m22: NaN, m23: NaN, m24: NaN,
270 m31: NaN, m32: NaN, m33: NaN, m34: NaN, 223 m31: NaN, m32: NaN, m33: NaN, m34: NaN,
271 m41: NaN, m42: NaN, m43: NaN, m44: NaN, 224 m41: NaN, m42: NaN, m43: NaN, m44: NaN,
272 is2D: false 225 is2D: false
273 }); 226 });
274 assert_equals(matrix.a, matrix.m11); 227 assert_equals(matrix.a, matrix.m11);
275 assert_equals(matrix.b, matrix.m12); 228 assert_equals(matrix.b, matrix.m12);
276 assert_equals(matrix.c, matrix.m21); 229 assert_equals(matrix.c, matrix.m21);
277 assert_equals(matrix.d, matrix.m22); 230 assert_equals(matrix.d, matrix.m22);
278 assert_equals(matrix.e, matrix.m41); 231 assert_equals(matrix.e, matrix.m41);
279 assert_equals(matrix.f, matrix.m42); 232 assert_equals(matrix.f, matrix.m42);
280 assert_3d_matrix_equals(matrix, { 233 assert_3d_matrix_equals(matrix, {
281 m11: NaN, m12: NaN, m13: NaN, m14: NaN, 234 m11: NaN, m12: NaN, m13: NaN, m14: NaN,
282 m21: NaN, m22: NaN, m23: NaN, m24: NaN, 235 m21: NaN, m22: NaN, m23: NaN, m24: NaN,
283 m31: NaN, m32: NaN, m33: NaN, m34: NaN, 236 m31: NaN, m32: NaN, m33: NaN, m34: NaN,
284 m41: NaN, m42: NaN, m43: NaN, m44: NaN, 237 m41: NaN, m42: NaN, m43: NaN, m44: NaN
285 isIdentity: false, is2D: false
286 }); 238 });
287 }, "DOMMatrix.fromMatrix(): NaN test"); 239 }, "DOMMatrix.fromMatrix(): NaN test");
288 240
289 test(() => { 241 test(() => {
290 assert_throws(new TypeError(), () => { 242 assert_throws(new TypeError(), () => {
291 var matrix = DOMMatrix.fromMatrix({a: 1, b: 2, m33: 3, m44: 4, is2D: tru e}); 243 var matrix = DOMMatrix.fromMatrix({a: 1, b: 2, m33: 3, m44: 4, is2D: tru e});
292 }, "The 'is2D' property is set to true but the input matrix is 3d matrix." ); 244 }, "The 'is2D' property is set to true but the input matrix is 3d matrix." );
293 assert_throws(new TypeError(), () => { 245 assert_throws(new TypeError(), () => {
294 var matrix = DOMMatrix.fromMatrix({a: 1, b: 2, m11: 3}); 246 var matrix = DOMMatrix.fromMatrix({a: 1, b: 2, m11: 3});
295 }, "The 'a' property should equal the 'm11' property."); 247 }, "The 'a' property should equal the 'm11' property.");
296 }, "DOMMatrix.fromMatrix(): Exception test."); 248 }, "DOMMatrix.fromMatrix(): Exception test.");
297 249
298 </script> 250 </script>
299 </body> 251 </body>
300 </html> 252 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/dom/resources/geometry-interfaces-test-helpers.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698