| 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 FullScreen 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/dom-geometry", "dojo/dom-style", "dojo/keys", "dojo/window", |
| 17 | "dijit/tests/helpers", "dojo/domReady!" |
| 18 | ], function(doh, robot, domGeom, domStyle, keys, winUtils, helpers){ |
| 19 | |
| 20 | robot.initRobot('../test_FullScreen.html'); |
| 21 | |
| 22 | function getPlugin(/*Editor*/ editor){ |
| 23 | // summary: |
| 24 | // Return full screen plugin for specified editor |
| 25 | var edPlugins = editor._plugins, i; |
| 26 | for(i = 0; i < edPlugins.length; i++){ |
| 27 | var p = edPlugins[i], fsPlugin; |
| 28 | if(p.declaredClass === "dijit._editor.plugins.FullScreen"){ |
| 29 | p.button.set("checked", false); |
| 30 | return p; |
| 31 | } |
| 32 | } |
| 33 | throw new Error("didn't find plugin"); |
| 34 | } |
| 35 | |
| 36 | var registry; |
| 37 | doh.register("setup", [ |
| 38 | { |
| 39 | name: "wait for editors to load", |
| 40 | timeout: 5000, |
| 41 | runTest: helpers.waitForLoad |
| 42 | }, |
| 43 | function setVars(){ |
| 44 | registry = robot.window.require("dijit/registry"); |
| 45 | } |
| 46 | ]); |
| 47 | |
| 48 | doh.register("General", [ |
| 49 | function setUp(){ |
| 50 | editor = registry.byId("editor0"); |
| 51 | fsPlugin = getPlugin(editor); |
| 52 | }, |
| 53 | { |
| 54 | name: "Keyboard: Go to Fullscreen (CTRL-SHIFT-F11)", |
| 55 | timeout: 20000, |
| 56 | runTest: function(){ |
| 57 | var d = new doh.Deferred(); |
| 58 | |
| 59 | //Focus on the editor window |
| 60 | robot.sequence(d.getTestErrback(function(){ |
| 61 | winUtils.scrollIntoView(editor.domNode); |
| 62 | editor.focus(); |
| 63 | }), 500); |
| 64 | |
| 65 | robot.keyPress(keys.F11, 500, {ctrl:true,shift:true}); |
| 66 | |
| 67 | robot.sequence(d.getTestCallback(function(){ |
| 68 | //Now check the state! |
| 69 | doh.t(fsPlugin.isFullscreen, "isFullScreen"); |
| 70 | var vp = winUtils.getBox(); |
| 71 | var edPos = domGeom.position(editor.domNode); |
| 72 | doh.is("absolute", domStyle.get(editor.domNode, "position")); |
| 73 | doh.is("0", domStyle.get(editor.domNode, "top"), "Top position check"); |
| 74 | doh.is("0", domStyle.get(editor.domNode, "left"), "Left position check"); |
| 75 | |
| 76 | //There may be a difference of a pixel or two, so check that the editor is real close |
| 77 | //to the viewport size. |
| 78 | doh.t(edPos.h >= vp.h && edPos.h < (vp.h + 5), |
| 79 | "Height check, ed = " + edPos.h + ", vp = " + vp.h); |
| 80 | doh.t(Math.ceil(edPos.w) >= vp.w && Math.floor(edPos.w) < (vp.w + 5), |
| 81 | "Width check, ed = " + edPos.w + ", vp = " + vp.w); |
| 82 | }), 1000); |
| 83 | |
| 84 | return d; |
| 85 | }, |
| 86 | tearDown: function(){ |
| 87 | fsPlugin.button.set("checked", false); |
| 88 | } |
| 89 | }, |
| 90 | { |
| 91 | name: "Keyboard: Go to fullscreen and back", |
| 92 | timeout: 20000, |
| 93 | runTest: function(){ |
| 94 | var d = new doh.Deferred(); |
| 95 | |
| 96 | //Focus on the editor window |
| 97 | robot.sequence(d.getTestErrback(function(){ |
| 98 | winUtils.scrollIntoView(editor.domNode); |
| 99 | editor.focus(); |
| 100 | }), 500); |
| 101 | |
| 102 | robot.keyPress(keys.F11, 500, {ctrl:true,shift:true}); |
| 103 | robot.keyPress(keys.F11, 1000, {ctrl:true,shift:true}); |
| 104 | |
| 105 | robot.sequence(d.getTestCallback(function(){ |
| 106 | //Now check the state! |
| 107 | doh.f(fsPlugin.isFullscreen, "isFullScreen"); |
| 108 | var edPos = domGeom.position(editor.domNode); |
| 109 | doh.isNot("absolute", domStyle.get(editor.domNode, "position")); |
| 110 | |
| 111 | //There may be a difference of a pixel or two depending on how the browser sizes |
| 112 | //so check that the editor is real close to the expected size defined in the test doc. |
| 113 | doh.t(edPos.h >= 400 && (edPos.h < 405), "Restored height check."); |
| 114 | doh.t(edPos.w >= 800 && (edPos.w < 805), "Restored width check."); |
| 115 | }), 2000); |
| 116 | |
| 117 | return d; |
| 118 | }, |
| 119 | tearDown: function(){ |
| 120 | fsPlugin.button.set("checked", false); |
| 121 | } |
| 122 | }, |
| 123 | { |
| 124 | name: "Mouse Click: Go to Fullscreen", |
| 125 | timeout: 20000, |
| 126 | runTest: function(){ |
| 127 | var d = new doh.Deferred(); |
| 128 | |
| 129 | //Focus on the editor window |
| 130 | robot.sequence(d.getTestErrback(function(){ |
| 131 | winUtils.scrollIntoView(editor.domNode); |
| 132 | editor.focus(); |
| 133 | }), 500); |
| 134 | |
| 135 | robot.mouseMoveAt(fsPlugin.button.domNode, 500); |
| 136 | robot.mouseClick({left: true}, 750); |
| 137 | |
| 138 | robot.sequence(d.getTestCallback(function(){ |
| 139 | //Now check the state! |
| 140 | doh.t(fsPlugin.isFullscreen, "isFullScreen"); |
| 141 | var vp = winUtils.getBox(); |
| 142 | var edPos = domGeom.position(editor.domNode); |
| 143 | doh.is("absolute", domStyle.get(editor.domNode, "position")); |
| 144 | doh.is("0", domStyle.get(editor.domNode, "top"), "Top position check"); |
| 145 | doh.is("0", domStyle.get(editor.domNode, "left"), "Left position check"); |
| 146 | |
| 147 | //There may be a difference of a pixel or two, so check that the editor is real close |
| 148 | //to the viewport size. |
| 149 | doh.t(edPos.h >= vp.h && edPos.h < (vp.h + 5), "Height check"); |
| 150 | doh.t(Math.ceil(edPos.w) >= vp.w && Math.floor(edPos.w) < (vp.w + 5), |
| 151 | "Width check, ed = " + edPos.w + ", vp = " + vp.w); |
| 152 | }), 1000); |
| 153 | |
| 154 | return d; |
| 155 | }, |
| 156 | tearDown: function(){ |
| 157 | fsPlugin.button.set("checked", false); |
| 158 | } |
| 159 | }, |
| 160 | { |
| 161 | name: "Mouse Click: Go to fullscreen and back", |
| 162 | timeout: 20000, |
| 163 | runTest: function(){ |
| 164 | var d = new doh.Deferred(); |
| 165 | |
| 166 | //Focus on the editor window |
| 167 | robot.sequence(d.getTestErrback(function(){ |
| 168 | winUtils.scrollIntoView(editor.domNode); |
| 169 | editor.focus(); |
| 170 | }), 500); |
| 171 | |
| 172 | //Click it, then click it again! |
| 173 | robot.mouseMoveAt(fsPlugin.button.domNode, 500); |
| 174 | robot.mouseClick({left: true}, 750); |
| 175 | robot.mouseMoveAt(fsPlugin.button.domNode, 500); |
| 176 | robot.mouseClick({left: true}, 750); |
| 177 | |
| 178 | robot.sequence(d.getTestCallback(function(){ |
| 179 | //Now check the state! |
| 180 | doh.f(fsPlugin.isFullscreen, "isFullScreen"); |
| 181 | var edPos = domGeom.position(editor.domNode); |
| 182 | doh.isNot("absolute", domStyle.get(editor.domNode, "position")); |
| 183 | |
| 184 | //There may be a difference of a pixel or two depending on how the browser sizes |
| 185 | //so check that the editor is real close to the expected size defined in the test doc. |
| 186 | doh.t(edPos.h >= 400 && (edPos.h < 405), "Restored height check."); |
| 187 | doh.t(edPos.w >= 800 && (edPos.w < 805), "Restored width check."); |
| 188 | }), 2000); |
| 189 | |
| 190 | return d; |
| 191 | }, |
| 192 | tearDown: function(){ |
| 193 | fsPlugin.button.set("checked", false); |
| 194 | } |
| 195 | } |
| 196 | ]); |
| 197 | |
| 198 | doh.register("BorderContainer", [ |
| 199 | function setUp(){ |
| 200 | editor = registry.byId("editor1"); |
| 201 | fsPlugin = getPlugin(editor); |
| 202 | container = registry.byId("bc"); |
| 203 | }, |
| 204 | |
| 205 | { |
| 206 | name: "BorderContainer: Go Fullscreen, Reduce BorderContainer, Exit FullScreen, Validate Resize", |
| 207 | timeout: 20000, |
| 208 | runTest: function(){ |
| 209 | var d = new doh.Deferred(); |
| 210 | |
| 211 | //Focus on the editor window |
| 212 | robot.sequence(d.getTestErrback(function(){ |
| 213 | winUtils.scrollIntoView(editor.domNode); |
| 214 | editor.focus(); |
| 215 | }), 500); |
| 216 | |
| 217 | var origEditorSize = domGeom.getMarginBox(editor.domNode); |
| 218 | var origContainerSize = domGeom.getMarginBox(container.domNode); |
| 219 | os = {w: origContainerSize.w, h: origContainerSize.h}; |
| 220 | |
| 221 | robot.sequence(d.getTestErrback(function(){ |
| 222 | // Engage FullScreen Mode |
| 223 | fsPlugin.button.set("checked", true); |
| 224 | }), 1000); |
| 225 | robot.sequence(d.getTestErrback(function(){ |
| 226 | // Resize the container |
| 227 | container.resize({w: 400, h: 400}); |
| 228 | }), 1000); |
| 229 | robot.sequence(d.getTestErrback(function(){ |
| 230 | // Disengage FullScreen Mode |
| 231 | fsPlugin.button.set("checked", false); |
| 232 | }), 1000); |
| 233 | robot.sequence(d.getTestCallback(function(){ |
| 234 | // Now validate the editor resized when it returned since |
| 235 | // the Container was resized. |
| 236 | var curEditorSize = domGeom.getMarginBox(editor.domNode); |
| 237 | var curContainerSize = domGeom.getMarginBox(container.domNode); |
| 238 | var containerWdiff = origContainerSize.w - curContainerSize.w; |
| 239 | var containerHdiff = origContainerSize.h - curContainerSize.h; |
| 240 | var eWdiff = origEditorSize.w - curEditorSize.w; |
| 241 | var eHdiff = origEditorSize.h - curEditorSize.h; |
| 242 | |
| 243 | doh.t(origEditorSize.w > curEditorSize.w, "Validating new width is less that the original size"); |
| 244 | doh.t(origEditorSize.h > curEditorSize.h, "Validating new height is less that the original size"); |
| 245 | 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); |
| 246 | 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); |
| 247 | }), 1000); |
| 248 | |
| 249 | return d; |
| 250 | }, |
| 251 | tearDown: function(){ |
| 252 | fsPlugin.button.set("checked", false); |
| 253 | if(container && os){container.resize(os);} |
| 254 | } |
| 255 | }, |
| 256 | { |
| 257 | name: "BorderContainer: Go Fullscreen, Increase BorderContainer, Exit FullScreen, Validate Resize", |
| 258 | timeout: 20000, |
| 259 | runTest: function(){ |
| 260 | var d = new doh.Deferred(); |
| 261 | |
| 262 | //Focus on the editor window |
| 263 | robot.sequence(d.getTestErrback(function(){ |
| 264 | winUtils.scrollIntoView(editor.domNode); |
| 265 | editor.focus(); |
| 266 | }), 500); |
| 267 | |
| 268 | var origEditorSize = domGeom.getMarginBox(editor.domNode); |
| 269 | var origContainerSize = domGeom.getMarginBox(container.domNode); |
| 270 | os = {w: origContainerSize.w, h: origContainerSize.h}; |
| 271 | |
| 272 | robot.sequence(d.getTestErrback(function(){ |
| 273 | // Engage FullScreen Mode |
| 274 | fsPlugin.button.set("checked", true); |
| 275 | }), 1000); |
| 276 | robot.sequence(d.getTestErrback(function(){ |
| 277 | // Resize the container |
| 278 | container.resize({w: 800, h: 800}); |
| 279 | }), 1000); |
| 280 | robot.sequence(d.getTestErrback(function(){ |
| 281 | // Disengage FullScreen Mode |
| 282 | fsPlugin.button.set("checked", false); |
| 283 | }), 1000); |
| 284 | robot.sequence(d.getTestCallback(function(){ |
| 285 | // Now validate the editor resized when it returned since |
| 286 | // the Container was resized. |
| 287 | var curEditorSize = domGeom.getMarginBox(editor.domNode); |
| 288 | var curContainerSize = domGeom.getMarginBox(container.domNode); |
| 289 | var containerWdiff = -(origContainerSize.w - curContainerSize.w); |
| 290 | var containerHdiff = -(origContainerSize.h - curContainerSize.h); |
| 291 | var eWdiff = -(origEditorSize.w - curEditorSize.w); |
| 292 | var eHdiff = -(origEditorSize.h - curEditorSize.h); |
| 293 | |
| 294 | doh.t(origEditorSize.w < curEditorSize.w, "Validating new width is less that the original size"); |
| 295 | doh.t(origEditorSize.h < curEditorSize.h, "Validating new height is less that the original size"); |
| 296 | 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); |
| 297 | 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); |
| 298 | }), 1000); |
| 299 | |
| 300 | return d; |
| 301 | }, |
| 302 | tearDown: function(){ |
| 303 | fsPlugin.button.set("checked", false); |
| 304 | if(container && os){container.resize(os);} |
| 305 | } |
| 306 | } |
| 307 | ]); |
| 308 | |
| 309 | doh.register("TabContainer", [ |
| 310 | function setUp(){ |
| 311 | editor = registry.byId("editor2"); |
| 312 | fsPlugin = getPlugin(editor); |
| 313 | container = registry.byId("tc"); |
| 314 | }, |
| 315 | |
| 316 | { |
| 317 | name: "TabContainer: Go Fullscreen, Reduce TabContainer, Exit FullScreen, Validate Resize", |
| 318 | timeout: 20000, |
| 319 | runTest: function(){ |
| 320 | var d = new doh.Deferred(); |
| 321 | |
| 322 | //Focus on the editor window |
| 323 | robot.sequence(d.getTestErrback(function(){ |
| 324 | winUtils.scrollIntoView(editor.domNode); |
| 325 | editor.focus(); |
| 326 | }), 500); |
| 327 | |
| 328 | var origEditorSize = domGeom.getMarginBox(editor.domNode); |
| 329 | var origContainerSize = domGeom.getMarginBox(container.domNode); |
| 330 | os = {w: origContainerSize.w, h: origContainerSize.h}; |
| 331 | |
| 332 | robot.sequence(d.getTestErrback(function(){ |
| 333 | // Engage FullScreen Mode |
| 334 | fsPlugin.button.set("checked", true); |
| 335 | }), 1000); |
| 336 | robot.sequence(d.getTestErrback(function(){ |
| 337 | // Resize the container |
| 338 | container.resize({w: 400, h: 400}); |
| 339 | }), 1000); |
| 340 | robot.sequence(d.getTestErrback(function(){ |
| 341 | // Disengage FullScreen Mode |
| 342 | fsPlugin.button.set("checked", false); |
| 343 | }), 1000); |
| 344 | robot.sequence(d.getTestCallback(function(){ |
| 345 | // Now validate the editor resized when it returned since |
| 346 | // the Container was resized. |
| 347 | var curEditorSize = domGeom.getMarginBox(editor.domNode); |
| 348 | var curContainerSize = domGeom.getMarginBox(container.domNode); |
| 349 | var containerWdiff = origContainerSize.w - curContainerSize.w; |
| 350 | var containerHdiff = origContainerSize.h - curContainerSize.h; |
| 351 | var eWdiff = origEditorSize.w - curEditorSize.w; |
| 352 | var eHdiff = origEditorSize.h - curEditorSize.h; |
| 353 | |
| 354 | doh.t(origEditorSize.w > curEditorSize.w, "Validating new width is less that the original size"); |
| 355 | doh.t(origEditorSize.h > curEditorSize.h, "Validating new height is less that the original size"); |
| 356 | 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); |
| 357 | 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); |
| 358 | }), 1000); |
| 359 | |
| 360 | return d; |
| 361 | }, |
| 362 | tearDown: function(){ |
| 363 | fsPlugin.button.set("checked", false); |
| 364 | if(container && os){container.resize(os);} |
| 365 | } |
| 366 | }, |
| 367 | { |
| 368 | name: "TabContainer: Go Fullscreen, Increase TabContainer, Exit FullScreen, Validate Resize", |
| 369 | timeout: 20000, |
| 370 | runTest: function(){ |
| 371 | var d = new doh.Deferred(); |
| 372 | |
| 373 | //Focus on the editor window |
| 374 | robot.sequence(d.getTestErrback(function(){ |
| 375 | winUtils.scrollIntoView(editor.domNode); |
| 376 | editor.focus(); |
| 377 | }), 500); |
| 378 | |
| 379 | var origEditorSize = domGeom.getMarginBox(editor.domNode); |
| 380 | var origContainerSize = domGeom.getMarginBox(container.domNode); |
| 381 | os = {w: origContainerSize.w, h: origContainerSize.h}; |
| 382 | |
| 383 | robot.sequence(d.getTestErrback(function(){ |
| 384 | // Engage FullScreen Mode |
| 385 | fsPlugin.button.set("checked", true); |
| 386 | }), 1000); |
| 387 | robot.sequence(d.getTestErrback(function(){ |
| 388 | // Resize the container |
| 389 | container.resize({w: 800, h: 800}); |
| 390 | }), 1000); |
| 391 | robot.sequence(d.getTestErrback(function(){ |
| 392 | // Disengage FullScreen Mode |
| 393 | fsPlugin.button.set("checked", false); |
| 394 | }), 1000); |
| 395 | robot.sequence(d.getTestCallback(function(){ |
| 396 | // Now validate the editor resized when it returned since |
| 397 | // the Container was resized. |
| 398 | var curEditorSize = domGeom.getMarginBox(editor.domNode); |
| 399 | var curContainerSize = domGeom.getMarginBox(container.domNode); |
| 400 | var containerWdiff = -(origContainerSize.w - curContainerSize.w); |
| 401 | var containerHdiff = -(origContainerSize.h - curContainerSize.h); |
| 402 | var eWdiff = -(origEditorSize.w - curEditorSize.w); |
| 403 | var eHdiff = -(origEditorSize.h - curEditorSize.h); |
| 404 | |
| 405 | doh.t(origEditorSize.w < curEditorSize.w, "Validating new width is less that the original size"); |
| 406 | doh.t(origEditorSize.h < curEditorSize.h, "Validating new height is less that the original size"); |
| 407 | 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); |
| 408 | 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); |
| 409 | }), 1000); |
| 410 | |
| 411 | return d; |
| 412 | }, |
| 413 | tearDown: function(){ |
| 414 | fsPlugin.button.set("checked", false); |
| 415 | if(container && os){container.resize(os);} |
| 416 | } |
| 417 | } |
| 418 | ]); |
| 419 | |
| 420 | doh.register("AccordionContainer", [ |
| 421 | function setUp(){ |
| 422 | editor = registry.byId("editor3"); |
| 423 | fsPlugin = getPlugin(editor); |
| 424 | container = registry.byId("ac"); |
| 425 | }, |
| 426 | |
| 427 | { |
| 428 | name: "AccordionContainer: Go Fullscreen, Reduce AccordionContainer, Exit FullScreen, Validate Resize", |
| 429 | timeout: 20000, |
| 430 | runTest: function(){ |
| 431 | var d = new doh.Deferred(); |
| 432 | |
| 433 | //Focus on the editor window |
| 434 | robot.sequence(d.getTestErrback(function(){ |
| 435 | winUtils.scrollIntoView(editor.domNode); |
| 436 | editor.focus(); |
| 437 | }), 500); |
| 438 | |
| 439 | var origEditorSize = domGeom.getMarginBox(editor.domNode); |
| 440 | var origContainerSize = domGeom.getMarginBox(container.domNode); |
| 441 | os = {w: origContainerSize.w, h: origContainerSize.h}; |
| 442 | |
| 443 | robot.sequence(d.getTestErrback(function(){ |
| 444 | // Engage FullScreen Mode |
| 445 | fsPlugin.button.set("checked", true); |
| 446 | }), 1000); |
| 447 | robot.sequence(d.getTestErrback(function(){ |
| 448 | // Resize the container |
| 449 | container.resize({w: 400, h: 400}); |
| 450 | }), 1000); |
| 451 | robot.sequence(d.getTestErrback(function(){ |
| 452 | // Disengage FullScreen Mode |
| 453 | fsPlugin.button.set("checked", false); |
| 454 | }), 1000); |
| 455 | robot.sequence(d.getTestCallback(function(){ |
| 456 | // Now validate the editor resized when it returned since |
| 457 | // the Container was resized. |
| 458 | var curEditorSize = domGeom.getMarginBox(editor.domNode); |
| 459 | var curContainerSize = domGeom.getMarginBox(container.domNode); |
| 460 | var containerWdiff = origContainerSize.w - curContainerSize.w; |
| 461 | var containerHdiff = origContainerSize.h - curContainerSize.h; |
| 462 | var eWdiff = origEditorSize.w - curEditorSize.w; |
| 463 | var eHdiff = origEditorSize.h - curEditorSize.h; |
| 464 | |
| 465 | doh.t(origEditorSize.w > curEditorSize.w, "Validating new width is less that the original size"); |
| 466 | doh.t(origEditorSize.h > curEditorSize.h, "Validating new height is less that the original size"); |
| 467 | 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); |
| 468 | 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); |
| 469 | }), 1000); |
| 470 | |
| 471 | return d; |
| 472 | }, |
| 473 | tearDown: function(){ |
| 474 | fsPlugin.button.set("checked", false); |
| 475 | if(container && os){container.resize(os);} |
| 476 | } |
| 477 | }, |
| 478 | { |
| 479 | name: "AccordionContainer: Go Fullscreen, Increase AccordionContainer, Exit FullScreen, Validate Resize", |
| 480 | timeout: 20000, |
| 481 | runTest: function(){ |
| 482 | var d = new doh.Deferred(); |
| 483 | |
| 484 | //Focus on the editor window |
| 485 | robot.sequence(d.getTestErrback(function(){ |
| 486 | winUtils.scrollIntoView(editor.domNode); |
| 487 | editor.focus(); |
| 488 | }), 500); |
| 489 | |
| 490 | var origEditorSize = domGeom.getMarginBox(editor.domNode); |
| 491 | var origContainerSize = domGeom.getMarginBox(container.domNode); |
| 492 | os = {w: origContainerSize.w, h: origContainerSize.h}; |
| 493 | |
| 494 | robot.sequence(d.getTestErrback(function(){ |
| 495 | // Engage FullScreen Mode |
| 496 | fsPlugin.button.set("checked", true); |
| 497 | }), 1000); |
| 498 | robot.sequence(d.getTestErrback(function(){ |
| 499 | // Resize the container |
| 500 | container.resize({w: 800, h: 800}); |
| 501 | }), 1000); |
| 502 | robot.sequence(d.getTestErrback(function(){ |
| 503 | // Disengage FullScreen Mode |
| 504 | fsPlugin.button.set("checked", false); |
| 505 | }), 1000); |
| 506 | robot.sequence(d.getTestCallback(function(){ |
| 507 | // Now validate the editor resized when it returned since |
| 508 | // the Container was resized. |
| 509 | var curEditorSize = domGeom.getMarginBox(editor.domNode); |
| 510 | var curContainerSize = domGeom.getMarginBox(container.domNode); |
| 511 | var containerWdiff = -(origContainerSize.w - curContainerSize.w); |
| 512 | var containerHdiff = -(origContainerSize.h - curContainerSize.h); |
| 513 | var eWdiff = -(origEditorSize.w - curEditorSize.w); |
| 514 | var eHdiff = -(origEditorSize.h - curEditorSize.h); |
| 515 | |
| 516 | doh.t(origEditorSize.w < curEditorSize.w, "Validating new width is less that the original size"); |
| 517 | doh.t(origEditorSize.h < curEditorSize.h, "Validating new height is less that the original size"); |
| 518 | 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); |
| 519 | 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); |
| 520 | }), 1000); |
| 521 | |
| 522 | return d; |
| 523 | }, |
| 524 | tearDown: function(){ |
| 525 | fsPlugin.button.set("checked", false); |
| 526 | if(container && os){container.resize(os);} |
| 527 | } |
| 528 | } |
| 529 | ]); |
| 530 | |
| 531 | doh.register("StackContainer", [ |
| 532 | function setUp(){ |
| 533 | editor = registry.byId("editor4"); |
| 534 | fsPlugin = getPlugin(editor); |
| 535 | container = registry.byId("sc"); |
| 536 | }, |
| 537 | |
| 538 | { |
| 539 | name: "StackContainer: Go Fullscreen, Reduce StackContainer, Exit FullScreen, Validate Resize", |
| 540 | timeout: 20000, |
| 541 | runTest: function(){ |
| 542 | var d = new doh.Deferred(); |
| 543 | |
| 544 | //Focus on the editor window |
| 545 | robot.sequence(d.getTestErrback(function(){ |
| 546 | winUtils.scrollIntoView(editor.domNode); |
| 547 | editor.focus(); |
| 548 | }), 500); |
| 549 | |
| 550 | var origEditorSize = domGeom.getMarginBox(editor.domNode); |
| 551 | var origContainerSize = domGeom.getMarginBox(container.domNode); |
| 552 | os = {w: origContainerSize.w, h: origContainerSize.h}; |
| 553 | |
| 554 | robot.sequence(d.getTestErrback(function(){ |
| 555 | // Engage FullScreen Mode |
| 556 | fsPlugin.button.set("checked", true); |
| 557 | }), 1000); |
| 558 | robot.sequence(d.getTestErrback(function(){ |
| 559 | // Resize the container |
| 560 | container.resize({w: 400, h: 400}); |
| 561 | }), 1000); |
| 562 | robot.sequence(d.getTestErrback(function(){ |
| 563 | // Disengage FullScreen Mode |
| 564 | fsPlugin.button.set("checked", false); |
| 565 | }), 1000); |
| 566 | robot.sequence(d.getTestCallback(function(){ |
| 567 | // Now validate the editor resized when it returned since |
| 568 | // the Container was resized. |
| 569 | var curEditorSize = domGeom.getMarginBox(editor.domNode); |
| 570 | var curContainerSize = domGeom.getMarginBox(container.domNode); |
| 571 | var containerWdiff = origContainerSize.w - curContainerSize.w; |
| 572 | var containerHdiff = origContainerSize.h - curContainerSize.h; |
| 573 | var eWdiff = origEditorSize.w - curEditorSize.w; |
| 574 | var eHdiff = origEditorSize.h - curEditorSize.h; |
| 575 | |
| 576 | doh.t(origEditorSize.w > curEditorSize.w, "Validating new width is less that the original size"); |
| 577 | doh.t(origEditorSize.h > curEditorSize.h, "Validating new height is less that the original size"); |
| 578 | 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); |
| 579 | 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); |
| 580 | }), 1000); |
| 581 | |
| 582 | return d; |
| 583 | }, |
| 584 | tearDown: function(){ |
| 585 | fsPlugin.button.set("checked", false); |
| 586 | if(container && os){container.resize(os);} |
| 587 | } |
| 588 | }, |
| 589 | { |
| 590 | name: "StackContainer: Go Fullscreen, Increase StackContainer, Exit FullScreen, Validate Resize", |
| 591 | timeout: 20000, |
| 592 | runTest: function(){ |
| 593 | var d = new doh.Deferred(); |
| 594 | |
| 595 | //Focus on the editor window |
| 596 | robot.sequence(d.getTestErrback(function(){ |
| 597 | winUtils.scrollIntoView(editor.domNode); |
| 598 | editor.focus(); |
| 599 | }), 500); |
| 600 | |
| 601 | var origEditorSize = domGeom.getMarginBox(editor.domNode); |
| 602 | var origContainerSize = domGeom.getMarginBox(container.domNode); |
| 603 | os = {w: origContainerSize.w, h: origContainerSize.h}; |
| 604 | |
| 605 | robot.sequence(d.getTestErrback(function(){ |
| 606 | // Engage FullScreen Mode |
| 607 | fsPlugin.button.set("checked", true); |
| 608 | }), 1000); |
| 609 | robot.sequence(d.getTestErrback(function(){ |
| 610 | // Resize the container |
| 611 | container.resize({w: 800, h: 800}); |
| 612 | }), 1000); |
| 613 | robot.sequence(d.getTestErrback(function(){ |
| 614 | // Disengage FullScreen Mode |
| 615 | fsPlugin.button.set("checked", false); |
| 616 | }), 1000); |
| 617 | robot.sequence(d.getTestCallback(function(){ |
| 618 | // Now validate the editor resized when it returned since |
| 619 | // the Container was resized. |
| 620 | var curEditorSize = domGeom.getMarginBox(editor.domNode); |
| 621 | var curContainerSize = domGeom.getMarginBox(container.domNode); |
| 622 | var containerWdiff = -(origContainerSize.w - curContainerSize.w); |
| 623 | var containerHdiff = -(origContainerSize.h - curContainerSize.h); |
| 624 | var eWdiff = -(origEditorSize.w - curEditorSize.w); |
| 625 | var eHdiff = -(origEditorSize.h - curEditorSize.h); |
| 626 | |
| 627 | doh.t(origEditorSize.w < curEditorSize.w, "Validating new width is less that the original size"); |
| 628 | doh.t(origEditorSize.h < curEditorSize.h, "Validating new height is less that the original size"); |
| 629 | 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); |
| 630 | 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); |
| 631 | }), 1000); |
| 632 | |
| 633 | return d; |
| 634 | }, |
| 635 | tearDown: function(){ |
| 636 | fsPlugin.button.set("checked", false); |
| 637 | if(container && os){container.resize(os);} |
| 638 | } |
| 639 | } |
| 640 | ]); |
| 641 | doh.run(); |
| 642 | }); |
| 643 | </script> |
| 644 | </head> |
| 645 | </html> |