| 1 | <!DOCTYPE HTML> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta http-equiv="content-type" content="text/html; charset=utf-8"/> |
| 5 | <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" /> |
| 6 | <meta name="apple-mobile-web-app-capable" content="yes" /> |
| 7 | <title>Check Box Tests</title> |
| 8 | <script type="text/javascript" src="../../../deviceTheme.js"></script> |
| 9 | <script type="text/javascript" src="../../../../../dojo/dojo.js" data-dojo-config="async: true, parseOnLoad: true"></script> |
| 10 | <script language="JavaScript" type="text/javascript"> |
| 11 | require([ |
| 12 | "dojo/dom-construct", // dojo.place |
| 13 | "dojo/ready", // dojo.ready |
| 14 | "dijit/registry", // dijit.byId |
| 15 | "doh/runner", //doh functions |
| 16 | "dojox/mobile/CheckBox", |
| 17 | "dojox/mobile", // This is a mobile app. |
| 18 | "dojox/mobile/View", // This mobile app uses mobile view |
| 19 | "dojox/mobile/compat", // This mobile app supports running on desktop browsers |
| 20 | "dojox/mobile/parser" // This mobile app uses declarative programming with fast mobile parser |
| 21 | ], function(domConst, ready, registry, runner, CheckBox){ |
| 22 | function _createCheckBoxDeclaratively(checkBoxId) { |
| 23 | return registry.byId(checkBoxId); |
| 24 | } |
| 25 | function _createCheckBoxProgrammatically(placeHolderId){ |
| 26 | var checkBox = new CheckBox(); |
| 27 | runner.assertNotEqual(null, checkBox); |
| 28 | domConst.place(checkBox.domNode, placeHolderId, "replace"); |
| 29 | checkBox.startup(); |
| 30 | return checkBox; |
| 31 | } |
| 32 | function _createCheckBoxProgrammaticallyWithSourceNodeReference(checkBoxId){ |
| 33 | return new CheckBox({}, checkBoxId); |
| 34 | } |
| 35 | function _assertCorrectCheckBox(checkBox){ |
| 36 | runner.assertNotEqual(null, checkBox); |
| 37 | runner.assertFalse(checkBox.checked, "unchecked id=" + checkBox.domNode.id); |
| 38 | checkBox.set("checked", true); |
| 39 | runner.assertTrue(checkBox.checked, "checked id=" + checkBox.domNode.id); |
| 40 | } |
| 41 | function _showView2(){ |
| 42 | var view1 = registry.byId("view1"); |
| 43 | view1.performTransition("view2", 1, "none"); |
| 44 | } |
| 45 | ready(function(){ |
| 46 | runner.register("dojox.mobile.test.doh.CheckBoxTests", [ |
| 47 | function testInView1(){ |
| 48 | var checkBox1 = _createCheckBoxDeclaratively("view1-checkBox1"); |
| 49 | var checkBox2 = _createCheckBoxProgrammatically("view1-checkBox2"); |
| 50 | var checkBox3 = _createCheckBoxProgrammaticallyWithSourceNodeReference("view1-checkBox3"); |
| 51 | |
| 52 | _assertCorrectCheckBox(checkBox1); |
| 53 | _assertCorrectCheckBox(checkBox2); |
| 54 | _assertCorrectCheckBox(checkBox3); |
| 55 | }, |
| 56 | function testInView2(){ |
| 57 | var checkBox1 = _createCheckBoxDeclaratively("view2-checkBox1"); |
| 58 | var checkBox2 = _createCheckBoxProgrammatically("view2-checkBox2"); |
| 59 | var checkBox3 = _createCheckBoxProgrammaticallyWithSourceNodeReference("view2-checkBox3"); |
| 60 | |
| 61 | _showView2(); |
| 62 | |
| 63 | _assertCorrectCheckBox(checkBox1); |
| 64 | _assertCorrectCheckBox(checkBox2); |
| 65 | _assertCorrectCheckBox(checkBox3); |
| 66 | } |
| 67 | ]); |
| 68 | runner.run(); |
| 69 | }); |
| 70 | }) |
| 71 | </script> |
| 72 | </head> |
| 73 | <body> |
| 74 | <div id="view1" data-dojo-type="dojox.mobile.View" selected="true"> |
| 75 | <h1>View 1</h1> |
| 76 | <input id="view1-checkBox1" type="checkbox" data-dojo-type="dojox.mobile.CheckBox"></input> |
| 77 | <div id="view1-checkBox2"></div> |
| 78 | <input id="view1-checkBox3" type="checkbox"></input> |
| 79 | </div> |
| 80 | <div id="view2" data-dojo-type="dojox.mobile.View"> |
| 81 | <h1>View 2</h1> |
| 82 | <input id="view2-checkBox1" type="checkbox" data-dojo-type="dojox.mobile.CheckBox"></input> |
| 83 | <div id="view2-checkBox2"></div> |
| 84 | <input id="view2-checkBox3" type="checkbox"></input> |
| 85 | </div> |
| 86 | </body> |
| 87 | </html> |