Debian Codegraph @

dijit/tests/layout/robot/BorderContainer_complex.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>robot BorderContainer complex 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"
13 data-dojo-config="isDebug: true"></script>
14
15 <script type="text/javascript">
16 require([
17 "doh/runner", "dojo/robotx", "dojo/aspect", "dojo/dom", "dojo/dom-geometry", "dojo/keys",
18 "dijit/tests/helpers", "dijit/tests/layout/robot/borderContainerTestFunctions", "dojo/domReady!"
19 ], function(doh, robot, aspect, dom, geom, keys, helpers, bcTest){
20
21 robot.initRobot('../test_BorderContainer_complex.html');
22
23 var registry, focus;
24
25 doh.register("setup", [
26 function setup(){
27 // get pointers to singletons loaded on test page
28 registry = robot.window.require("dijit/registry");
29 focus = robot.window.require("dijit/focus");
30 }
31 ]);
32
33 doh.register("API", [
34 function initialConditions(){
35 bcTest.checkBCpanes(registry.byId("border1"));
36 }
37 ]);
38
39 //test some basic functionality of the complex widgets to get a feel for whether they work inside the border container
40 doh.register("tabContainer", [
41 {
42 name: "tab2Selected",
43 runTest: function(t){
44 doh.f(registry.byId("tab1").selected, "tab1 not selected");
45 doh.t(registry.byId("tab2").selected, "tab2 selected");
46 doh.f(registry.byId("tab3").selected, "tab3 not selected");
47 doh.f(registry.byId("tab4").selected, "tab4 not selected");
48 doh.f(registry.byId("tab5").selected, "tab5 not selected");
49 doh.f(registry.byId("tab6").selected, "tab6 not selected");
50 }
51 },
52 {
53 name: "tabsCanBeShownWhenSelected_tab1",
54 timeout: 3000,
55 runTest: function(t){
56 var d = new doh.Deferred();
57
58 robot.mouseMoveAt("mainTabContainer_tablist_tab1", 500, 1);
59 robot.mouseClick({left:true}, 500);
60
61 robot.sequence(d.getTestCallback(function(){
62 doh.is("mainTabContainer_tablist_tab1", focus.curNode.id, "current focus");
63 doh.is("tab1", registry.byId("mainTabContainer").selectedChildWidget.id, "selectedChildWidget");
64 doh.t(helpers.isVisible(registry.byId("tab1")), "tab1 visible");
65 }), 1000);
66
67 return d;
68 }
69 },
70 {
71 name: "tabsCanBeShownWhenSelected_tab2",
72 timeout: 3000,
73 runTest: function(t){
74 var d = new doh.Deferred();
75 robot.keyPress(keys.RIGHT_ARROW, 1000, {});
76
77 robot.sequence(d.getTestCallback(function(){
78 doh.is("mainTabContainer_tablist_tab2", focus.curNode.id, "current focus");
79 doh.is("tab2", registry.byId("mainTabContainer").selectedChildWidget.id, "selectedChildWidget");
80 doh.t(helpers.isVisible(registry.byId("tab2")), "tab2 visible");
81 doh.t(helpers.isHidden(registry.byId("tab1")), "tab1 hidden");
82 }), 1000);
83
84 return d;
85 }
86 },
87 {
88 name: "tabsCanBeShownWhenSelected_tab3",
89 timeout: 3000,
90 runTest: function(t){
91 var d = new doh.Deferred();
92 robot.keyPress(keys.RIGHT_ARROW, 1000, {});
93
94 robot.sequence(d.getTestCallback(function(){
95 doh.is("mainTabContainer_tablist_tab3", focus.curNode.id, "current focus");
96 doh.is("tab3", registry.byId("mainTabContainer").selectedChildWidget.id, "selectedChildWidget");
97 doh.t(helpers.isVisible(registry.byId("tab3")), "tab3 visible");
98 doh.t(helpers.isHidden(registry.byId("tab2")), "tab2 hidden");
99 }), 1000);
100
101 return d;
102 }
103 },
104 {
105 name: "tabsCanBeShownWhenSelected_tab4",
106 timeout: 3000,
107 runTest: function(t){
108 var d = new doh.Deferred();
109 robot.keyPress(keys.RIGHT_ARROW, 1000, {});
110
111 robot.sequence(d.getTestCallback(function(){
112 doh.is("mainTabContainer_tablist_tab4", focus.curNode.id, "current focus");
113 doh.is("tab4", registry.byId("mainTabContainer").selectedChildWidget.id, "selectedChildeWidget");
114 doh.t(helpers.isVisible(registry.byId("tab4")), "Tab4 is hidden");
115 doh.t(helpers.isHidden(registry.byId("tab3")), "Tab3 is visible");
116 }), 1000);
117
118 return d;
119 }
120 },
121 {
122 name: "tabsCanBeShownWhenSelected_tab5",
123 timeout: 3000,
124 runTest: function(t){
125 var d = new doh.Deferred();
126 robot.keyPress(keys.RIGHT_ARROW, 1000, {});
127
128 robot.sequence(d.getTestCallback(function(){
129 doh.is("mainTabContainer_tablist_tab5", focus.curNode.id, "current focus");
130 doh.is("tab5", registry.byId("mainTabContainer").selectedChildWidget.id, "selectedChildWidget");
131 doh.t(helpers.isVisible(registry.byId("tab5")), "tab5 visible");
132 doh.t(helpers.isHidden(registry.byId("tab4")), "tab4 hidden");
133 }), 1000);
134
135 return d;
136 }
137 },
138 {
139 name: "tabsCanBeShownWhenSelected_tab6",
140 timeout: 3000,
141 runTest: function(t){
142 var d = new doh.Deferred();
143 robot.keyPress(keys.RIGHT_ARROW, 1000, {});
144
145 robot.sequence(d.getTestCallback(function(){
146 doh.is("mainTabContainer_tablist_tab6", focus.curNode.id, "current focus");
147 doh.is("tab6", registry.byId("mainTabContainer").selectedChildWidget.id, "selectedChildWidget");
148 doh.t(helpers.isVisible(registry.byId("tab6")), "tab6 visible");
149 doh.t(helpers.isHidden(registry.byId("tab5")), "tab5 hidden");
150 }), 1000);
151
152 return d;
153 }
154 }
155 ]);
156
157 doh.register("AccordionContainer", [
158 {
159 name: "pane1Selected",
160 runTest: function(t){
161 doh.t(registry.byId("ap1").selected, "ap1 selected");
162 doh.f(registry.byId("ap2").selected, "ap2 not selected");
163 doh.f(registry.byId("ap3").selected, "ap3 not selected");
164 doh.t(helpers.isVisible(registry.byId("ap1")), "ap1 is visible");
165 doh.t(helpers.isHidden(registry.byId("ap2")), "ap2 is hidden");
166 doh.t(helpers.isHidden(registry.byId("ap3")), "ap3 is hidden");
167 }
168 },
169 {
170 name: "focus ap1 title bar",
171 runTest: function(t){
172 registry.byId("ap1_button").focusNode.focus();
173 }
174 },
175 {
176 name: "select ap2",
177 timeout: 3000,
178 runTest: function(t){
179 var d = new doh.Deferred();
180
181 // Connect to _hideChild() as a trick to tell when animation is finished
182 handle = aspect.after(registry.byId("ac1"), "_hideChild", function(){
183 setTimeout(d.getTestCallback(function(){
184 doh.is("ap2_button", focus.curNode.parentNode.id, "current focus");
185 doh.is("ap2", registry.byId("ac1").selectedChildWidget.id, "selectedChildWidget");
186 doh.t(helpers.isVisible(registry.byId("ap2")), "ap2 visible");
187 doh.t(helpers.isHidden(registry.byId("ap1")), "ap1 hidden");
188 }), 0);
189 });
190
191 robot.keyPress(keys.DOWN_ARROW, 1000, {});
192
193 return d;
194 },
195 tearDown: function(){
196 handle.remove();
197 }
198 },
199 {
200 name: "select ap3",
201 timeout: 3000,
202 runTest: function(t){
203 var d = new doh.Deferred();
204
205 // Connect to _hideChild() as a trick to tell when animation is finished
206 handle = aspect.after(registry.byId("ac1"), "_hideChild", function(){
207 setTimeout(d.getTestCallback(function(){
208 doh.is("ap3_button", focus.curNode.parentNode.id, "current focus");
209 doh.is("ap3", registry.byId("ac1").selectedChildWidget.id, "selectedChildWidget");
210 doh.t(helpers.isVisible(registry.byId("ap3")), "ap3 visible");
211 doh.t(helpers.isHidden(registry.byId("ap2")), "ap2 hidden");
212 }), 0);
213 }, true);
214
215 robot.keyPress(keys.DOWN_ARROW, 1000, {});
216
217 return d;
218 },
219 tearDown: function(){
220 handle.remove();
221 }
222 },
223 {
224 name: "resize accordion",
225 timeout: 6000,
226 runTest: function(t){
227 var d = new doh.Deferred();
228
229 var accordion = geom.position(dom.byId("ac1"));
230 var centerPane = geom.position(dom.byId("mainCP"));
231 var centerPaneRight = centerPane.x + centerPane.w;
232 var filteringSelectWidth = geom.position(registry.byId("filteringSelect").domNode).w;
233 var move = filteringSelectWidth - centerPane.w + 30;
234
235 // Drag slider to shrink pane
236 var size = geom.position("ac1_splitter");
237 robot.mouseMoveAt("ac1_splitter", 0, 1);
238 robot.mousePress({left: true}, 500);
239 robot.mouseMoveAt("ac1_splitter", 500, 1, size.w/2-move, size.h/2);
240 robot.sequence(function(){
241 var newCenterPane = geom.position(dom.byId("mainCP"));
242 var newCenterPaneRight = newCenterPane.x + newCenterPane.w;
243 // center could overlap right pane
244 var move2 = centerPaneRight - newCenterPaneRight;
245 robot.mouseMoveAt("ac1_splitter", 500, 1, size.w/2-move2, size.h/2);
246 move += move2;
247
248 robot.mouseRelease({left: true}, 500);
249 robot.sequence(d.getTestCallback(function(){
250 // test that the margin box for the accordion pane grows the same size as the splitter moved
251 var newAccordion = geom.position(dom.byId("ac1"));
252 doh.is(Math.round(newAccordion.w), Math.round(accordion.w-move), 'old accordion w = ' + accordion.w + ', new w = ' + newAccordion.w);
253
254 // test that the center content got smaller by the same size that the splitter moved
255 var newCenterPane = geom.position(dom.byId("mainCP"));
256 var newCenterPaneRight = newCenterPane.x + newCenterPane.w;
257 doh.is(Math.round(newCenterPane.w), Math.round(centerPane.w+move-centerPaneRight+newCenterPaneRight), 'old center pane w = ' + centerPane.w + ', new w = ' + newCenterPane.w);
258 }), 500);
259 }, 500);
260
261 return d;
262 }
263 }
264 ]);
265
266 var filteringSelect, handler;
267 doh.register("filteringSelect", [
268 {
269 name: "changeValue",
270 timeout: 10000,
271 runTest: function(t){
272 var d = new doh.Deferred();
273
274 filteringSelect = registry.byId("filteringSelect");
275 handler = filteringSelect.on("change", function(e){
276 d.callback(true);
277 });
278
279 filteringSelect.focus();
280 robot.keyPress(keys.DOWN_ARROW, 1000, {});
281 robot.keyPress(keys.DOWN_ARROW, 1000, {});
282 robot.keyPress(keys.DOWN_ARROW, 500, {});
283 robot.keyPress(keys.ENTER, 500, {});
284
285 return d;
286 },
287 tearDown: function(t){
288 handler.remove();
289 }
290 }
291 ]);
292
293 doh.register("editor", [
294 {
295 name: "changeValue",
296 timeout: 3000,
297 runTest: function(t){
298 var d = new doh.Deferred();
299
300 robot.sequence(function(){
301 var editor = registry.byId("editor1");
302 editor.setValue("<div id='myDiv'>This is my new text</div>");
303 }, 1000);
304
305 robot.sequence(d.getTestCallback(function(){
306 var myDiv = registry.byId("editor1").editNode.childNodes[0];
307 doh.is("myDiv", myDiv.id, "myDiv was not the first child node as expected");
308 doh.t(helpers.isVisible(myDiv), "myDiv is visible");
309 }), 1000);
310
311 return d;
312 }
313 }
314 ]);
315
316 doh.run();
317 });
318 </script>
319 </head>
320 </html>