| 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 TabContainer 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/on", "dojo/query", |
| 19 |
"dijit/tests/helpers", "dojo/domReady!" |
| 20 |
], function(doh, robot, dom, geom, on, query, helpers){ |
| 21 |
|
| 22 |
robot.initRobot('../test_TabContainer.html'); |
| 23 |
|
| 24 |
var registry, focus; |
| 25 |
|
| 26 |
doh.register("setup", [ |
| 27 |
function setup(){ |
| 28 |
// get pointers to singletons loaded on test page |
| 29 |
registry = robot.window.require("dijit/registry"); |
| 30 |
doh.t(!!registry, "got registry"); |
| 31 |
} |
| 32 |
]); |
| 33 |
|
| 34 |
doh.register("general", [ |
| 35 |
{ |
| 36 |
name: "tab hover state", |
| 37 |
timeout: 5000, |
| 38 |
runTest: function(t){ |
| 39 |
var d = new doh.Deferred(); |
| 40 |
|
| 41 |
// workaround DOH robot bug where iframe overlay not removed |
| 42 |
robot.mouseClick({left: true}, 500); |
| 43 |
|
| 44 |
robot.mouseMoveAt('mainTabContainer_tablist_tab3', 500); |
| 45 |
|
| 46 |
on.once(dom.byId('mainTabContainer_tablist_tab3'), "mouseover", function(){ |
| 47 |
setTimeout(d.getTestCallback(function(){ |
| 48 |
// Check that .dijitTabHover class was applied |
| 49 |
var tabHover = query(".dijitTabHover #mainTabContainer_tablist_tab3"); |
| 50 |
doh.is(1, tabHover.length); |
| 51 |
}), 0); |
| 52 |
}); |
| 53 |
|
| 54 |
return d; |
| 55 |
} |
| 56 |
}, |
| 57 |
{ |
| 58 |
name: "click on a tab", |
| 59 |
timeout: 10000, |
| 60 |
runTest: function(t){ |
| 61 |
var d = new doh.Deferred(); |
| 62 |
|
| 63 |
robot.mouseMoveAt('mainTabContainer_tablist_tab3', 500); |
| 64 |
robot.mouseClick({left: true}, 500); |
| 65 |
|
| 66 |
var tc = registry.byId("mainTabContainer"); |
| 67 |
|
| 68 |
helpers.onFocus(d.getTestCallback(function(curNode){ |
| 69 |
// verify tab button is selected |
| 70 |
doh.is('mainTabContainer_tablist_tab3', curNode.id, "verify chosen tab is in its chosen state and focused"); |
| 71 |
|
| 72 |
// verify pane is shown |
| 73 |
doh.is("tab3", tc.selectedChildWidget.id, "verify that the appropriate contentpane is displayed"); |
| 74 |
doh.t(helpers.isVisible(registry.byId("tab3")), "tab3 shown"); |
| 75 |
doh.t(helpers.isHidden(registry.byId("tab2")), "tab2 hidden"); |
| 76 |
}), 500); |
| 77 |
|
| 78 |
return d; |
| 79 |
} |
| 80 |
}, |
| 81 |
{ |
| 82 |
name: "scrolling", |
| 83 |
timeout: 10000, |
| 84 |
runTest: function(t){ |
| 85 |
var d = new doh.Deferred(); |
| 86 |
|
| 87 |
// save original position of one of the tab labels |
| 88 |
var pos0 = geom.position("mainTabContainer_tablist_tab2").x, |
| 89 |
pos1, |
| 90 |
pos2; |
| 91 |
|
| 92 |
// Initially scrolled all the way to the left, so left scroll button |
| 93 |
// should be disabled |
| 94 |
doh.t(registry.byId("mainTabContainer_tablist_leftBtn").get("disabled"), "left scroll button disabled"); |
| 95 |
doh.f(registry.byId("mainTabContainer_tablist_rightBtn").get("disabled"), "right scroll button enabled"); |
| 96 |
|
| 97 |
// Scroll to the right |
| 98 |
robot.mouseMoveAt('mainTabContainer_tablist_rightBtn', 500); |
| 99 |
robot.mouseClick({left: true}, 500); |
| 100 |
robot.sequence(d.getTestErrback(function(){ |
| 101 |
pos1 = geom.position("mainTabContainer_tablist_tab2").x; |
| 102 |
doh.t(pos1 < pos0, "scrolled to the right: " + pos1 + " < " + pos0); |
| 103 |
doh.f(registry.byId("mainTabContainer_tablist_leftBtn").get("disabled"), "left scroll button enabled"); |
| 104 |
}), 500); |
| 105 |
|
| 106 |
// And then scroll back to the left |
| 107 |
robot.mouseMoveAt('mainTabContainer_tablist_leftBtn', 500); |
| 108 |
robot.mouseClick({left: true}, 500); |
| 109 |
robot.sequence(d.getTestCallback(function(){ |
| 110 |
pos2 = geom.position("mainTabContainer_tablist_tab2").x; |
| 111 |
doh.t(pos2 > pos1, "scrolled to the left: " + pos2 + " > " + pos1); |
| 112 |
}), 500); |
| 113 |
|
| 114 |
return d; |
| 115 |
} |
| 116 |
}, |
| 117 |
{ |
| 118 |
name: "close button hover state", |
| 119 |
timeout: 10000, |
| 120 |
runTest: function(t){ |
| 121 |
var d = new doh.Deferred(); |
| 122 |
|
| 123 |
robot.mouseMoveAt(query('.dijitTabCloseButton', registry.byId("mainTabContainer_tablist_tab3").domNode)[0], 500); |
| 124 |
|
| 125 |
// verify the close button is in its hover state |
| 126 |
robot.sequence(d.getTestCallback(function(){ |
| 127 |
var closeHover = query(".dijitTabCloseButtonHover", registry.byId("mainTabContainer_tablist_tab3").domNode); |
| 128 |
doh.is(1, closeHover.length, "close button hover CSS"); |
| 129 |
}), 500); |
| 130 |
|
| 131 |
return d; |
| 132 |
} |
| 133 |
}, |
| 134 |
{ |
| 135 |
name: "close a tab", |
| 136 |
timeout: 10000, |
| 137 |
runTest: function(t){ |
| 138 |
var d = new doh.Deferred(); |
| 139 |
|
| 140 |
robot.mouseMoveAt(query('.dijitTabCloseButton', registry.byId("mainTabContainer_tablist_tab3").domNode)[0], 500); |
| 141 |
robot.mouseClick({left: true}, 500); |
| 142 |
|
| 143 |
var tc = registry.byId("mainTabContainer"); |
| 144 |
robot.sequence(d.getTestCallback(function(){ |
| 145 |
doh.is(6, tc.getChildren().length); |
| 146 |
}), 500); |
| 147 |
|
| 148 |
return d; |
| 149 |
} |
| 150 |
}, |
| 151 |
{ |
| 152 |
name: "choose a tab from TabContainer's menu", |
| 153 |
timeout: 10000, |
| 154 |
runTest: function(t){ |
| 155 |
var d = new doh.Deferred(); |
| 156 |
|
| 157 |
robot.mouseMoveAt("mainTabContainer_tablist_menuBtn", 500); |
| 158 |
robot.mouseClick({left: true}, 500); |
| 159 |
robot.mouseMoveAt("tab4href_stcMi", 500); |
| 160 |
robot.mouseClick({left: true}, 1000); |
| 161 |
|
| 162 |
// verify SplitContainer tab is displayed (but it doesn't get focus, see #10727) |
| 163 |
robot.sequence(d.getTestCallback(function(){ |
| 164 |
// Check that tab button is scrolled correctly into view |
| 165 |
// TODO: this check won't work in RTL mode |
| 166 |
var tc = registry.byId("mainTabContainer"); |
| 167 |
|
| 168 |
var leftButton = dom.byId("mainTabContainer_tablist_leftBtn"); |
| 169 |
var tablistLeft = geom.position(leftButton).x + geom.position(leftButton).w; |
| 170 |
|
| 171 |
var rightButton = dom.byId("mainTabContainer_tablist_rightBtn"); |
| 172 |
var tablistRight = geom.position(rightButton).x; |
| 173 |
|
| 174 |
var tab = registry.byId("mainTabContainer_tablist_tab4href"); |
| 175 |
|
| 176 |
var tabLeft = geom.position(tab.domNode).x; |
| 177 |
var tabRight = geom.position(tab.domNode).x + geom.position(tab.domNode).w; |
| 178 |
|
| 179 |
var isTabVisible = (tablistLeft < tabLeft && tablistRight > tabRight); |
| 180 |
|
| 181 |
doh.t(isTabVisible, "verify tab is in display area"); |
| 182 |
|
| 183 |
// And verify that pane is shown |
| 184 |
doh.is("tab4href", tc.selectedChildWidget.id, "verify that the appropriate contentpane is displayed"); |
| 185 |
doh.t(helpers.isVisible(registry.byId("tab4href")), "tab4 shown"); |
| 186 |
doh.t(helpers.isHidden(registry.byId("tab1")), "tab1 hidden"); |
| 187 |
}), 1000); |
| 188 |
|
| 189 |
return d; |
| 190 |
} |
| 191 |
} |
| 192 |
]); |
| 193 |
|
| 194 |
doh.register("disabled tabs", [ |
| 195 |
{ |
| 196 |
name: "setup", |
| 197 |
runTest: function(){ |
| 198 |
tc = registry.byId("mainTabContainer"); |
| 199 |
tc.selectChild(registry.byId("tab1")); |
| 200 |
registry.byId("tab2").set("closable", true); |
| 201 |
registry.byId("tab2").set("disabled", true); |
| 202 |
} |
| 203 |
}, |
| 204 |
{ |
| 205 |
name: "click disabled tab", |
| 206 |
timeout: 10000, |
| 207 |
runTest: function(t){ |
| 208 |
var d = new doh.Deferred(); |
| 209 |
|
| 210 |
robot.mouseMoveAt('mainTabContainer_tablist_tab2', 500); |
| 211 |
robot.mouseClick({left: true}, 500); |
| 212 |
|
| 213 |
robot.sequence(d.getTestCallback(function(){ |
| 214 |
doh.is("tab1", tc.selectedChildWidget.id, "selected pane not changed"); |
| 215 |
}), 500); |
| 216 |
|
| 217 |
return d; |
| 218 |
} |
| 219 |
}, |
| 220 |
{ |
| 221 |
name: "close disabled tab", |
| 222 |
timeout: 10000, |
| 223 |
runTest: function(t){ |
| 224 |
var d = new doh.Deferred(); |
| 225 |
|
| 226 |
var nChildren = tc.getChildren().length; |
| 227 |
robot.mouseMoveAt(query('.dijitTabCloseButton', registry.byId("mainTabContainer_tablist_tab2").domNode)[0], 500); |
| 228 |
robot.mouseClick({left: true}, 500); |
| 229 |
|
| 230 |
robot.sequence(d.getTestCallback(function(){ |
| 231 |
doh.is(nChildren, tc.getChildren().length, "num children didn't change"); |
| 232 |
}), 500); |
| 233 |
|
| 234 |
return d; |
| 235 |
} |
| 236 |
}, |
| 237 |
{ |
| 238 |
name: "choose disabled tab from TabContainer's menu", |
| 239 |
timeout: 10000, |
| 240 |
runTest: function(t){ |
| 241 |
var d = new doh.Deferred(); |
| 242 |
|
| 243 |
robot.mouseMoveAt("mainTabContainer_tablist_menuBtn", 500); |
| 244 |
robot.mouseClick({left: true}, 500); |
| 245 |
robot.mouseMoveAt("tab2_stcMi", 500); |
| 246 |
robot.mouseClick({left: true}, 1000); |
| 247 |
|
| 248 |
robot.sequence(d.getTestCallback(function(){ |
| 249 |
doh.is("tab1", tc.selectedChildWidget.id, "selected pane not changed"); |
| 250 |
}), 500); |
| 251 |
|
| 252 |
return d; |
| 253 |
} |
| 254 |
}, |
| 255 |
{ |
| 256 |
name: "re-enable tab", |
| 257 |
runTest: function(){ |
| 258 |
registry.byId("tab2").set("disabled", false); |
| 259 |
} |
| 260 |
}, |
| 261 |
{ |
| 262 |
name: "click enabled tab", |
| 263 |
timeout: 10000, |
| 264 |
runTest: function(t){ |
| 265 |
var d = new doh.Deferred(); |
| 266 |
|
| 267 |
robot.mouseMoveAt('mainTabContainer_tablist_tab2', 500); |
| 268 |
robot.mouseClick({left: true}, 500); |
| 269 |
|
| 270 |
robot.sequence(d.getTestCallback(function(){ |
| 271 |
doh.is("tab2", tc.selectedChildWidget.id, "selected pane changed"); |
| 272 |
}), 500); |
| 273 |
|
| 274 |
return d; |
| 275 |
} |
| 276 |
}, |
| 277 |
{ |
| 278 |
name: "close enabled tab", |
| 279 |
timeout: 10000, |
| 280 |
runTest: function(t){ |
| 281 |
var d = new doh.Deferred(); |
| 282 |
|
| 283 |
var nChildren = tc.getChildren().length; |
| 284 |
robot.mouseMoveAt(query('.dijitTabCloseButton', registry.byId("mainTabContainer_tablist_tab2").domNode)[0], 500); |
| 285 |
robot.mouseClick({left: true}, 500); |
| 286 |
|
| 287 |
robot.sequence(d.getTestCallback(function(){ |
| 288 |
doh.is(nChildren-1, tc.getChildren().length, "num children decreased"); |
| 289 |
}), 500); |
| 290 |
|
| 291 |
return d; |
| 292 |
} |
| 293 |
} |
| 294 |
]); |
| 295 |
|
| 296 |
doh.register("initially disabled tab", [ |
| 297 |
{ |
| 298 |
name: "setup", |
| 299 |
runTest: function(){ |
| 300 |
tc = registry.byId("nomenu"); |
| 301 |
tc.selectChild(registry.byId("nomenu_tab2")); |
| 302 |
} |
| 303 |
}, |
| 304 |
{ |
| 305 |
name: "click disabled tab", |
| 306 |
timeout: 10000, |
| 307 |
runTest: function(t){ |
| 308 |
var d = new doh.Deferred(); |
| 309 |
|
| 310 |
robot.mouseMoveAt("nomenu_tablist_nomenu_tab3", 500); |
| 311 |
robot.mouseClick({left: true}, 500); |
| 312 |
|
| 313 |
robot.sequence(d.getTestCallback(function(){ |
| 314 |
doh.is("nomenu_tab2", tc.selectedChildWidget.id, "selected pane not changed"); |
| 315 |
}), 500); |
| 316 |
|
| 317 |
return d; |
| 318 |
} |
| 319 |
}, |
| 320 |
{ |
| 321 |
name: "close disabled tab", |
| 322 |
timeout: 10000, |
| 323 |
runTest: function(t){ |
| 324 |
var d = new doh.Deferred(); |
| 325 |
|
| 326 |
var nChildren = tc.getChildren().length; |
| 327 |
robot.mouseMoveAt(query('.dijitTabCloseButton', registry.byId("nomenu_tablist_nomenu_tab3").domNode)[0], 500); |
| 328 |
robot.mouseClick({left: true}, 500); |
| 329 |
|
| 330 |
robot.sequence(d.getTestCallback(function(){ |
| 331 |
doh.is(nChildren, tc.getChildren().length, "num children didn't change"); |
| 332 |
}), 500); |
| 333 |
|
| 334 |
return d; |
| 335 |
} |
| 336 |
} |
| 337 |
]); |
| 338 |
|
| 339 |
doh.run(); |
| 340 |
}); |
| 341 |
</script> |
| 342 |
</head> |
| 343 |
</html> |