OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE HTML> | |
2 <script src="../../resources/testharness.js"></script> | |
3 <script src="../../resources/testharnessreport.js"></script> | |
4 <script src="./resources/geometry-interfaces-test-helpers.js"></script> | |
5 <script> | |
6 | |
7 test(() => { | |
8 var matrix2d = new DOMMatrix(); | |
9 var expectedMatrix = new DOMMatrix(); | |
10 matrix2d.setMatrixValue(""); | |
11 assert_true(matrix2d.is2D); | |
12 assert_matrix_almost_equals(matrix2d, expectedMatrix); | |
13 }, "DOMMatrix setMatrix(EmptyString)"); | |
14 | |
15 test(() => { | |
16 var matrix2d = new DOMMatrix(); | |
17 var expectedMatrix = new DOMMatrix(); | |
18 matrix2d.setMatrixValue("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)"); | |
19 assert_true(matrix2d.is2D); | |
20 expectedMatrix.multiplySelf(new DOMMatrix([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])) | |
21 assert_matrix_almost_equals(matrix2d, expectedMatrix); | |
22 }, "DOMMatrix setMatrix('matrix2d')"); | |
23 | |
24 test(() => { | |
25 var matrix2d = new DOMMatrix(); | |
26 var expectedMatrix = new DOMMatrix(); | |
27 matrix2d.setMatrixValue("translate(44px, 55px)"); | |
28 assert_true(matrix2d.is2D); | |
29 expectedMatrix.translateSelf(44, 55) | |
30 assert_matrix_almost_equals(matrix2d, expectedMatrix); | |
31 }, "DOMMatrix setMatrix('translate')"); | |
32 | |
33 test(() => { | |
34 var matrix2d = new DOMMatrix(); | |
35 var expectedMatrix = new DOMMatrix(); | |
36 matrix2d.setMatrixValue("translateX(35px)"); | |
37 assert_true(matrix2d.is2D); | |
38 expectedMatrix.translateSelf(35, 0) | |
39 assert_matrix_almost_equals(matrix2d, expectedMatrix); | |
40 }, "DOMMatrix setMatrix('translateX')"); | |
41 | |
42 test(() => { | |
43 var matrix2d = new DOMMatrix(); | |
44 var expectedMatrix = new DOMMatrix(); | |
45 matrix2d.setMatrixValue("translateY(77px)"); | |
46 assert_true(matrix2d.is2D); | |
47 expectedMatrix.translateSelf(0, 77) | |
48 assert_matrix_almost_equals(matrix2d, expectedMatrix); | |
49 }, "DOMMatrix setMatrix('translateY')"); | |
50 | |
51 test(() => { | |
52 var matrix2d = new DOMMatrix(); | |
53 var expectedMatrix = new DOMMatrix(); | |
54 matrix2d.setMatrixValue("scale(2, 2)"); | |
55 assert_true(matrix2d.is2D); | |
56 expectedMatrix.scaleSelf(2, 2); | |
57 assert_matrix_almost_equals(matrix2d, expectedMatrix); | |
58 }, "DOMMatrix setMatrix('scale')"); | |
59 | |
60 test(() => { | |
61 var matrix2d = new DOMMatrix(); | |
62 var expectedMatrix = new DOMMatrix(); | |
63 matrix2d.setMatrixValue("scaleX(2)"); | |
64 assert_true(matrix2d.is2D); | |
65 expectedMatrix.scaleSelf(2, 1); | |
66 assert_matrix_almost_equals(matrix2d, expectedMatrix); | |
67 }, "DOMMatrix setMatrix('scaleX')"); | |
68 | |
69 test(() => { | |
70 var matrix2d = new DOMMatrix(); | |
71 var expectedMatrix = new DOMMatrix(); | |
72 matrix2d.setMatrixValue("scaleY(2)"); | |
73 assert_true(matrix2d.is2D); | |
74 expectedMatrix.scaleSelf(1, 2); | |
75 assert_matrix_almost_equals(matrix2d, expectedMatrix); | |
76 }, "DOMMatrix setMatrix('scaleY')"); | |
77 | |
78 test(() => { | |
79 var matrix2d = new DOMMatrix(); | |
80 var expectedMatrix = new DOMMatrix(); | |
81 matrix2d.setMatrixValue("rotate(90deg)"); | |
82 assert_true(matrix2d.is2D); | |
83 expectedMatrix.rotateAxisAngleSelf(0, 0, 1, 90); | |
84 assert_matrix_almost_equals(matrix2d, expectedMatrix); | |
85 }, "DOMMatrix setMatrix('rotate')"); | |
86 | |
87 test(() => { | |
88 var matrix2d = new DOMMatrix(); | |
89 var expectedMatrix = new DOMMatrix(); | |
90 matrix2d.setMatrixValue("skewX(30deg)"); | |
91 assert_true(matrix2d.is2D); | |
92 expectedMatrix.skewXSelf(30); | |
93 assert_matrix_almost_equals(matrix2d, expectedMatrix); | |
94 }, "DOMMatrix setMatrix('skewX')"); | |
95 | |
96 test(() => { | |
97 var matrix2d = new DOMMatrix(); | |
98 var expectedMatrix = new DOMMatrix(); | |
99 matrix2d.setMatrixValue("skewY(40deg)"); | |
100 assert_true(matrix2d.is2D); | |
101 expectedMatrix.skewYSelf(40); | |
102 assert_matrix_almost_equals(matrix2d, expectedMatrix); | |
103 }, "DOMMatrix setMatrix('skewY')"); | |
104 | |
105 test(() => { | |
106 var matrix2d = new DOMMatrix(); | |
Timothy Loh
2016/10/19 02:59:06
Why the name 'matrix2d'? I think just calling ever
Hwanseung Lee
2016/10/22 14:44:56
Done.
| |
107 var expectedMatrix = new DOMMatrix(); | |
108 matrix2d.setMatrixValue("matrix3d(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0)"); | |
109 assert_false(matrix2d.is2D); | |
110 expectedMatrix.multiplySelf(new DOMMatrix([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0])) | |
111 assert_matrix_almost_equals(matrix2d, expectedMatrix); | |
112 }, "DOMMatrix setMatrix(matrix3d)"); | |
113 | |
114 test(() => { | |
115 var matrix2d = new DOMMatrix(); | |
116 var expectedMatrix = new DOMMatrix(); | |
117 matrix2d.setMatrixValue("translate3d(10px, 20px, 30px)"); | |
118 assert_false(matrix2d.is2D); | |
119 expectedMatrix.translateSelf(10, 20, 30) | |
120 assert_matrix_almost_equals(matrix2d, expectedMatrix); | |
121 }, "DOMMatrix setMatrix(translate3d)"); | |
122 | |
123 test(() => { | |
124 var matrix2d = new DOMMatrix(); | |
125 var expectedMatrix = new DOMMatrix(); | |
126 matrix2d.setMatrixValue("translateZ(88px)"); | |
127 assert_false(matrix2d.is2D); | |
128 expectedMatrix.translateSelf(0, 0, 88) | |
129 assert_matrix_almost_equals(matrix2d, expectedMatrix); | |
130 }, "DOMMatrix setMatrix('translateY')"); | |
131 | |
132 test(() => { | |
133 var matrix2d = new DOMMatrix(); | |
134 var expectedMatrix = new DOMMatrix(); | |
135 matrix2d.setMatrixValue("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0) translate(44px, 55px) skewX(30deg)"); | |
136 assert_true(matrix2d.is2D); | |
137 expectedMatrix.multiplySelf(new DOMMatrix([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])) | |
138 expectedMatrix.translateSelf(44, 55) | |
139 expectedMatrix.skewXSelf(30); | |
140 assert_matrix_almost_equals(matrix2d, expectedMatrix); | |
141 }, "DOMMatrix setMatrix(multiple value)"); | |
142 | |
143 test(() => { | |
Timothy Loh
2016/10/19 02:59:06
This test would be more readable if you just used
Hwanseung Lee
2016/10/22 14:44:56
Done.
| |
144 assert_throws(new SyntaxError(), () => { | |
145 var matrix2d = new DOMMatrix(); | |
146 matrix2d.setMatrixValue("none"); | |
Timothy Loh
2016/10/19 02:59:06
As I said before, I'm not sure that 'none' is supp
Hwanseung Lee
2016/10/22 14:44:56
i fixed code to accept 'none' and i add test code
| |
147 }, "can't parsing none."); | |
148 | |
149 assert_throws(new SyntaxError(), () => { | |
150 var matrix2d = new DOMMatrix(); | |
151 matrix2d.setMatrixValue("notExist() =>"); | |
Timothy Loh
2016/10/19 02:59:06
Is the "=>" intentional here?
Hwanseung Lee
2016/10/22 14:44:56
no. it is mistake. i remove it.
| |
152 }, "can't parsing not exist function keyword."); | |
153 | |
154 assert_throws(new SyntaxError(), () => { | |
155 var matrix2d = new DOMMatrix(); | |
156 matrix2d.setMatrixValue("translateY(50%)"); | |
157 }, "Can't parse without absolute unit."); | |
158 | |
159 assert_throws(new SyntaxError(), () => { | |
160 var matrix2d = new DOMMatrix(); | |
161 matrix2d.setMatrixValue("translateX(1.2em)"); | |
162 }, "Can't parse without absolute unit."); | |
163 | |
164 assert_throws(new SyntaxError(), () => { | |
165 var matrix2d = new DOMMatrix(); | |
166 matrix2d.setMatrixValue("translateX(10ex)"); | |
167 }, "Can't parse without absolute unit."); | |
168 | |
169 assert_throws(new SyntaxError(), () => { | |
170 var matrix2d = new DOMMatrix(); | |
171 matrix2d.setMatrixValue("translateX(10ch)"); | |
172 }, "Can't parse without absolute unit."); | |
173 | |
174 assert_throws(new SyntaxError(), () => { | |
175 var matrix2d = new DOMMatrix(); | |
176 matrix2d.setMatrixValue("translateX(10rem)"); | |
177 }, "Can't parse without absolute unit."); | |
178 | |
179 assert_throws(new SyntaxError(), () => { | |
180 var matrix2d = new DOMMatrix(); | |
181 matrix2d.setMatrixValue("translateX(10vw)"); | |
182 }, "Can't parse without absolute unit."); | |
183 | |
184 assert_throws(new SyntaxError(), () => { | |
185 var matrix2d = new DOMMatrix(); | |
186 matrix2d.setMatrixValue("translateX(10vh)"); | |
187 }, "Can't parse without absolute unit."); | |
188 | |
189 assert_throws(new SyntaxError(), () => { | |
190 var matrix2d = new DOMMatrix(); | |
191 matrix2d.setMatrixValue("translateX(10vmin)"); | |
192 }, "Can't parse without absolute unit."); | |
193 | |
194 assert_throws(new SyntaxError(), () => { | |
195 var matrix2d = new DOMMatrix(); | |
196 matrix2d.setMatrixValue("translateX(10vmax)"); | |
197 }, "Can't parse without absolute unit."); | |
198 | |
199 }, "DOMMatrix.setMatrix(): Exception test."); | |
200 | |
201 </script> | |
OLD | NEW |