OLD | NEW |
---|---|
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Geometry Interfaces: DOMMatrix</title> | 4 <title>Geometry Interfaces: DOMMatrix</title> |
5 <script src="../../resources/js-test.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
6 </head> | 6 </head> |
7 <body> | 7 <body> |
8 <script> | 8 <script> |
9 | 9 |
10 debug("# DOMMatrix()"); | 10 test(function() { |
11 var matrix = new DOMMatrix(); | 11 var matrix = new DOMMatrix(); |
12 shouldBe("matrix.a", "matrix.m11"); | 12 assert_equals(matrix.m11, 1); |
13 shouldBe("matrix.b", "matrix.m12"); | 13 assert_equals(matrix.m12, 0); |
14 shouldBe("matrix.c", "matrix.m21"); | 14 assert_equals(matrix.m13, 0); |
15 shouldBe("matrix.d", "matrix.m22"); | 15 assert_equals(matrix.m14, 0); |
16 shouldBe("matrix.e", "matrix.m41"); | 16 assert_equals(matrix.m21, 0); |
17 shouldBe("matrix.f", "matrix.m42"); | 17 assert_equals(matrix.m22, 1); |
18 shouldBe("matrix.m11", "1"); | 18 assert_equals(matrix.m23, 0); |
19 shouldBe("matrix.m12", "0"); | 19 assert_equals(matrix.m24, 0); |
20 shouldBe("matrix.m13", "0"); | 20 assert_equals(matrix.m31, 0); |
21 shouldBe("matrix.m14", "0"); | 21 assert_equals(matrix.m32, 0); |
22 shouldBe("matrix.m21", "0"); | 22 assert_equals(matrix.m33, 1); |
23 shouldBe("matrix.m22", "1"); | 23 assert_equals(matrix.m34, 0); |
24 shouldBe("matrix.m23", "0"); | 24 assert_equals(matrix.m41, 0); |
25 shouldBe("matrix.m24", "0"); | 25 assert_equals(matrix.m42, 0); |
26 shouldBe("matrix.m31", "0"); | 26 assert_equals(matrix.m43, 0); |
27 shouldBe("matrix.m32", "0"); | 27 assert_equals(matrix.m44, 1); |
28 shouldBe("matrix.m33", "1"); | 28 assert_true(matrix.is2D); |
29 shouldBe("matrix.m34", "0"); | 29 assert_true(matrix.isIdentity); |
30 shouldBe("matrix.m41", "0"); | 30 }, "DOMMatrix() constructor"); |
31 shouldBe("matrix.m42", "0"); | |
32 shouldBe("matrix.m43", "0"); | |
33 shouldBe("matrix.m44", "1"); | |
34 shouldBeTrue("matrix.is2D"); | |
35 shouldBeTrue("matrix.isIdentity"); | |
36 debug(""); | |
37 | 31 |
38 debug("# DOMMatrix set attributes"); | 32 test(function() { |
39 matrix.a = 10; | 33 var other = new DOMMatrix(); |
40 matrix.b = 20; | 34 other.m11 = 10; |
41 matrix.m24 = 2; | 35 other.m12 = 20; |
42 matrix.m33 = 3; | 36 other.m24 = 2; |
43 matrix.m42 = 3; | 37 other.m33 = 3; |
44 matrix.m44 = 9; | 38 other.m42 = 3; |
45 shouldBe("matrix.a", "matrix.m11"); | 39 other.m44 = 9; |
pdr.
2014/08/25 01:54:08
Why did you remove these tests (e.g., matrix.a ==
zino
2014/08/25 05:43:37
The test cases is still checked in |DOMMatrix attr
| |
46 shouldBe("matrix.b", "matrix.m12"); | |
47 shouldBe("matrix.c", "matrix.m21"); | |
48 shouldBe("matrix.d", "matrix.m22"); | |
49 shouldBe("matrix.e", "matrix.m41"); | |
50 shouldBe("matrix.f", "matrix.m42"); | |
51 shouldBe("matrix.m11", "10"); | |
52 shouldBe("matrix.m12", "20"); | |
53 shouldBe("matrix.m13", "0"); | |
54 shouldBe("matrix.m14", "0"); | |
55 shouldBe("matrix.m21", "0"); | |
56 shouldBe("matrix.m22", "1"); | |
57 shouldBe("matrix.m23", "0"); | |
58 shouldBe("matrix.m24", "2"); | |
59 shouldBe("matrix.m31", "0"); | |
60 shouldBe("matrix.m32", "0"); | |
61 shouldBe("matrix.m33", "3"); | |
62 shouldBe("matrix.m34", "0"); | |
63 shouldBe("matrix.m41", "0"); | |
64 shouldBe("matrix.m42", "3"); | |
65 shouldBe("matrix.m43", "0"); | |
66 shouldBe("matrix.m44", "9"); | |
67 shouldBeFalse("matrix.is2D"); | |
68 shouldBeFalse("matrix.isIdentity"); | |
69 debug(""); | |
70 | 40 |
71 debug("# DOMMatrix(other)"); | 41 var matrix = new DOMMatrix(other); |
72 var other = matrix; | 42 assert_equals(matrix.m11, 10); |
73 matrix = new DOMMatrix(other); | 43 assert_equals(matrix.m12, 20); |
74 shouldBe("matrix.a", "matrix.m11"); | 44 assert_equals(matrix.m13, 0); |
75 shouldBe("matrix.b", "matrix.m12"); | 45 assert_equals(matrix.m14, 0); |
76 shouldBe("matrix.c", "matrix.m21"); | 46 assert_equals(matrix.m21, 0); |
77 shouldBe("matrix.d", "matrix.m22"); | 47 assert_equals(matrix.m22, 1); |
78 shouldBe("matrix.e", "matrix.m41"); | 48 assert_equals(matrix.m23, 0); |
79 shouldBe("matrix.f", "matrix.m42"); | 49 assert_equals(matrix.m24, 2); |
80 shouldBe("matrix.m11", "10"); | 50 assert_equals(matrix.m31, 0); |
81 shouldBe("matrix.m12", "20"); | 51 assert_equals(matrix.m32, 0); |
82 shouldBe("matrix.m13", "0"); | 52 assert_equals(matrix.m33, 3); |
83 shouldBe("matrix.m14", "0"); | 53 assert_equals(matrix.m34, 0); |
84 shouldBe("matrix.m21", "0"); | 54 assert_equals(matrix.m41, 0); |
85 shouldBe("matrix.m22", "1"); | 55 assert_equals(matrix.m42, 3); |
86 shouldBe("matrix.m23", "0"); | 56 assert_equals(matrix.m43, 0); |
87 shouldBe("matrix.m24", "2"); | 57 assert_equals(matrix.m44, 9); |
88 shouldBe("matrix.m31", "0"); | 58 assert_false(matrix.is2D); |
89 shouldBe("matrix.m32", "0"); | 59 assert_false(matrix.isIdentity); |
90 shouldBe("matrix.m33", "3"); | 60 }, "DOMMatrix(other) constructor"); |
91 shouldBe("matrix.m34", "0"); | |
92 shouldBe("matrix.m41", "0"); | |
93 shouldBe("matrix.m42", "3"); | |
94 shouldBe("matrix.m43", "0"); | |
95 shouldBe("matrix.m44", "9"); | |
96 shouldBeFalse("matrix.is2D"); | |
97 shouldBeFalse("matrix.isIdentity"); | |
98 debug(""); | |
99 | 61 |
100 debug("# DOMMatrix.is2D can never be set to 'true' when it was set to 'false' be fore calling setMatrixValue()."); | 62 test(function() { |
101 matrix = new DOMMatrix(); | 63 var matrix = new DOMMatrix(); |
102 shouldBeTrue("matrix.is2D"); | 64 matrix.a = 10; |
103 shouldBeTrue("matrix.isIdentity"); | 65 matrix.b = 20; |
104 matrix.m31 = 1; | 66 matrix.m24 = 2; |
105 matrix.m33 = 0; | 67 matrix.m33 = 3; |
106 shouldBeFalse("matrix.is2D"); | 68 matrix.m42 = 3; |
107 shouldBeFalse("matrix.isIdentity"); | 69 matrix.m44 = 9; |
108 matrix.m31 = 0; | 70 assert_equals(matrix.a, matrix.m11); |
109 matrix.m33 = 1; | 71 assert_equals(matrix.b, matrix.m12); |
110 shouldBeFalse("matrix.is2D"); | 72 assert_equals(matrix.c, matrix.m21); |
111 shouldBeTrue("matrix.isIdentity"); | 73 assert_equals(matrix.d, matrix.m22); |
112 debug(""); | 74 assert_equals(matrix.e, matrix.m41); |
75 assert_equals(matrix.f, matrix.m42); | |
76 assert_equals(matrix.m11, 10); | |
77 assert_equals(matrix.m12, 20); | |
78 assert_equals(matrix.m13, 0); | |
79 assert_equals(matrix.m14, 0); | |
80 assert_equals(matrix.m21, 0); | |
81 assert_equals(matrix.m22, 1); | |
82 assert_equals(matrix.m23, 0); | |
83 assert_equals(matrix.m24, 2); | |
84 assert_equals(matrix.m31, 0); | |
85 assert_equals(matrix.m32, 0); | |
86 assert_equals(matrix.m33, 3); | |
87 assert_equals(matrix.m34, 0); | |
88 assert_equals(matrix.m41, 0); | |
89 assert_equals(matrix.m42, 3); | |
90 assert_equals(matrix.m43, 0); | |
91 assert_equals(matrix.m44, 9); | |
92 assert_false(matrix.is2D); | |
93 assert_false(matrix.isIdentity); | |
94 }, "DOMMatrix attributes"); | |
95 | |
96 test(function() { | |
97 var matrix = new DOMMatrix(); | |
98 assert_true(matrix.is2D); | |
99 assert_true(matrix.isIdentity); | |
100 matrix.m31 = 1; | |
101 matrix.m33 = 0; | |
102 assert_false(matrix.is2D); | |
103 assert_false(matrix.isIdentity); | |
104 matrix.m31 = 0; | |
105 matrix.m33 = 1; | |
106 assert_false(matrix.is2D); | |
107 assert_true(matrix.isIdentity); | |
108 }, "DOMMatrix.is2D can never be set to 'true' when it was set to 'false' before calling setMatrixValue()."); | |
113 | 109 |
114 </script> | 110 </script> |
115 </body> | 111 </body> |
116 </html> | 112 </html> |
OLD | NEW |