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

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
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 test(() => {
8 var actualMatrix1 = new DOMMatrix([1, 2, 3, 4, 5, 6]);
9 var actualMatrix2 = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
10 var expectedMatrix = new DOMMatrix();
11 actualMatrix1.setMatrixValue("");
12 assert_true(actualMatrix1.is2D);
13 assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
14 actualMatrix2.setMatrixValue("");
15 assert_true(actualMatrix2.is2D);
16 assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
17 }, "DOMMatrix setMatrix(EmptyString)");
18
19 test(() => {
20 var actualMatrix1 = new DOMMatrix([1, 2, 3, 4, 5, 6]);
21 var actualMatrix2 = new DOMMatrix([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]);
22 var expectedMatrix = new DOMMatrix();
23 actualMatrix1.setMatrixValue("none");
24 assert_true(actualMatrix1.is2D);
25 assert_matrix_almost_equals(actualMatrix1, expectedMatrix);
26 actualMatrix2.setMatrixValue("none");
27 assert_true(actualMatrix2.is2D);
28 assert_matrix_almost_equals(actualMatrix2, expectedMatrix);
29 }, "DOMMatrix setMatrix('none')");
30
31 test(() => {
32 var actualMatrix = new DOMMatrix();
33 var expectedMatrix = new DOMMatrix();
34 actualMatrix.setMatrixValue("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)");
35 assert_true(actualMatrix.is2D);
36 expectedMatrix.multiplySelf(new DOMMatrix([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]))
37 assert_matrix_almost_equals(actualMatrix, expectedMatrix);
38 }, "DOMMatrix setMatrix('matrix')");
39
40 test(() => {
41 var actualMatrix = new DOMMatrix();
42 var expectedMatrix = new DOMMatrix();
43 actualMatrix.setMatrixValue("translate(44px, 55px)");
44 assert_true(actualMatrix.is2D);
45 expectedMatrix.translateSelf(44, 55)
46 assert_matrix_almost_equals(actualMatrix, expectedMatrix);
47 }, "DOMMatrix setMatrix('translate')");
48
49 test(() => {
50 var actualMatrix = new DOMMatrix();
51 var expectedMatrix = new DOMMatrix();
52 actualMatrix.setMatrixValue("translateX(35px)");
53 assert_true(actualMatrix.is2D);
54 expectedMatrix.translateSelf(35, 0)
55 assert_matrix_almost_equals(actualMatrix, expectedMatrix);
56 }, "DOMMatrix setMatrix('translateX')");
57
58 test(() => {
59 var actualMatrix = new DOMMatrix();
60 var expectedMatrix = new DOMMatrix();
61 actualMatrix.setMatrixValue("translateY(77px)");
62 assert_true(actualMatrix.is2D);
63 expectedMatrix.translateSelf(0, 77)
64 assert_matrix_almost_equals(actualMatrix, expectedMatrix);
65 }, "DOMMatrix setMatrix('translateY')");
66
67 test(() => {
68 var actualMatrix = new DOMMatrix();
69 var expectedMatrix = new DOMMatrix();
70 actualMatrix.setMatrixValue("scale(2, 2)");
71 assert_true(actualMatrix.is2D);
72 expectedMatrix.scaleSelf(2, 2);
73 assert_matrix_almost_equals(actualMatrix, expectedMatrix);
74 }, "DOMMatrix setMatrix('scale')");
75
76 test(() => {
77 var actualMatrix = new DOMMatrix();
78 var expectedMatrix = new DOMMatrix();
79 actualMatrix.setMatrixValue("scaleX(2)");
80 assert_true(actualMatrix.is2D);
81 expectedMatrix.scaleSelf(2, 1);
82 assert_matrix_almost_equals(actualMatrix, expectedMatrix);
83 }, "DOMMatrix setMatrix('scaleX')");
84
85 test(() => {
86 var actualMatrix = new DOMMatrix();
87 var expectedMatrix = new DOMMatrix();
88 actualMatrix.setMatrixValue("scaleY(2)");
89 assert_true(actualMatrix.is2D);
90 expectedMatrix.scaleSelf(1, 2);
91 assert_matrix_almost_equals(actualMatrix, expectedMatrix);
92 }, "DOMMatrix setMatrix('scaleY')");
93
94 test(() => {
95 var actualMatrix = new DOMMatrix();
96 var expectedMatrix = new DOMMatrix();
97 actualMatrix.setMatrixValue("rotate(90deg)");
98 assert_true(actualMatrix.is2D);
99 expectedMatrix.rotateAxisAngleSelf(0, 0, 1, 90);
100 assert_matrix_almost_equals(actualMatrix, expectedMatrix);
101 }, "DOMMatrix setMatrix('rotate')");
102
103 test(() => {
104 var actualMatrix = new DOMMatrix();
105 var expectedMatrix = new DOMMatrix();
106 actualMatrix.setMatrixValue("skewX(30deg)");
107 assert_true(actualMatrix.is2D);
108 expectedMatrix.skewXSelf(30);
109 assert_matrix_almost_equals(actualMatrix, expectedMatrix);
110 }, "DOMMatrix setMatrix('skewX')");
111
112 test(() => {
113 var actualMatrix = new DOMMatrix();
114 var expectedMatrix = new DOMMatrix();
115 actualMatrix.setMatrixValue("skewY(40deg)");
116 assert_true(actualMatrix.is2D);
117 expectedMatrix.skewYSelf(40);
118 assert_matrix_almost_equals(actualMatrix, expectedMatrix);
119 }, "DOMMatrix setMatrix('skewY')");
120
121 test(() => {
122 var actualMatrix = new DOMMatrix();
123 var expectedMatrix = new DOMMatrix();
124 actualMatrix.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)");
125 assert_false(actualMatrix.is2D);
126 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]))
127 assert_matrix_almost_equals(actualMatrix, expectedMatrix);
128 }, "DOMMatrix setMatrix(matrix3d)");
129
130 test(() => {
131 var actualMatrix = new DOMMatrix();
132 var expectedMatrix = new DOMMatrix();
133 actualMatrix.setMatrixValue("translate3d(10px, 20px, 30px)");
134 assert_false(actualMatrix.is2D);
135 expectedMatrix.translateSelf(10, 20, 30)
136 assert_matrix_almost_equals(actualMatrix, expectedMatrix);
137 }, "DOMMatrix setMatrix(translate3d)");
138
139 test(() => {
140 var actualMatrix = new DOMMatrix();
141 var expectedMatrix = new DOMMatrix();
142 actualMatrix.setMatrixValue("translateZ(88px)");
143 assert_false(actualMatrix.is2D);
144 expectedMatrix.translateSelf(0, 0, 88)
145 assert_matrix_almost_equals(actualMatrix, expectedMatrix);
146 }, "DOMMatrix setMatrix('translateY')");
147
148 test(() => {
149 var actualMatrix = new DOMMatrix();
150 var expectedMatrix = new DOMMatrix();
151 actualMatrix.setMatrixValue("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0) translate(44 px, 55px) skewX(30deg)");
152 assert_true(actualMatrix.is2D);
153 expectedMatrix.multiplySelf(new DOMMatrix([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]))
154 expectedMatrix.translateSelf(44, 55)
155 expectedMatrix.skewXSelf(30);
156 assert_matrix_almost_equals(actualMatrix, expectedMatrix);
157 }, "DOMMatrix setMatrix(multiple value)");
158
159 // TODO(hs1217.lee) : calc() function take only absolute unit. should be pass th is test.
160 // but calc() function is not supported not yet.
161 // refer to hasRelativeLengths() in TransformBuilder.cpp
162 // test(() => {
163 // var actualMatrix = new DOMMatrix();
164 // var expectedMatrix = new DOMMatrix();
165 // actualMatrix.setMatrixValue("translateX(calc(10px + 1px))");
166 // assert_true(actualMatrix.is2D);
167 // expectedMatrix.translateSelf(11, 0)
168 // assert_matrix_almost_equals(actualMatrix, expectedMatrix);
169 // }, "DOMMatrix setMatrix(multiple value)");
170
171 test(() => {
172
173 var actualMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]);
174 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]);
175
176 assert_throws(new SyntaxError(), () => {
177 actualMatrix.setMatrixValue("initial");
178 }, "CSS-wide keywords are disallowed.");
179
180 assert_throws(new SyntaxError(), () => {
181 actualMatrix.setMatrixValue("notExistFunction()");
182 }, "can't parse not exist function.");
183
184 assert_throws(new SyntaxError(), () => {
185 actualMatrix.setMatrixValue("translateY(50%)");
186 }, "Can't parse without absolute unit.");
187
188 assert_throws(new SyntaxError(), () => {
189 actualMatrix.setMatrixValue("translateX(1.2em)");
190 }, "Can't parse without absolute unit.");
191
192 assert_throws(new SyntaxError(), () => {
193 actualMatrix.setMatrixValue("translateX(10ex)");
194 }, "Can't parse without absolute unit.");
195
196 assert_throws(new SyntaxError(), () => {
197 actualMatrix.setMatrixValue("translateX(10ch)");
198 }, "Can't parse without absolute unit.");
199
200 assert_throws(new SyntaxError(), () => {
201 actualMatrix.setMatrixValue("translateX(10rem)");
202 }, "Can't parse without absolute unit.");
203
204 assert_throws(new SyntaxError(), () => {
205 actualMatrix.setMatrixValue("translateX(10vw)");
206 }, "Can't parse without absolute unit.");
207
208 assert_throws(new SyntaxError(), () => {
209 actualMatrix.setMatrixValue("translateX(10vh)");
210 }, "Can't parse without absolute unit.");
211
212 assert_throws(new SyntaxError(), () => {
213 actualMatrix.setMatrixValue("translateX(10vmin)");
214 }, "Can't parse without absolute unit.");
215
216 assert_throws(new SyntaxError(), () => {
217 actualMatrix.setMatrixValue("translateX(10vmax)");
218 }, "Can't parse without absolute unit.");
219
220 assert_throws(new SyntaxError(), () => {
221 actualMatrix.setMatrixValue("translateX(calc(10px + 1em))");
222 }, "Can't parse without absolute unit.");
223
224 //actualMatrix should be not changed.
225 assert_true(actualMatrix.is2D);
226 assert_matrix_almost_equals(actualMatrix, expectedMatrix);
227
228 }, "DOMMatrix.setMatrix(): Exception test.");
229
230 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698