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 matrix = new DOMMatrix(); | |
Timothy Loh
2016/10/24 04:18:30
I would create two DOMMatrix objects at the start
Hwanseung Lee
2016/10/24 13:23:37
i fixed it follow your comment.
Timothy Loh
2016/10/25 04:48:00
Sorry if I wasn't too clear, what I meant was that
Hwanseung Lee
2016/10/27 16:24:47
actually i don't know your intent correctly.
but i
Timothy Loh
2016/10/28 02:50:04
Something like this is fine, but you need to creat
Hwanseung Lee
2016/10/28 12:17:58
Done.
| |
9 var expectedMatrix = new DOMMatrix(); | |
10 matrix.setMatrixValue(""); | |
11 assert_true(matrix.is2D); | |
12 assert_matrix_almost_equals(matrix, expectedMatrix); | |
13 }, "DOMMatrix setMatrix(EmptyString)"); | |
14 | |
15 test(() => { | |
16 var matrix = new DOMMatrix(); | |
17 var expectedMatrix = new DOMMatrix(); | |
18 matrix.setMatrixValue("none"); | |
19 assert_true(matrix.is2D); | |
20 assert_matrix_almost_equals(matrix, expectedMatrix); | |
21 }, "DOMMatrix setMatrix('none')"); | |
22 | |
23 test(() => { | |
24 var matrix = new DOMMatrix(); | |
25 var expectedMatrix = new DOMMatrix(); | |
26 matrix.setMatrixValue("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)"); | |
27 assert_true(matrix.is2D); | |
28 expectedMatrix.multiplySelf(new DOMMatrix([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])) | |
29 assert_matrix_almost_equals(matrix, expectedMatrix); | |
30 }, "DOMMatrix setMatrix('matrix')"); | |
31 | |
32 test(() => { | |
33 var matrix = new DOMMatrix(); | |
34 var expectedMatrix = new DOMMatrix(); | |
35 matrix.setMatrixValue("translate(44px, 55px)"); | |
36 assert_true(matrix.is2D); | |
37 expectedMatrix.translateSelf(44, 55) | |
38 assert_matrix_almost_equals(matrix, expectedMatrix); | |
39 }, "DOMMatrix setMatrix('translate')"); | |
40 | |
41 test(() => { | |
42 var matrix = new DOMMatrix(); | |
43 var expectedMatrix = new DOMMatrix(); | |
44 matrix.setMatrixValue("translateX(35px)"); | |
45 assert_true(matrix.is2D); | |
46 expectedMatrix.translateSelf(35, 0) | |
47 assert_matrix_almost_equals(matrix, expectedMatrix); | |
48 }, "DOMMatrix setMatrix('translateX')"); | |
49 | |
50 test(() => { | |
51 var matrix = new DOMMatrix(); | |
52 var expectedMatrix = new DOMMatrix(); | |
53 matrix.setMatrixValue("translateY(77px)"); | |
54 assert_true(matrix.is2D); | |
55 expectedMatrix.translateSelf(0, 77) | |
56 assert_matrix_almost_equals(matrix, expectedMatrix); | |
57 }, "DOMMatrix setMatrix('translateY')"); | |
58 | |
59 test(() => { | |
60 var matrix = new DOMMatrix(); | |
61 var expectedMatrix = new DOMMatrix(); | |
62 matrix.setMatrixValue("scale(2, 2)"); | |
63 assert_true(matrix.is2D); | |
64 expectedMatrix.scaleSelf(2, 2); | |
65 assert_matrix_almost_equals(matrix, expectedMatrix); | |
66 }, "DOMMatrix setMatrix('scale')"); | |
67 | |
68 test(() => { | |
69 var matrix = new DOMMatrix(); | |
70 var expectedMatrix = new DOMMatrix(); | |
71 matrix.setMatrixValue("scaleX(2)"); | |
72 assert_true(matrix.is2D); | |
73 expectedMatrix.scaleSelf(2, 1); | |
74 assert_matrix_almost_equals(matrix, expectedMatrix); | |
75 }, "DOMMatrix setMatrix('scaleX')"); | |
76 | |
77 test(() => { | |
78 var matrix = new DOMMatrix(); | |
79 var expectedMatrix = new DOMMatrix(); | |
80 matrix.setMatrixValue("scaleY(2)"); | |
81 assert_true(matrix.is2D); | |
82 expectedMatrix.scaleSelf(1, 2); | |
83 assert_matrix_almost_equals(matrix, expectedMatrix); | |
84 }, "DOMMatrix setMatrix('scaleY')"); | |
85 | |
86 test(() => { | |
87 var matrix = new DOMMatrix(); | |
88 var expectedMatrix = new DOMMatrix(); | |
89 matrix.setMatrixValue("rotate(90deg)"); | |
90 assert_true(matrix.is2D); | |
91 expectedMatrix.rotateAxisAngleSelf(0, 0, 1, 90); | |
92 assert_matrix_almost_equals(matrix, expectedMatrix); | |
93 }, "DOMMatrix setMatrix('rotate')"); | |
94 | |
95 test(() => { | |
96 var matrix = new DOMMatrix(); | |
97 var expectedMatrix = new DOMMatrix(); | |
98 matrix.setMatrixValue("skewX(30deg)"); | |
99 assert_true(matrix.is2D); | |
100 expectedMatrix.skewXSelf(30); | |
101 assert_matrix_almost_equals(matrix, expectedMatrix); | |
102 }, "DOMMatrix setMatrix('skewX')"); | |
103 | |
104 test(() => { | |
105 var matrix = new DOMMatrix(); | |
106 var expectedMatrix = new DOMMatrix(); | |
107 matrix.setMatrixValue("skewY(40deg)"); | |
108 assert_true(matrix.is2D); | |
109 expectedMatrix.skewYSelf(40); | |
110 assert_matrix_almost_equals(matrix, expectedMatrix); | |
111 }, "DOMMatrix setMatrix('skewY')"); | |
112 | |
113 test(() => { | |
114 var matrix = new DOMMatrix(); | |
115 var expectedMatrix = new DOMMatrix(); | |
116 matrix.setMatrixValue("matrix3d(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 1 0.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0)"); | |
117 assert_false(matrix.is2D); | |
118 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])) | |
119 assert_matrix_almost_equals(matrix, expectedMatrix); | |
120 }, "DOMMatrix setMatrix(matrix3d)"); | |
121 | |
122 test(() => { | |
123 var matrix = new DOMMatrix(); | |
124 var expectedMatrix = new DOMMatrix(); | |
125 matrix.setMatrixValue("translate3d(10px, 20px, 30px)"); | |
126 assert_false(matrix.is2D); | |
127 expectedMatrix.translateSelf(10, 20, 30) | |
128 assert_matrix_almost_equals(matrix, expectedMatrix); | |
129 }, "DOMMatrix setMatrix(translate3d)"); | |
130 | |
131 test(() => { | |
132 var matrix = new DOMMatrix(); | |
133 var expectedMatrix = new DOMMatrix(); | |
134 matrix.setMatrixValue("translateZ(88px)"); | |
135 assert_false(matrix.is2D); | |
136 expectedMatrix.translateSelf(0, 0, 88) | |
137 assert_matrix_almost_equals(matrix, expectedMatrix); | |
138 }, "DOMMatrix setMatrix('translateY')"); | |
139 | |
140 test(() => { | |
141 var matrix = new DOMMatrix(); | |
142 var expectedMatrix = new DOMMatrix(); | |
143 matrix.setMatrixValue("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0) translate(44px, 55 px) skewX(30deg)"); | |
144 assert_true(matrix.is2D); | |
145 expectedMatrix.multiplySelf(new DOMMatrix([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])) | |
146 expectedMatrix.translateSelf(44, 55) | |
147 expectedMatrix.skewXSelf(30); | |
148 assert_matrix_almost_equals(matrix, expectedMatrix); | |
149 }, "DOMMatrix setMatrix(multiple value)"); | |
150 | |
151 test(() => { | |
152 | |
153 var matrix = new DOMMatrix(); | |
154 | |
155 assert_throws(new SyntaxError(), () => { | |
156 matrix.setMatrixValue("initial"); | |
157 }, "can't parse not exist keyword."); | |
Timothy Loh
2016/10/24 04:18:30
I would write something like "CSS-wide keywords ar
Hwanseung Lee
2016/10/24 13:23:37
Done.
| |
158 | |
159 assert_throws(new SyntaxError(), () => { | |
160 matrix.setMatrixValue("notExistFunction()"); | |
161 }, "can't parse not exist function."); | |
162 | |
163 assert_throws(new SyntaxError(), () => { | |
164 | |
Timothy Loh
2016/10/24 04:18:30
unintentional blank line?
Hwanseung Lee
2016/10/24 13:23:37
no it is typo.
| |
165 matrix.setMatrixValue("translateY(50%)"); | |
166 }, "Can't parse without absolute unit."); | |
167 | |
168 assert_throws(new SyntaxError(), () => { | |
169 matrix.setMatrixValue("translateX(1.2em)"); | |
170 }, "Can't parse without absolute unit."); | |
171 | |
172 assert_throws(new SyntaxError(), () => { | |
173 matrix.setMatrixValue("translateX(10ex)"); | |
174 }, "Can't parse without absolute unit."); | |
175 | |
176 assert_throws(new SyntaxError(), () => { | |
177 matrix.setMatrixValue("translateX(10ch)"); | |
178 }, "Can't parse without absolute unit."); | |
179 | |
180 assert_throws(new SyntaxError(), () => { | |
181 matrix.setMatrixValue("translateX(10rem)"); | |
182 }, "Can't parse without absolute unit."); | |
183 | |
184 assert_throws(new SyntaxError(), () => { | |
185 matrix.setMatrixValue("translateX(10vw)"); | |
186 }, "Can't parse without absolute unit."); | |
187 | |
188 assert_throws(new SyntaxError(), () => { | |
189 matrix.setMatrixValue("translateX(10vh)"); | |
190 }, "Can't parse without absolute unit."); | |
191 | |
192 assert_throws(new SyntaxError(), () => { | |
193 matrix.setMatrixValue("translateX(10vmin)"); | |
194 }, "Can't parse without absolute unit."); | |
195 | |
196 assert_throws(new SyntaxError(), () => { | |
197 matrix.setMatrixValue("translateX(10vmax)"); | |
198 }, "Can't parse without absolute unit."); | |
199 | |
200 assert_throws(new SyntaxError(), () => { | |
201 matrix.setMatrixValue("translateX(calc(10px + 1em))"); | |
202 }, "Can't parse without absolute unit."); | |
203 | |
204 // TODO(hs1217.lee) : should be throw exception. | |
Timothy Loh
2016/10/24 04:18:30
This case shouldn't throw an exception, right? So
Hwanseung Lee
2016/10/24 13:23:37
Yes, Your opinion is right, I'll move it.
| |
205 // refer to hasRelativeLengths() in TransformBuilder.cpp | |
206 // assert_throws(new SyntaxError(), () => { | |
207 // matrix.setMatrixValue("translateX(calc(10px + 1px))"); | |
208 // }, "Can't parse without absolute unit."); | |
209 | |
210 }, "DOMMatrix.setMatrix(): Exception test."); | |
211 | |
212 </script> | |
OLD | NEW |