d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp canvas = DOCUMENT && DOCUMENT.createElement("canvas"),
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Trippif(DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"))
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Trippelse if(canvas && canvas.getContext && canvas.getContext("2d"))
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp setUp: function () {
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp tearDown: function () {
7b4c159c66b840798b3abe52748239a21c614451Tripp "test default construction": function () {
7b4c159c66b840798b3abe52748239a21c614451Tripp "test render()": function () {
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp Y.one("#testbed").setContent('<div style="position:absolute;top:0px;left:0px;width:500px;height:400px" id="graphiccontainer"></div>');
7b4c159c66b840798b3abe52748239a21c614451Tripp graphic = new Y.Graphic({render: "#graphiccontainer"});
7b4c159c66b840798b3abe52748239a21c614451Tripp "test addShape(circle)": function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test mycircle.get(radius)": function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test mycircle.get(width)": function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test mycircle.get(height)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test mycircle.get(stroke)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test mycircle.get(fill)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test mycircle.get(x)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test mycircle.get(y)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test mycircle.set(stroke)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(this.updatedStrokeColor === mycircle.get("stroke").color);
7b4c159c66b840798b3abe52748239a21c614451Tripp "test mycircle.set(fill)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(this.updatedFillColor === mycircle.get("fill").color);
7b4c159c66b840798b3abe52748239a21c614451Tripp "testRemoveShape(circle)": function()
7b4c159c66b840798b3abe52748239a21c614451Tripp hasShape = (shapes.hasOwnProperty(id) && shapes[id] instanceof Y.Circle);
7b4c159c66b840798b3abe52748239a21c614451Tripp "test addShape(rect)": function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test myrect.get(width)": function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test myrect.get(height)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test myrect.get(stroke)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test myrect.get(fill)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test myrect.get(x)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test myrect.get(y)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test myrect.set(stroke)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(this.updatedStrokeColor === myrect.get("stroke").color);
2b904e83040752143af70b087f637e39035bb2e6Tripp "testRectStrokeWeightType" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test myrect.set(fill)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(this.updatedFillColor === myrect.get("fill").color);
7b4c159c66b840798b3abe52748239a21c614451Tripp "test removeShape(rect)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp hasShape = (shapes.hasOwnProperty(id) && shapes[id] instanceof Y.Rect);
7b4c159c66b840798b3abe52748239a21c614451Tripp "test addShape(ellipse)": function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test myellipse.get(width)": function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test myellipse.get(height)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test myellipse.get(stroke)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test myellipse.get(fill)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test myellipse.get(x)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test myellipse.get(y)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test myellipse.set(stroke)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(this.updatedStrokeColor === myellipse.get("stroke").color);
7b4c159c66b840798b3abe52748239a21c614451Tripp "test myellipse.set(fill)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(this.updatedFillColor === myellipse.get("fill").color);
7b4c159c66b840798b3abe52748239a21c614451Tripp "test removeShape(ellipse)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp hasShape = (shapes.hasOwnProperty(id) && shapes[id] instanceof Y.Ellipse);
7b4c159c66b840798b3abe52748239a21c614451Tripp "test addShape(path)": function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test mypath.get(width)": function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test mypath.get(height)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test mypath.get(stroke)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test mypath.get(fill)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test mypath.get(x)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test mypath.get(y)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "test mypath.set(stroke)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(this.updatedStrokeColor === mypath.get("stroke").color);
7b4c159c66b840798b3abe52748239a21c614451Tripp "test mypath.set(fill)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(this.updatedFillColor === mypath.get("fill").color);
7b4c159c66b840798b3abe52748239a21c614451Tripp "test removeShape(path)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp hasShape = (shapes.hasOwnProperty(id) && shapes[id] instanceof Y.Path);
7b4c159c66b840798b3abe52748239a21c614451Tripp "test passRotation(rect)" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp//suite of svg specific tests
7b4c159c66b840798b3abe52748239a21c614451Tripp setUp: function () {
7b4c159c66b840798b3abe52748239a21c614451Tripp tearDown: function () {
7b4c159c66b840798b3abe52748239a21c614451Tripp "testSVGGraphic()" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.one("#testbed").setContent('<div style="position:absolute;top:0px;left:0px;width:500px;height:400px" id="graphiccontainer"></div>');
7b4c159c66b840798b3abe52748239a21c614451Tripp var graphic = new Y.Graphic({render: "#graphiccontainer"});
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.Assert.isInstanceOf(SVGElement, graphic._contentNode);
7b4c159c66b840798b3abe52748239a21c614451Tripp "testSVGRectNode()" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.Assert.isInstanceOf(SVGRectElement, myrect.get("node"));
7b4c159c66b840798b3abe52748239a21c614451Tripp "testSVGRectNodeDimensions()" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "testSVGRectNodeFillColor()" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(node.getAttribute("fill") == this.initialFillColor);
7b4c159c66b840798b3abe52748239a21c614451Tripp "testSVGRectNodeFillOpacity()" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "testSVGRectNodeStrokeColor" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(node.getAttribute("stroke") == this.initialStrokeColor);
7b4c159c66b840798b3abe52748239a21c614451Tripp "testSVGRectNodeStrokeWidth" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "testSVGRectNodeStroke" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "testSVGRectNodeStrokeDashArray" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(node.getAttribute("stroke-dasharray") == "none");
7b4c159c66b840798b3abe52748239a21c614451Tripp "testSVGRectNodeStrokeLineCap" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(node.getAttribute("stroke-linecap") == "butt");
7b4c159c66b840798b3abe52748239a21c614451Tripp "testSVGRectNodeStrokeLineJoin" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(node.getAttribute("stroke-linejoin") == "round");
7b4c159c66b840798b3abe52748239a21c614451Tripp "testSVGRectNodeWidthAgainstShapeAttr" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(node.getAttribute("width") == this.myrect.get("width"));
7b4c159c66b840798b3abe52748239a21c614451Tripp "testSVGRectNodeHeightAgainstShapeAttr" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(node.getAttribute("height") == this.myrect.get("height"));
7b4c159c66b840798b3abe52748239a21c614451Tripp "testSVGRectNodeFillAgainstShapeAttr" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(opacity == node.getAttribute("fill-opacity"));
7b4c159c66b840798b3abe52748239a21c614451Tripp "testSVGRectNodeStrokeAgainstShapeAttr" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp linejoin = stroke.linejoin == undefined ? "round" : stroke.linejoin;
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(stroke.color == node.getAttribute("stroke"));
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(linejoin == node.getAttribute("stroke-linejoin"));
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(opacity == node.getAttribute("stroke-opacity"));
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(stroke.linecap == node.getAttribute("stroke-linecap"));
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(stroke.dashstyle == node.getAttribute("stroke-dasharray"));
2b904e83040752143af70b087f637e39035bb2e6Tripp Y.assert(stroke.weight == node.getAttribute("stroke-width"));
7b4c159c66b840798b3abe52748239a21c614451Tripp//suite of vml specific tests
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp setUp: function () {
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp tearDown: function () {
7b4c159c66b840798b3abe52748239a21c614451Tripp "testVMLGraphic()" : function()
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp Y.one("#testbed").setContent('<div style="position:absolute;top:0px;left:0px;width:500px;height:400px" id="graphiccontainer"></div>');
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp var graphic = new Y.Graphic({render: "#graphiccontainer"});
7b4c159c66b840798b3abe52748239a21c614451Tripp "testVMLRectNode()" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "testVMLRectNodeDimensions()" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(Y.one(node).getComputedStyle("width") == "300px");
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(Y.one(node).getComputedStyle("height") == "200px");
7b4c159c66b840798b3abe52748239a21c614451Tripp "testVMLRectNodeFillColor()" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp for(; i < len; ++i)
7b4c159c66b840798b3abe52748239a21c614451Tripp if(childNodes[i] && childNodes[i].nodeName == "fill" && childNodes[i].color == this.initialFillColor)
7b4c159c66b840798b3abe52748239a21c614451Tripp fillMatches = toHex(node.fillcolor) == toHex(this.initialFillColor) || toHex(node.fillcolor.value) == toHex(this.initialFillColor);
7b4c159c66b840798b3abe52748239a21c614451Tripp "testVMLRectNodeStrokeColor" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp for(; i < len; ++i)
7b4c159c66b840798b3abe52748239a21c614451Tripp if(childNodes[i] && childNodes[i].nodeName == "stroke" && ( toHex(childNodes[i].color) == toHex(this.initialStrokeColor) || toHex(childNodes[i].color.value) == toHex(this.initialStrokeColor)))
7b4c159c66b840798b3abe52748239a21c614451Tripp strokeMatches = toHex(node.strokecolor) == toHex(this.initialStrokeColor) || toHex(node.strokecolor.value) == toHex(this.initialStrokeColor);
7b4c159c66b840798b3abe52748239a21c614451Tripp "testVMLRectNodeStrokeWidth" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp for(; i < len; ++i)
7b4c159c66b840798b3abe52748239a21c614451Tripp if(childNodes[i] && childNodes[i].nodeName == "stroke" && childNodes[i].weight == "1")
7b4c159c66b840798b3abe52748239a21c614451Tripp "testVMLRectNodeStrokeOpacity" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp for(; i < len; ++i)
7b4c159c66b840798b3abe52748239a21c614451Tripp if(childNodes[i] && childNodes[i].nodeName == "stroke" && childNodes[i].opacity == "1")
7b4c159c66b840798b3abe52748239a21c614451Tripp "testVMLRectNodeStrokeDashArray" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp for(; i < len; ++i)
7b4c159c66b840798b3abe52748239a21c614451Tripp if(childNodes[i] && childNodes[i].nodeName == "stroke" && childNodes[i].dashstyle && childNodes[i].dashstyle == this.dashstyle)
7b4c159c66b840798b3abe52748239a21c614451Tripp "testVMLRectNodeStrokeLineCap" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp for(; i < len; ++i)
7b4c159c66b840798b3abe52748239a21c614451Tripp if(childNodes[i] && childNodes[i].nodeName == "stroke" && childNodes[i].endcap && childNodes[i].endcap == "flat")
7b4c159c66b840798b3abe52748239a21c614451Tripp "testVMLRectNodeStrokeLineJoin" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp for(; i < len; ++i)
7b4c159c66b840798b3abe52748239a21c614451Tripp if(childNodes[i] && childNodes[i].nodeName == "stroke" && childNodes[i].joinstyle && childNodes[i].joinstyle == this.linejoin)
7b4c159c66b840798b3abe52748239a21c614451Tripp "testVMLRectNodeWidthAgainstShapeAttr" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(Y.one(node).getComputedStyle("width") == this.myrect.get("width") + "px");
7b4c159c66b840798b3abe52748239a21c614451Tripp "testVMLRectNodeHeightAgainstShapeAttr" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(Y.one(node).getComputedStyle("height") == this.myrect.get("height") + "px");
7b4c159c66b840798b3abe52748239a21c614451Tripp "testVMLRectNodeFillAgainstShapeAttr" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp//suite of canvas specific tests
7b4c159c66b840798b3abe52748239a21c614451Tripp setUp: function () {
7b4c159c66b840798b3abe52748239a21c614451Tripp tearDown: function () {
7b4c159c66b840798b3abe52748239a21c614451Tripp "testCanvasGraphic()" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.one("#testbed").setContent('<div style="position:absolute;top:0px;left:0px;width:500px;height:400px" id="graphiccontainer"></div>');
7b4c159c66b840798b3abe52748239a21c614451Tripp var graphic = new Y.Graphic({render: "#graphiccontainer"});
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.Assert.isInstanceOf(HTMLElement, graphic.get("node"));
7b4c159c66b840798b3abe52748239a21c614451Tripp "testCanvasRectNode()" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "testCanvasRectNodeDimensions()" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(node.getAttribute("width") == this.width + weight);
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(node.getAttribute("height") == this.height + weight);
7b4c159c66b840798b3abe52748239a21c614451Tripp "testCanvasRectNodeFillColor()" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp opacity = Y.Lang.isNumber(opacity) && opacity < 1 ? opacity : 1;
7b4c159c66b840798b3abe52748239a21c614451Tripp if(shapeFillColor.indexOf("RGBA") > -1 || shapeFillColor.indexOf("rgba") > -1)
7b4c159c66b840798b3abe52748239a21c614451Tripp fillColor = this.toRGBA(this.TOHEX(fillColor), opacity)
7b4c159c66b840798b3abe52748239a21c614451Tripp "testCanvasRectNodeFillColorAgainstAttr()" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp opacity = Y.Lang.isNumber(opacity) && opacity < 1 ? opacity : 1;
7b4c159c66b840798b3abe52748239a21c614451Tripp if(shapeFillColor.indexOf("RGBA") > -1 || shapeFillColor.indexOf("rgba") > -1)
7b4c159c66b840798b3abe52748239a21c614451Tripp fillColor = this.toRGBA(this.TOHEX(fillColor), opacity)
7b4c159c66b840798b3abe52748239a21c614451Tripp "testCanvasRectNodeStrokeColor" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp opacity = Y.Lang.isNumber(opacity) && opacity < 1 ? opacity : 1
7b4c159c66b840798b3abe52748239a21c614451Tripp if(shapeStrokeColor.indexOf("RGBA") > -1 || shapeStrokeColor.indexOf("rgba") > -1)
7b4c159c66b840798b3abe52748239a21c614451Tripp shapeStrokeColor = shapeStrokeColor.replace(/, /g, ",");
7b4c159c66b840798b3abe52748239a21c614451Tripp strokeColor = this.toRGBA(this.TOHEX(strokeColor), opacity)
7b4c159c66b840798b3abe52748239a21c614451Tripp "testCanvasRectNodeStrokeColorAgainstAttr()" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp opacity = Y.Lang.isNumber(opacity) && opacity < 1 ? opacity : 1;
7b4c159c66b840798b3abe52748239a21c614451Tripp if(shapeStrokeColor.indexOf("RGBA") > -1 || shapeStrokeColor.indexOf("rgba") > -1)
7b4c159c66b840798b3abe52748239a21c614451Tripp shapeStrokeColor = shapeStrokeColor.replace(/, /g, ",");
7b4c159c66b840798b3abe52748239a21c614451Tripp strokeColor = this.toRGBA(this.TOHEX(strokeColor), opacity)
7b4c159c66b840798b3abe52748239a21c614451Tripp "testCanvasRectNodeStrokeWidth" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "testCanvasRectNodeStrokeWidthAgainstAttr()" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "testCanvasRectNodeStrokeLineCap" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "testCanvasRectNodeStrokeLineJoin" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "testCanvasRectNodeWidthAgainstShapeAttr" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp "testCanvasRectNodeHeightAgainstShapeAttr" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp defaultTransformString: "rotate(40) translate(45, 55) skew(30, 30)",
7b4c159c66b840798b3abe52748239a21c614451Tripp setUp: function () {
7b4c159c66b840798b3abe52748239a21c614451Tripp tearDown: function () {
7b4c159c66b840798b3abe52748239a21c614451Tripp "testGraphicInstantiation()" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.one("#testbed").setContent('<div style="position:absolute;top:0px;left:0px;width:500px;height:400px" id="graphiccontainer"></div>');
7b4c159c66b840798b3abe52748239a21c614451Tripp var graphic = new Y.Graphic({render: "#graphiccontainer"});
7b4c159c66b840798b3abe52748239a21c614451Tripp "testTransformAttributeIntantiation()" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(this.rect.get("transform") == this.defaultTransformString);
7b4c159c66b840798b3abe52748239a21c614451Tripp "testAddTransformStringAppend()" : function()
7b4c159c66b840798b3abe52748239a21c614451Tripp var scaleString = this.defaultTransformString + " scale(2, 2)";
7b4c159c66b840798b3abe52748239a21c614451Tripp "testAddTransformsAndCompareToString()": function()
7b4c159c66b840798b3abe52748239a21c614451Tripp Y.assert(this.rect.get("transform") == "translate(30, 10) rotate(90) skewX(10)");
28e8b297bc9a35b81b8507d1d11cb005703f850fTripp setUp: function () {
28e8b297bc9a35b81b8507d1d11cb005703f850fTripp Y.one("#testbed").setContent('<div style="position:absolute;top:0px;left:0px;width:500px;height:400px" id="graphiccontainer"></div>');
28e8b297bc9a35b81b8507d1d11cb005703f850fTripp this.graphic = new Y.Graphic({render: "#graphiccontainer"});
28e8b297bc9a35b81b8507d1d11cb005703f850fTripp tearDown: function () {
28e8b297bc9a35b81b8507d1d11cb005703f850fTripp "testSetVisibleUpfront()" : function()