OLD | NEW |
---|---|
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 </head> | 7 </head> |
8 <body> | 8 <body> |
9 <script> | 9 <script> |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 assert_equals(matrix.m34, 0); | 54 assert_equals(matrix.m34, 0); |
55 assert_equals(matrix.m41, 0); | 55 assert_equals(matrix.m41, 0); |
56 assert_equals(matrix.m42, 3); | 56 assert_equals(matrix.m42, 3); |
57 assert_equals(matrix.m43, 0); | 57 assert_equals(matrix.m43, 0); |
58 assert_equals(matrix.m44, 9); | 58 assert_equals(matrix.m44, 9); |
59 assert_false(matrix.is2D); | 59 assert_false(matrix.is2D); |
60 assert_false(matrix.isIdentity); | 60 assert_false(matrix.isIdentity); |
61 }, "DOMMatrix(other) constructor"); | 61 }, "DOMMatrix(other) constructor"); |
62 | 62 |
63 test(function() { | 63 test(function() { |
64 var float32Array = new Float32Array([1, 2, 3, 3, 2, 1]); | |
dominicc (has gone to gerrit)
2016/09/06 17:07:22
Why not use six distinct values?
Hwanseung Lee
2016/09/07 14:21:47
Done.
| |
65 var matrix2d = DOMMatrix.fromFloat32Array(float32Array); | |
66 assert_true(matrix2d.is2D); | |
67 assert_equals(matrix2d.a, 1); | |
68 assert_equals(matrix2d.b, 2); | |
69 assert_equals(matrix2d.c, 3); | |
70 assert_equals(matrix2d.d, 3); | |
71 assert_equals(matrix2d.e, 2); | |
72 assert_equals(matrix2d.f, 1); | |
73 }, "DOMMatrix fromFloat32Array - 2D matrix"); | |
74 | |
75 test(function() { | |
76 var float64Array = new Float64Array([1, 2, 3, 3.1, 2, 1]); | |
dominicc (has gone to gerrit)
2016/09/06 17:07:22
Is there a 64-bit value you could use to verify th
Hwanseung Lee
2016/09/07 14:21:47
Done.
| |
77 var matrix2d = DOMMatrix.fromFloat64Array(float64Array); | |
78 assert_true(matrix2d.is2D); | |
79 assert_equals(matrix2d.a, 1); | |
80 assert_equals(matrix2d.b, 2); | |
81 assert_equals(matrix2d.c, 3); | |
82 assert_equals(matrix2d.d, 3.1); | |
83 assert_equals(matrix2d.e, 2); | |
84 assert_equals(matrix2d.f, 1); | |
85 }, "DOMMatrix fromFloat64Array - 2D matrix"); | |
86 | |
87 test(function() { | |
88 var float32Array = new Float32Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]); | |
89 var matrix3d = DOMMatrix.fromFloat32Array(float32Array); | |
90 assert_false(matrix3d.is2D); | |
91 assert_equals(matrix3d.m11, 1); | |
92 assert_equals(matrix3d.m12, 2); | |
93 assert_equals(matrix3d.m13, 3); | |
94 assert_equals(matrix3d.m14, 4); | |
95 assert_equals(matrix3d.m21, 5); | |
96 assert_equals(matrix3d.m22, 6); | |
97 assert_equals(matrix3d.m23, 7); | |
98 assert_equals(matrix3d.m24, 8); | |
99 assert_equals(matrix3d.m31, 9); | |
100 assert_equals(matrix3d.m32, 10); | |
101 assert_equals(matrix3d.m33, 11); | |
102 assert_equals(matrix3d.m34, 12); | |
103 assert_equals(matrix3d.m41, 13); | |
104 assert_equals(matrix3d.m42, 14); | |
105 assert_equals(matrix3d.m43, 15); | |
106 assert_equals(matrix3d.m44, 16); | |
107 }, "DOMMatrix fromFloat32Array - 3D matrix"); | |
108 | |
109 test(function() { | |
110 var float64Array = new Float64Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10.1, 11, 12 , 13, 14, 15, 16.6]); | |
111 var matrix3d = DOMMatrix.fromFloat64Array(float64Array); | |
112 assert_false(matrix3d.is2D); | |
113 assert_equals(matrix3d.m11, 1); | |
114 assert_equals(matrix3d.m12, 2); | |
115 assert_equals(matrix3d.m13, 3); | |
116 assert_equals(matrix3d.m14, 4); | |
117 assert_equals(matrix3d.m21, 5); | |
118 assert_equals(matrix3d.m22, 6); | |
119 assert_equals(matrix3d.m23, 7); | |
120 assert_equals(matrix3d.m24, 8); | |
121 assert_equals(matrix3d.m31, 9); | |
122 assert_equals(matrix3d.m32, 10.1); | |
123 assert_equals(matrix3d.m33, 11); | |
124 assert_equals(matrix3d.m34, 12); | |
125 assert_equals(matrix3d.m41, 13); | |
126 assert_equals(matrix3d.m42, 14); | |
127 assert_equals(matrix3d.m43, 15); | |
128 assert_equals(matrix3d.m44, 16.6); | |
129 }, "DOMMatrix fromFloat64Array - 3D matrix"); | |
130 | |
131 test(function() { | |
64 var matrix = new DOMMatrix(); | 132 var matrix = new DOMMatrix(); |
65 matrix.a = 10; | 133 matrix.a = 10; |
66 matrix.b = 20; | 134 matrix.b = 20; |
67 matrix.m24 = 2; | 135 matrix.m24 = 2; |
68 matrix.m33 = 3; | 136 matrix.m33 = 3; |
69 matrix.m42 = 3; | 137 matrix.m42 = 3; |
70 matrix.m44 = 9; | 138 matrix.m44 = 9; |
71 assert_equals(matrix.a, matrix.m11); | 139 assert_equals(matrix.a, matrix.m11); |
72 assert_equals(matrix.b, matrix.m12); | 140 assert_equals(matrix.b, matrix.m12); |
73 assert_equals(matrix.c, matrix.m21); | 141 assert_equals(matrix.c, matrix.m21); |
(...skipping 27 matching lines...) Expand all Loading... | |
101 matrix.m31 = 1; | 169 matrix.m31 = 1; |
102 matrix.m33 = 0; | 170 matrix.m33 = 0; |
103 assert_false(matrix.is2D); | 171 assert_false(matrix.is2D); |
104 assert_false(matrix.isIdentity); | 172 assert_false(matrix.isIdentity); |
105 matrix.m31 = 0; | 173 matrix.m31 = 0; |
106 matrix.m33 = 1; | 174 matrix.m33 = 1; |
107 assert_false(matrix.is2D); | 175 assert_false(matrix.is2D); |
108 assert_true(matrix.isIdentity); | 176 assert_true(matrix.isIdentity); |
109 }, "DOMMatrix.is2D can never be set to 'true' when it was set to 'false' before calling setMatrixValue()."); | 177 }, "DOMMatrix.is2D can never be set to 'true' when it was set to 'false' before calling setMatrixValue()."); |
110 | 178 |
179 test(function() { | |
180 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat32Array(new F loat32Array(15)); }, | |
181 "DOMMatrixReadOnly constructor only accepts 1 number sequence with 6 or 16 elements."); | |
182 assert_throws(new TypeError(), function() { DOMMatrix.fromFloat64Array(new F loat64Array(15)); }, | |
dominicc (has gone to gerrit)
2016/09/06 17:07:22
Could we add tests for 0, 1, 5, 7, 15, 17 and "lar
Hwanseung Lee
2016/09/07 14:21:47
Done.
| |
183 "DOMMatrixReadOnly constructor only accepts 1 number sequence with 6 or 16 elements."); | |
184 }, "DOMMatrixReadOnly constructor - invalid arguments"); | |
185 | |
111 </script> | 186 </script> |
112 </body> | 187 </body> |
113 </html> | 188 </html> |
OLD | NEW |