diff options
author | Denis Anisimov <denis@vaadin.com> | 2014-09-14 12:49:23 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-12-10 12:49:27 +0000 |
commit | da91036c92d8088d02471bb939b21eb228638d8f (patch) | |
tree | 5cb6887ac458ffec8952988eb9002499db5f9585 /uitest | |
parent | ab9d395d3a380217d51b68a338382854bd6194e0 (diff) | |
download | vaadin-framework-da91036c92d8088d02471bb939b21eb228638d8f.tar.gz vaadin-framework-da91036c92d8088d02471bb939b21eb228638d8f.zip |
Set explicit calculated size for drag image element (#14617).
Change-Id: I6bfcd0a5ad78bd79aad2fa2357a7e33a00b3c33d
Diffstat (limited to 'uitest')
3 files changed, 116 insertions, 1 deletions
diff --git a/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropRelativeWidth.java b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropRelativeWidth.java new file mode 100644 index 0000000000..90ec704a8c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropRelativeWidth.java @@ -0,0 +1,58 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * 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. + */ +package com.vaadin.tests.components.draganddropwrapper; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.CssLayout; +import com.vaadin.ui.DragAndDropWrapper; +import com.vaadin.ui.DragAndDropWrapper.DragStartMode; +import com.vaadin.ui.Label; + +/** + * Test UI for DnD image element size + * + * @author Vaadin Ltd + */ +public class DragAndDropRelativeWidth extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + CssLayout layout = new CssLayout(); + layout.setWidth(300, Unit.PIXELS); + + Label label = new Label("drag source"); + label.addStyleName("drag-source"); + label.setWidth(100, Unit.PERCENTAGE); + DragAndDropWrapper wrapper = new DragAndDropWrapper(label); + wrapper.setWidth(100, Unit.PERCENTAGE); + wrapper.setDragStartMode(DragStartMode.COMPONENT); + + layout.addComponent(wrapper); + addComponent(layout); + } + + @Override + protected String getTestDescription() { + return "Set explicit size for drag image element using calclulated size from the source"; + } + + @Override + protected Integer getTicketNumber() { + return 14617; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropRelativeWidthTest.java b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropRelativeWidthTest.java new file mode 100644 index 0000000000..9cb7a63046 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragAndDropRelativeWidthTest.java @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * 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. + */ +package com.vaadin.tests.components.draganddropwrapper; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Dimension; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Test to check size of drag image element. + * + * @author Vaadin Ltd + */ +public class DragAndDropRelativeWidthTest extends MultiBrowserTest { + + @Test + public void testDragImageElementSize() { + openTestURL(); + + WebElement label = getDriver().findElement(By.className("drag-source")); + Dimension size = label.getSize(); + int height = size.getHeight(); + int width = size.getWidth(); + Actions actions = new Actions(getDriver()); + actions.moveToElement(label); + actions.clickAndHold(); + actions.moveByOffset(100, 100); + actions.build().perform(); + + WebElement dragImage = getDriver().findElement( + By.className("v-drag-element")); + + Assert.assertEquals("Drag image element height is unexpected", height, + dragImage.getSize().getHeight()); + Assert.assertEquals("Drag image element width is unexpected", width, + dragImage.getSize().getWidth()); + } + +} diff --git a/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragStartModesTest.java b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragStartModesTest.java index ba27ee293e..4e60b43ea2 100644 --- a/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragStartModesTest.java +++ b/uitest/src/com/vaadin/tests/components/draganddropwrapper/DragStartModesTest.java @@ -40,7 +40,7 @@ public class DragStartModesTest extends MultiBrowserTest { new Actions(driver).moveToElement(draggable, 10, 10).clickAndHold() .moveByOffset(5, 0).perform(); new Actions(driver).moveToElement(dropTarget, 12, 10).perform(); - compareScreen("dragMode" + dragMode); + compareScreen("dragImageMode" + dragMode); new Actions(driver).release().perform(); } |