| 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 Checkbox mouse Test</title> |
| 6 |
|
| 7 |
<style> |
| 8 |
@import "../../../../util/doh/robot/robot.css"; |
| 9 |
</style> |
| 10 |
|
| 11 |
|
| 12 |
<script type="text/javascript" src="../../../../dojo/dojo.js"></script> |
| 13 |
|
| 14 |
<script type="text/javascript"> |
| 15 |
dojo.require("dijit.robotx"); |
| 16 |
dojo.require("dijit.tests.helpers"); // functions to help test |
| 17 |
|
| 18 |
// These are the values assigned to the widgets in the page's HTML |
| 19 |
var originalGet = { |
| 20 |
cb1: [], |
| 21 |
cb2: ["on"], |
| 22 |
cb4: ["on"], |
| 23 |
cb5: [], |
| 24 |
cb6: ["on"], |
| 25 |
cb7: [], |
| 26 |
'g[1]': "on", |
| 27 |
g2: null |
| 28 |
}; |
| 29 |
|
| 30 |
var originalSubmit = { |
| 31 |
cb2: "on", |
| 32 |
cb4: "on", |
| 33 |
cb6: "on", |
| 34 |
'g[1]': "on" |
| 35 |
}; |
| 36 |
|
| 37 |
// attempt to change these values |
| 38 |
var change = { |
| 39 |
cb1: ["foo"], |
| 40 |
cb2: [], |
| 41 |
cb3: ["on"], |
| 42 |
cb4: [], |
| 43 |
cb5: ["on"], |
| 44 |
cb6: ["foo"], |
| 45 |
'g[1]': "", // weather |
| 46 |
g2: "country" |
| 47 |
}; |
| 48 |
|
| 49 |
// changed values |
| 50 |
var changedGet = { |
| 51 |
cb1: ["foo"], |
| 52 |
cb2: [], |
| 53 |
cb4: [], |
| 54 |
cb5: ["on"], |
| 55 |
cb6: [], |
| 56 |
cb7: [], |
| 57 |
'g[1]': null, |
| 58 |
g2: "country" |
| 59 |
}; |
| 60 |
|
| 61 |
var changedSubmit = { |
| 62 |
cb1: "foo", |
| 63 |
cb5: "on", |
| 64 |
g2: "country" |
| 65 |
}; |
| 66 |
|
| 67 |
dojo.ready(function(){ |
| 68 |
doh.robot.initRobot('../test_CheckBox.html'); |
| 69 |
|
| 70 |
|
| 71 |
var submitForm = function(name, testValues){ |
| 72 |
return { |
| 73 |
name: name, |
| 74 |
timeout: 5000, |
| 75 |
runTest: function(){ |
| 76 |
var d = new doh.Deferred(); |
| 77 |
var formWidget = dijit.byId("myForm"); |
| 78 |
submittedValues = function(formValues){ |
| 79 |
d.getTestCallback(function(){ |
| 80 |
for(var i in originalGet){ doh.is(testValues[i], formValues[i], i); } |
| 81 |
})(); |
| 82 |
}; |
| 83 |
formWidget.submit(); |
| 84 |
return d; |
| 85 |
}, |
| 86 |
tearDown: function(){ |
| 87 |
submittedValues = defaultSubmitHandler; |
| 88 |
} |
| 89 |
}; |
| 90 |
}; |
| 91 |
|
| 92 |
doh.register("CheckBox values", [ |
| 93 |
{ |
| 94 |
timeout:3000, |
| 95 |
name:"readOnly", |
| 96 |
runTest:function(){ |
| 97 |
var d = new doh.Deferred(); |
| 98 |
|
| 99 |
doh.robot.sequence(function(){ submitForm("reset submit", originalSubmit); }, 500); |
| 100 |
doh.robot.mouseMoveAt("cb4", 500, 1); |
| 101 |
doh.robot.mouseClick({left:true}, 500); |
| 102 |
|
| 103 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 104 |
doh.is( dojo.toJson(originalGet), dojo.global.dojo.toJson(dijit.byId("myForm").get('value')), "still have original values" ); |
| 105 |
submitForm("resubmit", originalSubmit); |
| 106 |
}), 1000); |
| 107 |
|
| 108 |
return d; |
| 109 |
} |
| 110 |
} |
| 111 |
]); |
| 112 |
|
| 113 |
doh.register("Radio button onChange",[ |
| 114 |
function checkInitialValues(){ |
| 115 |
doh.f(dijit.byId('g1rb1').checked, "news was checked"); |
| 116 |
doh.t(dijit.byId('g1rb2').checked, "talk was not checked"); |
| 117 |
doh.f(dijit.byId('g1rb3').checked, "weather was checked"); |
| 118 |
doh.f(dijit.byId('g2rb1').checked, "top 40 was checked"); |
| 119 |
doh.f(dijit.byId('g2rb2').checked, "oldies was checked"); |
| 120 |
doh.f(dijit.byId('g2rb3').checked, "country was checked"); |
| 121 |
doh.f(dojo.byId('g3rb1').checked, "rock was checked"); |
| 122 |
doh.f(dojo.byId('g3rb2').checked, "jazz was checked"); |
| 123 |
doh.t(dojo.byId('g3rb3').checked, "classical was not checked"); |
| 124 |
doh.t(dijit.byId('g4rb1').checked, "tea was not checked"); |
| 125 |
doh.f(dijit.byId('g4rb2').checked, "coffee was checked"); |
| 126 |
}, |
| 127 |
{ |
| 128 |
timeout:3000, |
| 129 |
name:"change value to news", |
| 130 |
runTest:function(){ |
| 131 |
var d = new doh.Deferred(); |
| 132 |
|
| 133 |
doh.robot.mouseMoveAt("g1rb1", 500, 1); |
| 134 |
doh.robot.mouseClick({left:true}, 500); |
| 135 |
|
| 136 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 137 |
doh.t(dijit.byId('g1rb1').checked, "news was not checked"); |
| 138 |
doh.f(dijit.byId('g1rb2').checked, "talk was checked"); |
| 139 |
doh.f(dijit.byId('g1rb3').checked, "weather was checked"); |
| 140 |
}), 1000); |
| 141 |
|
| 142 |
return d; |
| 143 |
} |
| 144 |
}, |
| 145 |
{ |
| 146 |
timeout:3000, |
| 147 |
name:"weather disabled", |
| 148 |
runTest:function(){ |
| 149 |
var d = new doh.Deferred(); |
| 150 |
|
| 151 |
doh.robot.mouseMoveAt("g1rb3", 500, 1); |
| 152 |
doh.robot.mouseClick({left:true}, 500); |
| 153 |
|
| 154 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 155 |
doh.t(dijit.byId('g1rb1').checked, "news was not checked"); |
| 156 |
doh.f(dijit.byId('g1rb2').checked, "talk was checked"); |
| 157 |
doh.f(dijit.byId('g1rb3').checked, "weather was checked"); |
| 158 |
}), 1000); |
| 159 |
|
| 160 |
return d; |
| 161 |
} |
| 162 |
}, |
| 163 |
{ |
| 164 |
timeout:4000, |
| 165 |
name:"weather enabled", |
| 166 |
runTest:function(){ |
| 167 |
var d = new doh.Deferred(); |
| 168 |
|
| 169 |
doh.robot.mouseMoveAt("enableWeatherButton", 500, 1); |
| 170 |
doh.robot.mouseClick({left:true}, 500); |
| 171 |
doh.robot.mouseMoveAt("g1rb3", 500, 1); |
| 172 |
doh.robot.mouseClick({left:true}, 500); |
| 173 |
|
| 174 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 175 |
doh.f(dijit.byId('g1rb1').checked, "news was checked"); |
| 176 |
doh.f(dijit.byId('g1rb2').checked, "talk was checked"); |
| 177 |
doh.t(dijit.byId('g1rb3').checked, "weather was not checked"); |
| 178 |
}), 1000); |
| 179 |
|
| 180 |
return d; |
| 181 |
} |
| 182 |
}, |
| 183 |
{ |
| 184 |
timeout:3000, |
| 185 |
name:"change value to county", |
| 186 |
runTest:function(){ |
| 187 |
var d = new doh.Deferred(); |
| 188 |
|
| 189 |
doh.robot.mouseMoveAt("g2rb3", 500, 1); |
| 190 |
doh.robot.mouseClick({left:true}, 500); |
| 191 |
|
| 192 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 193 |
doh.t(dijit.byId('g2rb3').checked, "country was not checked"); |
| 194 |
doh.f(dijit.byId('g2rb2').checked, "oldies was checked"); |
| 195 |
doh.f(dijit.byId('g2rb1').checked, "top 40 was checked"); |
| 196 |
}), 1000); |
| 197 |
|
| 198 |
return d; |
| 199 |
} |
| 200 |
}, |
| 201 |
{ |
| 202 |
timeout:3000, |
| 203 |
name:"change value to top 40", |
| 204 |
runTest:function(){ |
| 205 |
var d = new doh.Deferred(); |
| 206 |
|
| 207 |
doh.robot.mouseMoveAt("g2rb1", 500, 1); |
| 208 |
doh.robot.mouseClick({left:true}, 500); |
| 209 |
|
| 210 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 211 |
doh.f(dijit.byId('g2rb3').checked, "country was checked"); |
| 212 |
doh.f(dijit.byId('g2rb2').checked, "oldies was checked"); |
| 213 |
doh.t(dijit.byId('g2rb1').checked, "top 40 was not checked"); |
| 214 |
}), 1000); |
| 215 |
|
| 216 |
return d; |
| 217 |
} |
| 218 |
}, |
| 219 |
{ |
| 220 |
timeout:3000, |
| 221 |
name:"change value to oldies", |
| 222 |
runTest:function(){ |
| 223 |
var d = new doh.Deferred(); |
| 224 |
|
| 225 |
doh.robot.mouseMoveAt("g2rb2", 500, 1); |
| 226 |
doh.robot.mouseClick({left:true}, 500); |
| 227 |
|
| 228 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 229 |
doh.f(dijit.byId('g2rb3').checked, "country was checked"); |
| 230 |
doh.t(dijit.byId('g2rb2').checked, "oldies was not checked"); |
| 231 |
doh.f(dijit.byId('g2rb1').checked, "top 40 was checked"); |
| 232 |
}), 1000); |
| 233 |
|
| 234 |
return d; |
| 235 |
} |
| 236 |
}, |
| 237 |
{ |
| 238 |
timeout:3000, |
| 239 |
name:"change value to rock", |
| 240 |
runTest:function(){ |
| 241 |
var d = new doh.Deferred(); |
| 242 |
|
| 243 |
doh.robot.mouseMoveAt("g3rb1", 500, 1); |
| 244 |
doh.robot.mouseClick({left:true}, 500); |
| 245 |
|
| 246 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 247 |
doh.t(dojo.byId('g3rb1').checked, "rock was not checked"); |
| 248 |
doh.f(dojo.byId('g3rb2').checked, "jazz was checked"); |
| 249 |
doh.f(dojo.byId('g3rb3').checked, "classical was checked"); |
| 250 |
}), 1000); |
| 251 |
|
| 252 |
return d; |
| 253 |
} |
| 254 |
}, |
| 255 |
{ |
| 256 |
timeout:3000, |
| 257 |
name:"disabled jazz", |
| 258 |
runTest:function(){ |
| 259 |
var d = new doh.Deferred(); |
| 260 |
|
| 261 |
doh.robot.mouseMoveAt("g3rb2", 500, 1); |
| 262 |
doh.robot.mouseClick({left:true}, 500); |
| 263 |
|
| 264 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 265 |
doh.t(dojo.byId('g3rb1').checked, "rock was not checked"); |
| 266 |
doh.f(dojo.byId('g3rb2').checked, "jazz was checked"); |
| 267 |
doh.f(dojo.byId('g3rb3').checked, "classical was checked"); |
| 268 |
}), 1000); |
| 269 |
|
| 270 |
return d; |
| 271 |
} |
| 272 |
}, |
| 273 |
{ |
| 274 |
timeout:3000, |
| 275 |
name:"enable b1", |
| 276 |
runTest:function(){ |
| 277 |
var d = new doh.Deferred(); |
| 278 |
|
| 279 |
doh.robot.mouseMoveAt("b1", 500, 1); |
| 280 |
doh.robot.mouseClick({left:true}, 500); |
| 281 |
|
| 282 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 283 |
doh.t(dijit.byId('b1').checked, "b1 was not checked"); |
| 284 |
doh.f(dijit.byId('b2').checked, "b2 was checked"); |
| 285 |
doh.f(dijit.byId('c1').checked, "c1 was checked"); |
| 286 |
doh.f(dijit.byId('c2').checked, "c2 was checked"); |
| 287 |
doh.f(dijit.byId('d1').checked, "d1 was checked"); |
| 288 |
doh.f(dijit.byId('d2').checked, "d2 was checked"); |
| 289 |
}), 1000); |
| 290 |
|
| 291 |
return d; |
| 292 |
} |
| 293 |
}, |
| 294 |
{ |
| 295 |
timeout:3000, |
| 296 |
name:"enable b2", |
| 297 |
runTest:function(){ |
| 298 |
var d = new doh.Deferred(); |
| 299 |
|
| 300 |
doh.robot.mouseMoveAt("b2", 500, 1); |
| 301 |
doh.robot.mouseClick({left:true}, 500); |
| 302 |
|
| 303 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 304 |
doh.f(dijit.byId('b1').checked, "b1 was checked"); |
| 305 |
doh.t(dijit.byId('b2').checked, "b2 was not checked"); |
| 306 |
doh.f(dijit.byId('c1').checked, "c1 was checked"); |
| 307 |
doh.f(dijit.byId('c2').checked, "c2 was checked"); |
| 308 |
doh.f(dijit.byId('d1').checked, "d1 was checked"); |
| 309 |
doh.f(dijit.byId('d2').checked, "d2 was checked"); |
| 310 |
}), 1000); |
| 311 |
|
| 312 |
return d; |
| 313 |
} |
| 314 |
}, |
| 315 |
{ |
| 316 |
timeout:3000, |
| 317 |
name:"enable c1", |
| 318 |
runTest:function(){ |
| 319 |
var d = new doh.Deferred(); |
| 320 |
|
| 321 |
doh.robot.mouseMoveAt("c1", 500, 1); |
| 322 |
doh.robot.mouseClick({left:true}, 500); |
| 323 |
|
| 324 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 325 |
doh.f(dijit.byId('b1').checked, "b1 was checked"); |
| 326 |
doh.t(dijit.byId('b2').checked, "b2 was not checked"); |
| 327 |
doh.t(dijit.byId('c1').checked, "c1 was not checked"); |
| 328 |
doh.f(dijit.byId('c2').checked, "c2 was checked"); |
| 329 |
doh.f(dijit.byId('d1').checked, "d1 was checked"); |
| 330 |
doh.f(dijit.byId('d2').checked, "d2 was checked"); |
| 331 |
}), 1000); |
| 332 |
|
| 333 |
return d; |
| 334 |
} |
| 335 |
}, |
| 336 |
{ |
| 337 |
timeout:3000, |
| 338 |
name:"enable c2", |
| 339 |
runTest:function(){ |
| 340 |
var d = new doh.Deferred(); |
| 341 |
|
| 342 |
doh.robot.mouseMoveAt("c2", 500, 1); |
| 343 |
doh.robot.mouseClick({left:true}, 500); |
| 344 |
|
| 345 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 346 |
doh.f(dijit.byId('b1').checked, "b1 was checked"); |
| 347 |
doh.t(dijit.byId('b2').checked, "b2 was not checked"); |
| 348 |
doh.f(dijit.byId('c1').checked, "c1 was checked"); |
| 349 |
doh.t(dijit.byId('c2').checked, "c2 was not checked"); |
| 350 |
doh.f(dijit.byId('d1').checked, "d1 was checked"); |
| 351 |
doh.f(dijit.byId('d2').checked, "d2 was checked"); |
| 352 |
}), 1000); |
| 353 |
|
| 354 |
return d; |
| 355 |
} |
| 356 |
}, |
| 357 |
{ |
| 358 |
timeout:3000, |
| 359 |
name:"enable d2", |
| 360 |
runTest:function(){ |
| 361 |
var d = new doh.Deferred(); |
| 362 |
|
| 363 |
doh.robot.mouseMoveAt("d2", 500, 1); |
| 364 |
doh.robot.mouseClick({left:true}, 500); |
| 365 |
|
| 366 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 367 |
doh.f(dijit.byId('b1').checked, "b1 was checked"); |
| 368 |
doh.t(dijit.byId('b2').checked, "b2 was not checked"); |
| 369 |
doh.f(dijit.byId('c1').checked, "c1 was checked"); |
| 370 |
doh.t(dijit.byId('c2').checked, "c2 was not checked"); |
| 371 |
doh.f(dijit.byId('d1').checked, "d1 was checked"); |
| 372 |
doh.t(dijit.byId('d2').checked, "d2 was not checked"); |
| 373 |
}), 1000); |
| 374 |
|
| 375 |
return d; |
| 376 |
} |
| 377 |
}, |
| 378 |
{ |
| 379 |
timeout:3000, |
| 380 |
name:"enable d1", |
| 381 |
runTest:function(){ |
| 382 |
var d = new doh.Deferred(); |
| 383 |
|
| 384 |
doh.robot.mouseMoveAt("d1", 500, 1); |
| 385 |
doh.robot.mouseClick({left:true}, 500); |
| 386 |
|
| 387 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 388 |
doh.f(dijit.byId('b1').checked, "b1 was checked"); |
| 389 |
doh.t(dijit.byId('b2').checked, "b2 was not checked"); |
| 390 |
doh.f(dijit.byId('c1').checked, "c1 was checked"); |
| 391 |
doh.t(dijit.byId('c2').checked, "c2 was not checked"); |
| 392 |
doh.t(dijit.byId('d1').checked, "d1 was not checked"); |
| 393 |
doh.f(dijit.byId('d2').checked, "d2 was checked"); |
| 394 |
}), 1000); |
| 395 |
|
| 396 |
return d; |
| 397 |
} |
| 398 |
}, |
| 399 |
{ |
| 400 |
timeout:3000, |
| 401 |
name:"enable coffee", |
| 402 |
runTest:function(){ |
| 403 |
var d = new doh.Deferred(); |
| 404 |
|
| 405 |
doh.robot.mouseMoveAt("g4rb2", 500, 1); |
| 406 |
doh.robot.mouseClick({left:true}, 500); |
| 407 |
|
| 408 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 409 |
doh.f(dijit.byId('g4rb1').checked, "tea was checked"); |
| 410 |
doh.t(dijit.byId('g4rb2').checked, "coffee was not checked"); |
| 411 |
}), 1000); |
| 412 |
|
| 413 |
return d; |
| 414 |
} |
| 415 |
} |
| 416 |
]); |
| 417 |
|
| 418 |
doh.run(); |
| 419 |
}); |
| 420 |
</script> |
| 421 |
</head> |
| 422 |
</html> |