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

646 lines (570 loc) 27.1 kB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>doh.robot Editor FullScreen 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/dom-geometry", "dojo/dom-style", "dojo/keys", "dojo/window", "dijit/tests/helpers", "dojo/domReady!" ], function(doh, robot, domGeom, domStyle, keys, winUtils, helpers){ robot.initRobot('../test_FullScreen.html'); function getPlugin(/*Editor*/ editor){ // summary: // Return full screen 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.FullScreen"){ 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("General", [ function setUp(){ editor = registry.byId("editor0"); fsPlugin = getPlugin(editor); }, { name: "Keyboard: Go to Fullscreen (CTRL-SHIFT-F11)", timeout: 20000, runTest: function(){ var d = new doh.Deferred(); //Focus on the editor window robot.sequence(d.getTestErrback(function(){ winUtils.scrollIntoView(editor.domNode); editor.focus(); }), 500); robot.keyPress(keys.F11, 500, {ctrl:true,shift:true}); robot.sequence(d.getTestCallback(function(){ //Now check the state! doh.t(fsPlugin.isFullscreen, "isFullScreen"); var vp = winUtils.getBox(); var edPos = domGeom.position(editor.domNode); doh.is("absolute", domStyle.get(editor.domNode, "position")); doh.is("0", domStyle.get(editor.domNode, "top"), "Top position check"); doh.is("0", domStyle.get(editor.domNode, "left"), "Left position check"); //There may be a difference of a pixel or two, so check that the editor is real close //to the viewport size. doh.t(edPos.h >= vp.h && edPos.h < (vp.h + 5), "Height check, ed = " + edPos.h + ", vp = " + vp.h); doh.t(Math.ceil(edPos.w) >= vp.w && Math.floor(edPos.w) < (vp.w + 5), "Width check, ed = " + edPos.w + ", vp = " + vp.w); }), 1000); return d; }, tearDown: function(){ fsPlugin.button.set("checked", false); } }, { name: "Keyboard: Go to fullscreen and back", timeout: 20000, runTest: function(){ var d = new doh.Deferred(); //Focus on the editor window robot.sequence(d.getTestErrback(function(){ winUtils.scrollIntoView(editor.domNode); editor.focus(); }), 500); robot.keyPress(keys.F11, 500, {ctrl:true,shift:true}); robot.keyPress(keys.F11, 1000, {ctrl:true,shift:true}); robot.sequence(d.getTestCallback(function(){ //Now check the state! doh.f(fsPlugin.isFullscreen, "isFullScreen"); var edPos = domGeom.position(editor.domNode); doh.isNot("absolute", domStyle.get(editor.domNode, "position")); //There may be a difference of a pixel or two depending on how the browser sizes //so check that the editor is real close to the expected size defined in the test doc. doh.t(edPos.h >= 400 && (edPos.h < 405), "Restored height check."); doh.t(edPos.w >= 800 && (edPos.w < 805), "Restored width check."); }), 2000); return d; }, tearDown: function(){ fsPlugin.button.set("checked", false); } }, { name: "Mouse Click: Go to Fullscreen", timeout: 20000, runTest: function(){ var d = new doh.Deferred(); //Focus on the editor window robot.sequence(d.getTestErrback(function(){ winUtils.scrollIntoView(editor.domNode); editor.focus(); }), 500); robot.mouseMoveAt(fsPlugin.button.domNode, 500); robot.mouseClick({left: true}, 750); robot.sequence(d.getTestCallback(function(){ //Now check the state! doh.t(fsPlugin.isFullscreen, "isFullScreen"); var vp = winUtils.getBox(); var edPos = domGeom.position(editor.domNode); doh.is("absolute", domStyle.get(editor.domNode, "position")); doh.is("0", domStyle.get(editor.domNode, "top"), "Top position check"); doh.is("0", domStyle.get(editor.domNode, "left"), "Left position check"); //There may be a difference of a pixel or two, so check that the editor is real close //to the viewport size. doh.t(edPos.h >= vp.h && edPos.h < (vp.h + 5), "Height check"); doh.t(Math.ceil(edPos.w) >= vp.w && Math.floor(edPos.w) < (vp.w + 5), "Width check, ed = " + edPos.w + ", vp = " + vp.w); }), 1000); return d; }, tearDown: function(){ fsPlugin.button.set("checked", false); } }, { name: "Mouse Click: Go to fullscreen and back", timeout: 20000, runTest: function(){ var d = new doh.Deferred(); //Focus on the editor window robot.sequence(d.getTestErrback(function(){ winUtils.scrollIntoView(editor.domNode); editor.focus(); }), 500); //Click it, then click it again! robot.mouseMoveAt(fsPlugin.button.domNode, 500); robot.mouseClick({left: true}, 750); robot.mouseMoveAt(fsPlugin.button.domNode, 500); robot.mouseClick({left: true}, 750); robot.sequence(d.getTestCallback(function(){ //Now check the state! doh.f(fsPlugin.isFullscreen, "isFullScreen"); var edPos = domGeom.position(editor.domNode); doh.isNot("absolute", domStyle.get(editor.domNode, "position")); //There may be a difference of a pixel or two depending on how the browser sizes //so check that the editor is real close to the expected size defined in the test doc. doh.t(edPos.h >= 400 && (edPos.h < 405), "Restored height check."); doh.t(edPos.w >= 800 && (edPos.w < 805), "Restored width check."); }), 2000); return d; }, tearDown: function(){ fsPlugin.button.set("checked", false); } } ]); doh.register("BorderContainer", [ function setUp(){ editor = registry.byId("editor1"); fsPlugin = getPlugin(editor); container = registry.byId("bc"); }, { name: "BorderContainer: Go Fullscreen, Reduce BorderContainer, Exit FullScreen, Validate Resize", timeout: 20000, runTest: function(){ var d = new doh.Deferred(); //Focus on the editor window robot.sequence(d.getTestErrback(function(){ winUtils.scrollIntoView(editor.domNode); editor.focus(); }), 500); var origEditorSize = domGeom.getMarginBox(editor.domNode); var origContainerSize = domGeom.getMarginBox(container.domNode); os = {w: origContainerSize.w, h: origContainerSize.h}; robot.sequence(d.getTestErrback(function(){ // Engage FullScreen Mode fsPlugin.button.set("checked", true); }), 1000); robot.sequence(d.getTestErrback(function(){ // Resize the container container.resize({w: 400, h: 400}); }), 1000); robot.sequence(d.getTestErrback(function(){ // Disengage FullScreen Mode fsPlugin.button.set("checked", false); }), 1000); robot.sequence(d.getTestCallback(function(){ // Now validate the editor resized when it returned since // the Container was resized. var curEditorSize = domGeom.getMarginBox(editor.domNode); var curContainerSize = domGeom.getMarginBox(container.domNode); var containerWdiff = origContainerSize.w - curContainerSize.w; var containerHdiff = origContainerSize.h - curContainerSize.h; var eWdiff = origEditorSize.w - curEditorSize.w; var eHdiff = origEditorSize.h - curEditorSize.h; doh.t(origEditorSize.w > curEditorSize.w, "Validating new width is less that the original size"); doh.t(origEditorSize.h > curEditorSize.h, "Validating new height is less that the original size"); doh.t((eWdiff < (containerWdiff + 5)) && (eWdiff > (containerWdiff - 5)), "Doing a rough check that the editor width resized roughly to the Container difference, eWdiff = " + eWdiff + ", containerWdiff = " + containerWdiff); doh.t((eHdiff < (containerHdiff + 5)) && (eHdiff > (containerHdiff - 5)), "Doing a rough check that the editor height resized roughly to the Container difference, eHdiff = " + eHdiff + ", containerHdiff = " + containerHdiff); }), 1000); return d; }, tearDown: function(){ fsPlugin.button.set("checked", false); if(container && os){container.resize(os);} } }, { name: "BorderContainer: Go Fullscreen, Increase BorderContainer, Exit FullScreen, Validate Resize", timeout: 20000, runTest: function(){ var d = new doh.Deferred(); //Focus on the editor window robot.sequence(d.getTestErrback(function(){ winUtils.scrollIntoView(editor.domNode); editor.focus(); }), 500); var origEditorSize = domGeom.getMarginBox(editor.domNode); var origContainerSize = domGeom.getMarginBox(container.domNode); os = {w: origContainerSize.w, h: origContainerSize.h}; robot.sequence(d.getTestErrback(function(){ // Engage FullScreen Mode fsPlugin.button.set("checked", true); }), 1000); robot.sequence(d.getTestErrback(function(){ // Resize the container container.resize({w: 800, h: 800}); }), 1000); robot.sequence(d.getTestErrback(function(){ // Disengage FullScreen Mode fsPlugin.button.set("checked", false); }), 1000); robot.sequence(d.getTestCallback(function(){ // Now validate the editor resized when it returned since // the Container was resized. var curEditorSize = domGeom.getMarginBox(editor.domNode); var curContainerSize = domGeom.getMarginBox(container.domNode); var containerWdiff = -(origContainerSize.w - curContainerSize.w); var containerHdiff = -(origContainerSize.h - curContainerSize.h); var eWdiff = -(origEditorSize.w - curEditorSize.w); var eHdiff = -(origEditorSize.h - curEditorSize.h); doh.t(origEditorSize.w < curEditorSize.w, "Validating new width is less that the original size"); doh.t(origEditorSize.h < curEditorSize.h, "Validating new height is less that the original size"); doh.t((eWdiff < (containerWdiff + 5)) && (eWdiff > (containerWdiff - 5)), "Doing a rough check that the editor width resized roughly to the Container difference, eWdiff = " + eWdiff + ", containerWdiff = " + containerWdiff); doh.t((eHdiff < (containerHdiff + 5)) && (eHdiff > (containerHdiff - 5)), "Doing a rough check that the editor height resized roughly to the Container difference, eHdiff = " + eHdiff + ", containerHdiff = " + containerHdiff); }), 1000); return d; }, tearDown: function(){ fsPlugin.button.set("checked", false); if(container && os){container.resize(os);} } } ]); doh.register("TabContainer", [ function setUp(){ editor = registry.byId("editor2"); fsPlugin = getPlugin(editor); container = registry.byId("tc"); }, { name: "TabContainer: Go Fullscreen, Reduce TabContainer, Exit FullScreen, Validate Resize", timeout: 20000, runTest: function(){ var d = new doh.Deferred(); //Focus on the editor window robot.sequence(d.getTestErrback(function(){ winUtils.scrollIntoView(editor.domNode); editor.focus(); }), 500); var origEditorSize = domGeom.getMarginBox(editor.domNode); var origContainerSize = domGeom.getMarginBox(container.domNode); os = {w: origContainerSize.w, h: origContainerSize.h}; robot.sequence(d.getTestErrback(function(){ // Engage FullScreen Mode fsPlugin.button.set("checked", true); }), 1000); robot.sequence(d.getTestErrback(function(){ // Resize the container container.resize({w: 400, h: 400}); }), 1000); robot.sequence(d.getTestErrback(function(){ // Disengage FullScreen Mode fsPlugin.button.set("checked", false); }), 1000); robot.sequence(d.getTestCallback(function(){ // Now validate the editor resized when it returned since // the Container was resized. var curEditorSize = domGeom.getMarginBox(editor.domNode); var curContainerSize = domGeom.getMarginBox(container.domNode); var containerWdiff = origContainerSize.w - curContainerSize.w; var containerHdiff = origContainerSize.h - curContainerSize.h; var eWdiff = origEditorSize.w - curEditorSize.w; var eHdiff = origEditorSize.h - curEditorSize.h; doh.t(origEditorSize.w > curEditorSize.w, "Validating new width is less that the original size"); doh.t(origEditorSize.h > curEditorSize.h, "Validating new height is less that the original size"); doh.t((eWdiff < (containerWdiff + 5)) && (eWdiff > (containerWdiff - 5)), "Doing a rough check that the editor width resized roughly to the Container difference, eWdiff = " + eWdiff + ", containerWdiff = " + containerWdiff); doh.t((eHdiff < (containerHdiff + 5)) && (eHdiff > (containerHdiff - 5)), "Doing a rough check that the editor height resized roughly to the Container difference, eHdiff = " + eHdiff + ", containerHdiff = " + containerHdiff); }), 1000); return d; }, tearDown: function(){ fsPlugin.button.set("checked", false); if(container && os){container.resize(os);} } }, { name: "TabContainer: Go Fullscreen, Increase TabContainer, Exit FullScreen, Validate Resize", timeout: 20000, runTest: function(){ var d = new doh.Deferred(); //Focus on the editor window robot.sequence(d.getTestErrback(function(){ winUtils.scrollIntoView(editor.domNode); editor.focus(); }), 500); var origEditorSize = domGeom.getMarginBox(editor.domNode); var origContainerSize = domGeom.getMarginBox(container.domNode); os = {w: origContainerSize.w, h: origContainerSize.h}; robot.sequence(d.getTestErrback(function(){ // Engage FullScreen Mode fsPlugin.button.set("checked", true); }), 1000); robot.sequence(d.getTestErrback(function(){ // Resize the container container.resize({w: 800, h: 800}); }), 1000); robot.sequence(d.getTestErrback(function(){ // Disengage FullScreen Mode fsPlugin.button.set("checked", false); }), 1000); robot.sequence(d.getTestCallback(function(){ // Now validate the editor resized when it returned since // the Container was resized. var curEditorSize = domGeom.getMarginBox(editor.domNode); var curContainerSize = domGeom.getMarginBox(container.domNode); var containerWdiff = -(origContainerSize.w - curContainerSize.w); var containerHdiff = -(origContainerSize.h - curContainerSize.h); var eWdiff = -(origEditorSize.w - curEditorSize.w); var eHdiff = -(origEditorSize.h - curEditorSize.h); doh.t(origEditorSize.w < curEditorSize.w, "Validating new width is less that the original size"); doh.t(origEditorSize.h < curEditorSize.h, "Validating new height is less that the original size"); doh.t((eWdiff < (containerWdiff + 5)) && (eWdiff > (containerWdiff - 5)), "Doing a rough check that the editor width resized roughly to the Container difference, eWdiff = " + eWdiff + ", containerWdiff = " + containerWdiff); doh.t((eHdiff < (containerHdiff + 5)) && (eHdiff > (containerHdiff - 5)), "Doing a rough check that the editor height resized roughly to the Container difference, eHdiff = " + eHdiff + ", containerHdiff = " + containerHdiff); }), 1000); return d; }, tearDown: function(){ fsPlugin.button.set("checked", false); if(container && os){container.resize(os);} } } ]); doh.register("AccordionContainer", [ function setUp(){ editor = registry.byId("editor3"); fsPlugin = getPlugin(editor); container = registry.byId("ac"); }, { name: "AccordionContainer: Go Fullscreen, Reduce AccordionContainer, Exit FullScreen, Validate Resize", timeout: 20000, runTest: function(){ var d = new doh.Deferred(); //Focus on the editor window robot.sequence(d.getTestErrback(function(){ winUtils.scrollIntoView(editor.domNode); editor.focus(); }), 500); var origEditorSize = domGeom.getMarginBox(editor.domNode); var origContainerSize = domGeom.getMarginBox(container.domNode); os = {w: origContainerSize.w, h: origContainerSize.h}; robot.sequence(d.getTestErrback(function(){ // Engage FullScreen Mode fsPlugin.button.set("checked", true); }), 1000); robot.sequence(d.getTestErrback(function(){ // Resize the container container.resize({w: 400, h: 400}); }), 1000); robot.sequence(d.getTestErrback(function(){ // Disengage FullScreen Mode fsPlugin.button.set("checked", false); }), 1000); robot.sequence(d.getTestCallback(function(){ // Now validate the editor resized when it returned since // the Container was resized. var curEditorSize = domGeom.getMarginBox(editor.domNode); var curContainerSize = domGeom.getMarginBox(container.domNode); var containerWdiff = origContainerSize.w - curContainerSize.w; var containerHdiff = origContainerSize.h - curContainerSize.h; var eWdiff = origEditorSize.w - curEditorSize.w; var eHdiff = origEditorSize.h - curEditorSize.h; doh.t(origEditorSize.w > curEditorSize.w, "Validating new width is less that the original size"); doh.t(origEditorSize.h > curEditorSize.h, "Validating new height is less that the original size"); doh.t((eWdiff < (containerWdiff + 5)) && (eWdiff > (containerWdiff - 5)), "Doing a rough check that the editor width resized roughly to the Container difference, eWdiff = " + eWdiff + ", containerWdiff = " + containerWdiff); doh.t((eHdiff < (containerHdiff + 5)) && (eHdiff > (containerHdiff - 5)), "Doing a rough check that the editor height resized roughly to the Container difference, eHdiff = " + eHdiff + ", containerHdiff = " + containerHdiff); }), 1000); return d; }, tearDown: function(){ fsPlugin.button.set("checked", false); if(container && os){container.resize(os);} } }, { name: "AccordionContainer: Go Fullscreen, Increase AccordionContainer, Exit FullScreen, Validate Resize", timeout: 20000, runTest: function(){ var d = new doh.Deferred(); //Focus on the editor window robot.sequence(d.getTestErrback(function(){ winUtils.scrollIntoView(editor.domNode); editor.focus(); }), 500); var origEditorSize = domGeom.getMarginBox(editor.domNode); var origContainerSize = domGeom.getMarginBox(container.domNode); os = {w: origContainerSize.w, h: origContainerSize.h}; robot.sequence(d.getTestErrback(function(){ // Engage FullScreen Mode fsPlugin.button.set("checked", true); }), 1000); robot.sequence(d.getTestErrback(function(){ // Resize the container container.resize({w: 800, h: 800}); }), 1000); robot.sequence(d.getTestErrback(function(){ // Disengage FullScreen Mode fsPlugin.button.set("checked", false); }), 1000); robot.sequence(d.getTestCallback(function(){ // Now validate the editor resized when it returned since // the Container was resized. var curEditorSize = domGeom.getMarginBox(editor.domNode); var curContainerSize = domGeom.getMarginBox(container.domNode); var containerWdiff = -(origContainerSize.w - curContainerSize.w); var containerHdiff = -(origContainerSize.h - curContainerSize.h); var eWdiff = -(origEditorSize.w - curEditorSize.w); var eHdiff = -(origEditorSize.h - curEditorSize.h); doh.t(origEditorSize.w < curEditorSize.w, "Validating new width is less that the original size"); doh.t(origEditorSize.h < curEditorSize.h, "Validating new height is less that the original size"); doh.t((eWdiff < (containerWdiff + 5)) && (eWdiff > (containerWdiff - 5)), "Doing a rough check that the editor width resized roughly to the Container difference, eWdiff = " + eWdiff + ", containerWdiff = " + containerWdiff); doh.t((eHdiff < (containerHdiff + 5)) && (eHdiff > (containerHdiff - 5)), "Doing a rough check that the editor height resized roughly to the Container difference, eHdiff = " + eHdiff + ", containerHdiff = " + containerHdiff); }), 1000); return d; }, tearDown: function(){ fsPlugin.button.set("checked", false); if(container && os){container.resize(os);} } } ]); doh.register("StackContainer", [ function setUp(){ editor = registry.byId("editor4"); fsPlugin = getPlugin(editor); container = registry.byId("sc"); }, { name: "StackContainer: Go Fullscreen, Reduce StackContainer, Exit FullScreen, Validate Resize", timeout: 20000, runTest: function(){ var d = new doh.Deferred(); //Focus on the editor window robot.sequence(d.getTestErrback(function(){ winUtils.scrollIntoView(editor.domNode); editor.focus(); }), 500); var origEditorSize = domGeom.getMarginBox(editor.domNode); var origContainerSize = domGeom.getMarginBox(container.domNode); os = {w: origContainerSize.w, h: origContainerSize.h}; robot.sequence(d.getTestErrback(function(){ // Engage FullScreen Mode fsPlugin.button.set("checked", true); }), 1000); robot.sequence(d.getTestErrback(function(){ // Resize the container container.resize({w: 400, h: 400}); }), 1000); robot.sequence(d.getTestErrback(function(){ // Disengage FullScreen Mode fsPlugin.button.set("checked", false); }), 1000); robot.sequence(d.getTestCallback(function(){ // Now validate the editor resized when it returned since // the Container was resized. var curEditorSize = domGeom.getMarginBox(editor.domNode); var curContainerSize = domGeom.getMarginBox(container.domNode); var containerWdiff = origContainerSize.w - curContainerSize.w; var containerHdiff = origContainerSize.h - curContainerSize.h; var eWdiff = origEditorSize.w - curEditorSize.w; var eHdiff = origEditorSize.h - curEditorSize.h; doh.t(origEditorSize.w > curEditorSize.w, "Validating new width is less that the original size"); doh.t(origEditorSize.h > curEditorSize.h, "Validating new height is less that the original size"); doh.t((eWdiff < (containerWdiff + 5)) && (eWdiff > (containerWdiff - 5)), "Doing a rough check that the editor width resized roughly to the Container difference, eWdiff = " + eWdiff + ", containerWdiff = " + containerWdiff); doh.t((eHdiff < (containerHdiff + 5)) && (eHdiff > (containerHdiff - 5)), "Doing a rough check that the editor height resized roughly to the Container difference, eHdiff = " + eHdiff + ", containerHdiff = " + containerHdiff); }), 1000); return d; }, tearDown: function(){ fsPlugin.button.set("checked", false); if(container && os){container.resize(os);} } }, { name: "StackContainer: Go Fullscreen, Increase StackContainer, Exit FullScreen, Validate Resize", timeout: 20000, runTest: function(){ var d = new doh.Deferred(); //Focus on the editor window robot.sequence(d.getTestErrback(function(){ winUtils.scrollIntoView(editor.domNode); editor.focus(); }), 500); var origEditorSize = domGeom.getMarginBox(editor.domNode); var origContainerSize = domGeom.getMarginBox(container.domNode); os = {w: origContainerSize.w, h: origContainerSize.h}; robot.sequence(d.getTestErrback(function(){ // Engage FullScreen Mode fsPlugin.button.set("checked", true); }), 1000); robot.sequence(d.getTestErrback(function(){ // Resize the container container.resize({w: 800, h: 800}); }), 1000); robot.sequence(d.getTestErrback(function(){ // Disengage FullScreen Mode fsPlugin.button.set("checked", false); }), 1000); robot.sequence(d.getTestCallback(function(){ // Now validate the editor resized when it returned since // the Container was resized. var curEditorSize = domGeom.getMarginBox(editor.domNode); var curContainerSize = domGeom.getMarginBox(container.domNode); var containerWdiff = -(origContainerSize.w - curContainerSize.w); var containerHdiff = -(origContainerSize.h - curContainerSize.h); var eWdiff = -(origEditorSize.w - curEditorSize.w); var eHdiff = -(origEditorSize.h - curEditorSize.h); doh.t(origEditorSize.w < curEditorSize.w, "Validating new width is less that the original size"); doh.t(origEditorSize.h < curEditorSize.h, "Validating new height is less that the original size"); doh.t((eWdiff < (containerWdiff + 5)) && (eWdiff > (containerWdiff - 5)), "Doing a rough check that the editor width resized roughly to the Container difference, eWdiff = " + eWdiff + ", containerWdiff = " + containerWdiff); doh.t((eHdiff < (containerHdiff + 5)) && (eHdiff > (containerHdiff - 5)), "Doing a rough check that the editor height resized roughly to the Container difference, eHdiff = " + eHdiff + ", containerHdiff = " + containerHdiff); }), 1000); return d; }, tearDown: function(){ fsPlugin.button.set("checked", false); if(container && os){container.resize(os);} } } ]); doh.run(); }); </script> </head> </html>