You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
381 lines
9.6 KiB
381 lines
9.6 KiB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
|
"http://www.w3.org/TR/html4/strict.dtd"> |
|
<html> |
|
<head> |
|
<title>robot Dialog Mouse Test</title> |
|
|
|
<style> |
|
@import "../../../util/doh/robot/robot.css"; |
|
</style> |
|
|
|
<!-- required: dojo.js --> |
|
<script type="text/javascript" src="../../../dojo/dojo.js" |
|
data-dojo-config="isDebug: true"></script> |
|
|
|
<script type="text/javascript"> |
|
require([ |
|
"doh/runner", "dojo/robotx", |
|
"dojo/aspect", "dojo/dom", "dojo/keys", "dojo/query", |
|
"dijit/tests/helpers", "dojo/domReady!" |
|
], function(doh, robot, aspect, dom, keys, query, helpers){ |
|
|
|
robot.initRobot('../test_Dialog.html'); |
|
|
|
doh.register(function setup(){ |
|
// get pointer to registry in the iframe |
|
registry = robot.window.require("dijit/registry"); |
|
dfocus = robot.window.require("dijit/focus"); |
|
}); |
|
|
|
|
|
doh.register("dijit.Dialog mouse tests (cancel)", [ |
|
{ |
|
name: "open dialog", |
|
timeout: 4000, |
|
runTest: function(){ |
|
var d = new doh.Deferred(); |
|
|
|
var oldOnClick = registry.byId("dialog1button").onClick; |
|
registry.byId("dialog1button").onClick = function(){ |
|
registry.byId("dialog1").show().then(d.getTestCallback(function(){ |
|
doh.t(helpers.isVisible("dialog1"), "dialog 1 has been made visible"); |
|
doh.is("name", dfocus.curNode.id, "focus is on the first field"); |
|
})); |
|
registry.byId("dialog1button").onClick = oldOnClick; |
|
}; |
|
|
|
// Open the dialog |
|
robot.mouseMoveAt("dialog1button", 1000); |
|
robot.mouseClick({left: true}, 1000); |
|
|
|
return d; |
|
} |
|
}, |
|
|
|
{ |
|
name: "test that other controls on page can't be clicked", |
|
timeout: 4000, |
|
runTest: function(){ |
|
var d = new doh.Deferred(); |
|
|
|
robot.mouseMoveAt("plainInput", 500); |
|
robot.mouseClick({left: true}, 1000); |
|
|
|
robot.sequence(d.getTestCallback(function(){ |
|
doh.t(helpers.isVisible("dialog1"), "dialog 1 still visible"); |
|
doh.isNot("plainInput", dfocus.curNode && dfocus.curNode.id, |
|
"focus did not go to plain input"); |
|
}), 1000); |
|
|
|
return d; |
|
} |
|
}, |
|
|
|
{ |
|
name: "open date drop down", |
|
timeout: 10000, |
|
runTest: function(){ |
|
var d = new doh.Deferred(); |
|
|
|
helpers.onFocus(d.getTestCallback(function(){ |
|
var calDomNode = query(".dijitCalendarContainer"); |
|
doh.t(1, calDomNode.length, "found calendar"); |
|
doh.t(helpers.isVisible(calDomNode[0]), "calendar is being shown"); |
|
doh.t(dom.isDescendant(dfocus.curNode, calDomNode[0]), "focus is on the calendar"); |
|
}), 500); // Focus might first go to input, then to calendar, so wait for that |
|
|
|
|
|
robot.mouseMoveAt(function(){ |
|
return query(".dijitArrowButton", registry.byId("date").domNode)[0]; |
|
}, 500); |
|
robot.mouseClick({left: true}, 1000); |
|
|
|
return d; |
|
} |
|
}, |
|
|
|
{ |
|
name: "close date drop down", |
|
timeout: 4000, |
|
runTest: function(){ |
|
var d = new doh.Deferred(); |
|
|
|
robot.mouseMove(10, 10, 500); |
|
robot.mouseClick({left: true}, 1000); |
|
|
|
robot.sequence(d.getTestCallback(function(){ |
|
var calDomNode = query(".dijitCalendarContainer"); |
|
doh.t(calDomNode.length == 0 || helpers.isHidden(calDomNode[0]), "calendar has disappeared"); |
|
doh.t(helpers.isVisible("dialog1"), "dialog 1 wasn't closed"); |
|
}), 1000); |
|
|
|
return d; |
|
} |
|
}, |
|
|
|
{ |
|
name: "cancel dialog", |
|
timeout: 5000, |
|
runTest: function(){ |
|
var d = new doh.Deferred(); |
|
|
|
var button = query("#dialog1 .dijitDialogCloseIcon")[0]; |
|
robot.mouseMoveAt(button, 500); |
|
robot.mouseClick({left: true}, 500); |
|
|
|
robot.sequence(d.getTestCallback(function(node){ |
|
doh.t(helpers.isHidden("dialog1"), "dialog 1 was closed"); |
|
}), 500); |
|
|
|
return d; |
|
} |
|
} |
|
]); |
|
|
|
doh.register("dijit.Dialog mouse tests (submit)", [ |
|
{ |
|
name: "submit some data", |
|
timeout: 15000, |
|
setUp: function(){ |
|
registry.byId("dialog1").reset(); |
|
}, |
|
runTest: function(){ |
|
var d = new doh.Deferred(); |
|
|
|
// Setup handler to catch submitted data |
|
var data; |
|
aspect.after(registry.byId("dialog1"), "execute", function(vals){ |
|
data = vals; |
|
}, true); |
|
|
|
// Open the dialog |
|
robot.mouseMoveAt("dialog1button", 500, 1); |
|
robot.mouseClick({left: true}, 500); |
|
|
|
// Enter some info |
|
robot.mouseMoveAt("name", 500, 1); |
|
robot.mouseClick({left: true}, 500); |
|
robot.typeKeys("Ted", 500, 600); |
|
|
|
robot.mouseMoveAt("loc", 500, 1); |
|
robot.mouseClick({left: true}, 500); |
|
robot.typeKeys("America", 500, 1400); |
|
|
|
// Submit |
|
robot.mouseMoveAt("ok", 500, 1); |
|
robot.mouseClick({left: true}, 500); |
|
|
|
robot.sequence(d.getTestCallback(function(){ |
|
doh.t(helpers.isHidden("dialog1"), "dialog 1 was closed on submit"); |
|
doh.t(data, "got submit data"); |
|
doh.is("Ted", data.name, "Name"); |
|
doh.is("America", data.loc, "Location"); |
|
}), 1000); |
|
|
|
return d; |
|
} |
|
} |
|
]); |
|
|
|
doh.register("dijit.Dialog mouse tests (unfocusable open button)", [ |
|
{ |
|
name: "open #1", |
|
timeout: 10000, |
|
runTest: function(){ |
|
var d = new doh.Deferred(); |
|
|
|
// Open the dialog |
|
robot.mouseMoveAt("SelfDestructDlgBtn2", 1000); |
|
robot.mouseClick({left: true}, 1000); |
|
robot.sequence(d.getTestCallback(function(){ |
|
doh.t(registry.byId("SelfDestructDlg"), "dialog created"); |
|
doh.t(helpers.isVisible("SelfDestructDlgBtn2"), "dialog has been made visible"); |
|
doh.is("SelfDestructDlgInput", dfocus.curNode.id, "focus is on the first field"); |
|
}), 1000); |
|
|
|
return d; |
|
} |
|
}, |
|
{ |
|
name: "close #1", |
|
timeout: 10000, |
|
runTest: function(){ |
|
var d = new doh.Deferred(); |
|
|
|
// Close the dialog |
|
robot.mouseMoveAt(function(){ |
|
return query("#SelfDestructDlg .dijitDialogCloseIcon")[0]; |
|
}, 1000); |
|
robot.mouseClick({left: true}, 1000); |
|
robot.sequence(d.getTestCallback(function(){ |
|
doh.f(registry.byId("SelfDestructDlg"), "dialog destroyed"); |
|
|
|
var focus = dfocus.curNode; |
|
doh.f(focus, "focus should have been cleared, but set to " + |
|
focus + (focus && focus.tagName) + (focus && focus.id)); |
|
}), 1000); |
|
|
|
return d; |
|
} |
|
}, |
|
{ |
|
name: "open #2", |
|
timeout: 10000, |
|
runTest: function(){ |
|
var d = new doh.Deferred(); |
|
|
|
// Open the dialog |
|
robot.mouseMoveAt("SelfDestructDlgBtn2", 1000); |
|
robot.mouseClick({left: true}, 1000); |
|
robot.sequence(d.getTestCallback(function(){ |
|
doh.t(registry.byId("SelfDestructDlg"), "dialog created"); |
|
doh.t(helpers.isVisible("SelfDestructDlgBtn2"), "dialog has been made visible"); |
|
doh.is("SelfDestructDlgInput", dfocus.curNode.id, "focus is on the first field"); |
|
}), 1000); |
|
|
|
return d; |
|
} |
|
}, |
|
{ |
|
name: "close #2", |
|
timeout: 10000, |
|
runTest: function(){ |
|
var d = new doh.Deferred(); |
|
|
|
// Close the dialog |
|
robot.mouseMoveAt(function(){ |
|
return query("#SelfDestructDlg .dijitDialogCloseIcon")[0]; |
|
}, 1000); |
|
robot.mouseClick({left: true}, 1000); |
|
robot.sequence(d.getTestCallback(function(){ |
|
doh.f(registry.byId("SelfDestructDlg"), "dialog destroyed"); |
|
|
|
var focus = dfocus.curNode; |
|
doh.f(focus, "focus should have been cleared, but set to " + |
|
focus + (focus && focus.tagName) + (focus && focus.id)); |
|
}), 1000); |
|
|
|
return d; |
|
} |
|
} |
|
]); |
|
|
|
// Opening a context menu shifts focus away from the Dialog but we shouldn't automatically shift focus back |
|
doh.register("context menu", [ |
|
{ |
|
name: "open first", |
|
timeout: 10000, |
|
runTest: function(){ |
|
return registry.byId('dialog1').show(); |
|
} |
|
}, |
|
{ |
|
name: "open context menu", |
|
timeout: 10000, |
|
runTest: function(){ |
|
var d = new doh.Deferred(); |
|
|
|
robot.mouseMoveAt("dialog1", 500); |
|
robot.mouseClick({right: true}, 1000); |
|
|
|
robot.sequence(d.getTestCallback(function(){ |
|
doh.t(helpers.isVisible("dialog1"), "dialog 1 still visible"); |
|
doh.t(helpers.isVisible("dialog1ContextMenu"), "context menu visible"); |
|
doh.is("firstMenuItem", dfocus.curNode && dfocus.curNode.id, |
|
"focus on Menu"); |
|
}), 1000); |
|
|
|
return d; |
|
} |
|
}, |
|
{ |
|
name: "close first", |
|
timeout: 10000, |
|
runTest: function(){ |
|
return registry.byId('dialog1').hide(); |
|
} |
|
} |
|
]); |
|
|
|
doh.register("ESC", [ |
|
{ |
|
name: "open dialog", |
|
timeout: 4000, |
|
runTest: function(){ |
|
var d = new doh.Deferred(); |
|
|
|
// Open the dialog |
|
robot.mouseMoveAt("dialog1button", 1000); |
|
robot.mouseClick({left: true}, 1000); |
|
robot.sequence(d.getTestCallback(function(){})); |
|
|
|
return d; |
|
} |
|
}, |
|
|
|
{ |
|
name: "click background", |
|
timeout: 4000, |
|
runTest: function(){ |
|
var d = new doh.Deferred(); |
|
|
|
robot.mouseMoveAt("plainInput", 500); |
|
robot.mouseClick({left: true}, 1000); |
|
|
|
robot.sequence(d.getTestCallback(function(){ |
|
doh.t(helpers.isVisible("dialog1"), "dialog 1 still visible"); |
|
doh.isNot("plainInput", dfocus.curNode && dfocus.curNode.id, |
|
"focus did not go to plain input"); |
|
}), 1000); |
|
|
|
return d; |
|
} |
|
}, |
|
|
|
{ |
|
name: "close via ESC", |
|
timeout: 4000, |
|
runTest: function(){ |
|
var d = new doh.Deferred(); |
|
|
|
robot.keyPress(keys.ESCAPE, 500, {}); |
|
|
|
robot.sequence(d.getTestCallback(function(){ |
|
doh.t(helpers.isHidden("dialog1"), "dialog 1 was closed"); |
|
}), 1000); |
|
|
|
return d; |
|
} |
|
} |
|
]); |
|
|
|
doh.register("dijit.Dialog InlineEditBox w/Editor tests", [ |
|
{ |
|
name: "#17225", |
|
timeout: 10000, |
|
runTest: function(){ |
|
var d = new doh.Deferred(); |
|
|
|
// Open the dialog |
|
robot.mouseMoveAt("iebDialogBtn", 1000); |
|
robot.mouseClick({left: true}, 1000); |
|
|
|
// Open second InlineEditBox |
|
robot.mouseMoveAt("inlineRTE2", 1000); |
|
robot.mouseClick({left: true}, 1000); |
|
|
|
// Test that editor didn't close immediately and focus move back to the first field |
|
robot.sequence(d.getTestCallback(function(){ |
|
doh.t(helpers.isVisible("RTE2"), "editor 2 visible"); |
|
}), 1000); |
|
|
|
return d; |
|
} |
|
} |
|
]); |
|
|
|
doh.run(); |
|
}); |
|
</script> |
|
</head> |
|
</html>
|
|
|