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(function() { | |
8 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
9 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
meade_UTC10
2016/10/13 04:18:50
This seems suspicious - from reading your CL descr
Hwanseung Lee
2016/10/13 17:05:10
Done.
| |
10 matrix2d.setMatrixValue(""); | |
11 assert_true(matrix2d.is2D); | |
12 assert_array_almost_equals(matrix2d.toFloat64Array(), expectedMatrix.toFloat64 Array()); | |
13 }, "DOMMatrix setMatrix(EmptyString)"); | |
14 | |
15 test(function() { | |
16 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
17 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
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_array_almost_equals(matrix2d.toFloat64Array(), expectedMatrix.toFloat64 Array()); | |
22 }, "DOMMatrix setMatrix('matrix2d')"); | |
23 | |
24 test(function() { | |
25 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
26 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
27 matrix2d.setMatrixValue("translate(44px, 55px)"); | |
28 assert_true(matrix2d.is2D); | |
29 expectedMatrix.translateSelf(44, 55) | |
30 assert_array_almost_equals(matrix2d.toFloat64Array(), expectedMatrix.toFloat64 Array()); | |
31 }, "DOMMatrix setMatrix('translate')"); | |
32 | |
33 test(function() { | |
34 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
35 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
36 matrix2d.setMatrixValue("translateX(35px)"); | |
37 assert_true(matrix2d.is2D); | |
38 expectedMatrix.translateSelf(35, 0) | |
39 assert_array_almost_equals(matrix2d.toFloat64Array(), expectedMatrix.toFloat64 Array()); | |
40 }, "DOMMatrix setMatrix('translateX')"); | |
41 | |
42 test(function() { | |
43 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
44 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
45 matrix2d.setMatrixValue("translateY(77px)"); | |
46 assert_true(matrix2d.is2D); | |
47 expectedMatrix.translateSelf(0, 77) | |
48 assert_array_almost_equals(matrix2d.toFloat64Array(), expectedMatrix.toFloat64 Array()); | |
49 }, "DOMMatrix setMatrix('translateY')"); | |
50 | |
51 // TODO(hs1217.lee) : should be add test about scale function. | |
52 // parameter of DOMMatrix scale function is not matched with parameter of CSS Tr ansform scale function. | |
53 // it was reported at crbug(https://bugs.chromium.org/p/chromium/issues/detail?i d=645887) | |
54 | |
55 // TODO(hs1217.lee) : should be remove annotation. | |
56 // rotateAxisAngleSelf method is not implementation not yet. | |
57 // test(function() { | |
58 // var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
59 // var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
60 // matrix2d.setMatrixValue("rotate(90deg)"); | |
61 // assert_true(matrix2d.is2D); | |
62 // expectedMatrix.rotateAxisAngleSelf(0, 0, 1, 90); | |
63 // assert_array_almost_equals(matrix2d.toFloat64Array(), expectedMatrix.toFloa t64Array()); | |
64 // }, "DOMMatrix setMatrix('rotate')"); | |
65 | |
66 test(function() { | |
67 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
68 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
69 matrix2d.setMatrixValue("skewX(30deg)"); | |
70 assert_true(matrix2d.is2D); | |
71 expectedMatrix.skewXSelf(30); | |
72 assert_array_almost_equals(matrix2d.toFloat64Array(), expectedMatrix.toFloat64 Array()); | |
73 }, "DOMMatrix setMatrix('skewX')"); | |
74 | |
75 test(function() { | |
76 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
77 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
78 matrix2d.setMatrixValue("skewY(40deg)"); | |
79 assert_true(matrix2d.is2D); | |
80 expectedMatrix.skewYSelf(40); | |
81 assert_array_almost_equals(matrix2d.toFloat64Array(), expectedMatrix.toFloat64 Array()); | |
82 }, "DOMMatrix setMatrix('skewY')"); | |
83 | |
84 test(function() { | |
85 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
86 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
87 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)"); | |
88 assert_false(matrix2d.is2D); | |
89 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])) | |
90 assert_array_almost_equals(matrix2d.toFloat64Array(), expectedMatrix.toFloat64 Array()); | |
91 }, "DOMMatrix setMatrix(matrix3d)"); | |
92 | |
93 test(function() { | |
94 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
95 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
96 matrix2d.setMatrixValue("translate3d(10px, 20px, 30px)"); | |
97 assert_false(matrix2d.is2D); | |
98 expectedMatrix.translateSelf(10, 20, 30) | |
99 assert_array_almost_equals(matrix2d.toFloat64Array(), expectedMatrix.toFloat64 Array()); | |
100 }, "DOMMatrix setMatrix(translate3d)"); | |
101 | |
102 test(function() { | |
103 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
104 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
105 matrix2d.setMatrixValue("translateZ(88px)"); | |
106 assert_false(matrix2d.is2D); | |
107 expectedMatrix.translateSelf(0, 0, 88) | |
108 assert_array_almost_equals(matrix2d.toFloat64Array(), expectedMatrix.toFloat64 Array()); | |
109 }, "DOMMatrix setMatrix('translateY')"); | |
110 | |
111 test(function() { | |
112 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
113 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
114 matrix2d.setMatrixValue("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0) translate(44px, 55px) skewX(30deg)"); | |
115 assert_true(matrix2d.is2D); | |
116 expectedMatrix.multiplySelf(new DOMMatrix([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])) | |
117 expectedMatrix.translateSelf(44, 55) | |
118 expectedMatrix.skewXSelf(30); | |
119 assert_array_almost_equals(matrix2d.toFloat64Array(), expectedMatrix.toFloat64 Array()); | |
120 }, "DOMMatrix setMatrix(multiple value)"); | |
121 | |
122 test(() => { | |
123 assert_throws(new SyntaxError(), () => { | |
124 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
125 matrix2d.setMatrixValue("none"); | |
126 }, "can't parsing none."); | |
127 | |
128 assert_throws(new SyntaxError(), () => { | |
129 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
130 matrix2d.setMatrixValue("notExistFunction()"); | |
131 }, "can't parsing not exist function keyword."); | |
132 | |
133 assert_throws(new SyntaxError(), () => { | |
134 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
135 matrix2d.setMatrixValue("translateY(50%)"); | |
136 }, "can't parsing without absolute unit."); | |
137 | |
138 }, "DOMMatrix.setMatrix(): Exception test."); | |
139 | |
140 </script> | |
OLD | NEW |