| 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>robot Tooltip 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" |
| 13 |
data-dojo-config="isDebug: true"></script> |
| 14 |
|
| 15 |
<script type="text/javascript"> |
| 16 |
require([ |
| 17 |
"doh/runner", "dojo/robotx", |
| 18 |
"dojo/dom", "dojo/dom-geometry", "dojo/_base/lang", "dojo/query", "dojo/window", |
| 19 |
"dijit/tests/helpers", "dojo/domReady!" |
| 20 |
], function(doh, robot, dom, domGeom, lang, query, winUtils, helpers){ |
| 21 |
robot.initRobot('../test_Tooltip.html'); |
| 22 |
|
| 23 |
// Pointer to master tooltip. This gets set in the first test when the |
| 24 |
// first tooltip is shown |
| 25 |
var masterTT; |
| 26 |
|
| 27 |
doh.register(function setup(){ |
| 28 |
// get pointer to registry in the iframe |
| 29 |
registry = robot.window.require("dijit/registry"); |
| 30 |
dfocus = robot.window.require("dijit/focus"); |
| 31 |
Tooltip = robot.window.require("dijit/Tooltip"); |
| 32 |
}); |
| 33 |
|
| 34 |
doh.register("dijit.Tooltip mouse tests", [ |
| 35 |
{ |
| 36 |
name: "show on mouse over", |
| 37 |
timeout: 4000, |
| 38 |
runTest: function(){ |
| 39 |
var d = new doh.Deferred(), |
| 40 |
around = dom.byId("four"); |
| 41 |
|
| 42 |
robot.mouseMoveAt("four", 500); |
| 43 |
|
| 44 |
robot.sequence(d.getTestCallback(function(){ |
| 45 |
// At this point the master tooltip should have been created, so save in |
| 46 |
// global variable |
| 47 |
masterTT = Tooltip._masterTT; |
| 48 |
|
| 49 |
doh.t(masterTT && helpers.isVisible(masterTT.domNode), "tooltip shown"); |
| 50 |
}), 2000); |
| 51 |
|
| 52 |
return d; |
| 53 |
} |
| 54 |
}, |
| 55 |
|
| 56 |
{ |
| 57 |
name: "hide on unhover", |
| 58 |
timeout: 4000, |
| 59 |
runTest: function(){ |
| 60 |
var d = new doh.Deferred(); |
| 61 |
|
| 62 |
// Move off of the "button w/tooltip" to node which doesn't have a tooltip |
| 63 |
robot.mouseMoveAt(query("h1")[0], 500); |
| 64 |
|
| 65 |
robot.sequence(d.getTestCallback(function(){ |
| 66 |
doh.t(masterTT && helpers.isHidden(masterTT.domNode), "tooltip hidden"); |
| 67 |
}), 2000); |
| 68 |
|
| 69 |
return d; |
| 70 |
} |
| 71 |
}, |
| 72 |
|
| 73 |
{ |
| 74 |
name: "click to focus, then mouse away", |
| 75 |
timeout: 10000, |
| 76 |
runTest: function(){ |
| 77 |
var d = new doh.Deferred(); |
| 78 |
|
| 79 |
robot.mouseMoveAt("id1", 500); |
| 80 |
robot.mouseClick({left: true}, 500); |
| 81 |
|
| 82 |
robot.sequence(d.getTestErrback(function(){ |
| 83 |
doh.t(masterTT && helpers.isVisible(masterTT.domNode), "tooltip shown"); |
| 84 |
doh.is("id1", dfocus.curNode && dfocus.curNode.id, "node is focused"); |
| 85 |
}), 2000); |
| 86 |
|
| 87 |
// Move off of the focused node to node which doesn't have a tooltip |
| 88 |
robot.mouseMoveAt(query("h1")[0], 500); |
| 89 |
|
| 90 |
robot.sequence(d.getTestCallback(function(){ |
| 91 |
doh.t(masterTT && helpers.isHidden(masterTT.domNode), "tooltip hidden"); |
| 92 |
}), 2000); |
| 93 |
|
| 94 |
return d; |
| 95 |
} |
| 96 |
} |
| 97 |
]); |
| 98 |
|
| 99 |
doh.register("Tooltip on Menu", [ |
| 100 |
{ |
| 101 |
name: "show tooltip on MenuItem", |
| 102 |
timeout: 10000, |
| 103 |
runTest: function(){ |
| 104 |
var d = new doh.Deferred(); |
| 105 |
|
| 106 |
// Click the DropDownButton to open the Menu |
| 107 |
robot.mouseMoveAt("ddb", 500); |
| 108 |
robot.mouseClick({left: true}, 500); |
| 109 |
|
| 110 |
// Move over the MenuItem to show the tooltip |
| 111 |
robot.mouseMoveAt("copy", 2000); |
| 112 |
robot.sequence(d.getTestCallback(function(){ |
| 113 |
doh.t(masterTT && helpers.isVisible(masterTT.domNode), "tooltip shown"); |
| 114 |
doh.is("tooltip for copy", lang.trim(helpers.innerText(masterTT.domNode)), "tooltip text"); |
| 115 |
}), 750); |
| 116 |
|
| 117 |
return d; |
| 118 |
} |
| 119 |
}, |
| 120 |
|
| 121 |
{ |
| 122 |
name: "hide Tooltip on Menu close", |
| 123 |
timeout: 4000, |
| 124 |
runTest: function(){ |
| 125 |
var d = new doh.Deferred(); |
| 126 |
|
| 127 |
// Click the MenuItem to close the menu |
| 128 |
robot.mouseClick({left: true}, 500); |
| 129 |
|
| 130 |
robot.sequence(d.getTestCallback(function(){ |
| 131 |
doh.t(helpers.isHidden(registry.byId("ddm").domNode), "menu hidden"); |
| 132 |
doh.t(masterTT && helpers.isHidden(masterTT.domNode), "tooltip hidden"); |
| 133 |
}), 500); |
| 134 |
|
| 135 |
return d; |
| 136 |
} |
| 137 |
} |
| 138 |
]); |
| 139 |
|
| 140 |
doh.register("Tooltip in TitlePane", [ |
| 141 |
{ |
| 142 |
name: "show tooltip on span in TitlePane", |
| 143 |
timeout: 4000, |
| 144 |
runTest: function(){ |
| 145 |
var d = new doh.Deferred(); |
| 146 |
|
| 147 |
robot.mouseMoveAt("tpTooltipTarget", 500); |
| 148 |
|
| 149 |
robot.sequence(d.getTestCallback(function(){ |
| 150 |
doh.t(masterTT && helpers.isVisible(masterTT.domNode), "tooltip shown"); |
| 151 |
doh.is("tooltip on TitlePane span", lang.trim(helpers.innerText(masterTT.domNode)), "tooltip text"); |
| 152 |
}), 500); |
| 153 |
|
| 154 |
return d; |
| 155 |
} |
| 156 |
} |
| 157 |
]); |
| 158 |
|
| 159 |
doh.register("Mouse over nested div", [ |
| 160 |
{ |
| 161 |
name: "mouse over nested div", |
| 162 |
timeout: 4000, |
| 163 |
runTest: function(){ |
| 164 |
var d = new doh.Deferred(); |
| 165 |
|
| 166 |
// Start with mouse to the left of the nested divs |
| 167 |
robot.mouseMoveAt("nested", 500, 0, -50, 0); |
| 168 |
|
| 169 |
// Then move to inner div. The onmouseenter event will occur with evt.target == inner div |
| 170 |
robot.mouseMoveAt("nested", 500, 0); |
| 171 |
|
| 172 |
robot.sequence(d.getTestCallback(function(){ |
| 173 |
doh.t(masterTT && helpers.isVisible(masterTT.domNode), "tooltip shown"); |
| 174 |
|
| 175 |
var tooltipPos = domGeom.position(masterTT.domNode), |
| 176 |
anchorPos = domGeom.position("nested"); |
| 177 |
doh.t(tooltipPos.x >= anchorPos.x + anchorPos.w, |
| 178 |
"tooltip pos " + tooltipPos.x + " > anchor right edge at " + |
| 179 |
anchorPos.x + " + " + anchorPos.w); |
| 180 |
}), 500); |
| 181 |
|
| 182 |
return d; |
| 183 |
} |
| 184 |
} |
| 185 |
]); |
| 186 |
|
| 187 |
doh.register("Delegation", [ |
| 188 |
function scrollIntoView(){ |
| 189 |
// Scroll the whole table into view to make tooltip position tests work correctly |
| 190 |
winUtils.scrollIntoView("myTable"); |
| 191 |
}, |
| 192 |
{ |
| 193 |
name: "mouse over row 1", |
| 194 |
timeout: 4000, |
| 195 |
runTest: function(){ |
| 196 |
var d = new doh.Deferred(); |
| 197 |
|
| 198 |
robot.mouseMoveAt("myTable-row1", 500, 0); |
| 199 |
|
| 200 |
robot.sequence(d.getTestCallback(function(){ |
| 201 |
doh.t(masterTT && helpers.isVisible(masterTT.domNode), "tooltip shown"); |
| 202 |
doh.is("Tooltip for row 1", lang.trim(helpers.innerText(masterTT.domNode)), "tooltip text"); |
| 203 |
|
| 204 |
var tooltipPos = domGeom.position(masterTT.domNode), |
| 205 |
anchorPos = domGeom.position("myTable-row1"); |
| 206 |
doh.t(tooltipPos.y + tooltipPos.h/2 >= anchorPos.y, |
| 207 |
"tooltip pos " + tooltipPos.y + " height " + tooltipPos.h + |
| 208 |
"anchor " + anchorPos.y + " + height " + anchorPos.h); |
| 209 |
doh.t(tooltipPos.y + tooltipPos.h/2 <= anchorPos.y + anchorPos.h, |
| 210 |
"tooltip pos " + tooltipPos.y + " height " + tooltipPos.h + |
| 211 |
"anchor " + anchorPos.y + " + height " + anchorPos.h); |
| 212 |
}), 800); |
| 213 |
|
| 214 |
return d; |
| 215 |
} |
| 216 |
}, |
| 217 |
{ |
| 218 |
name: "mouse over row 3", |
| 219 |
timeout: 4000, |
| 220 |
runTest: function(){ |
| 221 |
var d = new doh.Deferred(); |
| 222 |
|
| 223 |
robot.mouseMoveAt("myTable-row3", 500, 0); |
| 224 |
|
| 225 |
robot.sequence(d.getTestCallback(function(){ |
| 226 |
doh.t(masterTT && helpers.isVisible(masterTT.domNode), "tooltip shown"); |
| 227 |
doh.is("Tooltip for row 3", lang.trim(helpers.innerText(masterTT.domNode)), "tooltip text"); |
| 228 |
|
| 229 |
var tooltipPos = domGeom.position(masterTT.domNode), |
| 230 |
anchorPos = domGeom.position("myTable-row3"); |
| 231 |
doh.t(tooltipPos.y + tooltipPos.h/2 >= anchorPos.y, |
| 232 |
"tooltip pos " + tooltipPos.y + " height " + tooltipPos.h + |
| 233 |
"anchor " + anchorPos.y + " + height " + anchorPos.h); |
| 234 |
doh.t(tooltipPos.y + tooltipPos.h/2 <= anchorPos.y + anchorPos.h, |
| 235 |
"tooltip pos " + tooltipPos.y + " height " + tooltipPos.h + |
| 236 |
"anchor " + anchorPos.y + " + height " + anchorPos.h); |
| 237 |
}), 500); |
| 238 |
|
| 239 |
return d; |
| 240 |
} |
| 241 |
}, |
| 242 |
{ |
| 243 |
name: "mouse over row 4", |
| 244 |
timeout: 4000, |
| 245 |
runTest: function(){ |
| 246 |
var d = new doh.Deferred(); |
| 247 |
|
| 248 |
robot.mouseMoveAt("myTable-row4", 500, 0); |
| 249 |
|
| 250 |
robot.sequence(d.getTestCallback(function(){ |
| 251 |
// should be no tooltip for rows >= 4 |
| 252 |
doh.t(masterTT && helpers.isHidden(masterTT.domNode), "tooltip hidden"); |
| 253 |
}), 500); |
| 254 |
|
| 255 |
return d; |
| 256 |
} |
| 257 |
}, |
| 258 |
{ |
| 259 |
name: "mouse over row 2", |
| 260 |
timeout: 4000, |
| 261 |
runTest: function(){ |
| 262 |
var d = new doh.Deferred(); |
| 263 |
|
| 264 |
robot.mouseMoveAt("myTable-row2", 500, 0); |
| 265 |
|
| 266 |
robot.sequence(d.getTestCallback(function(){ |
| 267 |
doh.t(masterTT && helpers.isVisible(masterTT.domNode), "tooltip shown"); |
| 268 |
doh.is("Tooltip for row 2", lang.trim(helpers.innerText(masterTT.domNode)), "tooltip text"); |
| 269 |
|
| 270 |
var tooltipPos = domGeom.position(masterTT.domNode), |
| 271 |
anchorPos = domGeom.position("myTable-row2"); |
| 272 |
doh.t(tooltipPos.y + tooltipPos.h/2 >= anchorPos.y, |
| 273 |
"tooltip pos " + tooltipPos.y + " height " + tooltipPos.h + |
| 274 |
"anchor " + anchorPos.y + " + height " + anchorPos.h); |
| 275 |
doh.t(tooltipPos.y + tooltipPos.h/2 <= anchorPos.y + anchorPos.h, |
| 276 |
"tooltip pos " + tooltipPos.y + " height " + tooltipPos.h + |
| 277 |
"anchor " + anchorPos.y + " + height " + anchorPos.h); |
| 278 |
}), 500); |
| 279 |
|
| 280 |
return d; |
| 281 |
} |
| 282 |
} |
| 283 |
]); |
| 284 |
|
| 285 |
doh.register("hideDelay", [ |
| 286 |
{ |
| 287 |
name: "mouse over button", |
| 288 |
timeout: 4000, |
| 289 |
runTest: function(){ |
| 290 |
var d = new doh.Deferred(); |
| 291 |
|
| 292 |
robot.mouseMoveAt("four", 500); |
| 293 |
|
| 294 |
robot.sequence(d.getTestCallback(function(){ |
| 295 |
doh.t(masterTT && helpers.isVisible(masterTT.domNode), "tooltip shown"); |
| 296 |
}), 2000); |
| 297 |
|
| 298 |
return d; |
| 299 |
} |
| 300 |
}, |
| 301 |
|
| 302 |
{ |
| 303 |
name: "mouse over tooltip", |
| 304 |
timeout: 4000, |
| 305 |
runTest: function(){ |
| 306 |
var d = new doh.Deferred(); |
| 307 |
|
| 308 |
robot.mouseMoveAt(masterTT.domNode, 500); |
| 309 |
|
| 310 |
robot.sequence(d.getTestCallback(function(){ |
| 311 |
doh.t(masterTT && helpers.isVisible(masterTT.domNode), "tooltip still shown"); |
| 312 |
}), 2000); |
| 313 |
|
| 314 |
return d; |
| 315 |
} |
| 316 |
}, |
| 317 |
|
| 318 |
{ |
| 319 |
name: "mouse over button again", |
| 320 |
timeout: 4000, |
| 321 |
runTest: function(){ |
| 322 |
var d = new doh.Deferred(); |
| 323 |
|
| 324 |
robot.mouseMoveAt("four", 500); |
| 325 |
|
| 326 |
robot.sequence(d.getTestCallback(function(){ |
| 327 |
doh.t(masterTT && helpers.isVisible(masterTT.domNode), "tooltip still shown"); |
| 328 |
}), 2000); |
| 329 |
|
| 330 |
return d; |
| 331 |
} |
| 332 |
}, |
| 333 |
|
| 334 |
|
| 335 |
{ |
| 336 |
name: "mouse away", |
| 337 |
timeout: 10000, |
| 338 |
runTest: function(){ |
| 339 |
var d = new doh.Deferred(); |
| 340 |
|
| 341 |
// move to node that doesn't have a tooltip |
| 342 |
robot.mouseMoveAt(query("h1")[0], 500); |
| 343 |
|
| 344 |
robot.sequence(d.getTestCallback(function(){ |
| 345 |
doh.t(masterTT && helpers.isHidden(masterTT.domNode), "tooltip hidden"); |
| 346 |
}), 2000); |
| 347 |
|
| 348 |
return d; |
| 349 |
} |
| 350 |
} |
| 351 |
]); |
| 352 |
|
| 353 |
doh.run(); |
| 354 |
}); |
| 355 |
</script> |
| 356 |
</head> |
| 357 |
</html> |