dijit
Version:
Dijit provides a complete collection of user interface controls based on Dojo, giving you the power to create web applications that are highly optimized for usability, performance, internationalization, accessibility, but above all deliver an incredible u
117 lines (99 loc) • 3.12 kB
HTML
<html>
<head>
<title>doh.robot Editor NewPage Plugin Test</title>
<style>
@import "../../../../util/doh/robot/robot.css";
</style>
<script type="text/javascript" src="../../../../dojo/dojo.js"></script>
<script type="text/javascript">
require([
"doh/runner", "dojo/robotx",
"dojo/_base/lang", "dojo/window", "dijit/tests/helpers", "dojo/domReady!"
], function(doh, robot, lang, winUtils, helpers){
robot.initRobot('../test_NewPage.html');
function getPlugin(/*Editor*/ editor){
// summary:
// Return new page plugin for specified editor
var edPlugins = editor._plugins, i;
for(i = 0; i < edPlugins.length; i++){
var p = edPlugins[i], fsPlugin;
if(p.declaredClass === "dijit._editor.plugins.NewPage"){
p.button.set("checked", false);
return p;
}
}
throw new Error("didn't find plugin");
}
var registry;
doh.register("setup", [
{
name: "wait for editors to load",
timeout: 5000,
runTest: helpers.waitForLoad
},
function setVars(){
registry = robot.window.require("dijit/registry");
}
]);
doh.register("NewPage_tests", [
{
name: "Mouse: Click new page clears editor",
timeout: 20000,
setUp: function(){
editor = registry.byId("editor0");
npPlugin = getPlugin(editor);
},
runTest: function(){
var d = new doh.Deferred();
// Focus on the editor window
winUtils.scrollIntoView(editor.domNode);
editor.focus();
value = editor.get("value");
robot.mouseMoveAt(npPlugin.button.domNode, 500);
robot.mouseClick({left:true}, 500);
robot.sequence(d.getTestCallback(function(){
//Now check the state!
doh.is("", editor.get("value"), "editor.get('value')");
}), 1000);
return d;
},
tearDown: function(){
editor.set("value", value);
}
},
{
name: "Mouse: Click new page sets editor with default content.",
timeout: 20000,
setUp: function(){
editor = registry.byId("editor1");
npPlugin = getPlugin(editor);
},
runTest: function(){
var d = new doh.Deferred();
// Focus on the editor window
winUtils.scrollIntoView(editor.domNode);
editor.focus();
value = editor.get("value");
robot.mouseMoveAt(npPlugin.button.domNode, 500);
robot.mouseClick({left:true}, 500);
robot.sequence(d.getTestCallback(function(){
//Now check the state!
var newVal = editor.get("value");
doh.isNot(value, newVal, "Verify the contents have changed.");
newVal = lang.trim(newVal);
doh.is("<p>This page intentionally left blank</p>", newVal, "Validate the contents are the defined default content");
}), 1000);
return d;
},
tearDown: function(){
editor.set("value", value);
}
}
]);
doh.run();
});
</script>
</head>
</html>