2150 |
mathias |
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 manager unit test</title>
|
|
|
6 |
<style type="text/css">
|
|
|
7 |
@import "../../../dojo/resources/dojo.css";
|
|
|
8 |
@import "../css/dijitTests.css";
|
|
|
9 |
</style>
|
|
|
10 |
<script type="text/javascript" src="../../../dojo/dojo.js"
|
|
|
11 |
djConfig="isDebug: true, parseOnLoad: true"></script>
|
|
|
12 |
<script type="text/javascript" src="../_testCommon.js"></script>
|
|
|
13 |
|
|
|
14 |
<script type="text/javascript">
|
|
|
15 |
dojo.require("doh.runner");
|
|
|
16 |
dojo.require("dijit.dijit");
|
|
|
17 |
|
|
|
18 |
dojo.declare("foo", dijit._Widget, {
|
|
|
19 |
name: "",
|
|
|
20 |
attr1: 0,
|
|
|
21 |
attr2: 0
|
|
|
22 |
});
|
|
|
23 |
|
|
|
24 |
dojo.declare("bar", dijit._Widget, {
|
|
|
25 |
name: "",
|
|
|
26 |
attr1: 0,
|
|
|
27 |
attr2: 0
|
|
|
28 |
});
|
|
|
29 |
|
|
|
30 |
dojo.addOnLoad(function(){
|
|
|
31 |
doh.register("dijit._base.manager",
|
|
|
32 |
[
|
|
|
33 |
function forEachTest(t){
|
|
|
34 |
var names=[];
|
|
|
35 |
dijit.registry.forEach(function(widget){ names.push(widget.name); });
|
|
|
36 |
t.is(names.join(" "), "bob is your uncle");
|
|
|
37 |
},
|
|
|
38 |
function filterTest(t){
|
|
|
39 |
var names=[];
|
|
|
40 |
dijit.registry.
|
|
|
41 |
filter(function(widget){ return widget.attr1==10; }).
|
|
|
42 |
forEach(function(widget){ names.push(widget.name); });
|
|
|
43 |
t.is(names.join(" "), "bob uncle");
|
|
|
44 |
},
|
|
|
45 |
function byId(t){
|
|
|
46 |
t.is(dijit.byId("three").name, "your");
|
|
|
47 |
},
|
|
|
48 |
function byClass(t){
|
|
|
49 |
var names=[];
|
|
|
50 |
dijit.registry.
|
|
|
51 |
byClass("bar").
|
|
|
52 |
forEach(function(widget){ names.push(widget.name); });
|
|
|
53 |
t.is(names.join(" "), "your uncle");
|
|
|
54 |
},
|
|
|
55 |
function deleteTest(t){
|
|
|
56 |
var names=[];
|
|
|
57 |
dijit.byId("two").destroy();
|
|
|
58 |
dijit.byId("four").destroy();
|
|
|
59 |
var names=[];
|
|
|
60 |
dijit.registry.forEach(function(widget){ names.push(widget.name); });
|
|
|
61 |
t.is(names.join(" "), "bob your");
|
|
|
62 |
},
|
|
|
63 |
function getEnclosingWidgetTest(t){
|
|
|
64 |
t.is(dijit.getEnclosingWidget(dojo.byId("not-a-widget")), null);
|
|
|
65 |
t.is(dijit.getEnclosingWidget(dojo.byId("three")).name, "your");
|
|
|
66 |
t.is(dijit.getEnclosingWidget(dojo.byId("three.one")).name, "your");
|
|
|
67 |
t.is(dijit.getEnclosingWidget(dojo.byId("three.one.one")).name, "your");
|
|
|
68 |
}
|
|
|
69 |
]
|
|
|
70 |
);
|
|
|
71 |
doh.run();
|
|
|
72 |
});
|
|
|
73 |
|
|
|
74 |
</script>
|
|
|
75 |
</head>
|
|
|
76 |
<body>
|
|
|
77 |
<h1>Dijit Manager Unit Test</h1>
|
|
|
78 |
<div dojoType="foo" id="one" name="bob" attr1="10" attr2="10"></div>
|
|
|
79 |
<div dojoType="foo" id="two" name="is" attr1="5" attr2="10"></div>
|
|
|
80 |
<div dojoType="bar" id="three" name="your" attr1="5" attr2="5">
|
|
|
81 |
<div id="three.one">
|
|
|
82 |
<div id="three.one.one"></div>
|
|
|
83 |
</div>
|
|
|
84 |
</div>
|
|
|
85 |
<div dojoType="bar" id="four" name="uncle" attr1="10" attr2="5"></div>
|
|
|
86 |
<div id="not-a-widget"></div>
|
|
|
87 |
</body>
|
|
|
88 |
</html>
|