| 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>doh.robot TabIndent Test</title> |
| 6 | |
| 7 | <style> |
| 8 | @import "../../../../util/doh/robot/robot.css"; |
| 9 | </style> |
| 10 | |
| 11 | <script type="text/javascript" src="../../../../dojo/dojo.js"></script> |
| 12 | |
| 13 | <script type="text/javascript"> |
| 14 | require([ |
| 15 | "doh/runner", "dojo/robotx", |
| 16 | "dojo/dom", "dojo/keys", "dojo/query", "dojo/window", |
| 17 | "dijit/tests/helpers", "dojo/domReady!" |
| 18 | ], function(doh, robot, dom, keys, query, winUtils, helpers){ |
| 19 | |
| 20 | robot.initRobot('../test_TabIndent.html'); |
| 21 | |
| 22 | var metaKey = {ctrl: true}; |
| 23 | |
| 24 | var registry; |
| 25 | doh.register("setup", [ |
| 26 | { |
| 27 | name: "wait for editors to load", |
| 28 | timeout: 5000, |
| 29 | runTest: helpers.waitForLoad |
| 30 | }, |
| 31 | function setVars(){ |
| 32 | registry = robot.window.require("dijit/registry"); |
| 33 | } |
| 34 | ]); |
| 35 | |
| 36 | doh.register("testTabIndent", [ |
| 37 | { |
| 38 | name: "toggleOn", |
| 39 | timeout: 6000, |
| 40 | runTest: function(){ |
| 41 | var d = new doh.Deferred(); |
| 42 | |
| 43 | var editor = registry.byId("tiTest"); |
| 44 | |
| 45 | robot.sequence(d.getTestErrback(function(){ |
| 46 | editor.setValue("<ol><li>a list item.</li><li>a list item2.</li></ol>"); |
| 47 | }),500); |
| 48 | |
| 49 | robot.mouseMoveAt(query(".dijitEditorIconTabIndent", robot.doc)[0], 1000); |
| 50 | robot.mouseClick({left: true}, 500); |
| 51 | robot.mouseMoveAt(function(){ return editor.editNode }, 500); |
| 52 | robot.mouseClick({left: true}, 500); |
| 53 | robot.keyPress(keys.DOWN_ARROW, 500); //make sure the last thing in the list is selected |
| 54 | robot.keyPress(keys.TAB, 500); |
| 55 | |
| 56 | robot.sequence(d.getTestCallback(function(){ |
| 57 | doh.is("<ol><li>a list item.</li><ol><li>a list item2.</li></ol></ol>", editor.getValue()); |
| 58 | }), 1000); |
| 59 | return d; |
| 60 | } |
| 61 | }, |
| 62 | { |
| 63 | name: "shiftTab", |
| 64 | timeout: 2000, |
| 65 | runTest: function(){ |
| 66 | var d = new doh.Deferred(); |
| 67 | var editor = registry.byId("tiTest"); |
| 68 | robot.keyPress(keys.TAB, 500, {shift: true}); |
| 69 | |
| 70 | robot.sequence(d.getTestCallback(function(){ |
| 71 | var editorValue = editor.getValue(); |
| 72 | var valid = editorValue === "<ol><li>a list item.</li><li>a list item2.<br /></li></ol>"; //chrome |
| 73 | valid = valid || editorValue === "<ol><li>a list item.</li><li>a list item2.<br/></li></ol>"; //safari |
| 74 | valid = valid || editorValue === "<ol><li>a list item.</li><li>a list item2.</li></ol>"; //everone else |
| 75 | doh.t(valid); |
| 76 | }), 1000); |
| 77 | return d; |
| 78 | } |
| 79 | }, |
| 80 | { |
| 81 | name: "toggleOff", |
| 82 | timeout: 6000, |
| 83 | runTest: function(){ |
| 84 | var d = new doh.Deferred(); |
| 85 | |
| 86 | var editor = registry.byId("tiTest"); |
| 87 | var origValue; |
| 88 | robot.sequence(d.getTestErrback(function(){ origValue = editor.getValue(); }), 1000); |
| 89 | robot.mouseMoveAt(query(".dijitEditorIconTabIndent", robot.doc)[0], 1000); |
| 90 | robot.mouseClick({left: true}, 500); |
| 91 | robot.mouseMoveAt(editor.editNode, 500); |
| 92 | robot.mouseClick({left: true}, 500); |
| 93 | robot.keyPress(keys.TAB, 500); |
| 94 | |
| 95 | robot.sequence(d.getTestCallback(function(){ |
| 96 | //verify the editor lost focus and therefore the value did not change |
| 97 | doh.is(origValue, editor.getValue()); |
| 98 | }), 1000); |
| 99 | return d; |
| 100 | } |
| 101 | }, |
| 102 | { |
| 103 | name: "toggleOn_ctrlM", |
| 104 | timeout: 6000, |
| 105 | runTest: function(){ |
| 106 | var d = new doh.Deferred(); |
| 107 | |
| 108 | var editor = registry.byId("tiTest"); |
| 109 | |
| 110 | robot.mouseMoveAt(function(){ return editor.editNode }, 500); |
| 111 | robot.mouseClick({left: true}, 500); |
| 112 | robot.keyPress("m", 500, {ctrl: true}); |
| 113 | robot.mouseMoveAt(function(){ return editor.editNode }, 500); |
| 114 | robot.mouseClick({left: true}, 500); |
| 115 | robot.keyPress(keys.DOWN_ARROW, 500); //make sure the last thing in the list is selected |
| 116 | robot.keyPress(keys.TAB, 500); |
| 117 | |
| 118 | robot.sequence(d.getTestCallback(function(){ |
| 119 | doh.is("<ol><li>a list item.</li><ol><li>a list item2.</li></ol></ol>", editor.getValue()); |
| 120 | }), 1000); |
| 121 | return d; |
| 122 | } |
| 123 | }, |
| 124 | { |
| 125 | name: "toggleOff_ctrlM", |
| 126 | timeout: 6000, |
| 127 | runTest: function(){ |
| 128 | var d = new doh.Deferred(); |
| 129 | |
| 130 | var editor = registry.byId("tiTest"); |
| 131 | var origValue; |
| 132 | robot.sequence(d.getTestErrback(function(){ origValue = editor.getValue(); }), 1000); |
| 133 | robot.mouseMoveAt(function(){ return editor.editNode }, 500); |
| 134 | robot.mouseClick({left: true}, 500); |
| 135 | robot.keyPress("m", 500, {ctrl: true}); |
| 136 | robot.mouseMoveAt(function(){ return editor.editNode }, 500); |
| 137 | robot.mouseClick({left: true}, 500); |
| 138 | robot.keyPress(keys.TAB, 500); |
| 139 | |
| 140 | robot.sequence(d.getTestCallback(function(){ |
| 141 | //verify the editor lost focus and therefore the value did not change |
| 142 | doh.is(origValue, editor.getValue()); |
| 143 | }), 1000); |
| 144 | return d; |
| 145 | } |
| 146 | } |
| 147 | ]); |
| 148 | doh.run(); |
| 149 | }); |
| 150 | </script> |
| 151 | </head> |
| 152 | </html> |