]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dijit/tests/_programaticTest.html
add Dojo 1.1.1
[eow] / static / dojo-release-1.1.1 / dijit / tests / _programaticTest.html
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>Dijit raw programatic test suite | The Dojo Toolkit</title>
6
7         <style type="text/css">
8                 @import "../../dojo/resources/dojo.css";
9                 @import "css/dijitTests.css";
10                 body, html { width:100%; height:100%; margin:0; padding:0; background:#fff !important; } 
11         </style>
12
13         <script type="text/javascript" src="../../dojo/dojo.js"
14                 djConfig="parseOnLoad: true, isDebug: true"></script>
15         <script type="text/javascript" src="_testCommon.js"></script>
16
17         <script language="JavaScript" type="text/javascript">
18                 dojo.require("dojo.data.ItemFileReadStore");
19                 dojo.require("dijit.dijit-all"); 
20
21                 var randomParams = function(){
22                         // need better params to test passing
23                         return { "length" : 20  };
24                 };
25
26                 var inspectClass = function(fullClassName){
27                         var newDijit, newDijitDom, newDijitParam = null;
28                         var createdWidgets = [];
29                         className = eval(fullClassName); // 
30
31                         // just try to make the class:
32                         try{
33                                 newDijit = new className({});
34                                 createdWidgets.push(newDijit);
35                         }catch(e){
36                                 console.warn('new only: ',fullClassName,e); 
37                         }
38
39                         // try starting this widget
40                         try{
41                                 if (newDijit && newDijit.startup){ newDijit.startup(); } 
42                         }catch(e){
43                                 console.warn('call startup: ',fullClassName,e); 
44                         }
45
46                         // try with a div in the dom
47                         try{
48                                 var tmpDiv = dojo.body().appendChild(document.createElement('div'));
49                                 newDijitDom = new className({},tmpDiv);
50                                 createdWidgets.push(newDijitDom);
51                         }catch(e){
52                                 console.warn('attached to div: ',fullClassName,e);
53                         }
54
55                         // lets pass random parameters
56                         try{
57                                 var tmpDiv = dojo.body().appendChild(document.createElement('div'));
58                                 newDijitParam = new className(randomParams(),tmpDiv);
59                                 createdWidgets.push(newDijitParam);             
60                         }catch(e){
61                                 console.warn('random param test: ',fullClassName,e); 
62                         }
63                         // add more tests ...
64
65                         // cleanup after ourselves
66                         dojo.forEach(createdWidgets,function(byeWidget){
67                                 try{
68                                         if(byeWidget.destroy){ byeWidget.destroy(); }
69                                 }catch(e){
70                                         console.warn('destroying: ',byeWidget.declaredClass,e,byeWidget);
71                                 }
72                         });
73
74                 };
75
76                 var storeError = function(e,request){
77                         console.warn(e,request);
78                 };
79                 
80                 var storeReady = function(items,request){
81                         dojo.forEach(items,function(item){
82                                 var testClass = theStore.getValue(item,"className");
83                                 try{
84                                         inspectClass(testClass);
85                                 }catch(e){
86                                         console.warn(e);
87                                 }
88                         });
89                 };
90
91                 var init = function(){
92                         var request = {
93                                 query: { },
94                                 onComplete: storeReady,
95                                 onError: storeError
96                         };
97                         theStore.fetch(request);
98                 };
99                 dojo.addOnLoad(init);
100
101         </script>
102
103 </head>
104 <body>
105         <div dojoType="dojo.data.ItemFileReadStore" jsId="theStore"
106                 url="../tests/_data/dijits.json"></div>
107         
108 </body>
109 </html>