| 1 |
<!DOCTYPE html> |
| 2 |
|
| 3 |
<html> |
| 4 |
<head> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 6 |
<title>doh.robot TextBox textDir Tests</title> |
| 7 |
|
| 8 |
<title>doh.robot Bidi Test</title> |
| 9 |
|
| 10 |
<style> |
| 11 |
@import "../../../../../util/doh/robot/robot.css"; |
| 12 |
</style> |
| 13 |
|
| 14 |
|
| 15 |
<script type="text/javascript" src="../../../../../dojo/dojo.js"> |
| 16 |
</script> |
| 17 |
|
| 18 |
<script type="text/javascript"> |
| 19 |
dojo.require("dijit.robotx"); |
| 20 |
|
| 21 |
dojo.ready(function(){ |
| 22 |
doh.robot.initRobot('../test_TextBoxes.html'); |
| 23 |
|
| 24 |
// execute some test as soon as the widget gets focus |
| 25 |
var focusThenRun = function(widget, fcn){ |
| 26 |
if(!widget.focused){ |
| 27 |
var handler = widget.connect(widget, '_onFocus', function(){ |
| 28 |
widget.disconnect(handler); |
| 29 |
setTimeout(fcn, 1); |
| 30 |
}); |
| 31 |
widget.focus(); |
| 32 |
}else{ |
| 33 |
fcn(); |
| 34 |
} |
| 35 |
}; |
| 36 |
var pos, range, textBox, modifier = dojo.isMac ? {meta: true} : {ctrl: true}; |
| 37 |
|
| 38 |
doh.register("LTR textBox", [ |
| 39 |
{ |
| 40 |
name: "initial text direction of empty 'ltrTextBox'", |
| 41 |
|
| 42 |
setUp: function(){ |
| 43 |
textBox = dijit.byId("ltrTextBox"); |
| 44 |
}, |
| 45 |
|
| 46 |
runTest: function(){ |
| 47 |
doh.is("ltr",textBox.focusNode.dir,"direction of :" + textBox.id); |
| 48 |
} |
| 49 |
}, |
| 50 |
{ |
| 51 |
name: "write in English in 'ltrTextBox'", |
| 52 |
timeout: 3000, |
| 53 |
|
| 54 |
runTest: function(){ |
| 55 |
var d = new doh.Deferred(); |
| 56 |
|
| 57 |
focusThenRun(textBox, function(){ |
| 58 |
doh.robot.typeKeys('Hello', 1, 300); |
| 59 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 60 |
doh.is("ltr",textBox.focusNode.dir, "direction of :" + textBox.id); |
| 61 |
}), 400); |
| 62 |
}); |
| 63 |
|
| 64 |
return d; |
| 65 |
} |
| 66 |
}, |
| 67 |
{ |
| 68 |
name: "paste Hebrew in 'ltrTextBox'", |
| 69 |
timeout: 5000, |
| 70 |
|
| 71 |
runTest: function(){ |
| 72 |
var d = new doh.Deferred(); |
| 73 |
|
| 74 |
focusThenRun(textBox, function(){ |
| 75 |
doh.robot.setClipboard("\u05e9\u05dc\u05d5\u05dd\u0021",'text/html'); |
| 76 |
doh.robot.keyPress("a", 400, modifier); |
| 77 |
doh.robot.keyPress("v", 300, modifier); |
| 78 |
// select text from the left side of the textbox |
| 79 |
doh.robot.mouseMoveAt(textBox.focusNode, 500, 1, 5, textBox.focusNode.offsetHeight >> 1); |
| 80 |
doh.robot.mousePress({left:true}, 500); |
| 81 |
doh.robot.mouseMoveAt(textBox.focusNode, 500, 1000, 20, textBox.focusNode.offsetHeight >> 1); |
| 82 |
doh.robot.mouseRelease({left:true}, 500); |
| 83 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 84 |
doh.is("ltr",textBox.focusNode.dir,"direction of :" + textBox.id); |
| 85 |
// verify text was selected from the left side of the textbox |
| 86 |
if(textBox.focusNode.selectionEnd){ |
| 87 |
doh.t(textBox.focusNode.selectionEnd > textBox.focusNode.selectionStart, "selected text " + textBox.focusNode.selectionStart + '. ' + textBox.focusNode.selectionEnd); |
| 88 |
}else{ |
| 89 |
range = dojo.global.window.document.selection.createRange(); |
| 90 |
pos = range.getBoundingClientRect(); |
| 91 |
doh.t(pos.right > pos.left, "selected text " + pos.left + '. ' + pos.right); |
| 92 |
} |
| 93 |
}), 400); |
| 94 |
}); |
| 95 |
|
| 96 |
return d; |
| 97 |
} |
| 98 |
} |
| 99 |
]); |
| 100 |
|
| 101 |
doh.register("RTL textBox", [ |
| 102 |
{ |
| 103 |
name: "initial text direction of empty 'rtlTextBox'", |
| 104 |
|
| 105 |
setUp: function(){ |
| 106 |
textBox = dijit.byId("rtlTextBox"); |
| 107 |
textBox.domNode.scrollIntoView(); |
| 108 |
}, |
| 109 |
|
| 110 |
runTest: function(){ |
| 111 |
doh.is("rtl",textBox.focusNode.dir,"direction of :" + textBox.id); |
| 112 |
} |
| 113 |
}, |
| 114 |
{ |
| 115 |
name: "write in English in 'rtlTextBox'", |
| 116 |
timeout: 5000, |
| 117 |
|
| 118 |
runTest: function(){ |
| 119 |
var d = new doh.Deferred(); |
| 120 |
|
| 121 |
focusThenRun(textBox, function(){ |
| 122 |
doh.robot.typeKeys('Hello', 1, 300); |
| 123 |
// select text from the right side of the textbox |
| 124 |
doh.robot.mouseMoveAt(textBox.focusNode, 50, 100, textBox.focusNode.offsetWidth-5, textBox.focusNode.offsetHeight >> 1); |
| 125 |
doh.robot.mousePress({left:true}, 500); |
| 126 |
doh.robot.mouseMoveAt(textBox.focusNode, 50, 1000, textBox.focusNode.offsetWidth-20, textBox.focusNode.offsetHeight >> 1); |
| 127 |
doh.robot.mouseRelease({left:true}, 500); |
| 128 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 129 |
doh.is("rtl",textBox.focusNode.dir,"direction of :" + textBox.id); |
| 130 |
// verify text was selected from the right side of the textbox |
| 131 |
if(textBox.focusNode.selectionEnd){ |
| 132 |
doh.t(textBox.focusNode.selectionEnd > textBox.focusNode.selectionStart, "selected text " + textBox.focusNode.selectionStart + '. ' + textBox.focusNode.selectionEnd); |
| 133 |
}else{ |
| 134 |
range = dojo.global.window.document.selection.createRange(); |
| 135 |
pos = range.getBoundingClientRect(); |
| 136 |
doh.t(pos.right > pos.left, "selected text " + pos.left + '. ' + pos.right); |
| 137 |
} |
| 138 |
}), 400); |
| 139 |
}); |
| 140 |
|
| 141 |
return d; |
| 142 |
} |
| 143 |
}, |
| 144 |
{ |
| 145 |
name: "paste Hebrew in 'rtlTextBox'", |
| 146 |
timeout: 4000, |
| 147 |
|
| 148 |
runTest: function(){ |
| 149 |
var d = new doh.Deferred(); |
| 150 |
|
| 151 |
focusThenRun(textBox, function(){ |
| 152 |
doh.robot.setClipboard("\u05e9\u05dc\u05d5\u05dd\u0021",'text/html'); |
| 153 |
|
| 154 |
doh.robot.keyPress("a", 400, modifier); |
| 155 |
doh.robot.keyPress("v", 300, modifier); |
| 156 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 157 |
doh.is("rtl",textBox.focusNode.dir,"direction of :" + textBox.id); |
| 158 |
}), 400); |
| 159 |
}); |
| 160 |
|
| 161 |
return d; |
| 162 |
} |
| 163 |
} |
| 164 |
]); |
| 165 |
|
| 166 |
doh.register("Contextual textBox", [ |
| 167 |
{ |
| 168 |
name: "initial text direction of empty 'contextualTextBox'", |
| 169 |
|
| 170 |
setUp: function(){ |
| 171 |
textBox = dijit.byId("contextualTextBox"); |
| 172 |
textBox.domNode.scrollIntoView(); |
| 173 |
}, |
| 174 |
|
| 175 |
runTest: function(){ |
| 176 |
doh.is("auto",textBox.textDir,"textDir of :" + textBox.id); |
| 177 |
} |
| 178 |
}, |
| 179 |
{ |
| 180 |
name: "write in English in 'contextualTextBox'", |
| 181 |
timeout: 5000, |
| 182 |
|
| 183 |
runTest: function(){ |
| 184 |
var d = new doh.Deferred(); |
| 185 |
|
| 186 |
focusThenRun(textBox, function(){ |
| 187 |
doh.robot.setClipboard("Hello",'text/html'); |
| 188 |
|
| 189 |
doh.robot.keyPress("v", 600, modifier); |
| 190 |
// select text from the left side of the textbox |
| 191 |
doh.robot.mouseMoveAt(textBox.focusNode, 50, 100, 5, textBox.focusNode.offsetHeight >> 1); |
| 192 |
doh.robot.mousePress({left:true}, 500); |
| 193 |
doh.robot.mouseMoveAt(textBox.focusNode, 50, 1000, 20, textBox.focusNode.offsetHeight >> 1); |
| 194 |
doh.robot.mouseRelease({left:true}, 500); |
| 195 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 196 |
doh.is("ltr",textBox.focusNode.dir,"direction of :" + textBox.id); |
| 197 |
// verify text was selected from the left side of the textbox |
| 198 |
if(textBox.focusNode.selectionEnd){ |
| 199 |
doh.t(textBox.focusNode.selectionEnd > textBox.focusNode.selectionStart, "selected text " + textBox.focusNode.selectionStart + '. ' + textBox.focusNode.selectionEnd); |
| 200 |
}else{ |
| 201 |
range = dojo.global.window.document.selection.createRange(); |
| 202 |
pos = range.getBoundingClientRect(); |
| 203 |
doh.t(pos.right > pos.left, "selected text " + pos.left + '. ' + pos.right); |
| 204 |
} |
| 205 |
}), 300); |
| 206 |
}); |
| 207 |
|
| 208 |
return d; |
| 209 |
} |
| 210 |
}, |
| 211 |
{ |
| 212 |
name: "text direction paste Hebrew before English", |
| 213 |
timeout: 5000, |
| 214 |
|
| 215 |
runTest: function(){ |
| 216 |
var d = new doh.Deferred(); |
| 217 |
|
| 218 |
focusThenRun(textBox, function(){ |
| 219 |
doh.robot.setClipboard("\u05d0\u05e0\u05d9\u0020\u05d0\u05d5\u05de\u05e8\u05ea\u003a\u0020",'text/html'); |
| 220 |
|
| 221 |
dojo.isMac ? doh.robot.keyPress("a", 100, {ctrl:true}): doh.robot.keyPress(dojo.keys.HOME, 100, {}); |
| 222 |
|
| 223 |
doh.robot.keyPress("v", 400, modifier); |
| 224 |
// select text from the right side of the textbox |
| 225 |
doh.robot.mouseMoveAt(textBox.focusNode, 50, 100, textBox.focusNode.offsetWidth-5, textBox.focusNode.offsetHeight >> 1); |
| 226 |
doh.robot.mousePress({left:true}, 500); |
| 227 |
doh.robot.mouseMoveAt(textBox.focusNode, 50, 1000, textBox.focusNode.offsetWidth-20, textBox.focusNode.offsetHeight >> 1); |
| 228 |
doh.robot.mouseRelease({left:true}, 500); |
| 229 |
doh.robot.sequence(d.getTestCallback(function(){ |
| 230 |
doh.is("rtl",textBox.focusNode.dir,"direction of :" + textBox.id); |
| 231 |
// verify text was selected from the right side of the textbox |
| 232 |
if(textBox.focusNode.selectionEnd){ |
| 233 |
doh.t(textBox.focusNode.selectionEnd > textBox.focusNode.selectionStart, "selected text " + textBox.focusNode.selectionStart + '. ' + textBox.focusNode.selectionEnd); |
| 234 |
}else{ |
| 235 |
range = dojo.global.window.document.selection.createRange(); |
| 236 |
pos = range.getBoundingClientRect(); |
| 237 |
doh.t(pos.right > pos.left, "selected text " + pos.left + '. ' + pos.right); |
| 238 |
} |
| 239 |
}), 400); |
| 240 |
}); |
| 241 |
|
| 242 |
return d; |
| 243 |
} |
| 244 |
} |
| 245 |
]); |
| 246 |
|
| 247 |
doh.register("test the programmatic textBox in the tab container", [ |
| 248 |
{ |
| 249 |
name: "initial direction of the textBoxs", |
| 250 |
|
| 251 |
setUp: function(){ |
| 252 |
textBox1 = dijit.byId("programmatic1"); |
| 253 |
textBox2 = dijit.byId("programmatic2"); |
| 254 |
textBox3 = dijit.byId("programmatic3"); |
| 255 |
}, |
| 256 |
|
| 257 |
runTest: function(){ |
| 258 |
doh.is("ltr",textBox1.focusNode.dir,"Initial direction of - 'programmatic'"); |
| 259 |
doh.is("rtl",textBox2.focusNode.dir,"Initial direction of - 'programmatic'"); |
| 260 |
doh.is("ltr",textBox3.focusNode.dir,"Initial direction of - 'programmatic'"); |
| 261 |
} |
| 262 |
}, |
| 263 |
{ |
| 264 |
name: "direction of textBoxs after change value button in second tab is pressed", |
| 265 |
|
| 266 |
runTest: function(){ |
| 267 |
var button = dojo.byId("changeValue"); |
| 268 |
|
| 269 |
button.click(); |
| 270 |
|
| 271 |
doh.is("ltr",textBox1.focusNode.dir,"Initial direction of - 'programmatic'"); |
| 272 |
doh.is("rtl",textBox2.focusNode.dir,"Initial direction of - 'programmatic'"); |
| 273 |
doh.is("rtl",textBox3.focusNode.dir,"Initial direction of - 'programmatic'"); |
| 274 |
} |
| 275 |
} |
| 276 |
]); |
| 277 |
|
| 278 |
doh.run(); |
| 279 |
}); |
| 280 |
</script> |
| 281 |
</head> |
| 282 |
</html> |