| 1 | <!DOCTYPE html> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/> |
| 5 | <meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| 6 | <title>_CheckBoxMixin tests</title> |
| 7 | |
| 8 | <style type="text/css"> |
| 9 | @import "../../themes/claro/document.css"; |
| 10 | @import "../../themes/dijit.css"; |
| 11 | |
| 12 | #table { |
| 13 | margin: 0; |
| 14 | padding: 2px; |
| 15 | } |
| 16 | #table, .dijit, BUTTON { |
| 17 | font-family: monospace; |
| 18 | font-size: 12pt; |
| 19 | } |
| 20 | #table .layout { |
| 21 | padding: 2px; |
| 22 | font-size: 100%; |
| 23 | margin: 0; |
| 24 | } |
| 25 | INPUT#mobile_attributes { |
| 26 | -webkit-appearance: radio; |
| 27 | width:32px; |
| 28 | height:32px; |
| 29 | border-radius: 0; |
| 30 | } |
| 31 | INPUT#mobile_events:not(:checked){ |
| 32 | background-color:rgba(255,0,0,1); |
| 33 | border-radius: 32px; |
| 34 | } |
| 35 | INPUT#mobile_events { |
| 36 | width:32px; |
| 37 | height:32px; |
| 38 | background-color:rgba(0,0,255,1); |
| 39 | border-radius: 32px; |
| 40 | } |
| 41 | INPUT#mobile_programmatic { |
| 42 | width:32px; |
| 43 | height:32px; |
| 44 | background-color:rgba(0,0,0,0); |
| 45 | border:0 none rgba(0,0,0,0); |
| 46 | border-radius: 0; |
| 47 | } |
| 48 | INPUT#mobile_programmatic:not(:checked){ |
| 49 | opacity:0; |
| 50 | } |
| 51 | .dijitCheckBox { |
| 52 | vertical-align: baseline !important; |
| 53 | } |
| 54 | </style> |
| 55 | <link id="themeStyles" rel="stylesheet" href="../../../dijit/themes/claro/claro.css"/> |
| 56 | |
| 57 | <script type="text/javascript" src="../../../dojo/dojo.js" |
| 58 | data-dojo-config="parseOnLoad: true, isDebug: true"></script> |
| 59 | |
| 60 | <script type="text/javascript"> |
| 61 | dojo.require("doh.runner"); |
| 62 | dojo.require("dojo.query"); |
| 63 | dojo.require("dijit.dijit"); // optimize: load dijit layer |
| 64 | dojo.require("dijit.form.CheckBox"); |
| 65 | dojo.require("dojox.mobile.CheckBox"); |
| 66 | var on = dojo.require("dojo.on"); |
| 67 | |
| 68 | dojo.ready(function(){ |
| 69 | |
| 70 | doh.register("attributes", [ |
| 71 | { |
| 72 | name: "dijit", |
| 73 | runTest: function(){ |
| 74 | var dijit_attributes = dijit.byId('dijit_attributes'); |
| 75 | doh.is("something", dijit_attributes.focusNode.value, 'dijit HTML element original value'); |
| 76 | doh.t(dijit_attributes.get('checked'), "dijit original get('checked')"); |
| 77 | doh.t(!!dijit_attributes.focusNode.checked, 'dijit HTML element originally checked'); |
| 78 | doh.t(dojo.hasClass(dijit_attributes.domNode, dijit_attributes.baseClass+"Checked"), "dijit baseClass checked"); |
| 79 | dijit_attributes.set('value', "something else"); |
| 80 | dijit_attributes.set('checked', false); |
| 81 | doh.f(dijit_attributes.get('checked'), "dijit get('checked')"); |
| 82 | doh.t(!dijit_attributes.focusNode.checked, 'dijit HTML element unchecked'); |
| 83 | doh.f(dojo.hasClass(dijit_attributes.domNode, dijit_attributes.baseClass+"Checked"), "dijit baseClass not checked"); |
| 84 | doh.t(dojo.hasClass(dijit_attributes.domNode, dijit_attributes.baseClass), "dijit baseClass"); |
| 85 | doh.t(dojo.hasClass(dijit_attributes.domNode, "mblRedButton"), "dijit original class"); |
| 86 | doh.is("something else", dijit_attributes.focusNode.value, 'dijit HTML element value'); |
| 87 | } |
| 88 | }, |
| 89 | { |
| 90 | name: "mobile", |
| 91 | runTest: function(){ |
| 92 | var mobile_attributes = dijit.byId('mobile_attributes'); |
| 93 | doh.is("something", mobile_attributes.focusNode.value, 'mobile HTML element original value'); |
| 94 | doh.t(mobile_attributes.get('checked'), "mobile original get('checked')"); |
| 95 | doh.t(!!mobile_attributes.focusNode.checked, 'mobile HTML element originally checked'); |
| 96 | doh.t(dojo.hasClass(mobile_attributes.domNode, mobile_attributes.baseClass+"Checked"), "mobile baseClass checked"); |
| 97 | mobile_attributes.set('checked', false); |
| 98 | mobile_attributes.set('value', "something else"); |
| 99 | doh.f(mobile_attributes.get('checked'), "mobile get('checked')"); |
| 100 | doh.t(!mobile_attributes.focusNode.checked, 'mobile HTML element unchecked'); |
| 101 | doh.f(dojo.hasClass(mobile_attributes.domNode, mobile_attributes.baseClass+"Checked"), "mobile baseClass not checked"); |
| 102 | doh.t(dojo.hasClass(mobile_attributes.domNode, mobile_attributes.baseClass), "mobile baseClass"); |
| 103 | doh.t(dojo.hasClass(mobile_attributes.domNode, "mblRedButton"), "mobile original class"); |
| 104 | doh.is("something else", mobile_attributes.focusNode.value, 'mobile HTML element value'); |
| 105 | } |
| 106 | } |
| 107 | ]); |
| 108 | |
| 109 | doh.register("events", [ |
| 110 | { |
| 111 | name: "dijit", |
| 112 | timeout: 5000, |
| 113 | runTest: function(){ |
| 114 | var |
| 115 | d = new doh.Deferred(), |
| 116 | dijit_events = dijit.byId('dijit_events'), |
| 117 | calledOnClick = false, |
| 118 | nop = function(){ return false; }; |
| 119 | |
| 120 | function onChange(v){ |
| 121 | dijit_events.set('onChange', nop); |
| 122 | d.callback(true); |
| 123 | } |
| 124 | dijit_events.set('onChange', onChange); |
| 125 | dijit_events.focusNode.click(); |
| 126 | |
| 127 | return d; |
| 128 | } |
| 129 | }, |
| 130 | { |
| 131 | name: "mobile", |
| 132 | timeout: 5000, |
| 133 | runTest: function(){ |
| 134 | var |
| 135 | d = new doh.Deferred(), |
| 136 | mobile_events = dijit.byId('mobile_events'), |
| 137 | nop = function(){ return false; }; |
| 138 | |
| 139 | function onChange(){ |
| 140 | mobile_events.set('onChange', nop); |
| 141 | d.callback(true); |
| 142 | } |
| 143 | mobile_events.set("onChange", onChange); |
| 144 | mobile_events.focusNode.click(); |
| 145 | |
| 146 | return d; |
| 147 | } |
| 148 | } |
| 149 | ]); |
| 150 | |
| 151 | doh.register("programmatic", [ |
| 152 | { |
| 153 | name: "dijit", |
| 154 | timeout: 5000, |
| 155 | runTest: function(){ |
| 156 | new dijit.form.CheckBox({id:"dijit_programmatic", checked:true,"aria-label":"check3dijit"}).placeAt("dijit_programmatic_container", "first"); |
| 157 | var dijit_programmatic = dijit.byId('dijit_programmatic'); |
| 158 | var pos = dojo.position(dijit_programmatic.domNode, true); |
| 159 | doh.t(pos.w > 0 && pos.h > 0 && pos.x > 0 && pos.y > 0, 'dijit position'); |
| 160 | doh.t(dijit_programmatic.get('checked'), 'dijit widget checked'); |
| 161 | doh.t(!!dijit_programmatic.focusNode.checked, 'dijit HTML element checked'); |
| 162 | } |
| 163 | }, |
| 164 | { |
| 165 | name: "mobile", |
| 166 | timeout: 5000, |
| 167 | runTest: function(){ |
| 168 | new dojox.mobile.CheckBox({id:"mobile_programmatic", checked:true,"aria-label":"check3mobile"}).placeAt("mobile_programmatic_container", "first"); |
| 169 | var mobile_programmatic = dijit.byId('mobile_programmatic'); |
| 170 | if(dojo.isIE < 8){ // older IE ignores setting checked after creation but before appending to the DOM |
| 171 | dojo.attr(mobile_programmatic.focusNode, "checked", mobile_programmatic.checked); |
| 172 | } |
| 173 | var pos = dojo.position(mobile_programmatic.domNode, true); |
| 174 | doh.t(pos.w > 0 && pos.h > 0 && pos.x > 0 && pos.y > 0, 'mobile position'); |
| 175 | doh.t(!!mobile_programmatic.focusNode.checked, 'mobile HTML element checked'); |
| 176 | doh.t(mobile_programmatic.get('checked'), 'mobile widget checked'); |
| 177 | } |
| 178 | } |
| 179 | ]); |
| 180 | |
| 181 | var form = dojo.byId('onClickTests'); |
| 182 | form.reset(); // so reload works |
| 183 | |
| 184 | // click all the checkboxes, but not too fast |
| 185 | doh.register("click all checkboxes", dojo.query("INPUT[type=checkbox]", form).map(function(inputNode){ |
| 186 | return { |
| 187 | timeout: 5000, |
| 188 | name: "click " + inputNode.id, |
| 189 | runTest: function(){ |
| 190 | var d = new doh.Deferred(); |
| 191 | on.once(form, "click", function(){ |
| 192 | setTimeout(function(){ d.callback(true); }, 1); |
| 193 | }); |
| 194 | setTimeout(function(){ inputNode.click(); }, 1); |
| 195 | return d; |
| 196 | } |
| 197 | }; |
| 198 | })); |
| 199 | |
| 200 | // check widgets |
| 201 | var widgets = dijit.findWidgets(form); |
| 202 | doh.register("onclick widgets", dojo.map(widgets, function(widget){ |
| 203 | return { |
| 204 | name: widget.id, |
| 205 | runTest: function () { |
| 206 | var id = widget.id, |
| 207 | testId = "t" + id.substr(1), |
| 208 | native = dojo.byId(testId); |
| 209 | var widgetVal = widget.checked; |
| 210 | var expectedVal = !!native.checked; |
| 211 | var widgetNodeVal = !!dojo.byId(id).checked; |
| 212 | doh.is(expectedVal, widgetVal, 'widget value'); |
| 213 | doh.is(expectedVal, widgetNodeVal, 'hidden node'); |
| 214 | } |
| 215 | }; |
| 216 | })); |
| 217 | |
| 218 | doh.run(); |
| 219 | }); |
| 220 | </script> |
| 221 | </head> |
| 222 | <body class="claro" role="main"> |
| 223 | <h1 class="testTitle">_CheckBoxMixin (dijit and mobile) non-robot tests</h1> |
| 224 | |
| 225 | <table id="table"> |
| 226 | <tr> |
| 227 | <th class="layout"> </th> |
| 228 | <th class="layout">dijit</th> |
| 229 | <th class="layout">mobile</th> |
| 230 | </tr> |
| 231 | <tr> |
| 232 | <td class="layout">attributes</td> |
| 233 | <td class="layout"><input id="dijit_attributes" aria-label="check1dijit" data-dojo-type="dijit/form/CheckBox" data-dojo-props='checked: true, "class":"mblRedButton", value:"something"'/></td> |
| 234 | <td class="layout"><input type="checkbox" aria-label="check1mobile" value="something" class="mblRedButton" checked id="mobile_attributes" dojoType="dojox/mobile/CheckBox"/></td> |
| 235 | </tr> |
| 236 | <tr> |
| 237 | <tr> |
| 238 | <td class="layout">Events</td> |
| 239 | <td class="layout"><input id="dijit_events" aria-label="check2dijit" data-dojo-type="dijit/form/CheckBox" data-dojo-props='onClick:function(){ return true; }' /></td> |
| 240 | <td class="layout"><input type="checkbox" aria-label="check2mobile" id="mobile_events" data-dojo-type="dojox/mobile/CheckBox" data-dojo-props='onClick:function(){ return true; }' /></td> |
| 241 | </tr> |
| 242 | <tr> |
| 243 | <td class="layout">Programmatic</td> |
| 244 | <td class="layout" id="dijit_programmatic_container"></td> |
| 245 | <td class="layout" id="mobile_programmatic_container"></td> |
| 246 | </tr> |
| 247 | </table> |
| 248 | <form method="get" id="onClickTests" style="font-family:monospace;font-size:16px;"> |
| 249 | before click: checked=true, onclick handler: return false, after click: |
| 250 | <input aria-label="t1" id="t1" type="checkbox" checked onclick="return false;"> |
| 251 | <input data-dojo-type="dijit/form/CheckBox" aria-label="w1" id="w1" type="checkbox" checked onclick="return false;"> |
| 252 | <input data-dojo-type="dojox/mobile/CheckBox" aria-label="m1" id="m1" type="checkbox" checked onclick="return false;"><br> |
| 253 | before click: checked=true, onclick handler: return true, after click: |
| 254 | <input aria-label="t2" id="t2" type="checkbox" checked onclick="return true;"> |
| 255 | <input data-dojo-type="dijit/form/CheckBox" aria-label="w2" id="w2" type="checkbox" checked onclick="return true;"> |
| 256 | <input data-dojo-type="dojox/mobile/CheckBox" aria-label="m2" id="m2" type="checkbox" checked onclick="return true;"><br> |
| 257 | before click: checked=false, onclick handler: return false, after click: |
| 258 | <input aria-label="t5" id="t5" type="checkbox" onclick="return false;"> |
| 259 | <input data-dojo-type="dijit/form/CheckBox" aria-label="w5" id="w5" type="checkbox" onclick="return false;"> |
| 260 | <input data-dojo-type="dojox/mobile/CheckBox" aria-label="m5" id="m5" type="checkbox" onclick="return false;"><br> |
| 261 | before click: checked=false, onclick handler: return true, after click: |
| 262 | <input aria-label="t6" id="t6" type="checkbox" onclick="return true;"> |
| 263 | <input data-dojo-type="dijit/form/CheckBox" aria-label="w6" id="w6" type="checkbox" onclick="return true;"> |
| 264 | <input data-dojo-type="dojox/mobile/CheckBox" aria-label="m6" id="m6" type="checkbox" onclick="return true;"><br> |
| 265 | before click: checked=true, onclick handler: no return, after click: |
| 266 | <input aria-label="t11" id="t11" type="checkbox" checked onclick="return;"> |
| 267 | <input data-dojo-type="dijit/form/CheckBox" aria-label="w11" id="w11" type="checkbox" checked onclick="return;"> |
| 268 | <input data-dojo-type="dojox/mobile/CheckBox" aria-label="m11" id="m11" type="checkbox" checked onclick="return;"><br> |
| 269 | before click: checked=false, onclick handler: no return, after click: |
| 270 | <input aria-label="t15" id="t15" type="checkbox" onclick="return;"> |
| 271 | <input data-dojo-type="dijit/form/CheckBox" aria-label="w15" id="w15" type="checkbox" onclick="return;"> |
| 272 | <input data-dojo-type="dojox/mobile/CheckBox" aria-label="m15" id="m15" type="checkbox" onclick="return;"><br> |
| 273 | before click: checked=true, onclick handler: checked=false and return false, after click: |
| 274 | <input id="t101" aria-label="t101" type="checkbox" checked onclick="this.checked=false;return false;"> |
| 275 | <input data-dojo-type="dijit/form/CheckBox" aria-label="w101" id="w101" type="checkbox" checked onclick="dijit.byId(this.id).set('checked',false);return false;"> |
| 276 | <input data-dojo-type="dojox/mobile/CheckBox" aria-label="m101" id="m101" type="checkbox" checked onclick="dijit.byId(this.id).set('checked',false);return false;"><br> |
| 277 | before click: checked=true, onclick handler: checked=false and return true, after click: |
| 278 | <input aria-label="t102" id="t102" type="checkbox" checked onclick="this.checked=false;return true;"> |
| 279 | <input data-dojo-type="dijit/form/CheckBox" aria-label="w102" id="w102" type="checkbox" checked onclick="dijit.byId(this.id).set('checked',false);return true;"> |
| 280 | <input data-dojo-type="dojox/mobile/CheckBox" aria-label="m102" id="m102" type="checkbox" checked onclick="dijit.byId(this.id).set('checked',false);return true;"><br> |
| 281 | before click: checked=true, onclick handler: checked=true and return false, after click: |
| 282 | <input aria-label="t103" id="t103" type="checkbox" checked onclick="this.checked=true;return false;"> |
| 283 | <input data-dojo-type="dijit/form/CheckBox" aria-label="w103" id="w103" type="checkbox" checked onclick="dijit.byId(this.id).set('checked',true);return false;"> |
| 284 | <input data-dojo-type="dojox/mobile/CheckBox" aria-label="m103" id="m103" type="checkbox" checked onclick="dijit.byId(this.id).set('checked',true);return false;"><br> |
| 285 | before click: checked=true, onclick handler: checked=true and return true, after click: |
| 286 | <input aria-label="t104" id="t104" type="checkbox" checked onclick="this.checked=true;return true;"> |
| 287 | <input data-dojo-type="dijit/form/CheckBox" aria-label="w104" id="w104" type="checkbox" checked onclick="dijit.byId(this.id).set('checked',true);return true;"> |
| 288 | <input data-dojo-type="dojox/mobile/CheckBox" aria-label="m104" id="m104" type="checkbox" checked onclick="dijit.byId(this.id).set('checked',true);return true;"><br> |
| 289 | before click: checked=false, onclick handler: checked=false and return false, after click: |
| 290 | <input aria-label="t105" id="t105" type="checkbox" onclick="this.checked=false;return false;"> |
| 291 | <input data-dojo-type="dijit/form/CheckBox" aria-label="w105" id="w105" type="checkbox" onclick="dijit.byId(this.id).set('checked',false);return false;"> |
| 292 | <input data-dojo-type="dojox/mobile/CheckBox" aria-label="m105" id="m105" type="checkbox" onclick="dijit.byId(this.id).set('checked',false);return false;"><br> |
| 293 | before click: checked=false, onclick handler: checked=false and return true, after click: |
| 294 | <input aria-label="t106" id="t106" type="checkbox" onclick="this.checked=false;return true;"> |
| 295 | <input data-dojo-type="dijit/form/CheckBox" aria-label="w106" id="w106" type="checkbox" onclick="dijit.byId(this.id).set('checked',false);return true;"> |
| 296 | <input data-dojo-type="dojox/mobile/CheckBox" aria-label="m106" id="m106" type="checkbox" onclick="dijit.byId(this.id).set('checked',false);return true;"><br> |
| 297 | before click: checked=false, onclick handler: checked=true and return false, after click: |
| 298 | <input aria-label="t107" id="t107" type="checkbox" onclick="this.checked=true;return false;"> |
| 299 | <input data-dojo-type="dijit/form/CheckBox" aria-label="w107" id="w107" type="checkbox" onclick="dijit.byId(this.id).set('checked',true);return false;"> |
| 300 | <input data-dojo-type="dojox/mobile/CheckBox" aria-label="m107" id="m107" type="checkbox" onclick="dijit.byId(this.id).set('checked',true);return false;"><br> |
| 301 | before click: checked=false, onclick handler: checked=true and return true, after click: |
| 302 | <input aria-label="t108" id="t108" type="checkbox" onclick="this.checked=true;return true;"> |
| 303 | <input data-dojo-type="dijit/form/CheckBox" aria-label="w108" id="w108" type="checkbox" onclick="dijit.byId(this.id).set('checked',true);return true;"> |
| 304 | <input data-dojo-type="dojox/mobile/CheckBox" aria-label="m108" id="m108" type="checkbox" onclick="dijit.byId(this.id).set('checked',true);return true;"><br> |
| 305 | before click: checked=true, onclick handler: checked=false and no return, after click: |
| 306 | <input aria-label="t111" id="t111" type="checkbox" checked onclick="this.checked=false;return;"> |
| 307 | <input data-dojo-type="dijit/form/CheckBox" aria-label="w111" id="w111" type="checkbox" checked onclick="dijit.byId(this.id).set('checked',false);return;"> |
| 308 | <input data-dojo-type="dojox/mobile/CheckBox" aria-label="m111" id="m111" type="checkbox" checked onclick="dijit.byId(this.id).set('checked',false);return;"><br> |
| 309 | before click: checked=true, onclick handler: checked=true and no return, after click: |
| 310 | <input aria-label="t113" id="t113" type="checkbox" checked onclick="this.checked=true;return;"> |
| 311 | <input data-dojo-type="dijit/form/CheckBox" aria-label="w113" id="w113" type="checkbox" checked onclick="dijit.byId(this.id).set('checked',true);return;"> |
| 312 | <input data-dojo-type="dojox/mobile/CheckBox" aria-label="m113" id="m113" type="checkbox" checked onclick="dijit.byId(this.id).set('checked',true);return;"><br> |
| 313 | before click: checked=false, onclick handler: checked=false and no return, after click: |
| 314 | <input aria-label="t115" id="t115" type="checkbox" onclick="this.checked=false;return;"> |
| 315 | <input data-dojo-type="dijit/form/CheckBox" aria-label="w115" id="w115" type="checkbox" onclick="dijit.byId(this.id).set('checked',false);return;"> |
| 316 | <input data-dojo-type="dojox/mobile/CheckBox" aria-label="m115" id="m115" type="checkbox" onclick="dijit.byId(this.id).set('checked',false);return;"><br> |
| 317 | before click: checked=false, onclick handler: checked=true and no return, after click: |
| 318 | <input aria-label="t117" id="t117" type="checkbox" onclick="this.checked=true;return;"> |
| 319 | <input data-dojo-type="dijit/form/CheckBox" aria-label="w117" id="w117" type="checkbox" onclick="dijit.byId(this.id).set('checked',true);return;"> |
| 320 | <input data-dojo-type="dojox/mobile/CheckBox" aria-label="m117" id="m117" type="checkbox" onclick="dijit.byId(this.id).set('checked',true);return;"><br> |
| 321 | </form> |
| 322 | </body> |
| 323 | </html> |