| 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 Form Valid/Invalid State 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 |
// Some of these tests are duplicated in Form.html, maybe the Form.html watch(state) and validate() |
| 19 |
// tests groups should be moved here. |
| 20 |
|
| 21 |
dojo.ready(function(){ |
| 22 |
doh.robot.initRobot('../test_Form_state.html'); |
| 23 |
|
| 24 |
doh.register("FormValidationState", [ |
| 25 |
{ |
| 26 |
name: "formLoadInvalid", |
| 27 |
runTest: function(){ |
| 28 |
doh.t(dijit.byId("submitButton").get("disabled")); |
| 29 |
} |
| 30 |
}, |
| 31 |
{ |
| 32 |
name: "initialFormInvalid", |
| 33 |
timeout: 5000, |
| 34 |
runTest: function(){ |
| 35 |
var d = new doh.Deferred(); |
| 36 |
|
| 37 |
doh.robot.sequence(function(){ dojo.byId("notes").focus(); }); |
| 38 |
doh.robot.typeKeys("my notes", 1, 1200); |
| 39 |
|
| 40 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 41 |
doh.t(dijit.byId("submitButton").get("disabled")); |
| 42 |
}), 1000); |
| 43 |
|
| 44 |
return d; |
| 45 |
} |
| 46 |
}, |
| 47 |
{ |
| 48 |
name: "initialFormInvalid2", |
| 49 |
timeout: 10000, |
| 50 |
runTest: function(){ |
| 51 |
var d = new doh.Deferred(); |
| 52 |
|
| 53 |
doh.robot.sequence(function(){ dojo.byId("name").focus(); }); |
| 54 |
doh.robot.typeKeys("my name", 1, 1000); |
| 55 |
|
| 56 |
doh.robot.sequence(function(){ |
| 57 |
dojo.byId("birth").focus(); |
| 58 |
dijit.byId('birth').set('value', null); |
| 59 |
}, 500); |
| 60 |
doh.robot.typeKeys("1/1/2010", 1, 1200); |
| 61 |
|
| 62 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 63 |
doh.t(dijit.byId("submitButton").get("disabled")); |
| 64 |
}), 1000); |
| 65 |
|
| 66 |
return d; |
| 67 |
} |
| 68 |
}, |
| 69 |
{ |
| 70 |
name: "initialFormValid", |
| 71 |
timeout: 3000, |
| 72 |
runTest: function(){ |
| 73 |
var d = new doh.Deferred(); |
| 74 |
|
| 75 |
dojo.byId("reset").focus(); |
| 76 |
dojo.byId("reset").click(); |
| 77 |
|
| 78 |
setTimeout(d.getTestCallback(function(){ |
| 79 |
doh.f(dijit.byId("submitButton").get("disabled")); |
| 80 |
}), 1000); |
| 81 |
|
| 82 |
return d; |
| 83 |
} |
| 84 |
}, |
| 85 |
{ |
| 86 |
name: "initialFormValid2", |
| 87 |
timeout: 8000, |
| 88 |
runTest: function(){ |
| 89 |
var d = new doh.Deferred(); |
| 90 |
|
| 91 |
doh.robot.sequence(function(){ |
| 92 |
dojo.byId("birth").focus(); |
| 93 |
dijit.byId('birth').set('value', null); |
| 94 |
}); |
| 95 |
doh.robot.typeKeys("1/1/2010", 1, 1200); |
| 96 |
|
| 97 |
doh.robot.sequence(function(){ |
| 98 |
dojo.byId("disable").focus(); |
| 99 |
dojo.byId("disable").click(); |
| 100 |
}, 500); |
| 101 |
|
| 102 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 103 |
doh.f(dijit.byId("submitButton").get("disabled")); |
| 104 |
}), 1000); |
| 105 |
|
| 106 |
return d; |
| 107 |
} |
| 108 |
}, |
| 109 |
{ |
| 110 |
name: "initialFormInvalid3", |
| 111 |
timeout: 3000, |
| 112 |
runTest: function(){ |
| 113 |
var d = new doh.Deferred(); |
| 114 |
|
| 115 |
dojo.byId("enable").focus(); |
| 116 |
dojo.byId("enable").click(); |
| 117 |
|
| 118 |
setTimeout(d.getTestCallback(function(){ |
| 119 |
doh.t(dijit.byId("submitButton").get("disabled")); |
| 120 |
}), 1000); |
| 121 |
|
| 122 |
return d; |
| 123 |
} |
| 124 |
}, |
| 125 |
{ |
| 126 |
name: "moreFieldsInvalid", |
| 127 |
timeout: 5000, |
| 128 |
runTest: function(){ |
| 129 |
var d = new doh.Deferred(); |
| 130 |
|
| 131 |
dojo.byId("reset").focus(); |
| 132 |
dojo.byId("reset").click(); |
| 133 |
|
| 134 |
dojo.byId("addMoreFields").focus(); |
| 135 |
dijit.byId("addMoreFields").onClick(); |
| 136 |
|
| 137 |
setTimeout(d.getTestCallback(function(){ |
| 138 |
doh.t(dijit.byId("submitButton").get("disabled")); |
| 139 |
}), 1000); |
| 140 |
|
| 141 |
return d; |
| 142 |
} |
| 143 |
}, |
| 144 |
{ |
| 145 |
name: "moreFieldsValid", |
| 146 |
timeout: 5000, |
| 147 |
runTest: function(){ |
| 148 |
var d = new doh.Deferred(); |
| 149 |
|
| 150 |
doh.robot.sequence(function(){ dojo.byId("lastName").focus(); }); |
| 151 |
doh.robot.typeKeys("my last name", 1, 1800); |
| 152 |
|
| 153 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 154 |
doh.f(dijit.byId("submitButton").get("disabled")); |
| 155 |
}), 1000); |
| 156 |
|
| 157 |
return d; |
| 158 |
} |
| 159 |
}, |
| 160 |
{ |
| 161 |
name: "moreFieldsInvalid2", |
| 162 |
timeout: 8000, |
| 163 |
runTest: function(){ |
| 164 |
var d = new doh.Deferred(); |
| 165 |
|
| 166 |
doh.robot.sequence(function(){ |
| 167 |
dojo.byId("color").focus(); |
| 168 |
dijit.byId('color').set('value', null); |
| 169 |
}); |
| 170 |
doh.robot.keyPress(dojo.keys.TAB, 1, {}); |
| 171 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 172 |
doh.t(dijit.byId("submitButton").get("disabled")); |
| 173 |
}), 1000); |
| 174 |
|
| 175 |
return d; |
| 176 |
} |
| 177 |
} |
| 178 |
]); |
| 179 |
|
| 180 |
doh.run(); |
| 181 |
}); |
| 182 |
</script> |
| 183 |
</head> |
| 184 |
</html> |