OLD | NEW |
---|---|
1 <!DOCTYPE HTML> | 1 <!DOCTYPE HTML> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Geometry Interfaces: DOMMatrixReadOnly</title> | 4 <title>Geometry Interfaces: DOMMatrixReadOnly</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 test(function() { | 10 test(function() { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 }, "DOMMatrixReadOnly toString() - 3D matrix"); | 52 }, "DOMMatrixReadOnly toString() - 3D matrix"); |
53 | 53 |
54 test(function() { | 54 test(function() { |
55 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly(1, 2, 3, 4 , 5, 6); }, | 55 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly(1, 2, 3, 4 , 5, 6); }, |
56 "DOMMatrixReadOnly constructor only accepts 1 argument"); | 56 "DOMMatrixReadOnly constructor only accepts 1 argument"); |
57 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly("myString" ); }, | 57 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly("myString" ); }, |
58 "DOMMatrixReadOnly constructor only accepts 1 number sequence"); | 58 "DOMMatrixReadOnly constructor only accepts 1 number sequence"); |
59 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly([1, 2, 3]) ; }, | 59 assert_throws(new TypeError(), function() { new DOMMatrixReadOnly([1, 2, 3]) ; }, |
60 "DOMMatrixReadOnly constructor only accepts 1 number sequence with 6 or 16 elements."); | 60 "DOMMatrixReadOnly constructor only accepts 1 number sequence with 6 or 16 elements."); |
61 }, "DOMMatrixReadOnly constructor - invalid arguments"); | 61 }, "DOMMatrixReadOnly constructor - invalid arguments"); |
62 | |
63 test(function() { | |
64 var matrix = DOMMatrixReadOnly.fromMatrix(); | |
65 assert_array_equals(matrix.toFloat64Array(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); | |
66 assert_true(matrix.is2D); | |
67 assert_true(matrix.isIdentity); | |
68 }, "DOMMatrixReadOnly.fromMatrix() with no parameter."); | |
69 | |
70 test(function() { | |
71 var matrix = DOMMatrixReadOnly.fromMatrix(null); | |
72 assert_array_equals(matrix.toFloat64Array(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); | |
73 assert_true(matrix.is2D); | |
74 assert_true(matrix.isIdentity); | |
75 }, "DOMMatrixReadOnly.fromMatrix() with null."); | |
76 | |
77 test(function() { | |
78 var matrix = DOMMatrixReadOnly.fromMatrix(undefined); | |
79 assert_array_equals(matrix.toFloat64Array(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); | |
80 assert_true(matrix.is2D); | |
81 assert_true(matrix.isIdentity); | |
82 }, "DOMMatrixReadOnly.fromMatrix() with undefined."); | |
83 | |
84 test(function() { | |
85 var matrix = DOMMatrixReadOnly.fromMatrix({}); | |
86 assert_array_equals(matrix.toFloat64Array(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); | |
87 assert_true(matrix.is2D); | |
88 assert_true(matrix.isIdentity); | |
89 }, "DOMMatrixReadOnly.fromMatrix() with empty object."); | |
90 | |
91 test(function() { | |
92 var matrix = DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, c: 3, d: 4, e: 5, f: 6} ); | |
93 assert_array_equals(matrix.toFloat64Array(), [1, 2, 0, 0, 3, 4, 0, 0, 0, 0, 1, 0, 5, 6, 0, 1]); | |
94 assert_true(matrix.is2D); | |
95 assert_false(matrix.isIdentity); | |
96 }, "DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, c: 3, d: 4, e: 5, f: 6}) should cr eate a 2D DOMMatrixReadOnly."); | |
97 | |
98 test(function() { | |
99 var matrix = DOMMatrixReadOnly.fromMatrix({m11: 1, m22: 2, m33: 3, m44: 4, m23 : 5, m43: 6}); | |
100 assert_array_equals(matrix.toFloat64Array(), [1, 0, 0, 0, 0, 2, 5, 0, 0, 0, 3, 0, 0, 0, 6, 4]); | |
101 assert_false(matrix.is2D); | |
102 assert_false(matrix.isIdentity); | |
103 }, "DOMMatrixReadOnly.fromMatrix({m11: 1, m22: 2, m33: 3, m44: 4, m23: 5, m43: 6 }) should create a 2D DOMMatrixReadOnly."); | |
104 | |
105 test(function() { | |
106 var matrix = DOMMatrixReadOnly.fromMatrix({a: 1, m12: 2, m21: 3, d: 4, m41: 5, f: 6}); | |
107 assert_equals(matrix.m11, 1); | |
108 assert_equals(matrix.b, 2); | |
109 assert_equals(matrix.c, 3); | |
110 assert_equals(matrix.m22, 4); | |
111 assert_equals(matrix.e, 5); | |
112 assert_equals(matrix.m42, 6); | |
113 }, "[a, b, c, d, e, f] members should equals [m11, m12, m21, m22, m41, m42]."); | |
114 | |
115 test(function() { | |
116 var matrix = DOMMatrixReadOnly.fromMatrix({a: 7, c: 9}); | |
117 assert_equals(matrix.a, 7); | |
118 assert_equals(matrix.b, 0); | |
119 assert_equals(matrix.c, 9); | |
120 assert_equals(matrix.d, 1); | |
121 assert_equals(matrix.e, 0); | |
122 assert_equals(matrix.f, 0); | |
123 assert_equals(matrix.m11, 7); | |
124 assert_equals(matrix.m12, 0); | |
125 assert_equals(matrix.m21, 9); | |
126 assert_equals(matrix.m22, 1); | |
127 assert_equals(matrix.m41, 0); | |
128 assert_equals(matrix.m42, 0); | |
129 }, "If 2d related members don't be set, should set to fallback."); | |
130 | |
131 test(function() { | |
132 assert_throws(new TypeError(), function() { | |
dominicc (has gone to gerrit)
2016/08/30 02:13:42
Consider using arrow functions. They're slightly m
zino
2016/09/10 10:18:15
Done.
| |
133 var matrix = DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m33: 3, m44: 4, i s2D: true}); | |
dominicc (has gone to gerrit)
2016/08/30 02:13:43
Why do you need this variable?
zino
2016/09/10 10:18:15
Done.
| |
134 }, "The is2D member is set to true but the input matrix is 3d matrix."); | |
135 assert_throws(new TypeError(), function() { | |
136 var matrix = DOMMatrixReadOnly.fromMatrix({a: 1, b: 2, m11: 3}); | |
137 }, "The a member should equal the m11 member."); | |
138 }, "DOMMatrixReadOnly.fromMatrix(): Exception tests."); | |
139 | |
62 </script> | 140 </script> |
63 </body> | 141 </body> |
64 </html> | 142 </html> |
OLD | NEW |