Debian Codegraph @

dijit/tests/robot/Dialog_mouse.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 Dialog Mouse 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",
18 "dojo/aspect", "dojo/dom", "dojo/keys", "dojo/query",
19 "dijit/tests/helpers", "dojo/domReady!"
20 ], function(doh, robot, aspect, dom, keys, query, helpers){
21
22 robot.initRobot('../test_Dialog.html');
23
24 doh.register(function setup(){
25 // get pointer to registry in the iframe
26 registry = robot.window.require("dijit/registry");
27 dfocus = robot.window.require("dijit/focus");
28 });
29
30
31 doh.register("dijit.Dialog mouse tests (cancel)", [
32 {
33 name: "open dialog",
34 timeout: 4000,
35 runTest: function(){
36 var d = new doh.Deferred();
37
38 var oldOnClick = registry.byId("dialog1button").onClick;
39 registry.byId("dialog1button").onClick = function(){
40 registry.byId("dialog1").show().then(d.getTestCallback(function(){
41 doh.t(helpers.isVisible("dialog1"), "dialog 1 has been made visible");
42 doh.is("name", dfocus.curNode.id, "focus is on the first field");
43 }));
44 registry.byId("dialog1button").onClick = oldOnClick;
45 };
46
47 // Open the dialog
48 robot.mouseMoveAt("dialog1button", 1000);
49 robot.mouseClick({left: true}, 1000);
50
51 return d;
52 }
53 },
54
55 {
56 name: "test that other controls on page can't be clicked",
57 timeout: 4000,
58 runTest: function(){
59 var d = new doh.Deferred();
60
61 robot.mouseMoveAt("plainInput", 500);
62 robot.mouseClick({left: true}, 1000);
63
64 robot.sequence(d.getTestCallback(function(){
65 doh.t(helpers.isVisible("dialog1"), "dialog 1 still visible");
66 doh.isNot("plainInput", dfocus.curNode && dfocus.curNode.id,
67 "focus did not go to plain input");
68 }), 1000);
69
70 return d;
71 }
72 },
73
74 {
75 name: "open date drop down",
76 timeout: 10000,
77 runTest: function(){
78 var d = new doh.Deferred();
79
80 helpers.onFocus(d.getTestCallback(function(){
81 var calDomNode = query(".dijitCalendarContainer");
82 doh.t(1, calDomNode.length, "found calendar");
83 doh.t(helpers.isVisible(calDomNode[0]), "calendar is being shown");
84 doh.t(dom.isDescendant(dfocus.curNode, calDomNode[0]), "focus is on the calendar");
85 }), 500); // Focus might first go to input, then to calendar, so wait for that
86
87
88 robot.mouseMoveAt(function(){
89 return query(".dijitArrowButton", registry.byId("date").domNode)[0];
90 }, 500);
91 robot.mouseClick({left: true}, 1000);
92
93 return d;
94 }
95 },
96
97 {
98 name: "close date drop down",
99 timeout: 4000,
100 runTest: function(){
101 var d = new doh.Deferred();
102
103 robot.mouseMove(10, 10, 500);
104 robot.mouseClick({left: true}, 1000);
105
106 robot.sequence(d.getTestCallback(function(){
107 var calDomNode = query(".dijitCalendarContainer");
108 doh.t(calDomNode.length == 0 || helpers.isHidden(calDomNode[0]), "calendar has disappeared");
109 doh.t(helpers.isVisible("dialog1"), "dialog 1 wasn't closed");
110 }), 1000);
111
112 return d;
113 }
114 },
115
116 {
117 name: "cancel dialog",
118 timeout: 5000,
119 runTest: function(){
120 var d = new doh.Deferred();
121
122 var button = query("#dialog1 .dijitDialogCloseIcon")[0];
123 robot.mouseMoveAt(button, 500);
124 robot.mouseClick({left: true}, 500);
125
126 robot.sequence(d.getTestCallback(function(node){
127 doh.t(helpers.isHidden("dialog1"), "dialog 1 was closed");
128 }), 500);
129
130 return d;
131 }
132 }
133 ]);
134
135 doh.register("dijit.Dialog mouse tests (submit)", [
136 {
137 name: "submit some data",
138 timeout: 15000,
139 setUp: function(){
140 registry.byId("dialog1").reset();
141 },
142 runTest: function(){
143 var d = new doh.Deferred();
144
145 // Setup handler to catch submitted data
146 var data;
147 aspect.after(registry.byId("dialog1"), "execute", function(vals){
148 data = vals;
149 }, true);
150
151 // Open the dialog
152 robot.mouseMoveAt("dialog1button", 500, 1);
153 robot.mouseClick({left: true}, 500);
154
155 // Enter some info
156 robot.mouseMoveAt("name", 500, 1);
157 robot.mouseClick({left: true}, 500);
158 robot.typeKeys("Ted", 500, 600);
159
160 robot.mouseMoveAt("loc", 500, 1);
161 robot.mouseClick({left: true}, 500);
162 robot.typeKeys("America", 500, 1400);
163
164 // Submit
165 robot.mouseMoveAt("ok", 500, 1);
166 robot.mouseClick({left: true}, 500);
167
168 robot.sequence(d.getTestCallback(function(){
169 doh.t(helpers.isHidden("dialog1"), "dialog 1 was closed on submit");
170 doh.t(data, "got submit data");
171 doh.is("Ted", data.name, "Name");
172 doh.is("America", data.loc, "Location");
173 }), 1000);
174
175 return d;
176 }
177 }
178 ]);
179
180 doh.register("dijit.Dialog mouse tests (unfocusable open button)", [
181 {
182 name: "open #1",
183 timeout: 10000,
184 runTest: function(){
185 var d = new doh.Deferred();
186
187 // Open the dialog
188 robot.mouseMoveAt("SelfDestructDlgBtn2", 1000);
189 robot.mouseClick({left: true}, 1000);
190 robot.sequence(d.getTestCallback(function(){
191 doh.t(registry.byId("SelfDestructDlg"), "dialog created");
192 doh.t(helpers.isVisible("SelfDestructDlgBtn2"), "dialog has been made visible");
193 doh.is("SelfDestructDlgInput", dfocus.curNode.id, "focus is on the first field");
194 }), 1000);
195
196 return d;
197 }
198 },
199 {
200 name: "close #1",
201 timeout: 10000,
202 runTest: function(){
203 var d = new doh.Deferred();
204
205 // Close the dialog
206 robot.mouseMoveAt(function(){
207 return query("#SelfDestructDlg .dijitDialogCloseIcon")[0];
208 }, 1000);
209 robot.mouseClick({left: true}, 1000);
210 robot.sequence(d.getTestCallback(function(){
211 doh.f(registry.byId("SelfDestructDlg"), "dialog destroyed");
212
213 var focus = dfocus.curNode;
214 doh.f(focus, "focus should have been cleared, but set to " +
215 focus + (focus && focus.tagName) + (focus && focus.id));
216 }), 1000);
217
218 return d;
219 }
220 },
221 {
222 name: "open #2",
223 timeout: 10000,
224 runTest: function(){
225 var d = new doh.Deferred();
226
227 // Open the dialog
228 robot.mouseMoveAt("SelfDestructDlgBtn2", 1000);
229 robot.mouseClick({left: true}, 1000);
230 robot.sequence(d.getTestCallback(function(){
231 doh.t(registry.byId("SelfDestructDlg"), "dialog created");
232 doh.t(helpers.isVisible("SelfDestructDlgBtn2"), "dialog has been made visible");
233 doh.is("SelfDestructDlgInput", dfocus.curNode.id, "focus is on the first field");
234 }), 1000);
235
236 return d;
237 }
238 },
239 {
240 name: "close #2",
241 timeout: 10000,
242 runTest: function(){
243 var d = new doh.Deferred();
244
245 // Close the dialog
246 robot.mouseMoveAt(function(){
247 return query("#SelfDestructDlg .dijitDialogCloseIcon")[0];
248 }, 1000);
249 robot.mouseClick({left: true}, 1000);
250 robot.sequence(d.getTestCallback(function(){
251 doh.f(registry.byId("SelfDestructDlg"), "dialog destroyed");
252
253 var focus = dfocus.curNode;
254 doh.f(focus, "focus should have been cleared, but set to " +
255 focus + (focus && focus.tagName) + (focus && focus.id));
256 }), 1000);
257
258 return d;
259 }
260 }
261 ]);
262
263 // Opening a context menu shifts focus away from the Dialog but we shouldn't automatically shift focus back
264 doh.register("context menu", [
265 {
266 name: "open first",
267 timeout: 10000,
268 runTest: function(){
269 return registry.byId('dialog1').show();
270 }
271 },
272 {
273 name: "open context menu",
274 timeout: 10000,
275 runTest: function(){
276 var d = new doh.Deferred();
277
278 robot.mouseMoveAt("dialog1", 500);
279 robot.mouseClick({right: true}, 1000);
280
281 robot.sequence(d.getTestCallback(function(){
282 doh.t(helpers.isVisible("dialog1"), "dialog 1 still visible");
283 doh.t(helpers.isVisible("dialog1ContextMenu"), "context menu visible");
284 doh.is("firstMenuItem", dfocus.curNode && dfocus.curNode.id,
285 "focus on Menu");
286 }), 1000);
287
288 return d;
289 }
290 },
291 {
292 name: "close first",
293 timeout: 10000,
294 runTest: function(){
295 return registry.byId('dialog1').hide();
296 }
297 }
298 ]);
299
300 doh.register("ESC", [
301 {
302 name: "open dialog",
303 timeout: 4000,
304 runTest: function(){
305 var d = new doh.Deferred();
306
307 // Open the dialog
308 robot.mouseMoveAt("dialog1button", 1000);
309 robot.mouseClick({left: true}, 1000);
310 robot.sequence(d.getTestCallback(function(){}));
311
312 return d;
313 }
314 },
315
316 {
317 name: "click background",
318 timeout: 4000,
319 runTest: function(){
320 var d = new doh.Deferred();
321
322 robot.mouseMoveAt("plainInput", 500);
323 robot.mouseClick({left: true}, 1000);
324
325 robot.sequence(d.getTestCallback(function(){
326 doh.t(helpers.isVisible("dialog1"), "dialog 1 still visible");
327 doh.isNot("plainInput", dfocus.curNode && dfocus.curNode.id,
328 "focus did not go to plain input");
329 }), 1000);
330
331 return d;
332 }
333 },
334
335 {
336 name: "close via ESC",
337 timeout: 4000,
338 runTest: function(){
339 var d = new doh.Deferred();
340
341 robot.keyPress(keys.ESCAPE, 500, {});
342
343 robot.sequence(d.getTestCallback(function(){
344 doh.t(helpers.isHidden("dialog1"), "dialog 1 was closed");
345 }), 1000);
346
347 return d;
348 }
349 }
350 ]);
351
352 doh.register("dijit.Dialog InlineEditBox w/Editor tests", [
353 {
354 name: "#17225",
355 timeout: 10000,
356 runTest: function(){
357 var d = new doh.Deferred();
358
359 // Open the dialog
360 robot.mouseMoveAt("iebDialogBtn", 1000);
361 robot.mouseClick({left: true}, 1000);
362
363 // Open second InlineEditBox
364 robot.mouseMoveAt("inlineRTE2", 1000);
365 robot.mouseClick({left: true}, 1000);
366
367 // Test that editor didn't close immediately and focus move back to the first field
368 robot.sequence(d.getTestCallback(function(){
369 doh.t(helpers.isVisible("RTE2"), "editor 2 visible");
370 }), 1000);
371
372 return d;
373 }
374 }
375 ]);
376
377 doh.run();
378 });
379 </script>
380 </head>
381 </html>