Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
|
dominicc (has gone to gerrit)
2016/08/30 02:13:43
This looks like a nice test. Is it also upstream i
| |
| 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 |
| 11 test(function() { | 11 test(function() { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 matrix.m31 = 1; | 101 matrix.m31 = 1; |
| 102 matrix.m33 = 0; | 102 matrix.m33 = 0; |
| 103 assert_false(matrix.is2D); | 103 assert_false(matrix.is2D); |
| 104 assert_false(matrix.isIdentity); | 104 assert_false(matrix.isIdentity); |
| 105 matrix.m31 = 0; | 105 matrix.m31 = 0; |
| 106 matrix.m33 = 1; | 106 matrix.m33 = 1; |
| 107 assert_false(matrix.is2D); | 107 assert_false(matrix.is2D); |
| 108 assert_true(matrix.isIdentity); | 108 assert_true(matrix.isIdentity); |
| 109 }, "DOMMatrix.is2D can never be set to 'true' when it was set to 'false' before calling setMatrixValue()."); | 109 }, "DOMMatrix.is2D can never be set to 'true' when it was set to 'false' before calling setMatrixValue()."); |
| 110 | 110 |
| 111 test(function() { | |
| 112 var matrix = DOMMatrix.fromMatrix(); | |
| 113 assert_array_equals(matrix.toFloat64Array(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); | |
|
dominicc (has gone to gerrit)
2016/08/30 02:13:43
This assert_array_equals/assert_true/assert_true i
zino
2016/09/10 10:18:15
Done.
| |
| 114 assert_true(matrix.is2D); | |
| 115 assert_true(matrix.isIdentity); | |
| 116 }, "DOMMatrix.fromMatrix() with no parameter."); | |
| 117 | |
| 118 test(function() { | |
| 119 var matrix = DOMMatrix.fromMatrix(null); | |
| 120 assert_array_equals(matrix.toFloat64Array(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); | |
| 121 assert_true(matrix.is2D); | |
| 122 assert_true(matrix.isIdentity); | |
| 123 }, "DOMMatrix.fromMatrix() with null."); | |
| 124 | |
| 125 test(function() { | |
| 126 var matrix = DOMMatrix.fromMatrix(undefined); | |
| 127 assert_array_equals(matrix.toFloat64Array(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); | |
| 128 assert_true(matrix.is2D); | |
| 129 assert_true(matrix.isIdentity); | |
| 130 }, "DOMMatrix.fromMatrix() with undefined."); | |
| 131 | |
| 132 test(function() { | |
| 133 var matrix = DOMMatrix.fromMatrix({}); | |
| 134 assert_array_equals(matrix.toFloat64Array(), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]); | |
| 135 assert_true(matrix.is2D); | |
| 136 assert_true(matrix.isIdentity); | |
| 137 }, "DOMMatrix.fromMatrix() with empty object."); | |
| 138 | |
| 139 test(function() { | |
| 140 var matrix = DOMMatrix.fromMatrix({a: 1, b: 2, c: 3, d: 4, e: 5, f: 6}); | |
| 141 assert_array_equals(matrix.toFloat64Array(), [1, 2, 0, 0, 3, 4, 0, 0, 0, 0, 1, 0, 5, 6, 0, 1]); | |
| 142 assert_true(matrix.is2D); | |
| 143 assert_false(matrix.isIdentity); | |
| 144 }, "DOMMatrix.fromMatrix({a: 1, b: 2, c: 3, d: 4, e: 5, f: 6}) should create a 2 D DOMMatrix."); | |
| 145 | |
| 146 test(function() { | |
| 147 var matrix = DOMMatrix.fromMatrix({m11: 1, m22: 2, m33: 3, m44: 4, m23: 5, m43 : 6}); | |
| 148 assert_array_equals(matrix.toFloat64Array(), [1, 0, 0, 0, 0, 2, 5, 0, 0, 0, 3, 0, 0, 0, 6, 4]); | |
| 149 assert_false(matrix.is2D); | |
| 150 assert_false(matrix.isIdentity); | |
| 151 }, "DOMMatrix.fromMatrix({m11: 1, m22: 2, m33: 3, m44: 4, m23: 5, m43: 6}) shoul d create a 2D DOMMatrix."); | |
| 152 | |
| 153 test(function() { | |
| 154 var matrix = DOMMatrix.fromMatrix({a: 1, m12: 2, m21: 3, d: 4, m41: 5, f: 6}); | |
| 155 assert_equals(matrix.m11, 1); | |
| 156 assert_equals(matrix.b, 2); | |
| 157 assert_equals(matrix.c, 3); | |
| 158 assert_equals(matrix.m22, 4); | |
| 159 assert_equals(matrix.e, 5); | |
| 160 assert_equals(matrix.m42, 6); | |
| 161 }, "[a, b, c, d, e, f] members should equals [m11, m12, m21, m22, m41, m42]."); | |
| 162 | |
| 163 test(function() { | |
| 164 var matrix = DOMMatrix.fromMatrix({a: 7, c: 9}); | |
| 165 assert_equals(matrix.a, 7); | |
| 166 assert_equals(matrix.b, 0); | |
| 167 assert_equals(matrix.c, 9); | |
| 168 assert_equals(matrix.d, 1); | |
| 169 assert_equals(matrix.e, 0); | |
| 170 assert_equals(matrix.f, 0); | |
| 171 assert_equals(matrix.m11, 7); | |
| 172 assert_equals(matrix.m12, 0); | |
| 173 assert_equals(matrix.m21, 9); | |
| 174 assert_equals(matrix.m22, 1); | |
| 175 assert_equals(matrix.m41, 0); | |
| 176 assert_equals(matrix.m42, 0); | |
| 177 }, "If 2d related members don't be set, should set to fallback."); | |
| 178 | |
| 179 test(function() { | |
| 180 assert_throws(new TypeError(), function() { | |
| 181 var matrix = DOMMatrix.fromMatrix({a: 1, b: 2, m33: 3, m44: 4, is2D: tru e}); | |
| 182 }, "The is2D member is set to true but the input matrix is 3d matrix."); | |
| 183 assert_throws(new TypeError(), function() { | |
| 184 var matrix = DOMMatrix.fromMatrix({a: 1, b: 2, m11: 3}); | |
| 185 }, "The a member should equal the m11 member."); | |
| 186 }, "DOMMatrix.fromMatrix(): Exception tests."); | |
| 187 | |
|
dominicc (has gone to gerrit)
2016/08/30 02:13:43
I think it would be worth adding NaN tests, given
zino
2016/09/10 10:18:15
Done.
| |
| 111 </script> | 188 </script> |
| 112 </body> | 189 </body> |
| 113 </html> | 190 </html> |
| OLD | NEW |