UNPKG

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

153 lines (133 loc) 5.02 kB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>doh.robot TabIndent 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/dom", "dojo/keys", "dojo/query", "dojo/window", "dijit/tests/helpers", "dojo/domReady!" ], function(doh, robot, dom, keys, query, winUtils, helpers){ robot.initRobot('../test_TabIndent.html'); var metaKey = {ctrl: true}; 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("testTabIndent", [ { name: "toggleOn", timeout: 6000, runTest: function(){ var d = new doh.Deferred(); var editor = registry.byId("tiTest"); robot.sequence(d.getTestErrback(function(){ editor.setValue("<ol><li>a list item.</li><li>a list item2.</li></ol>"); }),500); robot.mouseMoveAt(query(".dijitEditorIconTabIndent", robot.doc)[0], 1000); robot.mouseClick({left: true}, 500); robot.mouseMoveAt(function(){ return editor.editNode }, 500); robot.mouseClick({left: true}, 500); robot.keyPress(keys.DOWN_ARROW, 500); //make sure the last thing in the list is selected robot.keyPress(keys.TAB, 500); robot.sequence(d.getTestCallback(function(){ doh.is("<ol><li>a list item.</li><ol><li>a list item2.</li></ol></ol>", editor.getValue()); }), 1000); return d; } }, { name: "shiftTab", timeout: 2000, runTest: function(){ var d = new doh.Deferred(); var editor = registry.byId("tiTest"); robot.keyPress(keys.TAB, 500, {shift: true}); robot.sequence(d.getTestCallback(function(){ var editorValue = editor.getValue(); var valid = editorValue === "<ol><li>a list item.</li><li>a list item2.<br /></li></ol>"; //chrome valid = valid || editorValue === "<ol><li>a list item.</li><li>a list item2.<br/></li></ol>"; //safari valid = valid || editorValue === "<ol><li>a list item.</li><li>a list item2.</li></ol>"; //everone else doh.t(valid); }), 1000); return d; } }, { name: "toggleOff", timeout: 6000, runTest: function(){ var d = new doh.Deferred(); var editor = registry.byId("tiTest"); var origValue; robot.sequence(d.getTestErrback(function(){ origValue = editor.getValue(); }), 1000); robot.mouseMoveAt(query(".dijitEditorIconTabIndent", robot.doc)[0], 1000); robot.mouseClick({left: true}, 500); robot.mouseMoveAt(editor.editNode, 500); robot.mouseClick({left: true}, 500); robot.keyPress(keys.TAB, 500); robot.sequence(d.getTestCallback(function(){ //verify the editor lost focus and therefore the value did not change doh.is(origValue, editor.getValue()); }), 1000); return d; } }, { name: "toggleOn_ctrlM", timeout: 6000, runTest: function(){ var d = new doh.Deferred(); var editor = registry.byId("tiTest"); robot.mouseMoveAt(function(){ return editor.editNode }, 500); robot.mouseClick({left: true}, 500); robot.keyPress("m", 500, {ctrl: true}); robot.mouseMoveAt(function(){ return editor.editNode }, 500); robot.mouseClick({left: true}, 500); robot.keyPress(keys.DOWN_ARROW, 500); //make sure the last thing in the list is selected robot.keyPress(keys.TAB, 500); robot.sequence(d.getTestCallback(function(){ doh.is("<ol><li>a list item.</li><ol><li>a list item2.</li></ol></ol>", editor.getValue()); }), 1000); return d; } }, { name: "toggleOff_ctrlM", timeout: 6000, runTest: function(){ var d = new doh.Deferred(); var editor = registry.byId("tiTest"); var origValue; robot.sequence(d.getTestErrback(function(){ origValue = editor.getValue(); }), 1000); robot.mouseMoveAt(function(){ return editor.editNode }, 500); robot.mouseClick({left: true}, 500); robot.keyPress("m", 500, {ctrl: true}); robot.mouseMoveAt(function(){ return editor.editNode }, 500); robot.mouseClick({left: true}, 500); robot.keyPress(keys.TAB, 500); robot.sequence(d.getTestCallback(function(){ //verify the editor lost focus and therefore the value did not change doh.is(origValue, editor.getValue()); }), 1000); return d; } } ]); doh.run(); }); </script> </head> </html>