90 lines
3.3 KiB
HTML
90 lines
3.3 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
|
"http://www.w3.org/TR/html4/strict.dtd">
|
|
<html>
|
|
<head>
|
|
<title>GFX Test: Test the shape registry</title>
|
|
<style type="text/css">
|
|
@import "../../../dojo/resources/dojo.css";
|
|
@import "../../../dijit/tests/css/dijitTests.css";
|
|
</style>
|
|
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script>
|
|
<script type="text/javascript" src="../../../util/doh/runner.js"></script>
|
|
<script type="text/javascript">
|
|
dojo.require("doh.runner");
|
|
dojo.require("dojox.gfx");
|
|
dojo.require("dojox.gfx.shape");
|
|
</script>
|
|
<script type="text/javascript">
|
|
dojo.addOnLoad(function(){
|
|
var drawing;
|
|
var ta;
|
|
doh.register("GFX: Registry Tests", [
|
|
{
|
|
name: "dojox.gfx.shape.register",
|
|
timeout: 1000,
|
|
runTest: function(t){
|
|
var obj = {
|
|
declaredClass: 'module.sub.foo'
|
|
};
|
|
// register
|
|
var id = dojox.gfx.shape.register(obj);
|
|
t.t(dojo.isString(id) && id.length>0, "checking register() return value.");
|
|
var ret = dojox.gfx.shape.byId(id);
|
|
t.t(ret === obj, "Checking byId() after register().");
|
|
var obj2 = {declaredClass: 'module.sub.foo'};
|
|
var ret2 = dojox.gfx.shape.register(obj2);
|
|
t.t(dojo.isString(ret2) && ret2.length>0, "checking register() with same declaredClass.");
|
|
t.t(ret2 != id, "checking _uid unicity.");
|
|
//dispose
|
|
obj.getUID =function(){return id;};
|
|
dojox.gfx.shape.dispose(obj);
|
|
ret = dojox.gfx.shape.byId(id);
|
|
t.t(!ret, "Checking dojox.gfx.shape.dispose().");
|
|
}
|
|
},
|
|
{
|
|
name: "shape registration",
|
|
timeout: 1000,
|
|
setUp: function(){
|
|
if (!drawing) {
|
|
var dn = dojo.byId("gfxObject");
|
|
drawing = dojox.gfx.createSurface(dn, 300, 300);
|
|
}
|
|
},
|
|
runTest: function(t){
|
|
var dic={};
|
|
dojo.forEach(["Group", "Rect", "Ellipse", "Circle", "Line", "Polyline", "Image", "Text", "Path", "TextPath"], function(name, idx, values){
|
|
// no TextPath in Silverlight
|
|
if (idx == values.length-1 && dojox.gfx.renderer=='silverlight')
|
|
return;
|
|
var s = drawing["create"+name]();
|
|
t.t(s.getUID() && s.getUID().length>0,"Checking automatic shape registration for "+name);
|
|
var o = dojox.gfx.shape.byId(s.getUID());
|
|
t.t(o === s, "Checking dojox.gfx.shape.byId()");
|
|
// rawNode binding
|
|
var p = s.rawNode.tag ? 'tag' : '__gfxObject__';
|
|
t.t(s.rawNode[p] == s.getUID(),"Checking rawNode<->gfx binding.");
|
|
dic[name] = s.getUID();
|
|
});
|
|
// successive registration
|
|
dojo.forEach(["Group", "Rect", "Ellipse", "Circle", "Line", "Polyline", "Image", "Text", "Path", "TextPath"], function(name, idx, values){
|
|
// no TextPath in Silverlight
|
|
if (idx == values.length-1 && dojox.gfx.renderer=='silverlight')
|
|
return;
|
|
var s = drawing["create"+name]();
|
|
var id = s.getUID();
|
|
t.t(dic[name] != id, "Checking unicity.");
|
|
});
|
|
}
|
|
}
|
|
]);
|
|
doh.run();
|
|
});
|
|
</script>
|
|
</head>
|
|
<body class="tundra">
|
|
<h1>Test of GFX registry functions</h1>
|
|
<div id="gfxObject"></div>
|
|
</body>
|
|
</html>
|