Debian Codegraph @

dijit/tests/robot/TitlePane.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 TitlePane 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/_base/lang", "dojo/query", "dojo/window",
19 "dijit/tests/helpers", "dojo/domReady!"
20 ], function(doh, robot, aspect, dom, keys, lang, query, winUtils, helpers){
21
22 robot.initRobot('../test_TitlePane.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 var pane1, pane2, pane3, href1, href2;
31
32 doh.register("api", [
33 {
34 name: "setup",
35 runTest: function(){
36 pane1 = registry.byId("testPane1");
37 pane2 = registry.byId("pane_2");
38 pane3 = registry.byId("closed"); // initially closed
39 href1 = registry.byId("href1"); // initially closed href, href load completes after expand
40 href2 = registry.byId("href2"); // initially closed href, href load completes during expand
41 }
42 },
43 {
44 name: "title",
45 runTest: function(){
46 doh.is("Title Pane #1", pane1.get("title"), "title attr");
47 doh.is("Title Pane #1", helpers.innerText(pane1.titleNode), "inner text");
48
49 pane1.set("title", "modified title");
50
51 doh.is("modified title", pane1.get("title"), "title attr modified");
52 doh.is("modified title", helpers.innerText(pane1.titleNode), "inner text modified");
53 }
54 },
55
56 {
57 name: "open",
58 timeout: 10000,
59 runTest: function(){
60 var d = new doh.Deferred();
61
62 doh.t(pane1.domNode.offsetHeight > 100, "pane 1 is open");
63 doh.t(pane1.get("open"), "pane1.open is true");
64
65 pane1.set("open", false);
66
67 robot.sequence(d.getTestCallback(function(){
68 doh.t(pane1.domNode.offsetHeight < 100, "pane 1 is closed");
69 doh.f(pane1.get("open"), "pane1.open is false");
70 }), 500);
71
72 return d;
73 }
74 }
75 ]);
76
77 doh.register("keyboard", [
78 {
79 name: "tabbing",
80 timeout: 10000,
81 runTest: function(){
82 var d = new doh.Deferred();
83
84 dom.byId("input").focus();
85
86 // should go to title bar
87 robot.keyPress(keys.TAB, 500, {});
88
89 robot.sequence(d.getTestErrback(function(){
90 doh.is(pane1.focusNode, dfocus.curNode,"focused on pane1 title")
91 }), 500);
92
93 // should skip hidden content and go to button
94 robot.keyPress(keys.TAB, 500, {});
95
96 robot.sequence(d.getTestErrback(function(){
97 doh.is(dom.byId("titleButton"), dfocus.curNode,"focused on title button after pane")
98 }), 500);
99
100 // go back to title bar
101 robot.keyPress(keys.TAB, 500, {shift: true});
102
103 robot.sequence(d.getTestCallback(function(){
104 doh.is(pane1.focusNode, dfocus.curNode,"focused on pane1 title")
105 }), 500);
106
107 return d;
108 }
109 },
110
111 {
112 name: "open",
113 timeout: 10000,
114 runTest: function(){
115 var d = new doh.Deferred();
116
117 robot.keyPress(keys.SPACE, 500);
118
119 robot.sequence(d.getTestCallback(function(){
120 doh.t(pane1.domNode.offsetHeight > 100, "pane 1 is open");
121 doh.t(pane1.get("open"), "pane1.open is true");
122 }), 500);
123
124 return d;
125 }
126 },
127
128 {
129 name: "close",
130 timeout: 10000,
131 runTest: function(){
132 var d = new doh.Deferred();
133
134 robot.keyPress(keys.ENTER, 500);
135
136 robot.sequence(d.getTestCallback(function(){
137 doh.t(pane1.domNode.offsetHeight < 100, "pane 1 is closed");
138 }), 500);
139
140 return d;
141 }
142 }
143 ]);
144
145 doh.register("height checks", [
146 {
147 name: "content change",
148 timeout: 10000,
149 runTest: function(){
150 var d = new doh.Deferred();
151
152 var height1, height2, height3;
153
154 robot.sequence(d.getTestErrback(function(){
155 pane1.set("open", true);
156 }), 500);
157
158 // Changing the content while open should change the height
159 robot.sequence(d.getTestErrback(function(){
160 height1 = pane1.domNode.offsetHeight;
161 pane1.set("content", pane1.get("content") + "<br>new line");
162 }), 500);
163 robot.sequence(d.getTestErrback(function(){
164 height2 = pane1.domNode.offsetHeight;
165 doh.t(height2 > height1, "expected height increase, actually went from " + height1 + " to " + height2);
166 }), 500);
167
168 // Change the content while closed should also change the height (when it is next opened)
169 robot.sequence(d.getTestErrback(function(){
170 pane1.set("open", false);
171 }), 500);
172 robot.sequence(d.getTestErrback(function(){
173 pane1.set("content", pane1.get("content") + "<br>another new line");
174 pane1.set("open", true);
175 }), 500);
176 robot.sequence(d.getTestCallback(function(){
177 height3 = pane1.domNode.offsetHeight;
178 doh.t(height3 > height2, "expected height increase, actually went from " + height2 + " to " + height3);
179 }), 500);
180
181 return d;
182 }
183 },
184 {
185 name: "href loading",
186 timeout: 10000,
187 runTest: function(){
188 var d = new doh.Deferred();
189
190 // Open the href pane, causing the href to load
191 winUtils.scrollIntoView(registry.byId("inner").domNode);
192 robot.sequence(d.getTestErrback(function(){
193 href1.set("open", true);
194 }), 1000);
195
196 // Initially it should display "Loading..." with a small height (enough for that one message)
197 var height1, height2;
198 robot.sequence(d.getTestErrback(function(){
199 doh.is("Loading...", lang.trim(helpers.innerText(href1.containerNode)));
200 height1 = href1.domNode.offsetHeight;
201 }), 1500);
202
203 // Then the real content should be loaded and height should change to accommodate it
204 robot.sequence(d.getTestCallback(function(){
205 doh.isNot("Loading...", lang.trim(helpers.innerText(href1.containerNode)), "actual content");
206 height2 = href1.domNode.offsetHeight;
207 doh.t(height2 > height1, "expected height increase, actually went from " + height1 + " to " + height2);
208 }), 3000);
209
210 return d;
211 }
212 },
213 {
214 name: "href load complete during expand",
215 timeout: 10000,
216 runTest: function(){
217 var d = new doh.Deferred();
218
219 // Opening the href pane will cause it to expand, and during the expansion the load
220 // will finish. Make sure height shows full content
221 href2.set("open", true);
222
223 robot.sequence(d.getTestCallback(function(){
224 var height = href2.domNode.offsetHeight;
225 doh.t(height > 100, "height for full content not just loading message: " + height);
226 }), 2000);
227
228 return d;
229 }
230 }
231 ]);
232
233 doh.register("layout", [
234 {
235 name: "resize event",
236 timeout: 10000,
237 runTest: function(){
238 var d = new doh.Deferred();
239
240 // The first time pane3 is opened the tab container should get a resize event
241 var resized = false;
242 aspect.after(registry.byId("tabContainer"), "resize", function(){ resized = true;}, true);
243
244 doh.f(pane3.get("open"), "pane3 is closed");
245 pane3.set("open", true);
246 robot.sequence(d.getTestCallback(function(){
247 doh.t(resized, "tabcontainer was resized");
248 }), 500);
249
250 return d;
251 }
252 }
253 ]);
254
255 doh.register("TitlePane in AccordionContainer", [
256 {
257 name: "initial conditions",
258 runTest: function(){
259 // none of the TitlePane's inside of the AccordionContainer should have loaded
260 // their href, since they are closed
261 doh.f(robot.window["actp1Loaded"], "closed TitlePane in open accordion pane not loaded");
262 doh.t(robot.window["actp2Loaded"], "open TitlePane in open accordion pane loaded");
263 doh.f(robot.window["actp3Loaded"], "first TitlePane in closed accordion pane not loaded");
264 doh.f(robot.window["actp4Loaded"], "open TitlePane in closed accordion pane not loaded");
265 }
266 },
267
268 {
269 name: "switch open accordion pane",
270 timeout: 10000,
271 runTest: function(){
272 var d = new doh.Deferred();
273
274 registry.byId("ac").selectChild(registry.byId("accp2"));
275
276 setTimeout(d.getTestCallback(function(){
277 doh.f(robot.window["actp1Loaded"], "closed TitlePane in newly closed accordion pane not loaded");
278 doh.f(robot.window["actp3Loaded"], "closed TitlePane in newly opened accordion pane not loaded");
279 doh.t(robot.window["actp4Loaded"], "opened TitlePane in newly opened accordion pane loaded");
280 }), 500);
281
282 return d;
283 }
284 },
285
286 {
287 name: "open a TitlePane",
288 timeout: 10000,
289 runTest: function(){
290 var d = new doh.Deferred();
291
292 registry.byId("actp3").set("open", true);
293
294 setTimeout(d.getTestCallback(function(){
295 doh.t(robot.window["actp3Loaded"], "opening TitlePane causes href to load");
296 }), 500);
297
298 return d;
299 }
300 }
301 ]);
302
303 doh.run();
304 });
305 </script>
306 </head>
307 </html>