OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../resources/testharness.js"></script> | 2 <script src="../resources/testharness.js"></script> |
3 <script src="../resources/testharnessreport.js"></script> | 3 <script src="../resources/testharnessreport.js"></script> |
4 | 4 |
5 <script> | 5 <script> |
6 var EPSILON = 1e-6; // float epsilon | 6 var EPSILON = 1e-6; // float epsilon |
7 function angle(deg) { | 7 function angle(deg) { |
8 return new CSSAngleValue(deg, 'deg'); | 8 return new CSSAngleValue(deg, 'deg'); |
9 } | 9 } |
10 var values = [ | 10 var values = [ |
11 {input: new CSSRotation(angle(0)), angle: 0, x: 0, y: 0, z: 1, | 11 {input: new CSSRotation(angle(0)), angle: 0, x: 0, y: 0, z: 1, |
12 is2D: true, cssText: "rotate(0deg)", | 12 is2D: true, cssText: "rotate(0deg)", |
13 asMatrix: new CSSMatrixTransformComponent(1, 0, 0, 1, 0, 0)}, | 13 asMatrix: new CSSMatrixComponent(1, 0, 0, 1, 0, 0)}, |
14 {input: new CSSRotation(angle(10)), angle: 10, x: 0, y: 0, z: 1, | 14 {input: new CSSRotation(angle(10)), angle: 10, x: 0, y: 0, z: 1, |
15 is2D: true, cssText: "rotate(10deg)", | 15 is2D: true, cssText: "rotate(10deg)", |
16 asMatrix: new CSSMatrixTransformComponent(0.9848077, 0.1736481, -0.1736481,
0.9848077, 0, 0)}, | 16 asMatrix: new CSSMatrixComponent(0.9848077, 0.1736481, -0.1736481, 0.9848077
, 0, 0)}, |
17 {input: new CSSRotation(angle(-21)), angle: -21, x: 0, y: 0, z: 1, | 17 {input: new CSSRotation(angle(-21)), angle: -21, x: 0, y: 0, z: 1, |
18 is2D: true, cssText: "rotate(-21deg)", | 18 is2D: true, cssText: "rotate(-21deg)", |
19 asMatrix: new CSSMatrixTransformComponent(0.9335804, -0.3583679, 0.3583679,
0.9335804, 0, 0)}, | 19 asMatrix: new CSSMatrixComponent(0.9335804, -0.3583679, 0.3583679, 0.9335804
, 0, 0)}, |
20 {input: new CSSRotation(angle(3.2)), angle: 3.2, x: 0, y: 0, z: 1, | 20 {input: new CSSRotation(angle(3.2)), angle: 3.2, x: 0, y: 0, z: 1, |
21 is2D: true, cssText: "rotate(3.2deg)", | 21 is2D: true, cssText: "rotate(3.2deg)", |
22 asMatrix: new CSSMatrixTransformComponent(0.9984407, 0.0558215, -0.0558215,
0.9984407, 0, 0)}, | 22 asMatrix: new CSSMatrixComponent(0.9984407, 0.0558215, -0.0558215, 0.9984407
, 0, 0)}, |
23 {input: new CSSRotation(0, 0, 1, angle(90)), angle: 90, x: 0, y: 0, z: 1, | 23 {input: new CSSRotation(0, 0, 1, angle(90)), angle: 90, x: 0, y: 0, z: 1, |
24 is2D: false, cssText: "rotate3d(0, 0, 1, 90deg)", | 24 is2D: false, cssText: "rotate3d(0, 0, 1, 90deg)", |
25 asMatrix: new CSSMatrixTransformComponent(0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 1)}, | 25 asMatrix: new CSSMatrixComponent(0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0,
0, 1)}, |
26 {input: new CSSRotation(2.7, -3, 4.4, angle(0)), angle: 0, x: 2.7, y: -3, z: 4
.4, | 26 {input: new CSSRotation(2.7, -3, 4.4, angle(0)), angle: 0, x: 2.7, y: -3, z: 4
.4, |
27 is2D: false, cssText: "rotate3d(2.7, -3, 4.4, 0deg)", | 27 is2D: false, cssText: "rotate3d(2.7, -3, 4.4, 0deg)", |
28 asMatrix: new CSSMatrixTransformComponent(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0
, 0, 0, 0, 1)}, | 28 asMatrix: new CSSMatrixComponent(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0
, 1)}, |
29 {input: new CSSRotation(2, 3, 4, angle(10)), angle: 10, x: 2, y: 3, z: 4, | 29 {input: new CSSRotation(2, 3, 4, angle(10)), angle: 10, x: 2, y: 3, z: 4, |
30 is2D: false, cssText: "rotate3d(2, 3, 4, 10deg)", | 30 is2D: false, cssText: "rotate3d(2, 3, 4, 10deg)", |
31 asMatrix: new CSSMatrixTransformComponent(0.9869032, 0.1321258, -0.0925460,
0, -0.1258394, | 31 asMatrix: new CSSMatrixComponent(0.9869032, 0.1321258, -0.0925460, 0, -0.125
8394, |
32 0.9895225, 0.0707777, 0, 0.1009279, -0.0582048, 0.9931896, 0, 0, 0, 0, 1)}
, | 32 0.9895225, 0.0707777, 0, 0.1009279, -0.0582048, 0.9931896, 0, 0, 0, 0, 1)}
, |
33 {input: new CSSRotation(2, 3.7, -4, angle(-1.2)), angle: -1.2, x: 2, y: 3.7, z
: -4, | 33 {input: new CSSRotation(2, 3.7, -4, angle(-1.2)), angle: -1.2, x: 2, y: 3.7, z
: -4, |
34 is2D: false, cssText: "rotate3d(2, 3.7, -4, -1.2deg)", | 34 is2D: false, cssText: "rotate3d(2, 3.7, -4, -1.2deg)", |
35 asMatrix: new CSSMatrixTransformComponent(0.9998067, 0.01448049, 0.0132978,
0, -0.0143841, | 35 asMatrix: new CSSMatrixComponent(0.9998067, 0.01448049, 0.0132978, 0, -0.014
3841, |
36 0.9998698, -0.0073125, 0, -0.0134019, 0.0071198, 0.9998848, 0, 0, 0, 0, 1)}, | 36 0.9998698, -0.0073125, 0, -0.0134019, 0.0071198, 0.9998848, 0, 0, 0, 0, 1)}, |
37 {input: new CSSRotation(1, 0, 0, new CSSAngleValue(0.5, 'turn')), angle: 180,
x: 1, y: 0, z: 0, | 37 {input: new CSSRotation(1, 0, 0, new CSSAngleValue(0.5, 'turn')), angle: 180,
x: 1, y: 0, z: 0, |
38 is2D: false, cssText: "rotate3d(1, 0, 0, 0.5turn)", | 38 is2D: false, cssText: "rotate3d(1, 0, 0, 0.5turn)", |
39 asMatrix: new CSSMatrixTransformComponent(1, 0, 0, 0, 0, -1, 1.2246467991473
532e-16, 0, 0, | 39 asMatrix: new CSSMatrixComponent(1, 0, 0, 0, 0, -1, 1.2246467991473532e-16,
0, 0, |
40 -1.2246467991473532e-16, -1, 0, 0, 0, 0, 1)} | 40 -1.2246467991473532e-16, -1, 0, 0, 0, 0, 1)} |
41 ]; | 41 ]; |
42 | 42 |
43 test(function() { | 43 test(function() { |
44 for (var i = 0; i < values.length; ++i) { | 44 for (var i = 0; i < values.length; ++i) { |
45 assert_equals(values[i].input.angle.degrees, values[i].angle); | 45 assert_equals(values[i].input.angle.degrees, values[i].angle); |
46 assert_equals(values[i].input.x, values[i].x); | 46 assert_equals(values[i].input.x, values[i].x); |
47 assert_equals(values[i].input.y, values[i].y); | 47 assert_equals(values[i].input.y, values[i].y); |
48 assert_equals(values[i].input.z, values[i].z); | 48 assert_equals(values[i].input.z, values[i].z); |
49 } | 49 } |
(...skipping 24 matching lines...) Expand all Loading... |
74 // Due to the complex trigonometric calculations required for a CSSRotat
ion matrix, | 74 // Due to the complex trigonometric calculations required for a CSSRotat
ion matrix, |
75 // the 6 significant figures of each value in the cssText might be diffe
rent. | 75 // the 6 significant figures of each value in the cssText might be diffe
rent. |
76 // Hence, do not check cssText. | 76 // Hence, do not check cssText. |
77 assert_equals(inputAsMatrix[attribute], expectedMatrix[attribute]); | 77 assert_equals(inputAsMatrix[attribute], expectedMatrix[attribute]); |
78 } | 78 } |
79 } | 79 } |
80 } | 80 } |
81 }, "Test that asMatrix is constructed correctly for CSSRotation."); | 81 }, "Test that asMatrix is constructed correctly for CSSRotation."); |
82 | 82 |
83 </script> | 83 </script> |
OLD | NEW |