Debian Codegraph @

dojox/gfx/tests/test_registry.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
4 <head>
5 <title>GFX Test: Test the shape registry</title>
6 <style type="text/css">
7 @import "../../../dojo/resources/dojo.css";
8 @import "../../../dijit/tests/css/dijitTests.css";
9 </style>
10 <script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="isDebug: true"></script>
11 <script type="text/javascript" src="../../../util/doh/runner.js"></script>
12 <script type="text/javascript">
13 dojo.require("doh.runner");
14 dojo.require("dojox.gfx");
15 dojo.require("dojox.gfx.shape");
16 dojo.require("dojox.gfx.registry");
17 </script>
18 <script type="text/javascript">
19 dojo.addOnLoad(function(){
20 var drawing;
21 var ta;
22 doh.register("GFX: Registry Tests", [
23 {
24 name: "dojox.gfx.shape.register",
25 timeout: 1000,
26 runTest: function(t){
27 var obj = {
28 declaredClass: 'module.sub.foo'
29 };
30 // register
31 var id = dojox.gfx.shape.register(obj);
32 t.t(dojo.isString(id) && id.length>0, "checking register() return value.");
33 var ret = dojox.gfx.shape.byId(id);
34 t.t(ret === obj, "Checking byId() after register().");
35 var obj2 = {declaredClass: 'module.sub.foo'};
36 var ret2 = dojox.gfx.shape.register(obj2);
37 t.t(dojo.isString(ret2) && ret2.length>0, "checking register() with same declaredClass.");
38 t.t(ret2 != id, "checking _uid unicity.");
39 //dispose
40 obj.getUID =function(){return id;};
41 dojox.gfx.shape.dispose(obj);
42 ret = dojox.gfx.shape.byId(id);
43 t.t(!ret, "Checking dojox.gfx.shape.dispose().");
44 // optional recursive dispose
45 }
46 },
47 {
48 name:"recursive dispose",
49 runTest: function(t){
50
51 var obj = {
52 declaredClass: 'module.sub.foo',
53 children:[
54 { declaredClass: "foo.bar" },
55 { declaredClass: "bar.foo" }
56 ]
57 };
58 var id1 = dojox.gfx.shape.register(obj);
59 obj.getUID =function(){return id1;};
60 var id2 = dojox.gfx.shape.register(obj.children[0]);
61 obj.children[0].getUID =function(){return id2;};
62 var id3 = dojox.gfx.shape.register(obj.children[1]);
63 obj.children[1].getUID =function(){return id3;};
64 dojox.gfx.shape.dispose(obj, true);
65 var ret = dojox.gfx.shape.byId(id1);
66 t.t(!ret, "Shape id1 not disposed (recursive dispose).");
67 ret = dojox.gfx.shape.byId(id2);
68 t.t(!ret, "Child id2 not disposed (recursive dispose).");
69 ret = dojox.gfx.shape.byId(id3);
70 t.t(!ret, "Child id3 not disposed (recursive dispose).");
71 }
72 },
73 {
74 name: "shape registration",
75 timeout: 1000,
76 setUp: function(){
77 if (!drawing) {
78 var dn = dojo.byId("gfxObject");
79 drawing = dojox.gfx.createSurface(dn, 300, 300);
80 }
81 },
82 runTest: function(t){
83 var dic={};
84 dojo.forEach(["Group", "Rect", "Ellipse", "Circle", "Line", "Polyline", "Image", "Text", "Path", "TextPath"], function(name, idx, values){
85 // no TextPath in Silverlight
86 if (idx == values.length-1 && dojox.gfx.renderer=='silverlight')
87 return;
88 var s = drawing["create"+name]();
89 t.t(s.getUID() && s.getUID().length>0,"Checking automatic shape registration for "+name);
90 var o = dojox.gfx.shape.byId(s.getUID());
91 t.t(o === s, "Checking dojox.gfx.shape.byId()");
92 // rawNode binding
93 var p = s.rawNode.tag ? 'tag' : '__gfxObject__';
94 t.t(s.rawNode[p] == s,"Checking rawNode<->gfx binding.");
95 dic[name] = s.getUID();
96 });
97 // successive registration
98 dojo.forEach(["Group", "Rect", "Ellipse", "Circle", "Line", "Polyline", "Image", "Text", "Path", "TextPath"], function(name, idx, values){
99 // no TextPath in Silverlight
100 if (idx == values.length-1 && dojox.gfx.renderer=='silverlight')
101 return;
102 var s = drawing["create"+name]();
103 var id = s.getUID();
104 t.t(dic[name] != id, "Checking unicity.");
105 });
106 }
107 }
108 ]);
109 doh.run();
110 });
111 </script>
112 </head>
113 <body class="tundra">
114 <h1>Test of GFX registry functions</h1>
115 <div id="gfxObject"></div>
116 </body>
117 </html>