Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/geometry-interfaces-dom-matrix-setMatrixValue.html

Issue 2380713004: [GeometryInterface] Add setMatrixValue(transfromList) function. (Closed)
Patch Set: [GeometryInterface] Add setMatrixValue(transfromList) function. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 var matrix2d = new DOMMatrix([5, 4, 11, 34, 55, 11]);
8 var matrix3d = new DOMMatrix([5, 11, 55, 77, 44, 33, 55, 75, 88, 99, 12, 43, 65, 36, 85, 25]);
9
10 test(() => {
11 var actualMatrix1 = new DOMMatrix(matrix2d);
12 var actualMatrix2 = new DOMMatrix(matrix3d);
13 var expectedMatrix = new DOMMatrix();
14 actualMatrix1.setMatrixValue("");
15 assert_true(actualMatrix1.is2D);
16 assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
17 actualMatrix2.setMatrixValue("");
18 assert_true(actualMatrix2.is2D);
19 assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
20 }, "DOMMatrix setMatrix(EmptyString)");
21
22 test(() => {
23 var actualMatrix1 = new DOMMatrix(matrix2d);
24 var actualMatrix2 = new DOMMatrix(matrix3d);
25 var expectedMatrix = new DOMMatrix();
26 actualMatrix1.setMatrixValue("none");
27 assert_true(actualMatrix1.is2D);
28 assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
29 actualMatrix2.setMatrixValue("none");
30 assert_true(actualMatrix2.is2D);
31 assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
32 }, "DOMMatrix setMatrix('none')");
33
34 test(() => {
35 var actualMatrix1 = new DOMMatrix(matrix2d);
36 var actualMatrix2 = new DOMMatrix(matrix3d);
37 var expectedMatrix = new DOMMatrix();
38 actualMatrix1.setMatrixValue("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)");
39 assert_true(actualMatrix1.is2D);
40 actualMatrix2.setMatrixValue("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)");
41 assert_true(actualMatrix2.is2D);
42 expectedMatrix.multiplySelf(new DOMMatrix([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]))
43 assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
44 assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
45 }, "DOMMatrix setMatrix('matrix')");
46
47 test(() => {
48 var actualMatrix1 = new DOMMatrix(matrix2d);
49 var actualMatrix2 = new DOMMatrix(matrix3d);
50 var expectedMatrix = new DOMMatrix();
51 actualMatrix1.setMatrixValue("translate(44px, 55px)");
52 assert_true(actualMatrix1.is2D);
53 actualMatrix2.setMatrixValue("translate(44px, 55px)");
54 assert_true(actualMatrix2.is2D);
55 expectedMatrix.translateSelf(44, 55)
56 assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
57 assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
58 }, "DOMMatrix setMatrix('translate')");
59
60 test(() => {
61 var actualMatrix1 = new DOMMatrix(matrix2d);
62 var actualMatrix2 = new DOMMatrix(matrix3d);
63 var expectedMatrix = new DOMMatrix();
64 actualMatrix1.setMatrixValue("translateX(35px)");
65 assert_true(actualMatrix1.is2D);
66 actualMatrix2.setMatrixValue("translateX(35px)");
67 assert_true(actualMatrix2.is2D);
68 expectedMatrix.translateSelf(35, 0)
69 assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
70 assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
71 }, "DOMMatrix setMatrix('translateX')");
72
73 test(() => {
74 var actualMatrix1 = new DOMMatrix(matrix2d);
75 var actualMatrix2 = new DOMMatrix(matrix3d);
76 var expectedMatrix = new DOMMatrix();
77 actualMatrix1.setMatrixValue("translateY(77px)");
78 assert_true(actualMatrix1.is2D);
79 actualMatrix2.setMatrixValue("translateY(77px)");
80 assert_true(actualMatrix2.is2D);
81 expectedMatrix.translateSelf(0, 77)
82 assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
83 assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
84 }, "DOMMatrix setMatrix('translateY')");
85
86 test(() => {
87 var actualMatrix1 = new DOMMatrix(matrix2d);
88 var actualMatrix2 = new DOMMatrix(matrix3d);
89 var expectedMatrix = new DOMMatrix();
90 actualMatrix1.setMatrixValue("scale(2, 2)");
91 assert_true(actualMatrix1.is2D);
92 actualMatrix2.setMatrixValue("scale(2, 2)");
93 assert_true(actualMatrix2.is2D);
94 expectedMatrix.scaleSelf(2, 2);
95 assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
96 assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
97 }, "DOMMatrix setMatrix('scale')");
98
99 test(() => {
100 var actualMatrix1 = new DOMMatrix(matrix2d);
101 var actualMatrix2 = new DOMMatrix(matrix3d);
102 var expectedMatrix = new DOMMatrix();
103 actualMatrix1.setMatrixValue("scaleX(2)");
104 assert_true(actualMatrix1.is2D);
105 actualMatrix2.setMatrixValue("scaleX(2)");
106 assert_true(actualMatrix2.is2D);
107 expectedMatrix.scaleSelf(2, 1);
108 assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
109 assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
110 }, "DOMMatrix setMatrix('scaleX')");
111
112 test(() => {
113 var actualMatrix1 = new DOMMatrix(matrix2d);
114 var actualMatrix2 = new DOMMatrix(matrix3d);
115 var expectedMatrix = new DOMMatrix();
116 actualMatrix1.setMatrixValue("scaleY(2)");
117 assert_true(actualMatrix1.is2D);
118 actualMatrix2.setMatrixValue("scaleY(2)");
119 assert_true(actualMatrix2.is2D);
120 expectedMatrix.scaleSelf(1, 2);
121 assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
122 assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
123 }, "DOMMatrix setMatrix('scaleY')");
124
125 test(() => {
126 var actualMatrix1 = new DOMMatrix(matrix2d);
127 var actualMatrix2 = new DOMMatrix(matrix3d);
128 var expectedMatrix = new DOMMatrix();
129 actualMatrix1.setMatrixValue("rotate(90deg)");
130 assert_true(actualMatrix1.is2D);
131 actualMatrix2.setMatrixValue("rotate(90deg)");
132 assert_true(actualMatrix2.is2D);
133 expectedMatrix.rotateAxisAngleSelf(0, 0, 1, 90);
134 assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
135 assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
136 }, "DOMMatrix setMatrix('rotate')");
137
138 test(() => {
139 var actualMatrix1 = new DOMMatrix(matrix2d);
140 var actualMatrix2 = new DOMMatrix(matrix3d);
141 var expectedMatrix = new DOMMatrix();
142 actualMatrix1.setMatrixValue("skewX(30deg)");
143 assert_true(actualMatrix1.is2D);
144 actualMatrix2.setMatrixValue("skewX(30deg)");
145 assert_true(actualMatrix2.is2D);
146 expectedMatrix.skewXSelf(30);
147 assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
148 assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
149 }, "DOMMatrix setMatrix('skewX')");
150
151 test(() => {
152 var actualMatrix1 = new DOMMatrix(matrix2d);
153 var actualMatrix2 = new DOMMatrix(matrix3d);
154 var expectedMatrix = new DOMMatrix();
155 actualMatrix1.setMatrixValue("skewY(40deg)");
156 assert_true(actualMatrix1.is2D);
157 actualMatrix2.setMatrixValue("skewY(40deg)");
158 assert_true(actualMatrix2.is2D);
159 expectedMatrix.skewYSelf(40);
160 assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
161 assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
162 }, "DOMMatrix setMatrix('skewY')");
163
164 test(() => {
165 var actualMatrix1 = new DOMMatrix(matrix2d);
166 var actualMatrix2 = new DOMMatrix(matrix3d);
167 var expectedMatrix = new DOMMatrix();
168 actualMatrix1.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)");
169 assert_false(actualMatrix1.is2D);
170 actualMatrix2.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)");
171 assert_false(actualMatrix2.is2D);
172 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]))
173 assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
174 assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
175 }, "DOMMatrix setMatrix(matrix3d)");
176
177 test(() => {
178 var actualMatrix1 = new DOMMatrix(matrix2d);
179 var actualMatrix2 = new DOMMatrix(matrix3d);
180 var expectedMatrix = new DOMMatrix();
181 actualMatrix1.setMatrixValue("translate3d(10px, 20px, 30px)");
182 assert_false(actualMatrix1.is2D);
183 actualMatrix2.setMatrixValue("translate3d(10px, 20px, 30px)");
184 assert_false(actualMatrix2.is2D);
185 expectedMatrix.translateSelf(10, 20, 30)
186 assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
187 assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
188 }, "DOMMatrix setMatrix(translate3d)");
189
190 test(() => {
191 var actualMatrix1 = new DOMMatrix(matrix2d);
192 var actualMatrix2 = new DOMMatrix(matrix3d);
193 var expectedMatrix = new DOMMatrix();
194 actualMatrix1.setMatrixValue("translateZ(88px)");
195 assert_false(actualMatrix1.is2D);
196 actualMatrix2.setMatrixValue("translateZ(88px)");
197 assert_false(actualMatrix2.is2D);
198 expectedMatrix.translateSelf(0, 0, 88)
199 assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
200 assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
201 }, "DOMMatrix setMatrix('translateY')");
202
203 test(() => {
204 var actualMatrix1 = new DOMMatrix(matrix2d);
205 var actualMatrix2 = new DOMMatrix(matrix3d);
206 var expectedMatrix = new DOMMatrix();
207 actualMatrix1.setMatrixValue("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0) translate(4 4px, 55px) skewX(30deg)");
208 assert_true(actualMatrix1.is2D);
209 actualMatrix2.setMatrixValue("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0) translate(4 4px, 55px) skewX(30deg)");
210 assert_true(actualMatrix2.is2D);
211 expectedMatrix.multiplySelf(new DOMMatrix([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]))
212 expectedMatrix.translateSelf(44, 55)
213 expectedMatrix.skewXSelf(30);
214 assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
215 assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
216 }, "DOMMatrix setMatrix(multiple value)");
217
218 // TODO(hs1217.lee) : calc() function take only absolute unit. should be pass th is test.
219 // but calc() function is not supported not yet.
220 // refer to hasRelativeLengths() in TransformBuilder.cpp
221 // test(() => {
222 // var actualMatrix1 = new DOMMatrix(matrix2d);
223 // var actualMatrix2 = new DOMMatrix(matrix3d);
224 // var expectedMatrix = new DOMMatrix();
225 // actualMatrix1.setMatrixValue("translateX(calc(10px + 1px))");
226 // assert_true(actualMatrix1.is2D);
227 // actualMatrix2.setMatrixValue("translateX(calc(10px + 1px))");
228 // assert_true(actualMatrix2.is2D);
229 // expectedMatrix.translateSelf(11, 0)
230 // assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
231 // assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
232 // }, "DOMMatrix setMatrix(multiple value)");
233
234 test(() => {
235
236 var actualMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]);
237 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]);
238
239 assert_throws(new SyntaxError(), () => {
240 actualMatrix.setMatrixValue("initial");
241 }, "CSS-wide keywords are disallowed.");
242
243 assert_throws(new SyntaxError(), () => {
244 actualMatrix.setMatrixValue("notExistFunction()");
245 }, "can't parse not exist function.");
246
247 assert_throws(new SyntaxError(), () => {
248 actualMatrix.setMatrixValue("translateY(50%)");
249 }, "Can't parse without absolute unit.");
250
251 assert_throws(new SyntaxError(), () => {
252 actualMatrix.setMatrixValue("translateX(1.2em)");
253 }, "Can't parse without absolute unit.");
254
255 assert_throws(new SyntaxError(), () => {
256 actualMatrix.setMatrixValue("translateX(10ex)");
257 }, "Can't parse without absolute unit.");
258
259 assert_throws(new SyntaxError(), () => {
260 actualMatrix.setMatrixValue("translateX(10ch)");
261 }, "Can't parse without absolute unit.");
262
263 assert_throws(new SyntaxError(), () => {
264 actualMatrix.setMatrixValue("translateX(10rem)");
265 }, "Can't parse without absolute unit.");
266
267 assert_throws(new SyntaxError(), () => {
268 actualMatrix.setMatrixValue("translateX(10vw)");
269 }, "Can't parse without absolute unit.");
270
271 assert_throws(new SyntaxError(), () => {
272 actualMatrix.setMatrixValue("translateX(10vh)");
273 }, "Can't parse without absolute unit.");
274
275 assert_throws(new SyntaxError(), () => {
276 actualMatrix.setMatrixValue("translateX(10vmin)");
277 }, "Can't parse without absolute unit.");
278
279 assert_throws(new SyntaxError(), () => {
280 actualMatrix.setMatrixValue("translateX(10vmax)");
281 }, "Can't parse without absolute unit.");
282
283 assert_throws(new SyntaxError(), () => {
284 actualMatrix.setMatrixValue("translateX(calc(10px + 1em))");
285 }, "Can't parse without absolute unit.");
286
287 //actualMatrix should be not changed.
288 assert_true(actualMatrix.is2D);
289 assert_matrix_almost_equals(actualMatrix, expectedMatrix);
290
291 }, "DOMMatrix.setMatrix(): Exception test.");
292
293 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698