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]); | |
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 test(function() { | |
56 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
57 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
58 matrix2d.setMatrixValue("rotate(90deg)"); | |
59 assert_true(matrix2d.is2D); | |
60 expectedMatrix.rotateAxisAngleSelf(0, 0, 1, 90); | |
Hwanseung Lee
2016/09/29 23:15:55
patch_set 1 is failed in webkit_test.
because rot
| |
61 assert_array_almost_equals(matrix2d.toFloat64Array(), expectedMatrix.toFloat64 Array()); | |
62 }, "DOMMatrix setMatrix('rotate')"); | |
63 | |
64 test(function() { | |
65 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
66 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
67 matrix2d.setMatrixValue("skewX(30deg)"); | |
68 assert_true(matrix2d.is2D); | |
69 expectedMatrix.skewXSelf(30); | |
70 assert_array_almost_equals(matrix2d.toFloat64Array(), expectedMatrix.toFloat64 Array()); | |
71 }, "DOMMatrix setMatrix('skewX')"); | |
72 | |
73 test(function() { | |
74 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
75 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
76 matrix2d.setMatrixValue("skewY(40deg)"); | |
77 assert_true(matrix2d.is2D); | |
78 expectedMatrix.skewYSelf(40); | |
79 assert_array_almost_equals(matrix2d.toFloat64Array(), expectedMatrix.toFloat64 Array()); | |
80 }, "DOMMatrix setMatrix('skewY')"); | |
81 | |
82 test(function() { | |
83 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
84 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
85 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)"); | |
86 assert_false(matrix2d.is2D); | |
87 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])) | |
88 assert_array_almost_equals(matrix2d.toFloat64Array(), expectedMatrix.toFloat64 Array()); | |
89 }, "DOMMatrix setMatrix(matrix3d)"); | |
90 | |
91 test(function() { | |
92 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
93 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
94 matrix2d.setMatrixValue("translate3d(10px, 20px, 30px)"); | |
95 assert_false(matrix2d.is2D); | |
96 expectedMatrix.translateSelf(10, 20, 30) | |
97 assert_array_almost_equals(matrix2d.toFloat64Array(), expectedMatrix.toFloat64 Array()); | |
98 }, "DOMMatrix setMatrix(translate3d)"); | |
99 | |
100 test(function() { | |
101 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
102 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
103 matrix2d.setMatrixValue("translateZ(88px)"); | |
104 assert_false(matrix2d.is2D); | |
105 expectedMatrix.translateSelf(0, 0, 88) | |
106 assert_array_almost_equals(matrix2d.toFloat64Array(), expectedMatrix.toFloat64 Array()); | |
107 }, "DOMMatrix setMatrix('translateY')"); | |
108 | |
109 test(function() { | |
110 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
111 var expectedMatrix = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
112 matrix2d.setMatrixValue("matrix(1.0, 2.0, 3.0, 4.0, 5.0, 6.0) translate(44px, 55px) skewX(30deg)"); | |
113 assert_true(matrix2d.is2D); | |
114 expectedMatrix.multiplySelf(new DOMMatrix([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])) | |
115 expectedMatrix.translateSelf(44, 55) | |
116 expectedMatrix.skewXSelf(30); | |
117 assert_array_almost_equals(matrix2d.toFloat64Array(), expectedMatrix.toFloat64 Array()); | |
118 }, "DOMMatrix setMatrix(multiple value)"); | |
119 | |
120 test(() => { | |
121 assert_throws(new SyntaxError(), () => { | |
122 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
123 matrix2d.setMatrixValue("none"); | |
124 }, "can't parsing none."); | |
125 | |
126 assert_throws(new SyntaxError(), () => { | |
127 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
128 matrix2d.setMatrixValue("notExistFunction()"); | |
129 }, "can't parsing not exist function keyword."); | |
130 | |
131 assert_throws(new SyntaxError(), () => { | |
132 var matrix2d = new DOMMatrix([1, 2, 3, 4, 5, 6]); | |
133 matrix2d.setMatrixValue("translateY(50%)"); | |
134 }, "can't parsing without absolute unit."); | |
135 | |
136 }, "DOMMatrix.setMatrix(): Exception test."); | |
137 | |
138 </script> | |
OLD | NEW |