Debian Codegraph @

dojox/app/tests/doh/simpleModelApp/index.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
5 <meta name="apple-mobile-web-app-capable" content="yes" />
6 <title>Simple Model App Test</title>
7 <link href="../../../../mobile/themes/iphone/base.css" rel="stylesheet">
8 <style>
9 html,body {
10 width: 100%;
11 height: 100%;
12 background: #eee;
13 font-family: arial;
14 color: #333;
15 overflow: hidden;
16 margin: 0;
17 padding: 0;
18 visibility: visible;
19 }
20
21 #splash {
22 width: 90%;
23 height: 90%;
24 margin: auto;
25 overflow: hidden;
26 border: 2px solid green;
27 color: #333;
28 text-align: center;
29 }
30
31 </style>
32 <script type="text/javascript">
33 dojoConfig = {
34 parseOnLoad: false,
35 mblHideAddressBar: false,
36 mblAndroidWorkaround: false,
37 mblAlwaysHideAddressBar: false,
38 async:1,
39 app: {debugApp: 0} // set debugApp to log app transitions and view activate/deactivate
40 };
41 </script>
42 <script type="text/javascript" src="../../../../../dojo/dojo.js"></script>
43
44 <script>
45 // the actual launcher
46 require(["../../simpleModelApp/modelApp.js"], function(){});
47 </script>
48 <script type="text/javascript">
49 require([
50 "doh/runner",
51 "dojo/topic",
52 "dojo/_base/lang",
53 "dojox/mobile/TransitionEvent",
54 "dojo/parser",
55 "dojo/when",
56 "dojo/Stateful",
57 "dijit/registry",
58 "dojox/mvc/at"
59 ], function(doh, topic, lang, TransitionEvent, parser, when, Stateful, registry, at){
60 window.at = at;
61 var events = [];
62
63 var getLabelfromWid = function(wid, indx1, indx2){
64 var val = wid.labelNode.innerText || wid.labelNode.firstChild.nodeValue || "";
65 val = lang.trim(val);
66 if(indx2){
67 val = val.substring(indx1,indx2)
68 }
69 return val;
70 };
71
72 topic.subscribe("/app/status", lang.hitch(this, function(newStatus) {
73 events.push(newStatus);
74 if (newStatus == 2) {
75 var listItem_0TestStr = "simple - Using an mvcModel (dojox/mvc/ModelRefController) with json data, no store";
76 var listItem_1TestStr = "simple2 - Using an mvcModel (dojox/mvc/EditModelRefController) with json data, no store";
77 doh.register("Test-SimpleApp", [{
78 // Test initial listitem labels
79 name : "initial-listItem-labels",
80 runTest : function() {
81 var dfd = new doh.Deferred();
82 setTimeout(function() {
83 var ListItem_0Label = registry.byId("dojox_mobile_ListItem_0");
84 if(ListItem_0Label){
85 var lab = getLabelfromWid(ListItem_0Label,0,listItem_0TestStr.length);
86 doh.is(lab, listItem_0TestStr);
87 }else{
88 throw new Error("In initial-listItem-labels ListItem_0Label not found.");
89 }
90 var ListItem_1Label = registry.byId("dojox_mobile_ListItem_1");
91 if(ListItem_1Label){
92 doh.is(getLabelfromWid(ListItem_1Label,0,listItem_1TestStr.length), listItem_1TestStr);
93 }else{
94 throw new Error("In initial-listItem-labels ListItem_1Label not found.");
95 }
96 return dfd.callback(true);
97 }, 500);
98 return dfd;
99 }
100 }, {
101 // Test first transition
102 name : "transition-test-1",
103 runTest : function() {
104 var dfd = new doh.Deferred();
105 setTimeout(function() {
106 // transition to first li
107 var liWidget = registry.byId("dojox_mobile_ListItem_0");
108 var ev = new TransitionEvent(liWidget.domNode, liWidget.params);
109 ev.dispatch();
110 return dfd.callback(true);
111 }, 500);
112 }
113 }, {
114 // Test simple view 1
115 name : "simple-mvc-test-1",
116 timeout: 4000,
117 runTest : function() {
118 var dfd = new doh.Deferred();
119 setTimeout(function() {
120 var wid = registry.byId("streetInput");
121 if(wid){
122 doh.is("123 Valley Rd", wid.get("value"), "Street should be of ShipTo");
123 }else{
124 throw new Error("In simple-mvc-test-1 streetInput not found.");
125 //console.warn("In simple-mvc-test-1 streetInput not found.");
126 }
127 var wid = registry.byId("cityInput");
128 if(wid){
129 doh.is("Katonah", wid.get("value"), "City should be of ShipTo");
130 }else{
131 throw new Error("In simple-mvc-test-1 cityInput not found.");
132 //console.warn("In simple-mvc-test-1 cityInput not found.");
133 }
134 return dfd.callback(true);
135 }, 1000);
136 return dfd;
137 }
138 }, {
139 // Test switch to billto
140 name : "simple-mvc-test-2",
141 runTest : function() {
142 var dfd = new doh.Deferred();
143 setTimeout(function() {
144 var group = registry.byId("addrGroup");
145 group.set("target", at("rel:", "BillTo"));
146 doh.is("17 Skyline Dr", registry.byId("streetInput").get("value"), "Street should be of BillTo");
147 doh.is("Hawthorne", registry.byId("cityInput").get("value"), "City should be of BillTo");
148 return dfd.callback(true);
149 }, 500);
150 return dfd;
151 }
152 }, {
153 // Test switch back to home
154 name : "backToHome1",
155 runTest : function() {
156 var dfd = new doh.Deferred();
157 setTimeout(function() {
158 var backHeader = registry.byId("dojox_mobile_Heading_1");
159 var transOpts = {
160 viewid : "home",
161 reverse : true,
162 url : "#home" // this is optional if not set it will be created from target
163 };
164 var ev = new TransitionEvent(backHeader.domNode, transOpts);
165 ev.dispatch();
166 return dfd.callback(true);
167 }, 500);
168 return dfd;
169 }
170 }, {
171 // Test verify back to at home
172 name : "testbackToHome1",
173 runTest : function() {
174 var dfd = new doh.Deferred();
175 setTimeout(function() {
176 var ListItem_0Label = registry.byId("dojox_mobile_ListItem_0");
177 if(ListItem_0Label){
178 doh.is(getLabelfromWid(ListItem_0Label,0,82), listItem_0TestStr);
179 }else{
180 throw new Error("In testbackToHome1 ListItem_0Label not found.");
181 }
182 var ListItem_1Label = registry.byId("dojox_mobile_ListItem_1");
183 if(ListItem_1Label){
184 doh.is(getLabelfromWid(ListItem_1Label,0,87), listItem_1TestStr);
185 }else{
186 throw new Error("In testbackToHome1 ListItem_1Label not found.");
187 }
188 return dfd.callback(true);
189 }, 500);
190 return dfd;
191 }
192 }, {
193 // Test second transition
194 name : "transition-test-2",
195 runTest : function() {
196 // transition to first li
197 var dfd = new doh.Deferred();
198 setTimeout(function() {
199 var liWidget = registry.byId("dojox_mobile_ListItem_3");
200 var ev = new TransitionEvent(liWidget.domNode, liWidget.params);
201 ev.dispatch();
202 return dfd.callback(true);
203 }, 500);
204 return dfd;
205 }
206 }, {
207 // Test verify back to at home
208 name : "testInputs1",
209 runTest : function() {
210 var dfd = new doh.Deferred();
211 setTimeout(function() {
212 var wid = registry.byId("nameInput0");
213 if (wid) {
214 doh.is("Anne", registry.byId("nameInput0").get("value"), "NameInput0 should be Anne");
215 doh.is("Anne", registry.byId("firstInput").get("value"), "firstInput should be Anne");
216 }
217 return dfd.callback(true);
218 }, 500);
219 return dfd;
220 }
221 }, {
222 // Test switch back to home
223 name : "backToHome2",
224 runTest : function() {
225 var dfd = new doh.Deferred();
226 setTimeout(function() {
227 var backHeader = registry.byId("dojox_mobile_Heading_1");
228 var transOpts = {
229 viewid : "home",
230 reverse : true,
231 url : "#home" // this is optional if not set it will be created from target
232 };
233 var ev = new TransitionEvent(backHeader.domNode, transOpts);
234 ev.dispatch();
235 return dfd.callback(true);
236 }, 500);
237 return dfd;
238 }
239 }, {
240 // Test verify back to at home
241 name : "testbackToHome",
242 runTest : function() {
243 var dfd = new doh.Deferred();
244 setTimeout(function() {
245 var ListItem_0Label = registry.byId("dojox_mobile_ListItem_0");
246 if(ListItem_0Label){
247 doh.is(getLabelfromWid(ListItem_0Label,0,82), listItem_0TestStr);
248 }else{
249 throw new Error("In testbackToHome ListItem_0Label not found.");
250 }
251 var ListItem_1Label = registry.byId("dojox_mobile_ListItem_1");
252 if(ListItem_1Label){
253 doh.is(getLabelfromWid(ListItem_1Label,0,87), listItem_1TestStr);
254 }else{
255 throw new Error("In testbackToHome ListItem_1Label not found.");
256 }
257 return dfd.callback(true);
258 }, 500);
259 return dfd;
260 }
261 }]);
262
263 doh.run();
264 }
265 }));
266
267 });
268 </script>
269 </head>
270 <body>
271 <script type="dojo/require">at: "dojox/mvc/at"</script>
272 </body>
273 </html>