graphics-tests.js revision 2b904e83040752143af70b087f637e39035bb2e6
ENGINE = "vml",
if(DOCUMENT && DOCUMENT.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1"))
{
ENGINE = "svg";
}
{
ENGINE = "canvas";
}
name: "GraphicsTests",
graphic: null,
mycircle: null,
myrect: null,
myellipse: null,
mypath: null,
initialFillColor: "#f00",
initialStrokeColor: "#00f",
updatedFillColor: "#9aa",
updatedStrokeColor: "#99a",
setUp: function () {
},
tearDown: function () {
},
"test default construction": function () {
},
"test render()": function () {
Y.one("#testbed").setContent('<div style="position:absolute;top:0px;left:0px;width:500px;height:400px" id="graphiccontainer"></div>');
node,
});
},
"test addShape(circle)": function()
{
type: "circle",
stroke: {
color: this.initialStrokeColor,
weight: 1
},
fill: {
color: this.initialFillColor
},
radius: 12,
x: -5,
y: -5
});
},
"test mycircle.get(radius)": function()
{
},
"test mycircle.get(width)": function()
{
},
"test mycircle.get(height)" : function()
{
},
"test mycircle.get(stroke)" : function()
{
},
"test mycircle.get(fill)" : function()
{
},
"test mycircle.get(x)" : function()
{
},
"test mycircle.get(y)" : function()
{
},
"test mycircle.set(stroke)" : function()
{
color: this.updatedStrokeColor
});
},
"test mycircle.set(fill)" : function()
{
color: this.updatedFillColor
});
},
"testRemoveShape(circle)": function()
{
var id,
},
"test addShape(rect)": function()
{
type: "rect",
stroke: {
weight: 2,
color: this.initialStrokeColor
},
fill: {
color: this.initialFillColor
},
x: 5,
y: 5,
width:300,
height: 200
});
},
"test myrect.get(width)": function()
{
},
"test myrect.get(height)" : function()
{
},
"test myrect.get(stroke)" : function()
{
},
"test myrect.get(fill)" : function()
{
},
"test myrect.get(x)" : function()
{
},
"test myrect.get(y)" : function()
{
},
"test myrect.set(stroke)" : function()
{
color: this.updatedStrokeColor
});
},
"testRectStrokeWeightType" : function()
{
var strokeWeight = 2,
},
"test myrect.set(fill)" : function()
{
color: this.updatedFillColor
});
},
"test removeShape(rect)" : function()
{
var id,
},
"test addShape(ellipse)": function()
{
type: "ellipse",
stroke: {
color: this.initialStrokeColor,
weight: 2
},
fill: {
color: this.initialFillColor
},
width: 100,
height: 30,
x:100,
y:50
});
},
"test myellipse.get(width)": function()
{
},
"test myellipse.get(height)" : function()
{
},
"test myellipse.get(stroke)" : function()
{
},
"test myellipse.get(fill)" : function()
{
},
"test myellipse.get(x)" : function()
{
},
"test myellipse.get(y)" : function()
{
},
"test myellipse.set(stroke)" : function()
{
color: this.updatedStrokeColor
});
},
"test myellipse.set(fill)" : function()
{
color: this.updatedFillColor
});
},
"test removeShape(ellipse)" : function()
{
var id,
},
"test addShape(path)": function()
{
type: "path",
stroke: {
color: this.initialStrokeColor
},
fill: {
color: this.initialFillColor
}
});
},
"test mypath.get(width)": function()
{
},
"test mypath.get(height)" : function()
{
},
"test mypath.get(stroke)" : function()
{
},
"test mypath.get(fill)" : function()
{
},
"test mypath.get(x)" : function()
{
},
"test mypath.get(y)" : function()
{
},
"test mypath.set(stroke)" : function()
{
color: this.updatedStrokeColor
});
},
"test mypath.set(fill)" : function()
{
color: this.updatedFillColor
});
},
"test removeShape(path)" : function()
{
var id,
},
"test passRotation(rect)" : function()
{
type: "rect",
stroke: {
weight: 2,
color: this.initialStrokeColor
},
fill: {
color: this.initialFillColor
},
x: 5,
y: 5,
width:300,
height: 200,
rotation: 45
});
}
});
//suite of svg specific tests
name: "SVGGraphicsTests",
graphic: null,
mycircle: null,
myrect: null,
myellipse: null,
mypath: null,
initialFillColor: "#f00",
initialStrokeColor: "#00f",
updatedFillColor: "#9aa",
updatedStrokeColor: "#99a",
setUp: function () {
},
tearDown: function () {
},
"testSVGGraphic()" : function()
{
Y.one("#testbed").setContent('<div style="position:absolute;top:0px;left:0px;width:500px;height:400px" id="graphiccontainer"></div>');
});
},
"testSVGRectNode()" : function()
{
type: "rect",
width: 300,
height: 200,
fill: {
color: this.initialFillColor
},
stroke: {
color: this.initialStrokeColor
}
});
},
"testSVGRectNodeDimensions()" : function()
{
},
"testSVGRectNodeFillColor()" : function()
{
},
"testSVGRectNodeFillOpacity()" : function()
{
},
"testSVGRectNodeStrokeColor" : function()
{
},
"testSVGRectNodeStrokeWidth" : function()
{
},
"testSVGRectNodeStroke" : function()
{
},
"testSVGRectNodeStrokeDashArray" : function()
{
},
"testSVGRectNodeStrokeLineCap" : function()
{
},
"testSVGRectNodeStrokeLineJoin" : function()
{
},
"testSVGRectNodeWidthAgainstShapeAttr" : function()
{
},
"testSVGRectNodeHeightAgainstShapeAttr" : function()
{
},
"testSVGRectNodeFillAgainstShapeAttr" : function()
{
},
"testSVGRectNodeStrokeAgainstShapeAttr" : function()
{
}
});
//suite of vml specific tests
name: "VMLGraphicsTests",
graphic: null,
mycircle: null,
myrect: null,
myellipse: null,
mypath: null,
initialFillColor: "#f00",
initialStrokeColor: "#00f",
updatedFillColor: "#9aa",
updatedStrokeColor: "#99a",
dashstyle: "4 2",
linejoin: "round",
linecap: "butt",
setUp: function () {
},
tearDown: function () {
},
"testVMLGraphic()" : function()
{
Y.one("#testbed").setContent('<div style="position:absolute;top:0px;left:0px;width:500px;height:400px" id="graphiccontainer"></div>');
});
},
"testVMLRectNode()" : function()
{
type: "rect",
width: 300,
height: 200,
fill: {
color: this.initialFillColor
},
stroke: {
color: this.initialStrokeColor,
opacity: 1,
}
});
},
"testVMLRectNodeDimensions()" : function()
{
},
"testVMLRectNodeFillColor()" : function()
{
fillMatches = false,
i = 0,
for(; i < len; ++i)
{
if(childNodes[i] && childNodes[i].nodeName == "fill" && childNodes[i].color == this.initialFillColor)
{
fillMatches = true;
}
}
if(!fillMatches)
{
fillMatches = toHex(node.fillcolor) == toHex(this.initialFillColor) || toHex(node.fillcolor.value) == toHex(this.initialFillColor);
}
Y.assert(fillMatches);
},
"testVMLRectNodeStrokeColor" : function()
{
strokeMatches = false,
i = 0,
for(; i < len; ++i)
{
if(childNodes[i] && childNodes[i].nodeName == "stroke" && ( toHex(childNodes[i].color) == toHex(this.initialStrokeColor) || toHex(childNodes[i].color.value) == toHex(this.initialStrokeColor)))
{
strokeMatches = true;
}
}
if(!strokeMatches)
{
strokeMatches = toHex(node.strokecolor) == toHex(this.initialStrokeColor) || toHex(node.strokecolor.value) == toHex(this.initialStrokeColor);
}
Y.assert(strokeMatches);
},
"testVMLRectNodeStrokeWidth" : function()
{
strokeMatches = false,
i = 0,
for(; i < len; ++i)
{
{
strokeMatches = true;
}
}
if(!strokeMatches)
{
}
Y.assert(strokeMatches);
},
"testVMLRectNodeStrokeOpacity" : function()
{
strokeMatches = false,
i = 0,
for(; i < len; ++i)
{
{
strokeMatches = true;
}
}
if(!strokeMatches)
{
}
Y.assert(strokeMatches);
},
"testVMLRectNodeStrokeDashArray" : function()
{
strokeMatches = false,
i = 0,
for(; i < len; ++i)
{
if(childNodes[i] && childNodes[i].nodeName == "stroke" && childNodes[i].dashstyle && childNodes[i].dashstyle == this.dashstyle)
{
strokeMatches = true;
}
}
Y.assert(strokeMatches);
},
"testVMLRectNodeStrokeLineCap" : function()
{
strokeMatches = false,
i = 0,
for(; i < len; ++i)
{
if(childNodes[i] && childNodes[i].nodeName == "stroke" && childNodes[i].endcap && childNodes[i].endcap == "flat")
{
strokeMatches = true;
}
}
Y.assert(strokeMatches);
},
"testVMLRectNodeStrokeLineJoin" : function()
{
strokeMatches = false,
i = 0,
for(; i < len; ++i)
{
if(childNodes[i] && childNodes[i].nodeName == "stroke" && childNodes[i].joinstyle && childNodes[i].joinstyle == this.linejoin)
{
strokeMatches = true;
}
}
Y.assert(strokeMatches);
},
"testVMLRectNodeWidthAgainstShapeAttr" : function()
{
},
"testVMLRectNodeHeightAgainstShapeAttr" : function()
{
},
"testVMLRectNodeFillAgainstShapeAttr" : function()
{
}
});
//suite of canvas specific tests
name: "CanvasGraphicsTests",
graphic: null,
mycircle: null,
myrect: null,
myellipse: null,
mypath: null,
initialFillColor: "#f00",
initialFillOpacity: 0.5,
initialStrokeColor: "#00f",
updatedFillColor: "#9aa",
updatedStrokeColor: "#99a",
width: 300,
height: 200,
context: null,
linecap: "butt",
}
val = 'rgba(' + [
}
return val;
},
setUp: function () {
},
tearDown: function () {
},
"testCanvasGraphic()" : function()
{
Y.one("#testbed").setContent('<div style="position:absolute;top:0px;left:0px;width:500px;height:400px" id="graphiccontainer"></div>');
});
},
"testCanvasRectNode()" : function()
{
var node,
type: "rect",
fill: {
color: this.initialFillColor,
opacity: this.initialFillOpacity
},
stroke: {
color: this.initialStrokeColor,
weight: this.initialStrokeWeight
}
});
},
"testCanvasRectNodeDimensions()" : function()
{
weight *= 2;
},
"testCanvasRectNodeFillColor()" : function()
{
fillColor = this.initialFillColor,
{
}
else
{
}
},
"testCanvasRectNodeFillColorAgainstAttr()" : function()
{
{
}
else
{
}
},
"testCanvasRectNodeStrokeColor" : function()
{
{
}
else
{
}
},
"testCanvasRectNodeStrokeColorAgainstAttr()" : function()
{
{
}
else
{
}
},
"testCanvasRectNodeStrokeWidth" : function()
{
var weight = this.initialStrokeWeight,
},
"testCanvasRectNodeStrokeWidthAgainstAttr()" : function()
{
},
"testCanvasRectNodeStrokeLineCap" : function()
{
},
"testCanvasRectNodeStrokeLineJoin" : function()
{
},
"testCanvasRectNodeWidthAgainstShapeAttr" : function()
{
},
"testCanvasRectNodeHeightAgainstShapeAttr" : function()
{
}
});
name: "GraphicsTransformTests",
graphic: null,
myrect: null,
initialFillColor: "#f00",
initialStrokeColor: "#00f",
defaultTransformString: "rotate(40) translate(45, 55) skew(30, 30)",
width: 300,
height: 200,
setUp: function () {
},
tearDown: function () {
},
"testGraphicInstantiation()" : function()
{
Y.one("#testbed").setContent('<div style="position:absolute;top:0px;left:0px;width:500px;height:400px" id="graphiccontainer"></div>');
});
},
"testTransformAttributeIntantiation()" : function()
{
type: "rect",
stroke: {
color: this.initialStrokeColor
},
fill: {
color: this.initialFillColor
},
});
},
"testAddTransformStringAppend()" : function()
{
},
"testAddTransformsAndCompareToString()": function()
{
}
});
if(ENGINE == "svg")
{
}
if(ENGINE == "vml")
{
}
if(ENGINE == "canvas")
{
}