Debian Codegraph @

dijit/tests/editor/robot/Editor_NewPage.html

raw symbols SCIP
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 Editor NewPage Plugin 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/_base/lang", "dojo/window", "dijit/tests/helpers", "dojo/domReady!"
17 ], function(doh, robot, lang, winUtils, helpers){
18
19 robot.initRobot('../test_NewPage.html');
20
21 function getPlugin(/*Editor*/ editor){
22 // summary:
23 // Return new page plugin for specified editor
24 var edPlugins = editor._plugins, i;
25 for(i = 0; i < edPlugins.length; i++){
26 var p = edPlugins[i], fsPlugin;
27 if(p.declaredClass === "dijit._editor.plugins.NewPage"){
28 p.button.set("checked", false);
29 return p;
30 }
31 }
32 throw new Error("didn't find plugin");
33 }
34
35 var registry;
36 doh.register("setup", [
37 {
38 name: "wait for editors to load",
39 timeout: 5000,
40 runTest: helpers.waitForLoad
41 },
42 function setVars(){
43 registry = robot.window.require("dijit/registry");
44 }
45 ]);
46
47 doh.register("NewPage_tests", [
48 {
49 name: "Mouse: Click new page clears editor",
50 timeout: 20000,
51 setUp: function(){
52 editor = registry.byId("editor0");
53 npPlugin = getPlugin(editor);
54 },
55 runTest: function(){
56 var d = new doh.Deferred();
57
58 // Focus on the editor window
59 winUtils.scrollIntoView(editor.domNode);
60 editor.focus();
61
62 value = editor.get("value");
63 robot.mouseMoveAt(npPlugin.button.domNode, 500);
64 robot.mouseClick({left:true}, 500);
65
66 robot.sequence(d.getTestCallback(function(){
67 //Now check the state!
68 doh.is("", editor.get("value"), "editor.get('value')");
69 }), 1000);
70
71 return d;
72 },
73 tearDown: function(){
74 editor.set("value", value);
75
76 }
77 },
78 {
79 name: "Mouse: Click new page sets editor with default content.",
80 timeout: 20000,
81 setUp: function(){
82 editor = registry.byId("editor1");
83 npPlugin = getPlugin(editor);
84 },
85 runTest: function(){
86 var d = new doh.Deferred();
87
88 // Focus on the editor window
89 winUtils.scrollIntoView(editor.domNode);
90 editor.focus();
91
92 value = editor.get("value");
93 robot.mouseMoveAt(npPlugin.button.domNode, 500);
94 robot.mouseClick({left:true}, 500);
95
96 robot.sequence(d.getTestCallback(function(){
97 //Now check the state!
98 var newVal = editor.get("value");
99 doh.isNot(value, newVal, "Verify the contents have changed.");
100 newVal = lang.trim(newVal);
101 doh.is("<p>This page intentionally left blank</p>", newVal, "Validate the contents are the defined default content");
102 }), 1000);
103
104 return d;
105 },
106 tearDown: function(){
107 editor.set("value", value);
108
109 }
110 }
111 ]);
112 doh.run();
113 });
114 </script>
115 </head>
116 </html>