| 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 CustomPlugin 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", |
| 16 | "dojo/_base/array", "dojo/query", "dojo/robotx", "dijit/tests/helpers", "dojo/domReady!" |
| 17 | ], function(doh, array, query, robot, helpers){ |
| 18 | |
| 19 | // TODO: convert this to non-robot test, clicking button using button.click() |
| 20 | |
| 21 | robot.initRobot('../test_CustomPlugin.html'); |
| 22 | |
| 23 | var registry; |
| 24 | doh.register("setup", [ |
| 25 | { |
| 26 | name: "wait for editors to load", |
| 27 | timeout: 5000, |
| 28 | runTest: helpers.waitForLoad |
| 29 | }, |
| 30 | function setVars(){ |
| 31 | registry = robot.window.require("dijit/registry"); |
| 32 | } |
| 33 | ]); |
| 34 | |
| 35 | var myPlugin; |
| 36 | |
| 37 | doh.register("isVisible", [ |
| 38 | function initialConditions(){ |
| 39 | var pluginIcon = query(".customIcon", robot.doc)[0]; |
| 40 | doh.t(helpers.isVisible(pluginIcon), "isVisible(pluginIcon)"); |
| 41 | } |
| 42 | ]); |
| 43 | |
| 44 | |
| 45 | doh.register("testCustomPlugin", [ |
| 46 | { |
| 47 | name: "toggleOn", |
| 48 | setUp: function(){ |
| 49 | var editor = registry.byId("editor1"); |
| 50 | array.forEach(editor._plugins, function(plugin){ |
| 51 | if(plugin.name === "MyPlugin"){ |
| 52 | myPlugin = plugin; |
| 53 | } |
| 54 | }); |
| 55 | }, |
| 56 | timeout: 15000, |
| 57 | runTest: function(){ |
| 58 | var d = new doh.Deferred(); |
| 59 | myPlugin.button.focus(); |
| 60 | robot.mouseMoveAt(myPlugin.button.domNode, 500); |
| 61 | robot.mouseClick({left:true}, 500); |
| 62 | |
| 63 | robot.sequence(d.getTestCallback(function(){ |
| 64 | var foundClass = false; |
| 65 | doh.t(myPlugin.button.get("checked"), "Verifying button was checked."); |
| 66 | var sourceArea = myPlugin.sourceArea; |
| 67 | doh.t(helpers.isVisible(sourceArea), "isVisible(sourceArea)"); |
| 68 | }), 1000); |
| 69 | return d; |
| 70 | } |
| 71 | }, |
| 72 | { |
| 73 | name: "toggleOff", |
| 74 | setUp: function(){ |
| 75 | var editor = registry.byId("editor1"); |
| 76 | array.forEach(editor._plugins, function(plugin){ |
| 77 | if(plugin.name === "MyPlugin"){ |
| 78 | myPlugin = plugin; |
| 79 | } |
| 80 | }); |
| 81 | }, |
| 82 | timeout: 15000, |
| 83 | runTest: function(){ |
| 84 | var d = new doh.Deferred(); |
| 85 | myPlugin.button.focus(); |
| 86 | robot.mouseMoveAt(myPlugin.button.domNode, 500); |
| 87 | robot.mouseClick({left:true}, 500); |
| 88 | robot.sequence(d.getTestCallback(function(){ |
| 89 | doh.f(myPlugin.button.get("checked"), "Verifying button was unchecked."); |
| 90 | var sourceArea = myPlugin.sourceArea; |
| 91 | doh.f(helpers.isVisible(sourceArea), "isVisible(sourceArea)"); |
| 92 | }), 1000); |
| 93 | return d; |
| 94 | } |
| 95 | } |
| 96 | ]); |
| 97 | doh.run(); |
| 98 | }); |
| 99 | </script> |
| 100 | </head> |
| 101 | </html> |