OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE HTML> |
| 2 <script src="../../resources/js-test.js"></script> |
| 3 <script src="resources/SVGTransformList-helper.js"></script> |
| 4 |
| 5 <svg id="svg" xmlns="http://www.w3.org/2000/svg" width="200" height="200"> |
| 6 <circle id="circle1" cx="40" cy="40" r="40" fill="green" transform="scale(2,
2)"/> |
| 7 <circle id="circle2" cx="40" cy="40" r="40" fill="green" transform="scale(2,
2)"/> |
| 8 </svg> |
| 9 |
| 10 <script type="text/javascript"> |
| 11 description("This is a test of more SVGTransformList API parts."); |
| 12 |
| 13 if (window.testRunner) |
| 14 testRunner.dumpAsText(); |
| 15 |
| 16 var svg = document.getElementById("svg"); |
| 17 var circle1 = document.getElementById("circle1"); |
| 18 var circle2 = document.getElementById("circle2"); |
| 19 |
| 20 var translate = svg.createSVGTransform(); |
| 21 translate.setTranslate(100, 100); |
| 22 |
| 23 var scale = svg.createSVGTransform(); |
| 24 scale.setScale(3, 3); |
| 25 |
| 26 var transformList1 = circle1.transform.baseVal; |
| 27 var transformList2 = circle2.transform.baseVal; |
| 28 |
| 29 debug("Test appendItem with SVGTransform that already exist in a list"); |
| 30 transformList1.appendItem(translate); |
| 31 transformList2.appendItem(translate); |
| 32 shouldBe("transformList1.numberOfItems", "2"); |
| 33 shouldBe("transformList2.numberOfItems", "2"); |
| 34 shouldBeEqualToString("transformList1.getItem(1).toString()", "type=SVG_TRAN
SFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 100.0 100.0]"); |
| 35 shouldBeEqualToString("transformList2.getItem(1).toString()", "type=SVG_TRAN
SFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 100.0 100.0]"); |
| 36 |
| 37 debug(""); |
| 38 debug("Test changing SVGTransform value"); |
| 39 translate.setTranslate(200, 200); |
| 40 shouldBeEqualToString("transformList1.getItem(1).toString()", "type=SVG_TRAN
SFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 200.0 200.0]"); |
| 41 shouldBeEqualToString("transformList2.getItem(1).toString()", "type=SVG_TRAN
SFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 100.0 100.0]"); |
| 42 |
| 43 debug(""); |
| 44 debug("Test insertItemBefore with SVGTransform that already exist in a list"
); |
| 45 transformList1.insertItemBefore(translate,0); |
| 46 transformList2.insertItemBefore(translate,0); |
| 47 shouldBeEqualToString("transformList1.getItem(0).toString()", "type=SVG_TRAN
SFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 200.0 200.0]"); |
| 48 shouldBeEqualToString("transformList2.getItem(0).toString()", "type=SVG_TRAN
SFORM_TRANSLATE matrix=[1.0 0.0 0.0 1.0 200.0 200.0]"); |
| 49 shouldBe("transformList1.numberOfItems", "3"); |
| 50 shouldBe("transformList2.numberOfItems", "3"); |
| 51 |
| 52 debug(""); |
| 53 debug("Test replaceItem with SVGTransform that already exist in a list"); |
| 54 transformList1.replaceItem(scale,2); |
| 55 transformList2.replaceItem(scale,2); |
| 56 shouldBeEqualToString("transformList1.getItem(2).toString()", "type=SVG_TRAN
SFORM_SCALE matrix=[3.0 0.0 0.0 3.0 0.0 0.0]"); |
| 57 shouldBeEqualToString("transformList2.getItem(2).toString()", "type=SVG_TRAN
SFORM_SCALE matrix=[3.0 0.0 0.0 3.0 0.0 0.0]"); |
| 58 shouldBe("transformList1.numberOfItems", "3"); |
| 59 shouldBe("transformList2.numberOfItems", "3"); |
| 60 |
| 61 debug(""); |
| 62 debug("Test initialize with SVGTransform that already exist in a list"); |
| 63 transformList1.initialize(scale); |
| 64 transformList2.initialize(scale); |
| 65 shouldBeEqualToString("transformList1.getItem(0).toString()", "type=SVG_TRAN
SFORM_SCALE matrix=[3.0 0.0 0.0 3.0 0.0 0.0]"); |
| 66 shouldBeEqualToString("transformList2.getItem(0).toString()", "type=SVG_TRAN
SFORM_SCALE matrix=[3.0 0.0 0.0 3.0 0.0 0.0]"); |
| 67 shouldBe("transformList1.numberOfItems", "1"); |
| 68 shouldBe("transformList2.numberOfItems", "1"); |
| 69 |
| 70 </script> |
OLD | NEW |