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

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

Powered by Google App Engine
This is Rietveld 408576698