| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 |
"http://www.w3.org/TR/html4/strict.dtd"> |
| 3 |
<html> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 6 |
<title>doh.robot Validation Test</title> |
| 7 |
|
| 8 |
<style> |
| 9 |
@import "../../../../util/doh/robot/robot.css"; |
| 10 |
</style> |
| 11 |
|
| 12 |
|
| 13 |
<script type="text/javascript" src="../../../../dojo/dojo.js" |
| 14 |
data-dojo-config="isDebug: true"></script> |
| 15 |
|
| 16 |
<script type="text/javascript"> |
| 17 |
dojo.require("dijit.robotx"); |
| 18 |
dojo.require("dojo.on"); |
| 19 |
dojo.require("dijit.tests.helpers"); // functions to help test |
| 20 |
|
| 21 |
dojo.ready(function(){ |
| 22 |
doh.robot.initRobot('../test_validate.html'); |
| 23 |
|
| 24 |
doh.register("intermediatechanges", { |
| 25 |
name: "valid", |
| 26 |
textbox: "q01", |
| 27 |
timeout: 9000, |
| 28 |
setUp: function(){ |
| 29 |
this.textbox = dijit.byId(this.textbox); |
| 30 |
this.textbox.set('value', ''); |
| 31 |
this.textbox.focusNode.focus(); |
| 32 |
}, |
| 33 |
runTest: function(){ |
| 34 |
var d = new doh.Deferred(); |
| 35 |
var onChange = dojo.byId('oc1'); |
| 36 |
var keyPressOnTextBox; |
| 37 |
this.textbox.on("keypress", function(){ |
| 38 |
keypressOnTextbox = true; |
| 39 |
}); |
| 40 |
|
| 41 |
var keypressOnParent; |
| 42 |
dojo.on(this.textbox.domNode.parentNode, "keypress", function(){ |
| 43 |
keypressOnParent = true; |
| 44 |
}); |
| 45 |
|
| 46 |
doh.robot.typeKeys('Testing', 1000, 1400); |
| 47 |
|
| 48 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 49 |
// test that value changed while typing since intermediateChanges = true |
| 50 |
doh.is('Testing', this.textbox.focusNode.value, "focusNode value"); |
| 51 |
doh.is('Testing', this.textbox.get('value'), "attr value"); |
| 52 |
doh.is('Testing', onChange.value, "onChange.value"); |
| 53 |
|
| 54 |
// Test that keypress event visible on TextBox but doesn't bubble to TextBox's parent. |
| 55 |
// This is necessary when a TextBox is inside a Toolbar, which interprets keystrokes |
| 56 |
// as keyboard search (to the Toolbar's children) |
| 57 |
doh.t(keypressOnTextbox, "keypressOnTextbox"); |
| 58 |
doh.f(keypressOnParent, "keypressOnParent"); |
| 59 |
})), 1000); |
| 60 |
return d; |
| 61 |
} |
| 62 |
}); |
| 63 |
|
| 64 |
doh.register("allcaps", { |
| 65 |
name: "valid", |
| 66 |
textbox: "q02", |
| 67 |
timeout: 9000, |
| 68 |
setUp: function(){ |
| 69 |
this.textbox = dijit.byId(this.textbox); |
| 70 |
this.textbox.set('value', ''); |
| 71 |
this.textbox.focusNode.focus(); |
| 72 |
}, |
| 73 |
runTest: function(){ |
| 74 |
var d = new doh.Deferred(); |
| 75 |
doh.robot.typeKeys('Testing', 1000, 1400); |
| 76 |
doh.robot.sequence(function(){ |
| 77 |
dojo.byId("q01").focus(); |
| 78 |
}, 500); |
| 79 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 80 |
doh.is('TESTING', this.textbox.focusNode.value, "focusNode.value"); |
| 81 |
doh.is('TESTING', this.textbox.get('value'), "get('value')"); |
| 82 |
})), 1000); |
| 83 |
return d; |
| 84 |
} |
| 85 |
}); |
| 86 |
|
| 87 |
doh.register("aria-invalid", [ |
| 88 |
{ |
| 89 |
name: "initial state", |
| 90 |
textbox: "fav", |
| 91 |
timeout: 9000, |
| 92 |
setUp: function(){ |
| 93 |
this.textbox = dijit.byId(this.textbox); |
| 94 |
}, |
| 95 |
runTest: function(){ |
| 96 |
// Even though it's required, it shouldn't initially be marked invalid |
| 97 |
doh.is('false', this.textbox.focusNode.getAttribute("aria-invalid"), "aria-invalid"); |
| 98 |
} |
| 99 |
}, |
| 100 |
{ |
| 101 |
name: "after blur", |
| 102 |
textbox: "fav", |
| 103 |
timeout: 9000, |
| 104 |
setUp: function(){ |
| 105 |
this.textbox = dijit.byId(this.textbox); |
| 106 |
this.textbox.set('value', ''); |
| 107 |
this.textbox.focusNode.focus(); |
| 108 |
}, |
| 109 |
runTest: function(){ |
| 110 |
var d = new doh.Deferred(); |
| 111 |
doh.robot.keyPress(dojo.keys.TAB, 100, {}); |
| 112 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 113 |
doh.is('true', this.textbox.focusNode.getAttribute("aria-invalid"), "aria-invalid"); |
| 114 |
})), 1000); |
| 115 |
return d; |
| 116 |
} |
| 117 |
}, |
| 118 |
{ |
| 119 |
name: "type invalid value", |
| 120 |
textbox: "fav", |
| 121 |
timeout: 9000, |
| 122 |
setUp: function(){ |
| 123 |
this.textbox = dijit.byId(this.textbox); |
| 124 |
this.textbox.set('value', ''); |
| 125 |
this.textbox.focusNode.focus(); |
| 126 |
}, |
| 127 |
runTest: function(){ |
| 128 |
var d = new doh.Deferred(); |
| 129 |
doh.robot.typeKeys('abc', 1000, 600); |
| 130 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 131 |
doh.is('true', this.textbox.focusNode.getAttribute("aria-invalid"), "aria-invalid"); |
| 132 |
})), 1000); |
| 133 |
return d; |
| 134 |
} |
| 135 |
}, |
| 136 |
{ |
| 137 |
name: "type valid value", |
| 138 |
textbox: "fav", |
| 139 |
timeout: 9000, |
| 140 |
setUp: function(){ |
| 141 |
this.textbox = dijit.byId(this.textbox); |
| 142 |
this.textbox.set('value', ''); |
| 143 |
this.textbox.focusNode.focus(); |
| 144 |
}, |
| 145 |
runTest: function(){ |
| 146 |
var d = new doh.Deferred(); |
| 147 |
doh.robot.typeKeys('abc', 1000, 600); |
| 148 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 149 |
doh.is('true', this.textbox.focusNode.getAttribute("aria-invalid"), "aria-invalid"); |
| 150 |
})), 1000); |
| 151 |
return d; |
| 152 |
} |
| 153 |
} |
| 154 |
]); |
| 155 |
|
| 156 |
doh.register("maxlength", [ |
| 157 |
{ |
| 158 |
name: "3chars", |
| 159 |
textbox: "fav", |
| 160 |
timeout: 9000, |
| 161 |
setUp: function(){ |
| 162 |
this.textbox = dijit.byId(this.textbox); |
| 163 |
this.textbox.set('value', ''); |
| 164 |
this.textbox.focusNode.focus(); |
| 165 |
}, |
| 166 |
runTest: function(){ |
| 167 |
var d = new doh.Deferred(); |
| 168 |
doh.robot.typeKeys('100', 1000, 600); |
| 169 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 170 |
// test that value changed while typing since intermediateChanges = true |
| 171 |
doh.is('100', this.textbox.focusNode.value, "focusNode.value"); |
| 172 |
doh.is(100, this.textbox.get('value'), "get('value')"); |
| 173 |
})), 1000); |
| 174 |
return d; |
| 175 |
} |
| 176 |
}, |
| 177 |
|
| 178 |
{ |
| 179 |
name: "4chars", |
| 180 |
textbox: "fav", |
| 181 |
timeout: 9000, |
| 182 |
setUp: function(){ |
| 183 |
this.textbox = dijit.byId(this.textbox); |
| 184 |
this.textbox.set('value', ''); |
| 185 |
this.textbox.focusNode.focus(); |
| 186 |
}, |
| 187 |
runTest: function(){ |
| 188 |
var d = new doh.Deferred(); |
| 189 |
doh.robot.typeKeys('1001', 1000, 800); |
| 190 |
doh.robot.sequence(d.getTestErrback(dojo.hitch(this, function(){ |
| 191 |
// test that value changed while typing since intermediateChanges = true |
| 192 |
doh.is('100', this.textbox.focusNode.value, "focusNode.value"); |
| 193 |
doh.is(100, this.textbox.get('value'), "get('value')"); |
| 194 |
doh.robot.typeKeys('1', 500, 200); |
| 195 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 196 |
doh.is('100', this.textbox.focusNode.value, "focusNode.value"); |
| 197 |
doh.is(100, this.textbox.get('value'), "get('value')"); |
| 198 |
})), 500); |
| 199 |
})), 1000); |
| 200 |
return d; |
| 201 |
} |
| 202 |
} |
| 203 |
]); |
| 204 |
|
| 205 |
doh.register("errorStyle", [ |
| 206 |
{ |
| 207 |
name: "beforeFocus", |
| 208 |
textbox: "q04", |
| 209 |
runTest: function(){ |
| 210 |
this.textbox = dijit.byId(this.textbox); |
| 211 |
doh.is('Incomplete', this.textbox.get('state')); |
| 212 |
doh.is(false, this.textbox.isValid(), "isValid()"); |
| 213 |
} |
| 214 |
}, |
| 215 |
|
| 216 |
{ |
| 217 |
name: "focus", |
| 218 |
textbox: "q04", |
| 219 |
timeout: 9000, |
| 220 |
runTest: function(){ |
| 221 |
var d = new doh.Deferred(); |
| 222 |
this.textbox = dijit.byId(this.textbox); |
| 223 |
this.textbox.focusNode.focus(); |
| 224 |
doh.robot.sequence(dojo.hitch(this, function(){ |
| 225 |
dojo.byId("q01").focus(); |
| 226 |
}), 1000); // time for promptMessage to appear on q04 (IE6 takes a while due to iframe) |
| 227 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 228 |
doh.is('Error', this.textbox.get('state')); |
| 229 |
doh.is(false, this.textbox.isValid(), "isValid()"); |
| 230 |
})), 1000); |
| 231 |
return d; |
| 232 |
} |
| 233 |
}, |
| 234 |
|
| 235 |
{ |
| 236 |
name: "valid", |
| 237 |
textbox: "q04", |
| 238 |
timeout: 9000, |
| 239 |
runTest: function(){ |
| 240 |
var d = new doh.Deferred(); |
| 241 |
this.textbox = dijit.byId(this.textbox); |
| 242 |
this.textbox.focusNode.focus(); |
| 243 |
doh.robot.sequence(d.getTestErrback(dojo.hitch(this, function(){ |
| 244 |
doh.is('Error', this.textbox.get('state')); |
| 245 |
doh.is(false, this.textbox.isValid(), "isValid()"); |
| 246 |
doh.robot.typeKeys('a', 500, 200); |
| 247 |
doh.robot.sequence(d.getTestErrback(dojo.hitch(this, function(){ |
| 248 |
doh.is('a', this.textbox.get('value'), "get('value')"); |
| 249 |
doh.is('', this.textbox.get('state'), "state 1"); |
| 250 |
doh.is(true, this.textbox.isValid(), "isValid() 1"); |
| 251 |
dojo.byId("q01").focus(); |
| 252 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 253 |
doh.is('', this.textbox.get('state'), "state 2"); |
| 254 |
doh.is(true, this.textbox.isValid(), "isValid() 2"); |
| 255 |
})), 1000); |
| 256 |
})), 500); |
| 257 |
})), 1000); |
| 258 |
return d; |
| 259 |
} |
| 260 |
} |
| 261 |
]); |
| 262 |
|
| 263 |
doh.register("commaformat", [ |
| 264 |
{ |
| 265 |
name: "beforeFocus", |
| 266 |
textbox: "q05", |
| 267 |
setUp: function(){ |
| 268 |
this.textbox = dijit.byId(this.textbox); |
| 269 |
this.textbox.set('value', 3000); |
| 270 |
}, |
| 271 |
runTest: function(){ |
| 272 |
this.textbox = dijit.byId(this.textbox); |
| 273 |
doh.is('3,000', this.textbox.focusNode.value, "focusNode.value"); |
| 274 |
doh.is('3000', this.textbox.get('value'), "get('value')"); |
| 275 |
doh.is(true, this.textbox.isValid(), "isValid()"); |
| 276 |
} |
| 277 |
}, |
| 278 |
|
| 279 |
{ |
| 280 |
name: "focus", |
| 281 |
timeout: 9000, |
| 282 |
textbox: "q05", |
| 283 |
runTest: function(){ |
| 284 |
var d = new doh.Deferred(); |
| 285 |
this.textbox = dijit.byId(this.textbox); |
| 286 |
this.textbox.focusNode.focus(); |
| 287 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 288 |
// comma should disappear on click, value shouldn't change |
| 289 |
doh.is('3,000', this.textbox.focusNode.value, "focusNode.value"); |
| 290 |
doh.is('3000', this.textbox.get('value'), "get('value')"); |
| 291 |
doh.is(true, this.textbox.isValid(), "isValid()"); |
| 292 |
})), 500); |
| 293 |
return d; |
| 294 |
} |
| 295 |
}, |
| 296 |
|
| 297 |
{ |
| 298 |
name: "type_valid_nocomma", |
| 299 |
timeout: 9000, |
| 300 |
textbox: "q05", |
| 301 |
setUp: function(){ |
| 302 |
this.textbox = dijit.byId(this.textbox); |
| 303 |
this.textbox.set('value', ''); |
| 304 |
this.textbox.focusNode.focus(); |
| 305 |
}, |
| 306 |
runTest: function(){ |
| 307 |
var d = new doh.Deferred(); |
| 308 |
var onChange = dojo.byId('oc5'); |
| 309 |
doh.robot.typeKeys('3000', 1000, 800); |
| 310 |
doh.robot.sequence(d.getTestErrback(dojo.hitch(this, function(){ |
| 311 |
doh.is('3000', this.textbox.focusNode.value, "focusNode.value"); |
| 312 |
doh.is('3000', this.textbox.get('value'), "get('value')"); |
| 313 |
doh.is(true, this.textbox.isValid(), "isValid()"); |
| 314 |
doh.is('NaN', onChange.value); |
| 315 |
dojo.byId("q01").focus(); |
| 316 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 317 |
doh.is('3,000', this.textbox.focusNode.value, "focusNode.value"); |
| 318 |
doh.is('3000', this.textbox.get('value'), "get('value')"); |
| 319 |
doh.is(true, this.textbox.isValid(), "isValid()"); |
| 320 |
doh.is('3000', onChange.value); |
| 321 |
})), 1000); |
| 322 |
})), 1000); |
| 323 |
return d; |
| 324 |
} |
| 325 |
}, |
| 326 |
|
| 327 |
{ |
| 328 |
name: "type_valid_comma", |
| 329 |
timeout: 9000, |
| 330 |
textbox: "q05", |
| 331 |
setUp: function(){ |
| 332 |
this.textbox = dijit.byId(this.textbox); |
| 333 |
this.textbox.set('value', ''); |
| 334 |
this.textbox.focusNode.focus(); |
| 335 |
}, |
| 336 |
runTest: function(){ |
| 337 |
var d = new doh.Deferred(); |
| 338 |
var onChange = dojo.byId('oc5'); |
| 339 |
doh.robot.typeKeys('3,000', 1000, 1000); |
| 340 |
doh.robot.sequence(d.getTestErrback(dojo.hitch(this, function(){ |
| 341 |
doh.is('3,000', this.textbox.focusNode.value, "focusNode.value"); |
| 342 |
doh.is('3000', this.textbox.get('value'), "get('value')"); |
| 343 |
doh.is(true, this.textbox.isValid(), "isValid()"); |
| 344 |
doh.is('NaN', onChange.value); |
| 345 |
dojo.byId("q01").focus(); |
| 346 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 347 |
doh.is('3,000', this.textbox.focusNode.value, "focusNode.value"); |
| 348 |
doh.is('3000', this.textbox.get('value'), "get('value')"); |
| 349 |
doh.is(true, this.textbox.isValid(), "isValid()"); |
| 350 |
doh.is('3000', onChange.value); |
| 351 |
})), 1000); |
| 352 |
})), 1000); |
| 353 |
return d; |
| 354 |
} |
| 355 |
}, |
| 356 |
|
| 357 |
{ |
| 358 |
name: "type_invalid_comma", |
| 359 |
timeout: 9000, |
| 360 |
textbox: "q05", |
| 361 |
setUp: function(){ |
| 362 |
this.textbox = dijit.byId(this.textbox); |
| 363 |
this.textbox.set('value', ''); |
| 364 |
this.textbox.focusNode.focus(); |
| 365 |
}, |
| 366 |
runTest: function(){ |
| 367 |
var d = new doh.Deferred(); |
| 368 |
var onChange = dojo.byId('oc5'); |
| 369 |
doh.robot.typeKeys('300,0', 1000, 1000); |
| 370 |
doh.robot.sequence(d.getTestErrback(dojo.hitch(this, function(){ |
| 371 |
doh.is('300,0', this.textbox.focusNode.value, "focusNode.value"); |
| 372 |
doh.is(undefined, this.textbox.get('value'), "get('value')"); |
| 373 |
doh.is(false, this.textbox.isValid(), "isValid()"); |
| 374 |
doh.is('NaN', onChange.value); |
| 375 |
dojo.byId("q01").focus(); |
| 376 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 377 |
doh.is('300,0', this.textbox.focusNode.value, "focusNode.value"); |
| 378 |
doh.is(undefined, this.textbox.get('value'), "get('value')"); |
| 379 |
doh.is(false, this.textbox.isValid(), "isValid()"); |
| 380 |
doh.is('undefined', onChange.value); |
| 381 |
})), 1000); |
| 382 |
})), 1000); |
| 383 |
return d; |
| 384 |
} |
| 385 |
} |
| 386 |
]); |
| 387 |
|
| 388 |
doh.register("currencyFormat", [ |
| 389 |
{ |
| 390 |
name: "beforeFocus", |
| 391 |
textbox: "q08", |
| 392 |
runTest: function(){ |
| 393 |
this.textbox = dijit.byId(this.textbox); |
| 394 |
this.textbox.set("value", 54775.53); |
| 395 |
doh.is('$54,775.53', this.textbox.focusNode.value, "focusNode.value"); |
| 396 |
doh.is('54775.53', this.textbox.get('value'), "get('value')"); |
| 397 |
doh.is(true, this.textbox.isValid(), "isValid()"); |
| 398 |
} |
| 399 |
}, |
| 400 |
|
| 401 |
{ |
| 402 |
name: "focus", |
| 403 |
timeout: 9000, |
| 404 |
textbox: "q08", |
| 405 |
setUp: function(){ |
| 406 |
this.textbox = dijit.byId(this.textbox); |
| 407 |
this.textbox.focusNode.focus(); |
| 408 |
}, |
| 409 |
runTest: function(){ |
| 410 |
var d = new doh.Deferred(); |
| 411 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 412 |
// comma should disappear on click, value shouldn't change |
| 413 |
doh.is('54775.53', this.textbox.focusNode.value, "focusNode.value"); |
| 414 |
doh.is('54775.53', this.textbox.get('value'), "get('value')"); |
| 415 |
doh.is(true, this.textbox.isValid(), "isValid()"); |
| 416 |
})), 500); |
| 417 |
return d; |
| 418 |
} |
| 419 |
}, |
| 420 |
|
| 421 |
{ |
| 422 |
name: "type_valid_number", |
| 423 |
timeout: 9000, |
| 424 |
textbox: "q08", |
| 425 |
setUp: function(){ |
| 426 |
this.textbox = dijit.byId(this.textbox); |
| 427 |
this.textbox.set('value', ''); |
| 428 |
this.textbox.focusNode.focus(); |
| 429 |
}, |
| 430 |
runTest: function(){ |
| 431 |
var d = new doh.Deferred(); |
| 432 |
var onChange = dojo.byId('oc8'); |
| 433 |
doh.robot.typeKeys('10000.01', 1000, 1600); |
| 434 |
doh.robot.sequence(d.getTestErrback(dojo.hitch(this, function(){ |
| 435 |
doh.is('10000.01', this.textbox.focusNode.value, "focusNode.value"); |
| 436 |
doh.is('10000.01', this.textbox.get('value'), "get('value')"); |
| 437 |
doh.is(true, this.textbox.isValid(), "isValid()"); |
| 438 |
doh.is('NaN', onChange.value); |
| 439 |
dojo.byId("q01").focus(); |
| 440 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 441 |
doh.is('$10,000.01', this.textbox.focusNode.value, "focusNode.value"); |
| 442 |
doh.is('10000.01', this.textbox.get('value'), "get('value')"); |
| 443 |
doh.is(true, this.textbox.isValid(), "isValid()"); |
| 444 |
doh.is('10000.01', onChange.value); |
| 445 |
})), 1000); |
| 446 |
})), 1000); |
| 447 |
return d; |
| 448 |
} |
| 449 |
}, |
| 450 |
{ |
| 451 |
name: "type_valid_dollarsign", |
| 452 |
timeout: 9000, |
| 453 |
textbox: "q08", |
| 454 |
setUp: function(){ |
| 455 |
this.textbox = dijit.byId(this.textbox); |
| 456 |
this.textbox.set('value', ''); |
| 457 |
this.textbox.focusNode.focus(); |
| 458 |
}, |
| 459 |
runTest: function(){ |
| 460 |
var d = new doh.Deferred(); |
| 461 |
var textbox = this.textbox; |
| 462 |
var onChange = dojo.byId('oc8'); |
| 463 |
doh.robot.typeKeys('$20000.01', 1000, 1800); |
| 464 |
doh.robot.sequence(d.getTestErrback(function(){ |
| 465 |
doh.is('$20000.01', textbox.focusNode.value, "focusNode.value"); |
| 466 |
doh.is(20000.01, textbox.get('value'), "get('value')"); |
| 467 |
doh.is(true, textbox.isValid(), "isValid()"); |
| 468 |
doh.is('NaN', onChange.value); |
| 469 |
var handler = textbox.connect(textbox, 'onChange', |
| 470 |
function(){ |
| 471 |
textbox.disconnect(handler); |
| 472 |
setTimeout(d.getTestCallback(function(){ |
| 473 |
doh.is('$20,000.01', textbox.focusNode.value, "blurred focusNode.value"); |
| 474 |
doh.is(20000.01, textbox.get('value'), "blurred get('value')"); |
| 475 |
doh.is(true, textbox.isValid(), "blurred isValid()"); |
| 476 |
doh.is('20000.01', onChange.value); |
| 477 |
}), 1); |
| 478 |
}); |
| 479 |
dojo.byId("q01").focus(); |
| 480 |
}), 500); |
| 481 |
return d; |
| 482 |
} |
| 483 |
}, |
| 484 |
{ |
| 485 |
name: "missing required decimal", |
| 486 |
timeout: 9000, |
| 487 |
textbox: "q08", |
| 488 |
setUp: function(){ |
| 489 |
this.textbox = dijit.byId(this.textbox); |
| 490 |
this.textbox.set('value', ''); |
| 491 |
this.textbox.focusNode.focus(); |
| 492 |
}, |
| 493 |
runTest: function(){ |
| 494 |
var d = new doh.Deferred(); |
| 495 |
doh.robot.typeKeys('123', 1000, 600); |
| 496 |
doh.robot.sequence(d.getTestErrback(dojo.hitch(this, function(){ |
| 497 |
doh.is('123', this.textbox.focusNode.value, "focusNode.value"); |
| 498 |
doh.is(123, this.textbox.get('value'), "get('value')"); |
| 499 |
doh.f(this.textbox.isValid(), "!isValid()"); |
| 500 |
})), 1000); |
| 501 |
var textbox = this.textbox; |
| 502 |
var handler = textbox.connect(textbox, '_onBlur', |
| 503 |
function(){ |
| 504 |
textbox.disconnect(handler); |
| 505 |
setTimeout(d.getTestCallback(function(){ |
| 506 |
doh.is('$123.00', textbox.focusNode.value, "focusNode.value"); |
| 507 |
doh.is(123, textbox.get('value'), "get('value')"); |
| 508 |
doh.t(textbox.isValid(), "isValid()"); |
| 509 |
}), 150); |
| 510 |
}); |
| 511 |
doh.robot.keyPress(dojo.keys.TAB, 1500, {}); |
| 512 |
return d; |
| 513 |
} |
| 514 |
}, |
| 515 |
{ |
| 516 |
name: "too few decimal digits", |
| 517 |
timeout: 9000, |
| 518 |
textbox: "q08", |
| 519 |
setUp: function(){ |
| 520 |
this.textbox = dijit.byId(this.textbox); |
| 521 |
this.textbox.set('value', ''); |
| 522 |
this.textbox.focusNode.focus(); |
| 523 |
}, |
| 524 |
runTest: function(){ |
| 525 |
var d = new doh.Deferred(); |
| 526 |
doh.robot.typeKeys('123.0', 1000, 1000); |
| 527 |
doh.robot.sequence(d.getTestErrback(dojo.hitch(this, function(){ |
| 528 |
doh.is('123.0', this.textbox.focusNode.value, "focusNode.value"); |
| 529 |
doh.is(123, this.textbox.get('value'), "get('value')"); |
| 530 |
doh.f(this.textbox.isValid(), "!isValid()"); |
| 531 |
})), 1000); |
| 532 |
var textbox = this.textbox; |
| 533 |
var handler = textbox.connect(textbox, '_onBlur', |
| 534 |
function(){ |
| 535 |
textbox.disconnect(handler); |
| 536 |
setTimeout(d.getTestCallback(function(){ |
| 537 |
doh.is('$123.00', textbox.focusNode.value, "focusNode.value"); |
| 538 |
doh.is(123, textbox.get('value'), "get('value')"); |
| 539 |
doh.t(textbox.isValid(), "isValid()"); |
| 540 |
}), 150); |
| 541 |
}); |
| 542 |
doh.robot.keyPress(dojo.keys.TAB, 1500, {}); |
| 543 |
return d; |
| 544 |
} |
| 545 |
}, |
| 546 |
{ |
| 547 |
name: "too many decimal digits", |
| 548 |
timeout: 9000, |
| 549 |
textbox: "q08", |
| 550 |
setUp: function(){ |
| 551 |
this.textbox = dijit.byId(this.textbox); |
| 552 |
this.textbox.set('value', ''); |
| 553 |
this.textbox.focusNode.focus(); |
| 554 |
}, |
| 555 |
runTest: function(){ |
| 556 |
var d = new doh.Deferred(); |
| 557 |
doh.robot.typeKeys('123.000', 1000, 1400); |
| 558 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 559 |
doh.is('123.000', this.textbox.focusNode.value, "focusNode.value"); |
| 560 |
doh.is(undefined, this.textbox.get('value'), "get('value')"); |
| 561 |
doh.f(this.textbox.isValid(), "!isValid()"); |
| 562 |
})), 1500); |
| 563 |
return d; |
| 564 |
} |
| 565 |
}, |
| 566 |
{ |
| 567 |
name: "negative decimal", |
| 568 |
timeout: 9000, |
| 569 |
textbox: "q08", |
| 570 |
setUp: function(){ |
| 571 |
this.textbox = dijit.byId(this.textbox); |
| 572 |
this.textbox.set('value', ''); |
| 573 |
this.textbox.focusNode.focus(); |
| 574 |
}, |
| 575 |
runTest: function(){ |
| 576 |
var d = new doh.Deferred(); |
| 577 |
doh.robot.typeKeys('-123.00', 1000, 1400); |
| 578 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 579 |
doh.is('-123.00', this.textbox.focusNode.value, "focusNode.value"); |
| 580 |
doh.is(-123, this.textbox.get('value'), "get('value')"); |
| 581 |
doh.t(this.textbox.isValid(), "isValid()"); |
| 582 |
})), 1500); |
| 583 |
return d; |
| 584 |
} |
| 585 |
}, |
| 586 |
{ |
| 587 |
name: "negative currency", |
| 588 |
timeout: 9000, |
| 589 |
textbox: "q08", |
| 590 |
setUp: function(){ |
| 591 |
this.textbox = dijit.byId(this.textbox); |
| 592 |
this.textbox.set('value', ''); |
| 593 |
this.textbox.focusNode.focus(); |
| 594 |
}, |
| 595 |
runTest: function(){ |
| 596 |
var d = new doh.Deferred(); |
| 597 |
doh.robot.typeKeys('($123.00)', 1000, 1600); |
| 598 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 599 |
doh.is('($123.00)', this.textbox.focusNode.value, "focusNode.value"); |
| 600 |
doh.is(-123, this.textbox.get('value'), "get('value')"); |
| 601 |
doh.t(this.textbox.isValid(), "isValid()"); |
| 602 |
})), 2000); |
| 603 |
return d; |
| 604 |
} |
| 605 |
}, |
| 606 |
{ |
| 607 |
name: "convert negative decimal to negative currency", |
| 608 |
timeout: 9000, |
| 609 |
textbox: "q08", |
| 610 |
setUp: function(){ |
| 611 |
this.textbox = dijit.byId(this.textbox); |
| 612 |
this.textbox.set('value', ''); |
| 613 |
this.textbox.focusNode.focus(); |
| 614 |
}, |
| 615 |
runTest: function(){ |
| 616 |
var d = new doh.Deferred(); |
| 617 |
doh.robot.typeKeys('-123.45', 1000, 1400); |
| 618 |
|
| 619 |
var textbox = this.textbox; |
| 620 |
var handler = textbox.connect(textbox, '_onBlur', |
| 621 |
function(){ |
| 622 |
textbox.disconnect(handler); |
| 623 |
setTimeout(d.getTestCallback(function(){ |
| 624 |
doh.is('($123.45)', textbox.focusNode.value, "focusNode.value"); |
| 625 |
doh.is(-123.45, textbox.get('value'), "get('value')"); |
| 626 |
doh.t(textbox.isValid(), "isValid()"); |
| 627 |
}), 150); |
| 628 |
}); |
| 629 |
doh.robot.keyPress(dojo.keys.TAB, 100, {}); |
| 630 |
return d; |
| 631 |
} |
| 632 |
}, |
| 633 |
{ |
| 634 |
name: "convert negative negative currency to negative decimal", |
| 635 |
timeout: 9000, |
| 636 |
textbox: "q08", |
| 637 |
setUp: function(){ |
| 638 |
this.textbox = dijit.byId(this.textbox); |
| 639 |
this.textbox.set('value', ''); |
| 640 |
this.textbox.focusNode.focus(); |
| 641 |
}, |
| 642 |
runTest: function(){ |
| 643 |
var d = new doh.Deferred(); |
| 644 |
doh.robot.typeKeys('($123.45)', 1000, 1800); |
| 645 |
doh.robot.keyPress(dojo.keys.TAB, 500, {}); |
| 646 |
doh.robot.keyPress(dojo.keys.TAB, 500, {shift:true}); |
| 647 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 648 |
doh.is('-123.45', this.textbox.focusNode.value, "focusNode.value"); |
| 649 |
doh.is(-123.45, this.textbox.get('value'), "get('value')"); |
| 650 |
doh.t(this.textbox.isValid(), "isValid()"); |
| 651 |
})), 1000); |
| 652 |
return d; |
| 653 |
} |
| 654 |
}, |
| 655 |
{ |
| 656 |
name: "exponent not allowed", |
| 657 |
timeout: 9000, |
| 658 |
textbox: "q08", |
| 659 |
setUp: function(){ |
| 660 |
this.textbox = dijit.byId(this.textbox); |
| 661 |
this.textbox.set('value', ''); |
| 662 |
this.textbox.focusNode.focus(); |
| 663 |
}, |
| 664 |
runTest: function(){ |
| 665 |
var d = new doh.Deferred(); |
| 666 |
doh.robot.typeKeys('1.23e0', 1000, 1200); |
| 667 |
doh.robot.keyPress(dojo.keys.TAB, 500, {}); |
| 668 |
doh.robot.keyPress(dojo.keys.TAB, 500, {shift:true}); |
| 669 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 670 |
doh.is('1.23e0', this.textbox.focusNode.value, "focusNode.value"); |
| 671 |
doh.is(undefined, this.textbox.get('value'), "get('value')"); |
| 672 |
doh.f(this.textbox.isValid(), "!isValid()"); |
| 673 |
})), 1000); |
| 674 |
return d; |
| 675 |
} |
| 676 |
} |
| 677 |
]); |
| 678 |
|
| 679 |
doh.register("euroformat", { |
| 680 |
name: "type_1", |
| 681 |
timeout: 9000, |
| 682 |
textbox: "q08eur", |
| 683 |
setUp: function(){ |
| 684 |
this.textbox = dijit.byId(this.textbox); |
| 685 |
this.textbox.set('value', ''); |
| 686 |
this.textbox.focusNode.focus(); |
| 687 |
}, |
| 688 |
runTest: function(){ |
| 689 |
var d = new doh.Deferred(); |
| 690 |
doh.robot.typeKeys('1', 1000, 200); |
| 691 |
doh.robot.sequence(dojo.hitch(this, function(){ |
| 692 |
dijit.byId('q01').focusNode.focus(); |
| 693 |
}), 500); |
| 694 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 695 |
doh.is('€1.00', this.textbox.focusNode.value, "focusNode.value"); |
| 696 |
doh.is('1', this.textbox.get('value'), "get('value')"); |
| 697 |
doh.is(true, this.textbox.isValid(), "isValid()"); |
| 698 |
})), 1000); |
| 699 |
return d; |
| 700 |
} |
| 701 |
}); |
| 702 |
|
| 703 |
doh.register("regexp", [ |
| 704 |
{ |
| 705 |
name: "valid", |
| 706 |
timeout: 9000, |
| 707 |
textbox: "q22", |
| 708 |
setUp: function(){ |
| 709 |
this.textbox = dijit.byId(this.textbox); |
| 710 |
this.textbox.set('value', ''); |
| 711 |
this.textbox.focusNode.focus(); |
| 712 |
}, |
| 713 |
runTest: function(){ |
| 714 |
var d = new doh.Deferred(); |
| 715 |
doh.robot.typeKeys('a', 1000, 200); |
| 716 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 717 |
doh.is('a', this.textbox.focusNode.value, "focusNode.value"); |
| 718 |
doh.is('a', this.textbox.get('value'), "get('value')"); |
| 719 |
doh.is(true, this.textbox.isValid(), "isValid()"); |
| 720 |
})), 500); |
| 721 |
return d; |
| 722 |
} |
| 723 |
}, |
| 724 |
|
| 725 |
{ |
| 726 |
name: "invalid", |
| 727 |
timeout: 9000, |
| 728 |
textbox: "q22", |
| 729 |
setUp: function(){ |
| 730 |
this.textbox = dijit.byId(this.textbox); |
| 731 |
this.textbox.set('value', ''); |
| 732 |
this.textbox.focusNode.focus(); |
| 733 |
}, |
| 734 |
runTest: function(){ |
| 735 |
var d = new doh.Deferred(); |
| 736 |
doh.robot.typeKeys('a ', 1000, 400); |
| 737 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 738 |
doh.is('a ', this.textbox.focusNode.value, "focusNode.value"); |
| 739 |
doh.is('a ', this.textbox.get('value'), "get('value')"); |
| 740 |
doh.is(false, this.textbox.isValid(), "isValid()"); |
| 741 |
})), 500); |
| 742 |
return d; |
| 743 |
} |
| 744 |
} |
| 745 |
]); |
| 746 |
|
| 747 |
doh.register("password", { |
| 748 |
name: "type", |
| 749 |
timeout: 9000, |
| 750 |
textbox: "q23", |
| 751 |
setUp: function(){ |
| 752 |
this.textbox = dijit.byId(this.textbox); |
| 753 |
this.textbox.set('value', ''); |
| 754 |
this.textbox.focusNode.focus(); |
| 755 |
}, |
| 756 |
runTest: function(){ |
| 757 |
var d = new doh.Deferred(); |
| 758 |
doh.robot.typeKeys('abcdef', 1000, 1200); |
| 759 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 760 |
doh.is('abcdef', this.textbox.focusNode.value, "focusNode.value"); |
| 761 |
doh.is('abcdef', this.textbox.get('value'), "get('value')"); |
| 762 |
})), 1000); |
| 763 |
return d; |
| 764 |
} |
| 765 |
}); |
| 766 |
|
| 767 |
doh.register("readonly", [ |
| 768 |
{ |
| 769 |
name: "readonly", |
| 770 |
timeout: 9000, |
| 771 |
textbox: "q24", |
| 772 |
setUp: function(){ |
| 773 |
this.textbox = dijit.byId(this.textbox); |
| 774 |
dojo.byId("mname").focus(); |
| 775 |
}, |
| 776 |
runTest: function(){ |
| 777 |
doh.t(this.textbox.isFocusable(), "readOnly is focusable"); |
| 778 |
var d = new doh.Deferred(); |
| 779 |
|
| 780 |
// Tab into element (readonly *can* be focused, although disabled can't) |
| 781 |
doh.robot.keyPress(dojo.keys.TAB, 1000); |
| 782 |
|
| 783 |
// typing on a disabled element should have no effect |
| 784 |
doh.robot.typeKeys('abc', 1000, 600); |
| 785 |
|
| 786 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 787 |
doh.is("q24", (dojo.global.dijit.focus.curNode||{}).id, "did focus"); |
| 788 |
doh.is('cannot type here', this.textbox.focusNode.value, "focusNode.value"); |
| 789 |
doh.is('cannot type here', this.textbox.get('value'), "get('value')"); |
| 790 |
})), 1000); |
| 791 |
return d; |
| 792 |
} |
| 793 |
}, |
| 794 |
|
| 795 |
{ |
| 796 |
name: "write", |
| 797 |
timeout: 9000, |
| 798 |
textbox: "q24", |
| 799 |
setUp: function(){ |
| 800 |
this.textbox = dijit.byId(this.textbox); |
| 801 |
this.textbox.set('value', ''); |
| 802 |
this.textbox.set('readOnly', false); |
| 803 |
}, |
| 804 |
runTest: function(){ |
| 805 |
var d = new doh.Deferred(); |
| 806 |
|
| 807 |
// Click to focus |
| 808 |
doh.robot.mouseMoveAt(this.textbox.focusNode, 500, 1); |
| 809 |
doh.robot.mouseClick({left: true}, 500); |
| 810 |
|
| 811 |
doh.robot.typeKeys('abc', 1000, 600); |
| 812 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 813 |
doh.is('abc', this.textbox.focusNode.value, "focusNode.value"); |
| 814 |
doh.is('abc', this.textbox.get('value'), "get('value')"); |
| 815 |
})), 1000); |
| 816 |
return d; |
| 817 |
} |
| 818 |
} |
| 819 |
]); |
| 820 |
|
| 821 |
doh.register("disabled", [ |
| 822 |
{ |
| 823 |
name: "click doesn't focus", |
| 824 |
timeout: 9000, |
| 825 |
setUp: function(){ |
| 826 |
this.textbox = dijit.byId("q24"); |
| 827 |
dojo.byId("mname").focus(); |
| 828 |
this.textbox.set('disabled', true); |
| 829 |
}, |
| 830 |
runTest: function(){ |
| 831 |
doh.f(this.textbox.isFocusable(), "disabled is not focusable"); |
| 832 |
var d = new doh.Deferred(); |
| 833 |
|
| 834 |
// Clicking shouldn't have any effect since it's disabled |
| 835 |
doh.robot.mouseMoveAt(this.textbox.focusNode, 500, 1); |
| 836 |
doh.robot.mouseClick({left: true}, 500); |
| 837 |
|
| 838 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 839 |
doh.isNot("q24", (dojo.global.dijit.focus.curNode||{}).id, "didn't focus"); |
| 840 |
})), 500); |
| 841 |
return d; |
| 842 |
} |
| 843 |
}, |
| 844 |
|
| 845 |
{ |
| 846 |
name: "tab jumps over", |
| 847 |
timeout: 9000, |
| 848 |
|
| 849 |
setUp: function(){ |
| 850 |
var textbox = dijit.byId("q24"); |
| 851 |
dojo.byId("mname").focus(); |
| 852 |
textbox.set('disabled', true); |
| 853 |
}, |
| 854 |
runTest: function(){ |
| 855 |
var d = new doh.Deferred(); |
| 856 |
|
| 857 |
doh.robot.keyPress(dojo.keys.TAB, 500); |
| 858 |
|
| 859 |
doh.robot.sequence(d.getTestCallback(dojo.hitch(this, function(){ |
| 860 |
doh.is("q26", dojo.global.dijit.focus.curNode.id, |
| 861 |
"tabbed past input, to the button after it"); |
| 862 |
})), 500); |
| 863 |
return d; |
| 864 |
} |
| 865 |
} |
| 866 |
]); |
| 867 |
|
| 868 |
doh.register("selectOnClick", [ |
| 869 |
{ |
| 870 |
name: "1 click does highlight", |
| 871 |
timeout: 9000, |
| 872 |
setUp: function(){ |
| 873 |
dijit.byId("q02").focus(); |
| 874 |
}, |
| 875 |
runTest: function(){ |
| 876 |
var d = new doh.Deferred(), |
| 877 |
textbox = dijit.byId("q01"); |
| 878 |
|
| 879 |
textbox.set('value', 'Testing'); |
| 880 |
doh.robot.mouseMoveAt(textbox.focusNode, 500, 1); |
| 881 |
doh.robot.mouseClick({left: true}, 500); |
| 882 |
doh.robot.typeKeys("abc", 1000, 600); |
| 883 |
|
| 884 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 885 |
doh.is("Abc", textbox.get('value'), "was highlighted"); |
| 886 |
}), 500); |
| 887 |
return d; |
| 888 |
} |
| 889 |
}, |
| 890 |
{ |
| 891 |
name: "2 clicks doesn't highlight", |
| 892 |
timeout: 9000, |
| 893 |
setUp: function(){ |
| 894 |
dijit.byId("q02").focus(); |
| 895 |
}, |
| 896 |
runTest: function(){ |
| 897 |
var d = new doh.Deferred(), |
| 898 |
textbox = dijit.byId("q01"); |
| 899 |
|
| 900 |
textbox.set('value', 'Testing'); |
| 901 |
doh.robot.mouseMoveAt(textbox.focusNode, 500, 1); |
| 902 |
doh.robot.mouseClick({left: true}, 500); |
| 903 |
doh.robot.mouseClick({left: true}, 1000); |
| 904 |
var oldValue = textbox.get('value'); |
| 905 |
doh.robot.typeKeys("abc", 500, 600); |
| 906 |
|
| 907 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 908 |
doh.isNot(oldValue, textbox.get('value'), "didn't change at all"); |
| 909 |
doh.isNot("Abc", textbox.get('value'), "was highlighted"); |
| 910 |
}), 500); |
| 911 |
return d; |
| 912 |
} |
| 913 |
}, |
| 914 |
{ |
| 915 |
name: "TAB focus still highlights a selectOnFocus textbox", |
| 916 |
timeout: 9000, |
| 917 |
setUp: function(){ |
| 918 |
dijit.byId("q02").focus(); |
| 919 |
}, |
| 920 |
runTest: function(){ |
| 921 |
var d = new doh.Deferred(), |
| 922 |
textbox = dijit.byId("q01"); |
| 923 |
|
| 924 |
textbox.set('value', 'Testing'); |
| 925 |
doh.robot.mouseMoveAt(textbox.focusNode, 500, 1); |
| 926 |
doh.robot.mouseClick({left: true}, 500); |
| 927 |
doh.robot.mouseClick({left: true}, 1000); |
| 928 |
doh.robot.keyPress(dojo.keys.TAB, 1000); |
| 929 |
doh.robot.keyPress(dojo.keys.TAB, 1000, {shift:true}); |
| 930 |
doh.robot.typeKeys("abc", 500, 600); |
| 931 |
|
| 932 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 933 |
doh.is("Abc", textbox.get('value'), "was not highlighted"); |
| 934 |
}), 500); |
| 935 |
return d; |
| 936 |
} |
| 937 |
}, |
| 938 |
{ |
| 939 |
name: "click doesn't highlight after TAB focus", |
| 940 |
timeout: 9000, |
| 941 |
setUp: function(){ |
| 942 |
dijit.byId("q02").focus(); |
| 943 |
}, |
| 944 |
runTest: function(){ |
| 945 |
var d = new doh.Deferred(), |
| 946 |
textbox = dijit.byId("q01"); |
| 947 |
|
| 948 |
textbox.set('value', 'Testing'); |
| 949 |
doh.robot.mouseMoveAt(textbox.focusNode, 500, 1); |
| 950 |
doh.robot.mouseClick({left: true}, 500); |
| 951 |
doh.robot.mouseClick({left: true}, 1000); |
| 952 |
doh.robot.keyPress(dojo.keys.TAB, 1000); |
| 953 |
doh.robot.keyPress(dojo.keys.TAB, 1000, {shift:true}); |
| 954 |
doh.robot.mouseClick({left: true}, 1000); |
| 955 |
var oldValue = textbox.get('value'); |
| 956 |
doh.robot.typeKeys("abc", 500, 600); |
| 957 |
|
| 958 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 959 |
doh.isNot(oldValue, textbox.get('value'), "didn't change at all"); |
| 960 |
doh.isNot("Abc", textbox.get('value'), "was highlighted"); |
| 961 |
}), 500); |
| 962 |
return d; |
| 963 |
} |
| 964 |
}, |
| 965 |
{ |
| 966 |
name: "mouse selection still works", |
| 967 |
timeout: 9000, |
| 968 |
setUp: function(){ |
| 969 |
dijit.byId("q02").focus(); |
| 970 |
}, |
| 971 |
runTest: function(){ |
| 972 |
var d = new doh.Deferred(), |
| 973 |
textbox = dijit.byId("q01"); |
| 974 |
|
| 975 |
textbox.set('value', 'MMMMMMM'); |
| 976 |
doh.robot.mouseMoveAt(textbox.focusNode, 500, 1, 3, 6); |
| 977 |
doh.robot.mousePress({left: true}, 500); |
| 978 |
doh.robot.mouseMoveAt(textbox.focusNode, 500, 500, 10, 6); |
| 979 |
doh.robot.mouseRelease({left: true}, 500); |
| 980 |
doh.robot.typeKeys("abc", 500, 600); |
| 981 |
|
| 982 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 983 |
doh.is("AbcMMMMMM", textbox.get('value'), "could not select text"); |
| 984 |
}), 500); |
| 985 |
return d; |
| 986 |
} |
| 987 |
} |
| 988 |
]); |
| 989 |
|
| 990 |
doh.register("set constraints", [ |
| 991 |
{ |
| 992 |
name: "number", |
| 993 |
timeout: 9000, |
| 994 |
runTest: function(){ |
| 995 |
var textWidget = dijit.byId("q05"); |
| 996 |
textWidget.set('value', 12345); |
| 997 |
doh.is("12,345", textWidget.get('displayedValue'), "default value"); |
| 998 |
textWidget.set('constraints', {places:2}); |
| 999 |
doh.is("12,345.00", textWidget.get('displayedValue'), "decimal value"); |
| 1000 |
} |
| 1001 |
}, |
| 1002 |
{ |
| 1003 |
name: "currency", |
| 1004 |
timeout: 9000, |
| 1005 |
runTest: function(){ |
| 1006 |
var textWidget = dijit.byId("q08eurde"); |
| 1007 |
textWidget.set('value', 12345.25); |
| 1008 |
doh.is("12.345,25\xa0€", textWidget.get('displayedValue'), "EUR value"); |
| 1009 |
textWidget.set('constraints', {currency:'USD', locale:'en-us'}); |
| 1010 |
doh.is("$12,345.25", textWidget.get('displayedValue'), "USD value"); |
| 1011 |
} |
| 1012 |
} |
| 1013 |
]); |
| 1014 |
|
| 1015 |
doh.register("placeholder", [ |
| 1016 |
{ |
| 1017 |
name: "textbox", |
| 1018 |
runTest: function(){ |
| 1019 |
var textWidget = dijit.byId("q26"); |
| 1020 |
doh.is('', textWidget.get('value'),'initial value is empty'); |
| 1021 |
doh.is('placeholder is here', textWidget._phspan.innerHTML, '_phspan.innerHTML'); |
| 1022 |
textWidget.set('value','abc'); |
| 1023 |
doh.is('abc', textWidget.get('value')); |
| 1024 |
textWidget.set('placeHolder','new placeholder'); |
| 1025 |
doh.f(textWidget.focusNode.hasAttribute("placeholder"), |
| 1026 |
"make sure placeholder attribute didn't get set natively on <input> too") |
| 1027 |
doh.is('abc', textWidget.get('value')); |
| 1028 |
textWidget.set('value',''); |
| 1029 |
doh.is('new placeholder', textWidget._phspan.innerHTML, '_phspan.innerHTML 1'); |
| 1030 |
doh.is('', textWidget.get('value')); |
| 1031 |
} |
| 1032 |
}, |
| 1033 |
{ |
| 1034 |
name: "focus/blur textbox", |
| 1035 |
timeout: 9000, |
| 1036 |
runTest: function(){ |
| 1037 |
var d = new doh.Deferred(), textWidget = dijit.byId("q26"); |
| 1038 |
textWidget.set('placeHolder','placeholder is here'); |
| 1039 |
textWidget.set('value',''); |
| 1040 |
|
| 1041 |
// Clicking into the input should hide _phspan |
| 1042 |
doh.robot.mouseMoveAt(textWidget.focusNode, 500, 1); |
| 1043 |
doh.robot.mouseClick({left: true}, 500); |
| 1044 |
|
| 1045 |
doh.robot.sequence(d.getTestErrback(function(){ |
| 1046 |
doh.is("", textWidget.get('value'), "get('value')"); |
| 1047 |
doh.isNot("none", textWidget._phspan.style.display, "_phspan.style.display"); |
| 1048 |
|
| 1049 |
doh.robot.keyPress(dojo.keys.TAB, 500, {shift:true}); |
| 1050 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 1051 |
doh.is("", textWidget.get('value'), "get('value')"); |
| 1052 |
doh.isNot("none", textWidget._phspan.style.display, "_phspan.style.display 1"); |
| 1053 |
}), 1000); |
| 1054 |
}), 1000); |
| 1055 |
return d; |
| 1056 |
} |
| 1057 |
}, |
| 1058 |
{ |
| 1059 |
name: "type in textbox", |
| 1060 |
timeout: 9000, |
| 1061 |
runTest: function(){ |
| 1062 |
var d = new doh.Deferred(), textWidget = dijit.byId("q26"); |
| 1063 |
textWidget.set('placeHolder','placeholder is here'); |
| 1064 |
textWidget.set('value',''); |
| 1065 |
|
| 1066 |
// Clicking into the input should hide _phspan |
| 1067 |
doh.robot.mouseMoveAt(textWidget.focusNode, 500, 1); |
| 1068 |
doh.robot.mouseClick({left: true}, 500); |
| 1069 |
|
| 1070 |
doh.robot.sequence(d.getTestErrback(function(){ |
| 1071 |
doh.is("", textWidget.get('value'), "get('value')"); |
| 1072 |
doh.isNot("none", textWidget._phspan.style.display, "_phspan.style.display 1"); |
| 1073 |
|
| 1074 |
doh.robot.typeKeys('new', 0, 600); |
| 1075 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 1076 |
doh.is("new", textWidget.get('value'), "get('value')"); |
| 1077 |
doh.is("none", textWidget._phspan.style.display, "_phspan.style.display 2"); |
| 1078 |
}), 500); |
| 1079 |
}), 1000); |
| 1080 |
return d; |
| 1081 |
} |
| 1082 |
}, |
| 1083 |
{ |
| 1084 |
name: "reset textbox", |
| 1085 |
timeout: 9000, |
| 1086 |
runTest: function(){ |
| 1087 |
var textWidget = dijit.byId("q26"), d = new doh.Deferred(); |
| 1088 |
textWidget.focus(); |
| 1089 |
textWidget.set('placeHolder','placeholder is here'); |
| 1090 |
textWidget.set('value',''); |
| 1091 |
|
| 1092 |
doh.is("", textWidget.get('value'), "get('value') 1"); |
| 1093 |
doh.isNot("none", textWidget._phspan.style.display, "_phspan.style.display"); |
| 1094 |
|
| 1095 |
textWidget.set('value','abc'); |
| 1096 |
textWidget.reset(); |
| 1097 |
|
| 1098 |
doh.is("", textWidget.get('value'), "get('value') 2"); |
| 1099 |
doh.isNot("none", textWidget._phspan.style.display, "_phspan.style.display 1"); |
| 1100 |
|
| 1101 |
var handler = textWidget.connect(textWidget, '_onBlur', |
| 1102 |
function(){ |
| 1103 |
textWidget.disconnect(handler); |
| 1104 |
textWidget.set('value','xyz'); |
| 1105 |
textWidget.reset(); |
| 1106 |
setTimeout(d.getTestCallback(function(){ |
| 1107 |
doh.is("", textWidget.get('value'), "get('value')"); |
| 1108 |
doh.isNot("none", textWidget._phspan.style.display, "_phspan.style.display 2"); |
| 1109 |
}), 150); |
| 1110 |
}); |
| 1111 |
doh.robot.keyPress(dojo.keys.TAB, 500, {}); |
| 1112 |
|
| 1113 |
return d; |
| 1114 |
} |
| 1115 |
}, |
| 1116 |
{ |
| 1117 |
name: "set textbox value", |
| 1118 |
runTest: function(){ |
| 1119 |
var textWidget = dijit.byId("q26"); |
| 1120 |
textWidget.set('placeHolder','placeholder is here'); |
| 1121 |
textWidget.set('value','value'); |
| 1122 |
doh.is("none", textWidget._phspan.style.display, "_phspan.style.display"); |
| 1123 |
} |
| 1124 |
} |
| 1125 |
]); |
| 1126 |
|
| 1127 |
function testOn(evt, widget, deferred, callback, delay){ |
| 1128 |
var handler = widget.connect(widget.focusNode, "on"+evt, |
| 1129 |
function(){ |
| 1130 |
widget.disconnect(handler); |
| 1131 |
setTimeout(deferred.getTestCallback(callback), delay||250); |
| 1132 |
}); |
| 1133 |
} |
| 1134 |
|
| 1135 |
// Supplementary test from validationMessages.html, to make sure tooltip doesn't flash |
| 1136 |
// on typing multiple invalid characters |
| 1137 |
doh.register("no flashing on validation", [ |
| 1138 |
{ |
| 1139 |
name: "first focus, empty value", |
| 1140 |
timeout: 5000, |
| 1141 |
runTest: function(){ |
| 1142 |
var d = new doh.Deferred(); |
| 1143 |
textbox = dijit.byId("q03"); |
| 1144 |
textbox.focusNode.scrollIntoView(); |
| 1145 |
textbox.set("value", ""); |
| 1146 |
textbox.focus(); |
| 1147 |
setTimeout(d.getTestCallback(function(){ |
| 1148 |
// Tooltip should appear with information message |
| 1149 |
masterTT = dojo.global.dijit._masterTT; |
| 1150 |
doh.t(masterTT && isVisible(masterTT.domNode), "visible"); |
| 1151 |
doh.is("(optional) Enter an age between 0 and 120", dojo.trim(innerText(masterTT.domNode))); |
| 1152 |
}), 750); |
| 1153 |
return d; |
| 1154 |
} |
| 1155 |
}, |
| 1156 |
{ |
| 1157 |
name: "first invalid character", |
| 1158 |
timeout: 2000, |
| 1159 |
runTest: function(){ |
| 1160 |
var d = new doh.Deferred(); |
| 1161 |
testOn('keyup', textbox, d, function(){ |
| 1162 |
masterTT = dojo.global.dijit._masterTT; |
| 1163 |
doh.t(masterTT && isVisible(masterTT.domNode), "visible"); |
| 1164 |
doh.is("The value entered is not valid.", dojo.trim(innerText(masterTT.domNode)), |
| 1165 |
"message changed from info message to error message"); |
| 1166 |
}); |
| 1167 |
doh.robot.typeKeys("a", 0, 0); |
| 1168 |
return d; |
| 1169 |
} |
| 1170 |
}, |
| 1171 |
{ |
| 1172 |
name: "second invalid character", |
| 1173 |
timeout: 2000, |
| 1174 |
runTest: function(){ |
| 1175 |
var d = new doh.Deferred(); |
| 1176 |
var tooltipHidden = false; |
| 1177 |
testOn('keyup', textbox, d, function(){ |
| 1178 |
masterTT = dojo.global.dijit._masterTT; |
| 1179 |
doh.f(tooltipHidden, "tooltip didn't blink or disappear"); |
| 1180 |
doh.is("The value entered is not valid.", dojo.trim(innerText(masterTT.domNode)), |
| 1181 |
"same message"); |
| 1182 |
}); |
| 1183 |
dojo.connect(dijit, "hideTooltip", function(){ tooltipHidden = true; }); |
| 1184 |
doh.robot.typeKeys("a", 0, 0); |
| 1185 |
return d; |
| 1186 |
} |
| 1187 |
}, |
| 1188 |
{ |
| 1189 |
name: "tab away", |
| 1190 |
timeout: 2000, |
| 1191 |
runTest: function(){ |
| 1192 |
var d = new doh.Deferred(); |
| 1193 |
testOn('blur', textbox, d, function(){ |
| 1194 |
masterTT = dojo.global.dijit._masterTT; |
| 1195 |
doh.t(masterTT && isHidden(masterTT.domNode), "hidden"); |
| 1196 |
}); |
| 1197 |
doh.robot.keyPress(dojo.keys.TAB, 0); |
| 1198 |
return d; |
| 1199 |
} |
| 1200 |
}, |
| 1201 |
{ |
| 1202 |
name: "tab back", |
| 1203 |
timeout: 2000, |
| 1204 |
runTest: function(){ |
| 1205 |
var d = new doh.Deferred(); |
| 1206 |
testOn('focus', textbox, d, function(){ |
| 1207 |
masterTT = dojo.global.dijit._masterTT; |
| 1208 |
doh.t(masterTT && isVisible(masterTT.domNode), "visible again"); |
| 1209 |
doh.is("The value entered is not valid.", dojo.trim(innerText(masterTT.domNode)), |
| 1210 |
"same message"); |
| 1211 |
}); |
| 1212 |
doh.robot.keyPress(dojo.keys.TAB, 0, { shift:true }); |
| 1213 |
return d; |
| 1214 |
} |
| 1215 |
} |
| 1216 |
]); |
| 1217 |
|
| 1218 |
doh.register("Ensure value formatting doesn't change entered values", [ |
| 1219 |
{ |
| 1220 |
name: "Ensure leading 0s don't cause a value change on blur", |
| 1221 |
timeout: 1000, |
| 1222 |
setUp: function(){ |
| 1223 |
var textWidget = dijit.byId("ticket17955"); |
| 1224 |
textWidget.set('maxLength', 8); |
| 1225 |
textWidget.set('constraints', {pattern: "000.#"}); |
| 1226 |
}, |
| 1227 |
runTest: function(){ |
| 1228 |
var textWidget = dijit.byId("ticket17955"); |
| 1229 |
textWidget.textbox.focus(); |
| 1230 |
textWidget.textbox.value = "02103.5"; |
| 1231 |
textWidget.textbox.blur(); |
| 1232 |
doh.is(2103.5, textWidget.get("value"), "textbox.get('value')"); |
| 1233 |
} |
| 1234 |
}, |
| 1235 |
{ |
| 1236 |
name: "Ensure extra digits do not cause a value change on blur", |
| 1237 |
timeout: 1000, |
| 1238 |
setUp: function(){ |
| 1239 |
var textWidget = dijit.byId("ticket17955"); |
| 1240 |
textWidget.set('maxLength', 8); |
| 1241 |
textWidget.set('constraints', {pattern: "000.#"}); |
| 1242 |
}, |
| 1243 |
runTest: function(){ |
| 1244 |
var textWidget = dijit.byId("ticket17955"); |
| 1245 |
textWidget.textbox.focus(); |
| 1246 |
textWidget.textbox.value = "5123123"; |
| 1247 |
textWidget.textbox.blur(); |
| 1248 |
doh.is(5123123, textWidget.get("value"), "textbox.get('value')"); |
| 1249 |
} |
| 1250 |
}, |
| 1251 |
{ |
| 1252 |
name: "Verify patterns without a decimal work as expected", |
| 1253 |
timeout: 1000, |
| 1254 |
setUp: function(){ |
| 1255 |
var textWidget = dijit.byId("ticket17955"); |
| 1256 |
textWidget.set('maxLength', null); |
| 1257 |
textWidget.set('constraints', {pattern: "#"}); |
| 1258 |
}, |
| 1259 |
runTest: function(){ |
| 1260 |
var textWidget = dijit.byId("ticket17955"); |
| 1261 |
textWidget.textbox.focus(); |
| 1262 |
textWidget.textbox.value = "80000"; |
| 1263 |
textWidget.textbox.blur(); |
| 1264 |
doh.is(80000, textWidget.get("value"), "textbox.get('value')"); |
| 1265 |
} |
| 1266 |
} |
| 1267 |
]); |
| 1268 |
|
| 1269 |
doh.register("Leading 0 parsing for NumberTextBox", [ |
| 1270 |
{ |
| 1271 |
name: "valid with 2 leading zeros", |
| 1272 |
timeout: 2000, |
| 1273 |
setUp: function(){ |
| 1274 |
var textbox = dijit.byId("ticket17923"); |
| 1275 |
textbox.set('value', ''); |
| 1276 |
textbox.set('constraints', dojo.mixin({}, textbox.get('constraints'), {min: 1})); |
| 1277 |
textbox.set('maxLength', 3); |
| 1278 |
// When this is run at the end of the tests in IE 9, the incomplete |
| 1279 |
// state is not properly triggered. Focus and blur to fix. |
| 1280 |
textbox.focusNode.focus(); |
| 1281 |
textbox.focusNode.blur(); |
| 1282 |
}, |
| 1283 |
runTest: function(){ |
| 1284 |
var d = new doh.Deferred(), |
| 1285 |
textbox = dijit.byId("ticket17923"); |
| 1286 |
textbox.focusNode.scrollIntoView(); |
| 1287 |
textbox.focusNode.focus(); |
| 1288 |
doh.robot.typeKeys('00', 500, 500); |
| 1289 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 1290 |
doh.is("Incomplete", textbox.get('state'), "textbox.get('state')"); |
| 1291 |
}), 500); |
| 1292 |
return d; |
| 1293 |
} |
| 1294 |
}, |
| 1295 |
{ |
| 1296 |
name: "invalid with 3 leading zeros", |
| 1297 |
timeout: 2000, |
| 1298 |
setUp: function(){ |
| 1299 |
var textbox = dijit.byId("ticket17923"); |
| 1300 |
textbox.set('value', ''); |
| 1301 |
textbox.set('constraints', dojo.mixin({}, textbox.get('constraints'), {min: 1})); |
| 1302 |
textbox.set('maxLength', 3); |
| 1303 |
}, |
| 1304 |
runTest: function(){ |
| 1305 |
var d = new doh.Deferred(), |
| 1306 |
textbox = dijit.byId("ticket17923"); |
| 1307 |
textbox.focusNode.scrollIntoView(); |
| 1308 |
textbox.focusNode.focus(); |
| 1309 |
doh.robot.typeKeys('000', 500, 500); |
| 1310 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 1311 |
doh.is("Error", textbox.get('state'), "textbox.get('state')"); |
| 1312 |
}), 500); |
| 1313 |
return d; |
| 1314 |
} |
| 1315 |
}, |
| 1316 |
{ |
| 1317 |
name: "invalid with 2 leading zeros", |
| 1318 |
timeout: 2000, |
| 1319 |
setUp: function(){ |
| 1320 |
var textbox = dijit.byId("ticket17923"); |
| 1321 |
textbox.set('value', ''); |
| 1322 |
textbox.set('constraints', dojo.mixin({}, textbox.get('constraints'), {min: 100})); |
| 1323 |
textbox.set('maxLength', 4); |
| 1324 |
}, |
| 1325 |
runTest: function(){ |
| 1326 |
var d = new doh.Deferred(), |
| 1327 |
textbox = dijit.byId("ticket17923"); |
| 1328 |
textbox.focusNode.scrollIntoView(); |
| 1329 |
textbox.focusNode.focus(); |
| 1330 |
doh.robot.typeKeys('00', 500, 500); |
| 1331 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 1332 |
doh.is("Error", textbox.get('state'), "textbox.get('state')"); |
| 1333 |
}), 500); |
| 1334 |
return d; |
| 1335 |
} |
| 1336 |
}, |
| 1337 |
{ |
| 1338 |
name: "valid with 5 leading zeros", |
| 1339 |
timeout: 2000, |
| 1340 |
setUp: function(){ |
| 1341 |
var textbox = dijit.byId("ticket17923"); |
| 1342 |
textbox.set('value', ''); |
| 1343 |
textbox.set('constraints', dojo.mixin({}, textbox.get('constraints'), {min: 10})); |
| 1344 |
textbox.set('maxLength', 7); |
| 1345 |
}, |
| 1346 |
runTest: function(){ |
| 1347 |
var d = new doh.Deferred(), |
| 1348 |
textbox = dijit.byId("ticket17923"); |
| 1349 |
textbox.focusNode.scrollIntoView(); |
| 1350 |
textbox.focusNode.focus(); |
| 1351 |
doh.robot.typeKeys('00000', 500, 500); |
| 1352 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 1353 |
doh.is("Incomplete", textbox.get('state'), "textbox.get('state')"); |
| 1354 |
}), 500); |
| 1355 |
return d; |
| 1356 |
} |
| 1357 |
}, |
| 1358 |
{ |
| 1359 |
name: "invalid with 0.1 leading zeros", |
| 1360 |
timeout: 2000, |
| 1361 |
setUp: function(){ |
| 1362 |
var textbox = dijit.byId("ticket17923"); |
| 1363 |
textbox.set('value', ''); |
| 1364 |
textbox.set('constraints', dojo.mixin({}, textbox.get('constraints'), {min: 10})); |
| 1365 |
textbox.set('maxLength', 7); |
| 1366 |
}, |
| 1367 |
runTest: function(){ |
| 1368 |
var d = new doh.Deferred(), |
| 1369 |
textbox = dijit.byId("ticket17923"); |
| 1370 |
textbox.focusNode.scrollIntoView(); |
| 1371 |
textbox.focusNode.focus(); |
| 1372 |
doh.robot.typeKeys('0.1', 500, 500); |
| 1373 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 1374 |
doh.is("Error", textbox.get('state'), "textbox.get('state')"); |
| 1375 |
}), 500); |
| 1376 |
return d; |
| 1377 |
} |
| 1378 |
}, |
| 1379 |
{ |
| 1380 |
name: "invalid with -9.01", |
| 1381 |
timeout: 2000, |
| 1382 |
setUp: function(){ |
| 1383 |
var textbox = dijit.byId("ticket17923"); |
| 1384 |
textbox.set('value', ''); |
| 1385 |
textbox.set('constraints', dojo.mixin({}, textbox.get('constraints'), {max: -9.02})); |
| 1386 |
textbox.set('maxLength', 7); |
| 1387 |
}, |
| 1388 |
runTest: function(){ |
| 1389 |
var d = new doh.Deferred(), |
| 1390 |
textbox = dijit.byId("ticket17923"); |
| 1391 |
textbox.focusNode.scrollIntoView(); |
| 1392 |
textbox.focusNode.focus(); |
| 1393 |
doh.robot.typeKeys('-9.01', 500, 500); |
| 1394 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 1395 |
doh.is("Error", textbox.get('state'), "textbox.get('state')"); |
| 1396 |
}), 500); |
| 1397 |
return d; |
| 1398 |
} |
| 1399 |
}, |
| 1400 |
{ |
| 1401 |
name: "valid with -9.021", |
| 1402 |
timeout: 2000, |
| 1403 |
setUp: function(){ |
| 1404 |
var textbox = dijit.byId("ticket17923"); |
| 1405 |
textbox.set('value', ''); |
| 1406 |
textbox.set('constraints', dojo.mixin({}, textbox.get('constraints'), {min: -9.03, max: -9.02})); |
| 1407 |
textbox.set('maxLength', 7); |
| 1408 |
}, |
| 1409 |
runTest: function(){ |
| 1410 |
var d = new doh.Deferred(), |
| 1411 |
textbox = dijit.byId("ticket17923"); |
| 1412 |
textbox.focusNode.scrollIntoView(); |
| 1413 |
textbox.focusNode.focus(); |
| 1414 |
doh.robot.typeKeys('-9.021', 500, 500); |
| 1415 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 1416 |
doh.is("", textbox.get('state'), "textbox.get('state')"); |
| 1417 |
}),500); |
| 1418 |
return d; |
| 1419 |
} |
| 1420 |
}, |
| 1421 |
{ |
| 1422 |
name: "checking each keypress for -9.01: 1 of 5", |
| 1423 |
timeout: 500, |
| 1424 |
setUp: function(){ |
| 1425 |
var textbox = dijit.byId("ticket17923"); |
| 1426 |
textbox.set('value', ''); |
| 1427 |
textbox.set('constraints', dojo.mixin({}, textbox.get('constraints'), {min: -9.03, max: -9.02})); |
| 1428 |
textbox.set('maxLength', 7); |
| 1429 |
}, |
| 1430 |
runTest: function(){ |
| 1431 |
var d = new doh.Deferred(), |
| 1432 |
textbox = dijit.byId("ticket17923"); |
| 1433 |
textbox.focusNode.scrollIntoView(); |
| 1434 |
textbox.focusNode.focus(); |
| 1435 |
doh.robot.typeKeys('-', 50, 100); |
| 1436 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 1437 |
doh.is("Incomplete", textbox.get('state'), "textbox.get('state')"); |
| 1438 |
})); |
| 1439 |
return d; |
| 1440 |
} |
| 1441 |
}, |
| 1442 |
{ |
| 1443 |
name: "checking each keypress for -9.01: 2 of 5", |
| 1444 |
timeout: 500, |
| 1445 |
runTest: function(){ |
| 1446 |
var d = new doh.Deferred(), |
| 1447 |
textbox = dijit.byId("ticket17923"); |
| 1448 |
textbox.focusNode.focus(); |
| 1449 |
doh.robot.typeKeys('9', 50, 100); |
| 1450 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 1451 |
doh.is("Incomplete", textbox.get('state'), "textbox.get('state')"); |
| 1452 |
})); |
| 1453 |
return d; |
| 1454 |
} |
| 1455 |
}, |
| 1456 |
{ |
| 1457 |
name: "checking each keypress for -9.01: 3 of 5", |
| 1458 |
timeout: 500, |
| 1459 |
runTest: function(){ |
| 1460 |
var d = new doh.Deferred(), |
| 1461 |
textbox = dijit.byId("ticket17923"); |
| 1462 |
textbox.focusNode.focus(); |
| 1463 |
doh.robot.typeKeys('.', 50, 100); |
| 1464 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 1465 |
doh.is("Incomplete", textbox.get('state'), "textbox.get('state')"); |
| 1466 |
})); |
| 1467 |
return d; |
| 1468 |
} |
| 1469 |
}, |
| 1470 |
{ |
| 1471 |
name: "checking each keypress for -9.01: 4 of 5", |
| 1472 |
timeout: 500, |
| 1473 |
runTest: function(){ |
| 1474 |
var d = new doh.Deferred(), |
| 1475 |
textbox = dijit.byId("ticket17923"); |
| 1476 |
textbox.focusNode.focus(); |
| 1477 |
doh.robot.typeKeys('0', 50, 100); |
| 1478 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 1479 |
doh.is("Incomplete", textbox.get('state'), "textbox.get('state')"); |
| 1480 |
})); |
| 1481 |
return d; |
| 1482 |
} |
| 1483 |
}, |
| 1484 |
{ |
| 1485 |
name: "checking each keypress for -9.01: 5 of 5", |
| 1486 |
timeout: 500, |
| 1487 |
runTest: function(){ |
| 1488 |
var d = new doh.Deferred(), |
| 1489 |
textbox = dijit.byId("ticket17923"); |
| 1490 |
textbox.focusNode.focus(); |
| 1491 |
doh.robot.typeKeys('1', 50, 100); |
| 1492 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 1493 |
doh.is("Error", textbox.get('state'), "textbox.get('state')"); |
| 1494 |
})); |
| 1495 |
return d; |
| 1496 |
} |
| 1497 |
}]); |
| 1498 |
|
| 1499 |
// This should be the last test since it destroys a ValidationTextBox |
| 1500 |
doh.register("tooltip hide on destroy", [ |
| 1501 |
{ |
| 1502 |
name: "focus", |
| 1503 |
timeout: 5000, |
| 1504 |
runTest: function(){ |
| 1505 |
var d = new doh.Deferred(); |
| 1506 |
textbox = dijit.byId("q03"); |
| 1507 |
textbox.focusNode.scrollIntoView(); |
| 1508 |
textbox.set("value", ""); |
| 1509 |
textbox.focus(); |
| 1510 |
setTimeout(d.getTestCallback(function(){ |
| 1511 |
// Tooltip should appear with information message |
| 1512 |
masterTT = dojo.global.dijit._masterTT; |
| 1513 |
doh.t(masterTT && isVisible(masterTT.domNode), "visible"); |
| 1514 |
}), 750); |
| 1515 |
return d; |
| 1516 |
} |
| 1517 |
}, |
| 1518 |
{ |
| 1519 |
name: "destroy", |
| 1520 |
timeout: 2000, |
| 1521 |
runTest: function(){ |
| 1522 |
var d = new doh.Deferred(); |
| 1523 |
textbox.destroy(); |
| 1524 |
setTimeout(d.getTestCallback(function(){ |
| 1525 |
// Tooltip should disappear when ValidationTextBox (or enclosing Dialog) destroyed |
| 1526 |
masterTT = dojo.global.dijit._masterTT; |
| 1527 |
doh.t(masterTT && isHidden(masterTT.domNode), "hidden"); |
| 1528 |
}), 300); |
| 1529 |
return d; |
| 1530 |
} |
| 1531 |
} |
| 1532 |
]); |
| 1533 |
|
| 1534 |
doh.register("Ensure rounding works with locale's whose decimal separator is not a period", [ |
| 1535 |
{ |
| 1536 |
name: "basic rounding test", |
| 1537 |
runTest: function(){ |
| 1538 |
// Expects the textbox to have a constraint of up to 1 decimal place, and the lang of 'de-de', |
| 1539 |
// which uses a comma instead of a period as the decimal separator. |
| 1540 |
var textbox = dijit.byId("ticket18260"); |
| 1541 |
textbox.set('value', 12.9); |
| 1542 |
doh.is(12.9, textbox.get('value'), 'textbox.value == 12.9'); |
| 1543 |
textbox.set('value', 12.99); |
| 1544 |
doh.is(13.0, textbox.get('value'), 'textbox.value == 13.0'); |
| 1545 |
} |
| 1546 |
} |
| 1547 |
]); |
| 1548 |
|
| 1549 |
doh.register("Ensure using both forms of the places constraint work as expected", [ |
| 1550 |
{ |
| 1551 |
name: "Fixed numeric places test, 2", |
| 1552 |
runTest: function(){ |
| 1553 |
var textbox = dijit.byId("ticket18367"); |
| 1554 |
textbox.set('constraints', {places:2}); |
| 1555 |
textbox.set('value', 12.991); |
| 1556 |
doh.is(12.99, textbox.get('value'), 'textbox.value == 12.99'); |
| 1557 |
} |
| 1558 |
}, |
| 1559 |
{ |
| 1560 |
name: "Range places test 0,4", |
| 1561 |
runTest: function(){ |
| 1562 |
var textbox = dijit.byId("ticket18367"); |
| 1563 |
textbox.set('constraints', {places: "0,4"}); |
| 1564 |
textbox.set('value', 12); |
| 1565 |
doh.is(12, textbox.get('value'), 'textbox.value == 12'); |
| 1566 |
textbox.set('value', 12.9); |
| 1567 |
doh.is(12.9, textbox.get('value'), 'textbox.value == 12.9'); |
| 1568 |
textbox.set('value', 12.99); |
| 1569 |
doh.is(12.99, textbox.get('value'), 'textbox.value == 12.99'); |
| 1570 |
textbox.set('value', 12.991); |
| 1571 |
doh.is(12.991, textbox.get('value'), 'textbox.value == 12.991'); |
| 1572 |
textbox.set('value', 12.9912); |
| 1573 |
doh.is(12.9912, textbox.get('value'), 'textbox.value == 12.9912'); |
| 1574 |
textbox.set('value', 12.99123); |
| 1575 |
doh.is(12.9912, textbox.get('value'), 'textbox.value == 12.9912'); |
| 1576 |
textbox.set('value', 12.1); |
| 1577 |
doh.is(12.1, textbox.get('value'), 'textbox.value == 12.1'); |
| 1578 |
} |
| 1579 |
} |
| 1580 |
]); |
| 1581 |
doh.run(); |
| 1582 |
}); |
| 1583 |
</script> |
| 1584 |
</head> |
| 1585 |
</html> |