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 <script src="./resources/geometry-interfaces-test-helpers.js"></script> | 4 <script src="./resources/geometry-interfaces-test-helpers.js"></script> |
5 <script> | 5 <script> |
6 test(() => { | 6 test(() => { |
7 var p1 = new DOMPoint(0, 1, 3, 4); | 7 var p1 = new DOMPoint(0, 1, 3, 4); |
8 var p2 = new DOMPoint(5, 6, 7, 8); | 8 var p2 = new DOMPoint(5, 6, 7, 8); |
9 var p3 = new DOMPoint(9, 10, 11, 12); | 9 var p3 = new DOMPoint(9, 10, 11, 12); |
10 var p4 = new DOMPoint(13, 14, 15, 16); | 10 var p4 = new DOMPoint(13, 14, 15, 16); |
11 var quad = new DOMQuad(p1, p2, p3, p4); | 11 var quad = new DOMQuad(p1, p2, p3, p4); |
12 assert_dom_point_equals(quad.p1, p1); | 12 assert_dom_point_equals(quad.p1, p1); |
13 assert_dom_point_equals(quad.p2, p2); | 13 assert_dom_point_equals(quad.p2, p2); |
14 assert_dom_point_equals(quad.p3, p3); | 14 assert_dom_point_equals(quad.p3, p3); |
15 assert_dom_point_equals(quad.p4, p4); | 15 assert_dom_point_equals(quad.p4, p4); |
16 }, "DOMQuad() constructor"); | 16 }, "DOMQuad() constructor"); |
17 | 17 |
18 test(() => { | 18 test(() => { |
19 var p1 = new DOMPoint(0, 1, 3, 4); | 19 var p1 = new DOMPoint(0, 1, 3, 4); |
20 var p2 = new DOMPoint(5, 6, 7, 8); | 20 var p2 = new DOMPoint(5, 6, 7, 8); |
21 var p3 = new DOMPoint(9, 10, 11, 12); | 21 var p3 = new DOMPoint(9, 10, 11, 12); |
22 var p4 = new DOMPoint(13, 14, 15, 16); | 22 var p4 = new DOMPoint(13, 14, 15, 16); |
23 var quad = new DOMQuad(p1, p2, p3, p4); | 23 var quad = new DOMQuad(p1, p2, p3, p4); |
24 assert_dom_point_equals(quad.toJSON().p1, p1, "p1"); | 24 assert_dom_point_equals(quad.toJSON().p1, p1, "p1"); |
25 assert_dom_point_equals(quad.toJSON().p2, p2, "p2"); | 25 assert_dom_point_equals(quad.toJSON().p2, p2, "p2"); |
26 assert_dom_point_equals(quad.toJSON().p3, p3, "p3"); | 26 assert_dom_point_equals(quad.toJSON().p3, p3, "p3"); |
27 assert_dom_point_equals(quad.toJSON().p4, p4, "p4"); | 27 assert_dom_point_equals(quad.toJSON().p4, p4, "p4"); |
28 }, "DOMQuad() toJSON()"); | 28 }, "DOMQuad() toJSON()"); |
29 | 29 |
30 test(() => { | 30 test(() => { |
31 var expect_p1 = new DOMPoint(10, 20, 0, 1); | 31 var expect_p1 = new DOMPoint(10, 20, 0, 1); |
32 var expect_p2 = new DOMPoint(90, 20, 0, 1); | 32 var expect_p2 = new DOMPoint(90, 20, 0, 1); |
33 var expect_p3 = new DOMPoint(90, 70, 0, 1); | 33 var expect_p3 = new DOMPoint(90, 70, 0, 1); |
34 var expect_p4 = new DOMPoint(10, 70, 0, 1); | 34 var expect_p4 = new DOMPoint(10, 70, 0, 1); |
35 var quad = DOMQuad.fromRect({x: 10, y: 20, width: 80, height: 50}); | 35 var quad = DOMQuad.fromRect({x: 10, y: 20, width: 80, height: 50}); |
36 assert_dom_point_equals(quad.p1, expect_p1, "p1"); | 36 assert_dom_point_equals(quad.p1, expect_p1, "p1"); |
37 assert_dom_point_equals(quad.p2, expect_p2, "p2"); | 37 assert_dom_point_equals(quad.p2, expect_p2, "p2"); |
38 assert_dom_point_equals(quad.p3, expect_p3, "p3"); | 38 assert_dom_point_equals(quad.p3, expect_p3, "p3"); |
39 assert_dom_point_equals(quad.p4, expect_p4, "p4"); | 39 assert_dom_point_equals(quad.p4, expect_p4, "p4"); |
40 }, "DOMQuad() fromRect"); | 40 }, "DOMQuad() fromRect"); |
41 | 41 |
| 42 test(() => { |
| 43 var expect_p1 = new DOMPoint(0, 1, 2, 3); |
| 44 var expect_p2 = new DOMPoint(4, 5, 6, 7); |
| 45 var expect_p3 = new DOMPoint(8, 9, 10, 11); |
| 46 var expect_p4 = new DOMPoint(12, 13, 14, 15); |
| 47 var quad = DOMQuad.fromQuad({p1: {x: 0, y: 1, z: 2, w: 3}, |
| 48 p2: {x: 4, y: 5, z: 6, w: 7}, |
| 49 p3: {x: 8, y: 9, z: 10, w: 11}, |
| 50 p4: {x: 12, y: 13, z: 14, w: 15}}); |
| 51 assert_dom_point_equals(quad.p1, expect_p1, "p1"); |
| 52 assert_dom_point_equals(quad.p2, expect_p2, "p2"); |
| 53 assert_dom_point_equals(quad.p3, expect_p3, "p3"); |
| 54 assert_dom_point_equals(quad.p4, expect_p4, "p4"); |
| 55 }, "DOMQuad() fromQuad"); |
| 56 |
| 57 test(() => { |
| 58 var expect_p1 = new DOMPoint(0, 0, 0, 1); |
| 59 var expect_p2 = new DOMPoint(0, 0, 0, 1); |
| 60 var expect_p3 = new DOMPoint(0, 0, 0, 1); |
| 61 var expect_p4 = new DOMPoint(0, 0, 0, 1); |
| 62 var quad = DOMQuad.fromQuad({}); |
| 63 assert_dom_point_equals(quad.p1, expect_p1, "p1"); |
| 64 assert_dom_point_equals(quad.p2, expect_p2, "p2"); |
| 65 assert_dom_point_equals(quad.p3, expect_p3, "p3"); |
| 66 assert_dom_point_equals(quad.p4, expect_p4, "p4"); |
| 67 }, "DOMQuad() fromQuad - parameter of fromQuad function does not have any point.
"); |
| 68 |
42 </script> | 69 </script> |
OLD | NEW |