graphics-tests.js revision e7f83e93bb5c263f4c00b4a9438330da561df764
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"))
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp//suite of svg specific tests
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp setUp: function () {
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp tearDown: function () {
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testSVGGraphic()" : function()
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp Y.one("#testbed").setContent('<div style="position:absolute;top:0px;left:0px;width:500px;height:400px" id="graphiccontainer"></div>');
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp var graphic = new Y.Graphic({render: "#graphiccontainer"});
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp Y.Assert.isInstanceOf(SVGElement, graphic._contentNode);
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testSVGRectNode()" : function()
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp Y.Assert.isInstanceOf(SVGRectElement, myrect.get("node"));
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testSVGRectNodeDimensions()" : function()
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testSVGRectNodeFillColor()" : function()
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp Y.assert(node.getAttribute("fill") == this.initialFillColor);
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testSVGRectNodeFillOpacity()" : function()
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testSVGRectNodeStrokeColor" : function()
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp Y.assert(node.getAttribute("stroke") == this.initialStrokeColor);
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testSVGRectNodeStrokeWidth" : function()
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testSVGRectNodeStroke" : function()
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testSVGRectNodeStrokeDashArray" : function()
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp Y.assert(node.getAttribute("stroke-dasharray") == "none");
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testSVGRectNodeStrokeLineCap" : function()
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp Y.assert(node.getAttribute("stroke-linecap") == "butt");
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testSVGRectNodeStrokeLineJoin" : function()
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp Y.assert(node.getAttribute("stroke-linejoin") == "round");
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testSVGRectNodeWidthAgainstShapeAttr" : function()
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp Y.assert(node.getAttribute("width") == this.myrect.get("width"));
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testSVGRectNodeHeightAgainstShapeAttr" : function()
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp Y.assert(node.getAttribute("height") == this.myrect.get("height"));
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testSVGRectNodeFillAgainstShapeAttr" : function()
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp Y.assert(opacity == node.getAttribute("fill-opacity"));
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testSVGRectNodeStrokeAgainstShapeAttr" : function()
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp linejoin = stroke.linejoin == undefined ? "round" : stroke.linejoin;
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp Y.assert(stroke.color == node.getAttribute("stroke"));
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp Y.assert(linejoin == node.getAttribute("stroke-linejoin"));
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp Y.assert(opacity == node.getAttribute("stroke-opacity"));
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp Y.assert(stroke.linecap == node.getAttribute("stroke-linecap"));
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp Y.assert(stroke.dashstyle == node.getAttribute("stroke-dasharray"));
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp//suite of vml specific tests
c093c1aed867e18aa4778708592e1ceb45d18cffTripp setUp: function () {
c093c1aed867e18aa4778708592e1ceb45d18cffTripp tearDown: function () {
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testVMLGraphic()" : function()
c093c1aed867e18aa4778708592e1ceb45d18cffTripp Y.one("#testbed").setContent('<div style="position:absolute;top:0px;left:0px;width:500px;height:400px" id="graphiccontainer"></div>');
c093c1aed867e18aa4778708592e1ceb45d18cffTripp var graphic = new Y.Graphic({render: "#graphiccontainer"});
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testVMLRectNode()" : function()
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testVMLRectNodeDimensions()" : function()
c093c1aed867e18aa4778708592e1ceb45d18cffTripp Y.assert(Y.one(node).getComputedStyle("width") == "300px");
c093c1aed867e18aa4778708592e1ceb45d18cffTripp Y.assert(Y.one(node).getComputedStyle("height") == "200px");
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testVMLRectNodeFillColor()" : function()
c093c1aed867e18aa4778708592e1ceb45d18cffTripp for(; i < len; ++i)
c093c1aed867e18aa4778708592e1ceb45d18cffTripp if(childNodes[i] && childNodes[i].nodeName == "fill" && childNodes[i].color == this.initialFillColor)
c093c1aed867e18aa4778708592e1ceb45d18cffTripp fillMatches = toHex(node.fillcolor) == toHex(this.initialFillColor) || toHex(node.fillcolor.value) == toHex(this.initialFillColor);
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testVMLRectNodeStrokeColor" : function()
c093c1aed867e18aa4778708592e1ceb45d18cffTripp for(; i < len; ++i)
c093c1aed867e18aa4778708592e1ceb45d18cffTripp if(childNodes[i] && childNodes[i].nodeName == "stroke" && ( toHex(childNodes[i].color) == toHex(this.initialStrokeColor) || toHex(childNodes[i].color.value) == toHex(this.initialStrokeColor)))
c093c1aed867e18aa4778708592e1ceb45d18cffTripp strokeMatches = toHex(node.strokecolor) == toHex(this.initialStrokeColor) || toHex(node.strokecolor.value) == toHex(this.initialStrokeColor);
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testVMLRectNodeStrokeWidth" : function()
c093c1aed867e18aa4778708592e1ceb45d18cffTripp for(; i < len; ++i)
c093c1aed867e18aa4778708592e1ceb45d18cffTripp if(childNodes[i] && childNodes[i].nodeName == "stroke" && childNodes[i].weight == "1")
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testVMLRectNodeStrokeOpacity" : function()
c093c1aed867e18aa4778708592e1ceb45d18cffTripp for(; i < len; ++i)
c093c1aed867e18aa4778708592e1ceb45d18cffTripp if(childNodes[i] && childNodes[i].nodeName == "stroke" && childNodes[i].opacity == "1")
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testVMLRectNodeStrokeDashArray" : function()
c093c1aed867e18aa4778708592e1ceb45d18cffTripp for(; i < len; ++i)
c093c1aed867e18aa4778708592e1ceb45d18cffTripp if(childNodes[i] && childNodes[i].nodeName == "stroke" && childNodes[i].dashstyle && childNodes[i].dashstyle == this.dashstyle)
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testVMLRectNodeStrokeLineCap" : function()
c093c1aed867e18aa4778708592e1ceb45d18cffTripp for(; i < len; ++i)
c093c1aed867e18aa4778708592e1ceb45d18cffTripp if(childNodes[i] && childNodes[i].nodeName == "stroke" && childNodes[i].endcap && childNodes[i].endcap == "flat")
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testVMLRectNodeStrokeLineJoin" : function()
c093c1aed867e18aa4778708592e1ceb45d18cffTripp for(; i < len; ++i)
c093c1aed867e18aa4778708592e1ceb45d18cffTripp if(childNodes[i] && childNodes[i].nodeName == "stroke" && childNodes[i].joinstyle && childNodes[i].joinstyle == this.linejoin)
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testVMLRectNodeWidthAgainstShapeAttr" : function()
c093c1aed867e18aa4778708592e1ceb45d18cffTripp Y.assert(Y.one(node).getComputedStyle("width") == this.myrect.get("width") + "px");
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testVMLRectNodeHeightAgainstShapeAttr" : function()
c093c1aed867e18aa4778708592e1ceb45d18cffTripp Y.assert(Y.one(node).getComputedStyle("height") == this.myrect.get("height") + "px");
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "testVMLRectNodeFillAgainstShapeAttr" : function()
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp//suite of canvas specific tests
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp setUp: function () {
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp tearDown: function () {
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp "testCanvasGraphic()" : 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"});
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp Y.Assert.isInstanceOf(HTMLElement, graphic.get("node"));
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp "testCanvasRectNode()" : function()
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp "testCanvasRectNodeDimensions()" : function()
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp Y.assert(node.getAttribute("width") == this.width + weight);
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp Y.assert(node.getAttribute("height") == this.height + weight);
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp "testCanvasRectNodeFillColor()" : function()
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp opacity = Y.Lang.isNumber(opacity) && opacity < 1 ? opacity : 1;
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp if(shapeFillColor.indexOf("RGBA") > -1 || shapeFillColor.indexOf("rgba") > -1)
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp fillColor = this.toRGBA(this.TOHEX(fillColor), opacity)
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp "testCanvasRectNodeFillColorAgainstAttr()" : function()
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp opacity = Y.Lang.isNumber(opacity) && opacity < 1 ? opacity : 1;
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp if(shapeFillColor.indexOf("RGBA") > -1 || shapeFillColor.indexOf("rgba") > -1)
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp fillColor = this.toRGBA(this.TOHEX(fillColor), opacity)
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp "testCanvasRectNodeStrokeColor" : function()
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp opacity = Y.Lang.isNumber(opacity) && opacity < 1 ? opacity : 1
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp if(shapeStrokeColor.indexOf("RGBA") > -1 || shapeStrokeColor.indexOf("rgba") > -1)
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp shapeStrokeColor = shapeStrokeColor.replace(/, /g, ",");
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp strokeColor = this.toRGBA(this.TOHEX(strokeColor), opacity)
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp "testCanvasRectNodeStrokeColorAgainstAttr()" : function()
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp opacity = Y.Lang.isNumber(opacity) && opacity < 1 ? opacity : 1;
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp if(shapeStrokeColor.indexOf("RGBA") > -1 || shapeStrokeColor.indexOf("rgba") > -1)
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp shapeStrokeColor = shapeStrokeColor.replace(/, /g, ",");
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp strokeColor = this.toRGBA(this.TOHEX(strokeColor), opacity)
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp "testCanvasRectNodeStrokeWidth" : function()
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp "testCanvasRectNodeStrokeWidthAgainstAttr()" : function()
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp "testCanvasRectNodeStrokeLineCap" : function()
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp "testCanvasRectNodeStrokeLineJoin" : function()
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp "testCanvasRectNodeWidthAgainstShapeAttr" : function()
e7f83e93bb5c263f4c00b4a9438330da561df764Tripp "testCanvasRectNodeHeightAgainstShapeAttr" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp setUp: function () {
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp tearDown: function () {
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test default construction": function () {
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test render()": function () {
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp Y.one("#testbed").setContent('<div style="position:absolute;top:0px;left:0px;width:500px;height:400px" id="graphiccontainer"></div>');
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp graphic = new Y.Graphic({render: "#graphiccontainer"});
a674c2c1af7be192fa94e4401511641f5a95ee47Tripp "test addShape(circle)": function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test mycircle.get(radius)": function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test mycircle.get(width)": function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test mycircle.get(height)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test mycircle.get(stroke)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test mycircle.get(fill)" : function()
c093c1aed867e18aa4778708592e1ceb45d18cffTripp "test mycircle.get(x)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test mycircle.get(y)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test mycircle.set(stroke)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp Y.assert(this.updatedStrokeColor === mycircle.get("stroke").color);
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test mycircle.set(fill)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp Y.assert(this.updatedFillColor === mycircle.get("fill").color);
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "testRemoveShape(circle)": function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp hasShape = (shapes.hasOwnProperty(id) && shapes[id] instanceof Y.Circle);
a674c2c1af7be192fa94e4401511641f5a95ee47Tripp "test addShape(rect)": function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test myrect.get(width)": function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test myrect.get(height)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test myrect.get(stroke)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test myrect.get(fill)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test myrect.get(x)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test myrect.get(y)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test myrect.set(stroke)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp Y.assert(this.updatedStrokeColor === myrect.get("stroke").color);
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test myrect.set(fill)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp Y.assert(this.updatedFillColor === myrect.get("fill").color);
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test removeShape(rect)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp hasShape = (shapes.hasOwnProperty(id) && shapes[id] instanceof Y.Rect);
a674c2c1af7be192fa94e4401511641f5a95ee47Tripp "test addShape(ellipse)": function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test myellipse.get(width)": function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test myellipse.get(height)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test myellipse.get(stroke)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test myellipse.get(fill)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test myellipse.get(x)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test myellipse.get(y)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test myellipse.set(stroke)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp Y.assert(this.updatedStrokeColor === myellipse.get("stroke").color);
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test myellipse.set(fill)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp Y.assert(this.updatedFillColor === myellipse.get("fill").color);
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test removeShape(ellipse)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp hasShape = (shapes.hasOwnProperty(id) && shapes[id] instanceof Y.Ellipse);
a674c2c1af7be192fa94e4401511641f5a95ee47Tripp "test addShape(path)": function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test mypath.get(width)": function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test mypath.get(height)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test mypath.get(stroke)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test mypath.get(fill)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test mypath.get(x)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test mypath.get(y)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test mypath.set(stroke)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp Y.assert(this.updatedStrokeColor === mypath.get("stroke").color);
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test mypath.set(fill)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp Y.assert(this.updatedFillColor === mypath.get("fill").color);
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp "test removeShape(path)" : function()
4228965449d116d2787c15d2b39a075b37ac2fe0Tripp hasShape = (shapes.hasOwnProperty(id) && shapes[id] instanceof Y.Path);
d51d1ee45c9f8f0479d8e63f4f1589afafdd2be4Tripp "test passRotation(rect)" : function()