Debian Codegraph @

dijit/tests/tree/robot/Tree_v1.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>doh.robot Tree_v1 Test</title>
6
7 <style>
8 @import "../../../../util/doh/robot/robot.css";
9 </style>
10
11 <!-- required: dojo.js -->
12 <script type="text/javascript" src="../../../../dojo/dojo.js"></script>
13
14 <script type="text/javascript">
15 dojo.require("dijit.robotx");
16 dojo.require("dijit.tests.helpers"); // functions to help test
17
18 dojo.ready(function(){
19 doh.robot.initRobot('../test_Tree_v1.html');
20
21 doh.register("_setup", [
22 {
23 name: "wait for widgets to load",
24 timeout: 10000,
25 runTest: waitForLoad
26 },
27 function setVars(){
28 registry = dojo.global.require("dijit/registry");
29 }
30 ]);
31
32 doh.register("Test tree 1", [
33 {
34 name: "expand first child",
35 timeout: 7000,
36 runTest: function(){
37 var d = new doh.Deferred();
38
39 var myTree = registry.byId("mytree");
40 var children = myTree.rootNode.getChildren();
41
42 doh.robot.mouseMoveAt(children[0].contentNode, 500, 1);
43 doh.robot.mouseClick({left: true}, 500);
44 doh.robot.mouseMoveAt(children[4].contentNode, 1000, 1);
45 doh.robot.mouseClick({left: true}, 500);
46
47 doh.robot.sequence(d.getTestCallback(function(){
48 doh.t(children[0].isExpanded, "failed to expand africa child node");
49 doh.t(children[4].isExpanded, "failed to expand north america child node");
50 }), 1000);
51 return d;
52 }
53 },
54 {
55 name: "click Africa's first child",
56 timeout: 7000,
57 runTest: function(){
58 var d = new doh.Deferred();
59
60 var myTree = registry.byId("mytree");
61 var rootChildren = myTree.rootNode.getChildren();
62 var africaChildren = rootChildren[0].getChildren();
63 var naChildren = rootChildren[4].getChildren();
64 doh.robot.mouseMoveAt(naChildren[0].contentNode, 500, 1);
65 doh.robot.mouseClick({left: true}, 500);
66
67 doh.robot.mouseMoveAt(africaChildren[0].contentNode, 1000, 1);
68 doh.robot.mouseClick({left: true}, 500);
69
70 doh.robot.sequence(d.getTestCallback(function(){
71 doh.is("Egypt was clicked", africaChildren[0].labelNode.innerHTML);
72 }), 1000);
73 return d;
74 }
75 },
76 {
77 name: "click Mexico's first child",
78 timeout: 4000,
79 runTest: function(){
80 var d = new doh.Deferred();
81
82 var myTree = registry.byId("mytree");
83 var rootChildren = myTree.rootNode.getChildren();
84 var naChildren = rootChildren[4].getChildren();
85 var mexicoChildren = naChildren[0].getChildren();
86
87 doh.robot.mouseMoveAt(mexicoChildren[0].contentNode, 500, 1);
88 doh.robot.mouseClick({left: true}, 500);
89
90 doh.robot.sequence(d.getTestCallback(function(){
91 doh.is("Mexico City was clicked", mexicoChildren[0].labelNode.innerHTML);
92 }), 1000);
93 return d;
94 }
95 },
96 {
97 name: "close tree nodes",
98 timeout: 7000,
99 runTest: function(){
100 var d = new doh.Deferred();
101
102 var myTree = registry.byId("mytree");
103 var rootChildren = myTree.rootNode.getChildren();
104 var naChildren = rootChildren[4].getChildren();
105
106 doh.robot.mouseMoveAt(naChildren[0].contentNode, 500, 1);
107 doh.robot.mouseClick({left: true}, 500);
108
109 doh.robot.mouseMoveAt(rootChildren[4].contentNode, 500, 1);
110 doh.robot.mouseClick({left: true}, 500);
111
112 doh.robot.mouseMoveAt(rootChildren[0].contentNode, 500, 1);
113 doh.robot.mouseClick({left: true}, 500);
114
115 doh.robot.sequence(d.getTestCallback(function(){
116 doh.f(naChildren[0].isExpanded, "failed to close Mexico child node");
117 doh.f(rootChildren[0].isExpanded, "failed to close Africa child node");
118 doh.f(rootChildren[4].isExpanded, "failed to close North America child node");
119 }), 500);
120 return d;
121 }
122 },
123 {
124 name: "Destroy tree",
125 timeout: 4000,
126 runTest: function(){
127 registry.byId("mytree").destroy();
128
129 doh.is(undefined, registry.byId("mytree"), "tree was not destroyed");
130 doh.is(undefined, dojo.byId("mytree"), 'widget was removed');
131 }
132 }
133 ]);
134
135 doh.register("Test tree 2", [
136 {
137 name: "expand first node",
138 timeout: 4000,
139 runTest: function(){
140 var d = new doh.Deferred();
141
142 var myTree = registry.byId("tree2");
143 var children = myTree.rootNode.getChildren();
144
145 var ex = children[0].expandoNode;
146 doh.robot.mouseMoveAt(children[0].expandoNode, 500, 1);
147 doh.robot.mouseClick({left: true}, 500);
148
149 doh.robot.sequence(d.getTestCallback(function(){
150 doh.f(isVisible(myTree.rootNode.labelNode), "root node is visible");
151 doh.t(children[0].isExpanded, "failed to expand first node");
152
153 var style = dojo.getComputedStyle(children[0].iconNode);
154 doh.t(style.backgroundImage.indexOf("folderIcons.")>0, "custom icon was not used");
155 }), 1000);
156 return d;
157 }
158 },
159 {
160 name: "click Africa",
161 timeout: 4000,
162 runTest: function(){
163 var d = new doh.Deferred();
164
165 var myTree = registry.byId("tree2");
166 var rootChildren = myTree.rootNode.getChildren();
167
168 doh.robot.mouseMoveAt(rootChildren[0].contentNode, 500, 1);
169 doh.robot.mouseClick({left: true}, 500);
170
171 doh.robot.sequence(d.getTestCallback(function(){
172 doh.is("Africa (population: 900 million)", rootChildren[0].labelNode.innerHTML);
173 }), 1000);
174 return d;
175 }
176 }
177 ]);
178
179 doh.run();
180 });
181 </script>
182 </head>
183 </html>