source: Dev/branches/rest-dojo-ui/client/dijit/tests/robot/TitlePane.html @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

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