| 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>Lifecycle and Controller Test</title> |
| 7 | <script type="text/javascript"> |
| 8 | dojoConfig = { |
| 9 | parseOnLoad: false, |
| 10 | async:1, |
| 11 | app: {debugApp: 0} // set debugApp to log app transitions and view activate/deactivate |
| 12 | }; |
| 13 | </script> |
| 14 | <script type="text/javascript" src="../../../../../dojo/dojo.js"></script> |
| 15 | |
| 16 | <script> |
| 17 | // the actual launcher |
| 18 | require(["./modelApp.js"], function(){}); |
| 19 | </script> |
| 20 | <script type="text/javascript"> |
| 21 | require([ |
| 22 | "doh/runner", |
| 23 | "dojo/topic", |
| 24 | "dojo/_base/lang", |
| 25 | "dojox/mobile/TransitionEvent", |
| 26 | "dojo/parser", |
| 27 | "dojo/when", |
| 28 | "dojox/app/controllers/Load", |
| 29 | "dojox/app/controllers/Transition", |
| 30 | "dojox/app/controllers/Layout", |
| 31 | "dojox/app/controllers/History", |
| 32 | "dojox/app/controllers/HistoryHash", |
| 33 | "dojox/app/utils/config", |
| 34 | "dojox/json/ref", |
| 35 | "dojo/sniff", |
| 36 | "dojo/text!./config.json" |
| 37 | ], function(doh, topic, lang, TransitionEvent, parser, when, Load, Transition, Layout, History, HistoryHash, |
| 38 | configUtil, jsonRef, has, config) { |
| 39 | var originalConfig = jsonRef.fromJson(config); |
| 40 | var isTablet = false; |
| 41 | var width = window.innerWidth || document.documentElement.clientWidth; |
| 42 | if(width > 600){ |
| 43 | isTablet = true; |
| 44 | } |
| 45 | |
| 46 | has.add("testTrue", true); |
| 47 | has.add("tablet", isTablet); |
| 48 | has.add("phone", !isTablet); |
| 49 | has.add("notIE", !has("ie")); |
| 50 | |
| 51 | // configUtil.configProcessHas is only called here to test the configProcessHas, normally the app does not call it directly |
| 52 | config = configUtil.configProcessHas(originalConfig); |
| 53 | doh.register("Test-HasConfig", [{ |
| 54 | name : "test-HasConfig", |
| 55 | runTest : function(t) { |
| 56 | var dfd = new doh.Deferred(); |
| 57 | setTimeout(function() { |
| 58 | t.assertEqual(config.controllers[0], "dojox/app/controllers/Load"); |
| 59 | t.assertEqual(config.configTestSetTrueInHas, "SetInHasOk"); |
| 60 | t.assertEqual(config.configTestNotSetInHas, "InitOk"); |
| 61 | if(config.isTablet){ |
| 62 | t.assertEqual(config.configTestTablet, "Yes"); |
| 63 | t.assertEqual(config.configTestPhone, "No"); |
| 64 | }else{ |
| 65 | t.assertEqual(config.configTestTablet, "No"); |
| 66 | t.assertEqual(config.configTestPhone, "Yes"); |
| 67 | } |
| 68 | return dfd.callback(true); |
| 69 | }, 500); |
| 70 | return dfd; |
| 71 | } |
| 72 | }, { |
| 73 | // Test controllers |
| 74 | name : "test-Controllers", |
| 75 | runTest : function(t) { |
| 76 | var dfd = new doh.Deferred(); |
| 77 | setTimeout(function() { |
| 78 | // test controllers |
| 79 | t.assertEqual(4, config.controllers.length); |
| 80 | if(has("ie")){ |
| 81 | t.assertEqual(config.controllers[3], "dojox/app/controllers/HistoryHash"); |
| 82 | t.assertTrue(testApp.controllers[3] instanceof HistoryHash); |
| 83 | }else{ |
| 84 | t.assertEqual(config.controllers[3], "dojox/app/controllers/History"); |
| 85 | t.assertTrue(testApp.controllers[3] instanceof History); |
| 86 | } |
| 87 | return dfd.callback(true); |
| 88 | }, 500); |
| 89 | return dfd; |
| 90 | } |
| 91 | }]); |
| 92 | |
| 93 | doh.run(); |
| 94 | |
| 95 | |
| 96 | }); |
| 97 | </script> |
| 98 | </head> |
| 99 | <body> |
| 100 | </body> |
| 101 | </html> |