aboutsummaryrefslogtreecommitdiff
path: root/includes/js/dijit/tests/_programaticTest.html
blob: 41b1815389865344bd250e720bbf52c152c48313 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
		"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>Dijit raw programatic test suite | The Dojo Toolkit</title>

	<style type="text/css">
		@import "../../dojo/resources/dojo.css";
		@import "css/dijitTests.css";
		body, html { width:100%; height:100%; margin:0; padding:0; background:#fff !important; } 
	</style>

	<script type="text/javascript" src="../../dojo/dojo.js"
		djConfig="parseOnLoad: true, isDebug: true"></script>
	<script type="text/javascript" src="_testCommon.js"></script>

	<script language="JavaScript" type="text/javascript">
		dojo.require("dojo.data.ItemFileReadStore");
		dojo.require("dijit.dijit-all"); 

		var randomParams = function(){
			// need better params to test passing
			return { "length" : 20 	};
		};

		var inspectClass = function(fullClassName){
			var newDijit, newDijitDom, newDijitParam = null;
			var createdWidgets = [];
			className = eval(fullClassName); // 

			// just try to make the class:
			try{
				newDijit = new className({});
				createdWidgets.push(newDijit);
			}catch(e){
				console.warn('new only: ',fullClassName,e); 
			}

			// try starting this widget
			try{
				if (newDijit && newDijit.startup){ newDijit.startup(); } 
			}catch(e){
				console.warn('call startup: ',fullClassName,e); 
			}

			// try with a div in the dom
			try{
				var tmpDiv = dojo.body().appendChild(document.createElement('div'));
				newDijitDom = new className({},tmpDiv);
				createdWidgets.push(newDijitDom);
			}catch(e){
				console.warn('attached to div: ',fullClassName,e);
			}

			// lets pass random parameters
			try{
				var tmpDiv = dojo.body().appendChild(document.createElement('div'));
				newDijitParam = new className(randomParams(),tmpDiv);
				createdWidgets.push(newDijitParam);		
			}catch(e){
				console.warn('random param test: ',fullClassName,e); 
			}
			// add more tests ...

			// cleanup after ourselves
			dojo.forEach(createdWidgets,function(byeWidget){
				try{
					if(byeWidget.destroy){ byeWidget.destroy(); }
				}catch(e){
					console.warn('destroying: ',byeWidget.declaredClass,e,byeWidget);
				}
			});

		};

		var storeError = function(e,request){
			console.warn(e,request);
		};
		
		var storeReady = function(items,request){
			dojo.forEach(items,function(item){
				var testClass = theStore.getValue(item,"className");
				try{
					inspectClass(testClass);
				}catch(e){
					console.warn(e);
				}
			});
		};

		var init = function(){
			var request = {
				query: { },
				onComplete: storeReady,
				onError: storeError
			};
			theStore.fetch(request);
		};
		dojo.addOnLoad(init);

	</script>

</head>
<body>
	<div dojoType="dojo.data.ItemFileReadStore" jsId="theStore"
		url="../tests/_data/dijits.json"></div>
	
</body>
</html>