From d3c1ae55f097e4e443026c42ed67e38086916e07 Mon Sep 17 00:00:00 2001 From: fab-b Date: Wed, 24 Sep 2014 14:08:30 +0200 Subject: [PATCH] fix #1297 Resizable dialog is not working inside a page with some scroll This fix is changing the way we set the position of the resizable overlay, using the real position of the element insted of its position inside the viewport. --- src/aria/utils/overlay/Overlay.js | 5 +- .../resize/AbstractResizableDialogTestCase.js | 398 ++++++++++++++++ .../dialog/resize/DialogResizeTestSuite.js | 4 +- .../resize/test2/ResizableDialogTestCase.js | 446 +----------------- .../test4/DialogOnResizeScrollTestCase.js | 33 ++ .../test5/OverlayOnResizeScrollTemplate.tpl | 39 ++ .../test5/OverlayOnResizeScrollTestCase.js | 99 ++++ test/attester-packaged.yml | 2 + 8 files changed, 580 insertions(+), 446 deletions(-) create mode 100644 test/aria/widgets/container/dialog/resize/AbstractResizableDialogTestCase.js create mode 100644 test/aria/widgets/container/dialog/resize/test4/DialogOnResizeScrollTestCase.js create mode 100644 test/aria/widgets/container/dialog/resize/test5/OverlayOnResizeScrollTemplate.tpl create mode 100644 test/aria/widgets/container/dialog/resize/test5/OverlayOnResizeScrollTestCase.js diff --git a/src/aria/utils/overlay/Overlay.js b/src/aria/utils/overlay/Overlay.js index cc11cbddf..fe0a91ae2 100644 --- a/src/aria/utils/overlay/Overlay.js +++ b/src/aria/utils/overlay/Overlay.js @@ -102,8 +102,9 @@ module.exports = Aria.classDefinition({ var geometry = ariaUtilsDom.getGeometry(element); if (geometry) { overlayStyle.position = "absolute"; - overlayStyle.top = geometry.y + "px"; - overlayStyle.left = geometry.x + "px"; + var scroll = dom.getDocumentScrollElement(); + overlayStyle.top = geometry.y + scroll.scrollTop + "px"; + overlayStyle.left = geometry.x + scroll.scrollLeft + "px"; overlayStyle.width = (geometry.width - border.left - border.right) + "px"; overlayStyle.height = (geometry.height - border.top - border.bottom) + "px"; overlayStyle.display = "block"; diff --git a/test/aria/widgets/container/dialog/resize/AbstractResizableDialogTestCase.js b/test/aria/widgets/container/dialog/resize/AbstractResizableDialogTestCase.js new file mode 100644 index 000000000..a59d55639 --- /dev/null +++ b/test/aria/widgets/container/dialog/resize/AbstractResizableDialogTestCase.js @@ -0,0 +1,398 @@ +/* + * Copyright 2012 Amadeus s.a.s. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Abstract class for resize dialog test. + */ +Aria.classDefinition({ + $classpath : "test.aria.widgets.container.dialog.resize.AbstractResizableDialogTestCase", + $extends : "aria.jsunit.RobotTestCase", + $dependencies : ["aria.utils.Dom"], + $constructor : function () { + this.$RobotTestCase.constructor.call(this); + + this.domSelector = aria.utils.Dom; + this.data = { + firstDialog : { + visible : true, + height : 250, + width : 500, + x : 0, + y : 0 + } + }; + + this.handleEle = ""; + this.handleEleParent = ""; + this.isIE9orNewer = aria.core.Browser.isIE9 || aria.core.Browser.isIE10; + this.tolerance = this.isIE9orNewer ? 10 : 2; + this.toleranceShadow = this.isIE9orNewer ? 11 : 5; + this.movementDuration = 500; + this.setTestEnv({ + template : "test.aria.widgets.container.dialog.resize.test2.ResizableDialogTemplate", + data : this.data + }); + }, + $prototype : { + startResizeTest : function () { + aria.core.Timer.addCallback({ + fn : this._afterFirstDialogShow, + scope : this, + delay : 1000 + }); + }, + + _afterFirstDialogShow : function () { + var dom = aria.utils.Dom; + var handleEle = this._getHandle("firstDialog", 1); + this.handleEle = handleEle.handle; + this.handleEleParent = handleEle.parent; + var handleGeometry = dom.getGeometry(this.handleEle); + var parentGeometry = dom.getGeometry(this.handleEleParent); + + this.data.firstDialog.x = parentGeometry.x; + this.data.firstDialog.y = parentGeometry.y; + + this.assertEquals(parentGeometry.height, 250, "Dialog Widget height is wrong before Resizing. Expected %2, got %1."); + this.assertEqualsWithTolerance(parentGeometry.width, 500, this.tolerance, "Dialog Widget height is wrong before Resizing.. Expected %2, got %1"); + + var from = { + x : handleGeometry.x + handleGeometry.width / 2, + y : handleGeometry.y + handleGeometry.height / 2 + }; + var options = { + duration : this.movementDuration, + to : { + x : from.x + 0, + y : from.y + 10 + } + }; + + this.data.firstDialog.height -= 10; + this.data.firstDialog.y += 10; + + this.synEvent.execute([["drag", options, from]], { + fn : this._NResize, + scope : this + }); + }, + + _NResize : function () { + var handleEle = this._getHandle("firstDialog"); + this.handleEleParent = handleEle.parent; + var parentGeometry = aria.utils.Dom.getGeometry(this.handleEleParent); + this.assertEqualsWithTolerance(this.data.firstDialog.height, parentGeometry.height, this.tolerance, "The dialog height is not corrrectly set, expected %1, actual %2."); + this.assertEqualsWithTolerance(this.data.firstDialog.y, parentGeometry.y, this.tolerance, "The dialog ypos position is not corrrectly set, expected %1, actual %2."); + + var from = { + x : parentGeometry.x + parentGeometry.width / 2, + y : parentGeometry.y + }; + var options = { + duration : this.movementDuration, + to : { + x : from.x + 0, + y : from.y - 10 + } + }; + this.data.firstDialog.height += 10; + this.data.firstDialog.y -= 10; + + this.synEvent.execute([["drag", options, from]], { + fn : this._checkNSize, + scope : this + }); + + }, + + _checkNSize : function () { + var handleEle = this._getHandle("firstDialog"); + this.handleEleParent = handleEle.parent; + var parentGeometry = aria.utils.Dom.getGeometry(this.handleEleParent); + var partialMsg = " is not correct after top resize: expected %1, actual %2."; + + this.assertEqualsWithTolerance(this.data.firstDialog.height, parentGeometry.height, this.tolerance, ("The dialog height" + partialMsg)); + this.assertEqualsWithTolerance(this.data.firstDialog.y, parentGeometry.y, this.tolerance, ("The dialog ypos" + partialMsg)); + this._NWresize(); + }, + + _NWresize : function () { + var handleEle = this._getHandle("firstDialog", 6); + this.handleEle = handleEle.handle; + var position = aria.utils.Dom.getGeometry(this.handleEle); + + var from = { + x : position.x, + y : position.y + }; + var options = { + duration : this.movementDuration, + to : { + x : from.x + 10, + y : from.y + 10 + } + }; + this.data.firstDialog.height -= 10; + this.data.firstDialog.width -= 10; + this.data.firstDialog.y += 10; + this.data.firstDialog.x += 10; + + this.synEvent.execute([["drag", options, from]], { + fn : this._checkNWSize, + scope : this + }); + + }, + _checkNWSize : function () { + var handleEle = this._getHandle("firstDialog"); + this.handleEleParent = handleEle.parent; + var parentGeometry = aria.utils.Dom.getGeometry(this.handleEleParent); + var partialMsg = " is not correct after top west resize: expected %1, actual %2."; + + this.assertEqualsWithTolerance(this.data.firstDialog.height, parentGeometry.height, this.tolerance, ("The dialog height" + partialMsg)); + this.assertEqualsWithTolerance(this.data.firstDialog.width, parentGeometry.width, this.tolerance, ("The dialog width" + partialMsg)); + this.assertEqualsWithTolerance(this.data.firstDialog.x, parentGeometry.x, this.tolerance, ("The dialog x position" + partialMsg)); + this.assertEqualsWithTolerance(this.data.firstDialog.y, parentGeometry.y, this.tolerance, ("The dialog y position" + partialMsg)); + this._NEresize(); + + }, + _NEresize : function () { + var handleEle = this._getHandle("firstDialog", 5); + this.handleEle = handleEle.handle; + var position = aria.utils.Dom.getGeometry(this.handleEle); + + var from = { + x : position.x + 5, + y : position.y + }; + var options = { + duration : this.movementDuration, + to : { + x : from.x - 10, + y : from.y + 10 + } + }; + this.data.firstDialog.height -= 10; + this.data.firstDialog.width -= 10; + this.data.firstDialog.y += 10; + + this.synEvent.execute([["drag", options, from]], { + fn : this._checkNESize, + scope : this + }); + + }, + _checkNESize : function () { + var handleEle = this._getHandle("firstDialog"); + this.handleEleParent = handleEle.parent; + var parentGeometry = aria.utils.Dom.getGeometry(this.handleEleParent); + var partialMsg = " is not correct after top east resize: expected %1, actual %2."; + + this.assertEqualsWithTolerance(this.data.firstDialog.height, parentGeometry.height, this.tolerance, ("The dialog height" + partialMsg)); + this.assertEqualsWithTolerance(this.data.firstDialog.width, parentGeometry.width, this.toleranceShadow, ("The dialog width" + partialMsg)); + this.assertEqualsWithTolerance(this.data.firstDialog.y, parentGeometry.y, this.tolerance, ("The dialog y position" + partialMsg)); + this._SEresize(); + + }, + _SEresize : function () { + var handleEle = this._getHandle("firstDialog", 7); + this.handleEle = handleEle.handle; + var position = aria.utils.Dom.getGeometry(this.handleEle); + + var from = { + x : position.x + 5, + y : position.y + 2 + }; + var options = { + duration : this.movementDuration, + to : { + x : from.x - 10, + y : from.y - 10 + } + }; + // to compensate shadow + this.data.firstDialog.height -= 8; + this.data.firstDialog.width -= 8; + + this.synEvent.execute([["drag", options, from]], { + fn : this._checkSESize, + scope : this + }); + + }, + _checkSESize : function () { + var handleEle = this._getHandle("firstDialog"); + this.handleEleParent = handleEle.parent; + var parentGeometry = aria.utils.Dom.getGeometry(this.handleEleParent); + var partialMsg = " is not correct after bottom east resize: expected %1, actual %2."; + + this.assertEqualsWithTolerance(this.data.firstDialog.height, parentGeometry.height, this.toleranceShadow, ("The dialog height" + partialMsg)); + this.assertEqualsWithTolerance(this.data.firstDialog.width, parentGeometry.width, this.toleranceShadow, ("The dialog width " + partialMsg)); + this._SWresize(); + + }, + + _SWresize : function () { + var handleEle = this._getHandle("firstDialog", 8); + this.handleEle = handleEle.handle; + var position = aria.utils.Dom.getGeometry(this.handleEle); + + var from = { + x : position.x + 4, + y : position.y + 1 + }; + var options = { + duration : this.movementDuration, + to : { + x : from.x + 10, + y : from.y - 10 + } + }; + this.data.firstDialog.height -= 10; + this.data.firstDialog.width -= 10; + this.data.firstDialog.x += 10; + + this.synEvent.execute([["drag", options, from]], { + fn : this._checkSWSize, + scope : this + }); + + }, + _checkSWSize : function () { + var handleEle = this._getHandle("firstDialog"); + this.handleEleParent = handleEle.parent; + var parentGeometry = aria.utils.Dom.getGeometry(this.handleEleParent); + var partialMsg = " is not correct after bottom west resize: expected %1, actual %2."; + + this.assertEqualsWithTolerance(this.data.firstDialog.height, parentGeometry.height, this.toleranceShadow, ("The dialog height" + partialMsg)); + this.assertEqualsWithTolerance(this.data.firstDialog.width, parentGeometry.width, this.toleranceShadow, ("The dialog width" + partialMsg)); + this.assertEqualsWithTolerance(this.data.firstDialog.x, parentGeometry.x, this.tolerance, ("The dialog xpos" + partialMsg)); + this._Wresize(); + + }, + _Wresize : function () { + var handleEle = this._getHandle("firstDialog", 4); + this.handleEle = handleEle.handle; + var position = aria.utils.Dom.getGeometry(this.handleEle); + + var from = { + x : position.x, + y : position.y + position.height / 2 + }; + var options = { + duration : this.movementDuration, + to : { + x : from.x + 10, + y : from.y + } + }; + // for shadow + this.data.firstDialog.width -= 8; + + this.synEvent.execute([["drag", options, from]], { + fn : this._checkWSize, + scope : this + }); + + }, + _checkWSize : function () { + var handleEle = this._getHandle("firstDialog"); + this.handleEleParent = handleEle.parent; + var parentGeometry = aria.utils.Dom.getGeometry(this.handleEleParent); + this.assertEqualsWithTolerance(this.data.firstDialog.width, parentGeometry.width, this.toleranceShadow, "The dialog width is not correct after west resize. Expected %1, actual %2."); + this._Eresize(); + + }, + _Eresize : function () { + var handleEle = this._getHandle("firstDialog", 3); + this.handleEle = handleEle.handle; + var position = aria.utils.Dom.getGeometry(this.handleEle); + + var from = { + x : position.x, + y : position.y + position.height / 2 + }; + var options = { + duration : this.movementDuration, + to : { + x : from.x - 10, + y : from.y + } + }; + this.data.firstDialog.width -= 10; + + this.synEvent.execute([["drag", options, from]], { + fn : this._checkESize, + scope : this + }); + + }, + _checkESize : function () { + var handleEle = this._getHandle("firstDialog"); + this.handleEleParent = handleEle.parent; + var parentGeometry = aria.utils.Dom.getGeometry(this.handleEleParent); + this.assertEqualsWithTolerance(this.data.firstDialog.width, parentGeometry.width, this.toleranceShadow, "The dialog width is not correct after east resize. Expected %1, actual %2."); + this._SResize(); + + }, + + _SResize : function () { + var handleEle = this._getHandle("firstDialog", 2); + this.handleEle = handleEle.handle; + var position = aria.utils.Dom.getGeometry(this.handleEle); + + var from = { + x : position.x + position.width / 2, + y : position.y + }; + var options = { + duration : this.movementDuration, + to : { + x : from.x, + y : from.y - 10 + } + }; + // for shadow + this.data.firstDialog.height -= 8; + + this.synEvent.execute([["drag", options, from]], { + fn : this._checkSSize, + scope : this + }); + + }, + + _checkSSize : function () { + var handleEle = this._getHandle("firstDialog"); + this.handleEleParent = handleEle.parent; + var parentGeometry = aria.utils.Dom.getGeometry(this.handleEleParent); + this.assertEqualsWithTolerance(this.data.firstDialog.height, parentGeometry.height, this.toleranceShadow, "The dialog height is not correct after south resize. Expected %1, actual %2."); + + this._end(); + }, + _getHandle : function (dialogId, index) { + var options = {}; + options.parent = this.getWidgetInstance(dialogId)._domElt; + if (index) { + options.handle = aria.utils.Dom.getDomElementChild(options.parent, index, false); + } + return options; + }, + + _end : function () { + this.notifyTemplateTestEnd(); + } + } +}); diff --git a/test/aria/widgets/container/dialog/resize/DialogResizeTestSuite.js b/test/aria/widgets/container/dialog/resize/DialogResizeTestSuite.js index fc507248b..523ccf85a 100644 --- a/test/aria/widgets/container/dialog/resize/DialogResizeTestSuite.js +++ b/test/aria/widgets/container/dialog/resize/DialogResizeTestSuite.js @@ -21,6 +21,8 @@ Aria.classDefinition({ this._tests = ["test.aria.widgets.container.dialog.resize.test1.DialogOnResizeTestCase", "test.aria.widgets.container.dialog.resize.test2.ResizableDialogTestCase", - "test.aria.widgets.container.dialog.resize.test3.DialogOnResizeTestCase"]; + "test.aria.widgets.container.dialog.resize.test3.DialogOnResizeTestCase", + "test.aria.widgets.container.dialog.resize.test4.DialogOnResizeScrollTestCase", + "test.aria.widgets.container.dialog.resize.test5.OverlayOnResizeScrollTestCase"]; } }); diff --git a/test/aria/widgets/container/dialog/resize/test2/ResizableDialogTestCase.js b/test/aria/widgets/container/dialog/resize/test2/ResizableDialogTestCase.js index a6ecca388..8ba6bb63e 100644 --- a/test/aria/widgets/container/dialog/resize/test2/ResizableDialogTestCase.js +++ b/test/aria/widgets/container/dialog/resize/test2/ResizableDialogTestCase.js @@ -18,451 +18,11 @@ */ Aria.classDefinition({ $classpath : "test.aria.widgets.container.dialog.resize.test2.ResizableDialogTestCase", - $extends : "aria.jsunit.RobotTestCase", - $dependencies : ["aria.utils.Dom"], - $constructor : function () { - this.$RobotTestCase.constructor.call(this); - - this.domSelector = aria.utils.Dom; - this.data = { - firstDialog : { - visible : true, - height : 250, - width : 500, - x : 0, - y : 0, - resizetext : "" - } - }; - - this.handleEle = ""; - this.handleEleParent = ""; - this.isIE9orNewer = aria.core.Browser.isIE9 || aria.core.Browser.isIE10; - this.tolerance = this.isIE9orNewer ? 10 : 2; - this.toleranceShadow = this.isIE9orNewer ? 11 : 5; - this.movementDuration = 500; - this.setTestEnv({ - template : "test.aria.widgets.container.dialog.resize.test2.ResizableDialogTemplate", - data : this.data - }); - // this.defaultTestTimeout = 20000; - }, + $extends : "test.aria.widgets.container.dialog.resize.AbstractResizableDialogTestCase", $prototype : { - runTemplateTest : function () { - // handle for top - aria.core.Timer.addCallback({ - fn : this._afterFirstDialogShow, - scope : this, - delay : 1000 - }); - }, - - _afterFirstDialogShow : function () { - var dom = aria.utils.Dom; - var handleEle = this._getHandle("firstDialog", 1); - this.handleEle = handleEle.handle; - this.handleEleParent = handleEle.parent; - var handleGeometry = dom.getGeometry(this.handleEle); - var parentGeometry = dom.getGeometry(this.handleEleParent); - - this.data.firstDialog.x = parentGeometry.x; - this.data.firstDialog.y = parentGeometry.y; - - this.assertEquals(parentGeometry.height, 250, "Dialog Widget height is wrong before Resizing. Expected %2, got %1."); - this.assertEqualsWithTolerance(parentGeometry.width, 500, this.tolerance, "Dialog Widget height is wrong before Resizing.. Expected %2, got %1"); - - var from = { - x : handleGeometry.x + handleGeometry.width / 2, - y : handleGeometry.y + handleGeometry.height / 2 - }; - var options = { - duration : this.movementDuration, - to : { - x : from.x + 0, - y : from.y + 10 - } - }; - // defaultSetTimeout - this.data.firstDialog.height -= 10; - this.data.firstDialog.y += 10; - var that = this; - this.synEvent.execute([["drag", options, from]], { - fn : this._NResize, - scope : this - }); - }, - - _NResize : function () { - aria.core.Timer.addCallback({ - fn : function () { - - }, - delay : 1000, - scope : this - }); - var handleEle = this._getHandle("firstDialog"); - this.handleEleParent = handleEle.parent; - var parentGeometry = aria.utils.Dom.getGeometry(this.handleEleParent); - this.assertEqualsWithTolerance(this.data.firstDialog.height, parentGeometry.height, this.tolerance, "The dialog height is not corrrectly set, expected %1, actual %2."); - this.assertEqualsWithTolerance(this.data.firstDialog.y, parentGeometry.y, this.tolerance, "The dialog ypos position is not corrrectly set, expected %1, actual %2."); - - var from = { - x : parentGeometry.x + parentGeometry.width / 2, - y : parentGeometry.y - }; - var options = { - duration : this.movementDuration, - to : { - x : from.x + 0, - y : from.y - 10 - } - }; - this.data.firstDialog.height += 10; - this.data.firstDialog.y -= 10; - var that = this; - this.synEvent.execute([["drag", options, from]], { - fn : this._checkNSize, - scope : this - }); - - }, - - _checkNSize : function () { - aria.core.Timer.addCallback({ - fn : function () { - - }, - delay : 1000, - scope : this - }); - - var handleEle = this._getHandle("firstDialog"); - this.handleEleParent = handleEle.parent; - var parentGeometry = aria.utils.Dom.getGeometry(this.handleEleParent); - var partialMsg = " is not correct after top resize: expected %1, actual %2."; - - this.assertEqualsWithTolerance(this.data.firstDialog.height, parentGeometry.height, this.tolerance, ("The dialog height" + partialMsg)); - this.assertEqualsWithTolerance(this.data.firstDialog.y, parentGeometry.y, this.tolerance, ("The dialog ypos" + partialMsg)); - this._NWresize(); - }, - - _NWresize : function () { - var handleEle = this._getHandle("firstDialog", 6); - this.handleEle = handleEle.handle; - var position = aria.utils.Dom.getGeometry(this.handleEle); - - var from = { - x : position.x, - y : position.y - }; - var options = { - duration : this.movementDuration, - to : { - x : from.x + 10, - y : from.y + 10 - } - }; - this.data.firstDialog.height -= 10; - this.data.firstDialog.width -= 10; - this.data.firstDialog.y += 10; - this.data.firstDialog.x += 10; - var that = this; - this.synEvent.execute([["drag", options, from]], { - fn : this._checkNWSize, - scope : that - }); - - }, - _checkNWSize : function () { - aria.core.Timer.addCallback({ - fn : function () { - - }, - delay : 1000, - scope : this - }); - - var handleEle = this._getHandle("firstDialog"); - this.handleEleParent = handleEle.parent; - var parentGeometry = aria.utils.Dom.getGeometry(this.handleEleParent); - var partialMsg = " is not correct after top west resize: expected %1, actual %2."; - - this.assertEqualsWithTolerance(this.data.firstDialog.height, parentGeometry.height, this.tolerance, ("The dialog height" + partialMsg)); - this.assertEqualsWithTolerance(this.data.firstDialog.width, parentGeometry.width, this.tolerance, ("The dialog width" + partialMsg)); - this.assertEqualsWithTolerance(this.data.firstDialog.x, parentGeometry.x, this.tolerance, ("The dialog x position" + partialMsg)); - this.assertEqualsWithTolerance(this.data.firstDialog.y, parentGeometry.y, this.tolerance, ("The dialog y position" + partialMsg)); - this._NEresize(); - - }, - _NEresize : function () { - var handleEle = this._getHandle("firstDialog", 5); - this.handleEle = handleEle.handle; - var position = aria.utils.Dom.getGeometry(this.handleEle); - - var from = { - x : position.x + 5, - y : position.y - }; - var options = { - duration : this.movementDuration, - to : { - x : from.x - 10, - y : from.y + 10 - } - }; - this.data.firstDialog.height -= 10; - this.data.firstDialog.width -= 10; - this.data.firstDialog.y += 10; - var that = this; - this.synEvent.execute([["drag", options, from]], { - fn : this._checkNESize, - scope : that - }); - - }, - _checkNESize : function () { - aria.core.Timer.addCallback({ - fn : function () { - - }, - delay : 1000, - scope : this - }); - var handleEle = this._getHandle("firstDialog"); - this.handleEleParent = handleEle.parent; - var parentGeometry = aria.utils.Dom.getGeometry(this.handleEleParent); - var partialMsg = " is not correct after top east resize: expected %1, actual %2."; - - this.assertEqualsWithTolerance(this.data.firstDialog.height, parentGeometry.height, this.tolerance, ("The dialog height" + partialMsg)); - this.assertEqualsWithTolerance(this.data.firstDialog.width, parentGeometry.width, this.toleranceShadow, ("The dialog width" + partialMsg)); - this.assertEqualsWithTolerance(this.data.firstDialog.y, parentGeometry.y, this.tolerance, ("The dialog y position" + partialMsg)); - this._SEresize(); - - }, - _SEresize : function () { - var handleEle = this._getHandle("firstDialog", 7); - this.handleEle = handleEle.handle; - var position = aria.utils.Dom.getGeometry(this.handleEle); - - var from = { - x : position.x + 5, - y : position.y + 2 - }; - var options = { - duration : this.movementDuration, - to : { - x : from.x - 10, - y : from.y - 10 - } - }; - // to compensate shadow - this.data.firstDialog.height -= 8; - this.data.firstDialog.width -= 8; - var that = this; - this.synEvent.execute([["drag", options, from]], { - fn : this._checkSESize, - scope : that - }); - }, - _checkSESize : function () { - aria.core.Timer.addCallback({ - fn : function () {}, - delay : 1000, - scope : this - }); - var handleEle = this._getHandle("firstDialog"); - this.handleEleParent = handleEle.parent; - var parentGeometry = aria.utils.Dom.getGeometry(this.handleEleParent); - var partialMsg = " is not correct after bottom east resize: expected %1, actual %2."; - - this.assertEqualsWithTolerance(this.data.firstDialog.height, parentGeometry.height, this.toleranceShadow, ("The dialog height" + partialMsg)); - this.assertEqualsWithTolerance(this.data.firstDialog.width, parentGeometry.width, this.toleranceShadow, ("The dialog width " + partialMsg)); - this._SWresize(); - - }, - - _SWresize : function () { - var handleEle = this._getHandle("firstDialog", 8); - this.handleEle = handleEle.handle; - var position = aria.utils.Dom.getGeometry(this.handleEle); - - var from = { - x : position.x + 4, - y : position.y + 1 - }; - var options = { - duration : this.movementDuration, - to : { - x : from.x + 10, - y : from.y - 10 - } - }; - this.data.firstDialog.height -= 10; - this.data.firstDialog.width -= 10; - this.data.firstDialog.x += 10; - var that = this; - this.synEvent.execute([["drag", options, from]], { - fn : this._checkSWSize, - scope : that - }); - - }, - _checkSWSize : function () { - aria.core.Timer.addCallback({ - fn : function () { - - }, - delay : 1000, - scope : this - }); - - var handleEle = this._getHandle("firstDialog"); - this.handleEleParent = handleEle.parent; - var parentGeometry = aria.utils.Dom.getGeometry(this.handleEleParent); - var partialMsg = " is not correct after bottom west resize: expected %1, actual %2."; - - this.assertEqualsWithTolerance(this.data.firstDialog.height, parentGeometry.height, this.toleranceShadow, ("The dialog height" + partialMsg)); - this.assertEqualsWithTolerance(this.data.firstDialog.width, parentGeometry.width, this.toleranceShadow, ("The dialog width" + partialMsg)); - this.assertEqualsWithTolerance(this.data.firstDialog.x, parentGeometry.x, this.tolerance, ("The dialog xpos" + partialMsg)); - this._Wresize(); - - }, - _Wresize : function () { - var handleEle = this._getHandle("firstDialog", 4); - this.handleEle = handleEle.handle; - var position = aria.utils.Dom.getGeometry(this.handleEle); - - var from = { - x : position.x, - y : position.y + position.height / 2 - }; - var options = { - duration : this.movementDuration, - to : { - x : from.x + 10, - y : from.y - } - }; - // for shadow - this.data.firstDialog.width -= 8; - var that = this; - this.synEvent.execute([["drag", options, from]], { - fn : this._checkWSize, - scope : that - }); - - }, - _checkWSize : function () { - aria.core.Timer.addCallback({ - fn : function () { - - }, - delay : 1000, - scope : this - }); - - var handleEle = this._getHandle("firstDialog"); - this.handleEleParent = handleEle.parent; - var parentGeometry = aria.utils.Dom.getGeometry(this.handleEleParent); - this.assertEqualsWithTolerance(this.data.firstDialog.width, parentGeometry.width, this.toleranceShadow, "The dialog width is not correct after west resize. Expected %1, actual %2."); - this._Eresize(); - - }, - _Eresize : function () { - var handleEle = this._getHandle("firstDialog", 3); - this.handleEle = handleEle.handle; - var position = aria.utils.Dom.getGeometry(this.handleEle); - - var from = { - x : position.x, - y : position.y + position.height / 2 - }; - var options = { - duration : this.movementDuration, - to : { - x : from.x - 10, - y : from.y - } - }; - this.data.firstDialog.width -= 10; - var that = this; - this.synEvent.execute([["drag", options, from]], { - fn : this._checkESize, - scope : that - }); - - }, - _checkESize : function () { - aria.core.Timer.addCallback({ - fn : function () { - - }, - delay : 1000, - scope : this - }); - - var handleEle = this._getHandle("firstDialog"); - this.handleEleParent = handleEle.parent; - var parentGeometry = aria.utils.Dom.getGeometry(this.handleEleParent); - this.assertEqualsWithTolerance(this.data.firstDialog.width, parentGeometry.width, this.toleranceShadow, "The dialog width is not correct after east resize. Expected %1, actual %2."); - this._SResize(); - - }, - - _SResize : function () { - var handleEle = this._getHandle("firstDialog", 2); - this.handleEle = handleEle.handle; - var position = aria.utils.Dom.getGeometry(this.handleEle); - - var from = { - x : position.x + position.width / 2, - y : position.y - }; - var options = { - duration : this.movementDuration, - to : { - x : from.x, - y : from.y - 10 - } - }; - // for shadow - this.data.firstDialog.height -= 8; - var that = this; - this.synEvent.execute([["drag", options, from]], { - fn : this._checkSSize, - scope : that - }); - - }, - - _checkSSize : function () { - aria.core.Timer.addCallback({ - fn : function () { - - }, - delay : 1000, - scope : this - }); - - var handleEle = this._getHandle("firstDialog"); - this.handleEleParent = handleEle.parent; - var parentGeometry = aria.utils.Dom.getGeometry(this.handleEleParent); - this.assertEqualsWithTolerance(this.data.firstDialog.height, parentGeometry.height, this.toleranceShadow, "The dialog height is not correct after south resize. Expected %1, actual %2."); - - this._end(); - }, - _getHandle : function (dialogId, index) { - var options = {}; - options.parent = this.getWidgetInstance(dialogId)._domElt; - if (index) { - options.handle = aria.utils.Dom.getDomElementChild(options.parent, index, false); - } - return options; - }, - - _end : function () { - this.notifyTemplateTestEnd(); + runTemplateTest : function () { + this.startResizeTest(); } } }); diff --git a/test/aria/widgets/container/dialog/resize/test4/DialogOnResizeScrollTestCase.js b/test/aria/widgets/container/dialog/resize/test4/DialogOnResizeScrollTestCase.js new file mode 100644 index 000000000..c74671ba4 --- /dev/null +++ b/test/aria/widgets/container/dialog/resize/test4/DialogOnResizeScrollTestCase.js @@ -0,0 +1,33 @@ +/* + * Copyright 2013 Amadeus s.a.s. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +Aria.classDefinition({ + $classpath : "test.aria.widgets.container.dialog.resize.test4.DialogOnResizeScrollTestCase", + $extends : "test.aria.widgets.container.dialog.resize.AbstractResizableDialogTestCase", + $constructor : function () { + this.$AbstractResizableDialogTestCase.constructor.call(this); + + this.setTestEnv({ + css : "position:relative;top:400px;border:15px solid blue;" + }); + }, + $prototype : { + + runTemplateTest : function () { + Aria.$window.scrollBy(0,150); + this.startResizeTest(); + } + } +}); \ No newline at end of file diff --git a/test/aria/widgets/container/dialog/resize/test5/OverlayOnResizeScrollTemplate.tpl b/test/aria/widgets/container/dialog/resize/test5/OverlayOnResizeScrollTemplate.tpl new file mode 100644 index 000000000..bbb592537 --- /dev/null +++ b/test/aria/widgets/container/dialog/resize/test5/OverlayOnResizeScrollTemplate.tpl @@ -0,0 +1,39 @@ +/* + * Copyright 2013 Amadeus s.a.s. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{Template { + $classpath:"test.aria.widgets.container.dialog.resize.test5.OverlayOnResizeScrollTemplate" +}} + {macro main()} + {@aria:Dialog { + id : "firstDialog", + macro : "displayDialogContent", + icon : "std:info", + width : 500, + height : 250, + visible : true, + resizable : true + }/} + {/macro} + + {macro displayDialogContent()} + + {@aria:Text { + text : "Content of the dialog" + }/} + + {/macro} + +{/Template} diff --git a/test/aria/widgets/container/dialog/resize/test5/OverlayOnResizeScrollTestCase.js b/test/aria/widgets/container/dialog/resize/test5/OverlayOnResizeScrollTestCase.js new file mode 100644 index 000000000..3cfa93998 --- /dev/null +++ b/test/aria/widgets/container/dialog/resize/test5/OverlayOnResizeScrollTestCase.js @@ -0,0 +1,99 @@ +/* + * Copyright 2013 Amadeus s.a.s. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +Aria.classDefinition({ + $classpath : "test.aria.widgets.container.dialog.resize.test5.OverlayOnResizeScrollTestCase", + $extends : "aria.jsunit.RobotTestCase", + $dependencies : ["aria.utils.Dom"], + $constructor : function () { + this.$RobotTestCase.constructor.call(this); + + this.data = {}; + this._robot = aria.jsunit.Robot; + + this.setTestEnv({ + template : "test.aria.widgets.container.dialog.resize.test5.OverlayOnResizeScrollTemplate", + css : "position:relative;top:400px;border:15px solid blue;", + data : this.data + }); + }, + $prototype : { + runTemplateTest : function () { + Aria.$window.scrollBy(0,150); + aria.core.Timer.addCallback({ + fn : this._firstDrag, + scope : this, + delay : 1000 + }); + }, + + _firstDrag : function () { + var dom = aria.utils.Dom; + this.assertEquals(dom.getDocumentScrollElement().scrollTop, 150, "The page should have %2 px of scroll, but it has %1 px instead"); + + var handleEle = this._getHandle("firstDialog", 1); + this.handleEle = handleEle.handle; + this.handleEleParent = handleEle.parent; + var handleGeometry = dom.getGeometry(this.handleEle); + var parentGeometry = dom.getGeometry(this.handleEleParent); + + this.assertEquals(parentGeometry.height, 250, "Dialog Widget height is wrong before Resizing. Expected %2, got %1."); + this.assertEquals(parentGeometry.width, 500, "Dialog Widget height is wrong before Resizing.. Expected %2, got %1"); + + var from = { + x : handleGeometry.x + handleGeometry.width / 2, + y : handleGeometry.y + handleGeometry.height / 2 + }; + var options = { + duration : this.movementDuration, + to : { + x : from.x + 0, + y : from.y + 10 + } + }; + + var seq = [["mouseMove", from], ["mousePress", this._robot.BUTTON1_MASK], ["move", options, from]]; + + this.synEvent.execute(seq, { + fn : this._afterFirstDrag, + scope : this + }); + }, + + _afterFirstDrag : function () { + var dom = aria.utils.Dom; + var handleEle = this._getHandle("firstDialog"); + this.handleEleParent = handleEle.parent; + var parentGeometry = dom.getGeometry(this.handleEleParent); + + var overlay = dom.getElementsByClassName(Aria.$window.document.body, "xOverlay")[0]; + var overlayGeometry = dom.getGeometry(overlay); + + this.assertEquals(parentGeometry.x, overlayGeometry.x, "The overlay xpos is not the same as the dialog one. Expected %1, got %2."); + this.assertEquals(parentGeometry.y, overlayGeometry.y - 10, "The overlay ypos is not 10px (resize) more than the dialog one. Expected %1, got %2."); + + this.end(); + }, + + _getHandle : function (dialogId, index) { + var options = {}; + options.parent = this.getWidgetInstance(dialogId)._domElt; + if (index) { + options.handle = aria.utils.Dom.getDomElementChild(options.parent, index, false); + } + return options; + } + } +}); diff --git a/test/attester-packaged.yml b/test/attester-packaged.yml index bddb51fa7..daa6362c5 100644 --- a/test/attester-packaged.yml +++ b/test/attester-packaged.yml @@ -20,6 +20,8 @@ tests: #Excluded because PhantomJS has random issues with the viewport - test.aria.widgets.container.dialog.scroll.OnScrollTestCase - test.aria.widgets.container.dialog.resize.test3.DialogOnResizeTestCase + - test.aria.widgets.container.dialog.resize.test4.DialogOnResizeScrollTestCase + - test.aria.widgets.container.dialog.resize.test5.OverlayOnResizeScrollTestCase - test.aria.utils.overlay.loadingIndicator.scrollableBody.ScrollableBodyTest - test.aria.widgets.container.dialog.indicators.DialogTestCase - test.aria.widgets.container.dialog.movable.test5.MovableDialogTestCaseFive