From 3d77d5fb627976b1419cbcc714e8f2c3b74af39d Mon Sep 17 00:00:00 2001 From: Anna Koskinen Date: Wed, 30 Jul 2014 15:48:20 +0300 Subject: [PATCH] TableColumnResizeContentsWidth test upgrade (#14292) Change-Id: I1adc4dfea7bf62191a23a89440eeca677f47e6a6 --- .../table/TableColumnResizeContentsWidth.html | 61 --------------- .../table/TableColumnResizeContentsWidth.java | 9 ++- .../TableColumnResizeContentsWidthTest.java | 76 +++++++++++++++++++ 3 files changed, 81 insertions(+), 65 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.html create mode 100644 uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidthTest.java diff --git a/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.html b/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.html deleted file mode 100644 index f2a3a06254..0000000000 --- a/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
open/run/com.vaadin.tests.components.table.TableColumnResizeContentsWidth?restartApplication&debug
dragAndDropvaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]-20,+0
assertElementWidthvaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VTextField[0]80
dragAndDropvaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]+40,+0
assertElementWidthvaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VTextField[0]120
clickvaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0]
assertElementWidthvaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VTextField[0]80
clickvaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]
assertElementWidthvaadin=runcomvaadintestscomponentstableTableColumnResizeContentsWidth::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[0]/VTextField[0]100
- - diff --git a/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java b/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java index 0b695b41c7..b785f439ea 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java +++ b/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidth.java @@ -1,18 +1,19 @@ package com.vaadin.tests.components.table; -import com.vaadin.tests.components.TestBase; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Table; import com.vaadin.ui.Table.ColumnGenerator; import com.vaadin.ui.TextField; -public class TableColumnResizeContentsWidth extends TestBase { +public class TableColumnResizeContentsWidth extends AbstractTestUI { private static final String COL1 = "COL1"; @Override - protected void setup() { + protected void setup(VaadinRequest request) { final Table table = new Table(); table.addGeneratedColumn(COL1, new ColumnGenerator() { @Override @@ -47,7 +48,7 @@ public class TableColumnResizeContentsWidth extends TestBase { } @Override - protected String getDescription() { + protected String getTestDescription() { return "When a column is resized, it's contents should update to match the new size"; } diff --git a/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidthTest.java b/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidthTest.java new file mode 100644 index 0000000000..0e98e7ddec --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableColumnResizeContentsWidthTest.java @@ -0,0 +1,76 @@ +/* + * 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.table; + +import static org.junit.Assert.assertEquals; + +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.TableElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests that components within table cells get resized when their column gets + * resized. + * + * @author Vaadin Ltd + */ +public class TableColumnResizeContentsWidthTest extends MultiBrowserTest { + + @Test + public void testResizing() throws InterruptedException { + openTestURL(); + + TableElement table = $(TableElement.class).first(); + List buttons = $(ButtonElement.class).all(); + + WebElement textField = table.findElement(By.className("v-textfield")); + WebElement resizer = table.findElement(By.className("v-table-resizer")); + + assertEquals(100, textField.getSize().width); + + // drag resizer to left + new Actions(getDriver()).moveToElement(resizer).clickAndHold() + .moveByOffset(-20, 0).release().perform(); + + assertEquals(80, textField.getSize().width); + + // drag resizer to right + new Actions(getDriver()).moveToElement(resizer).clickAndHold() + .moveByOffset(40, 0).release().perform(); + + assertEquals(120, textField.getSize().width); + + // click the button for decreasing size + buttons.get(1).click(); + sleep(50); + + assertEquals(80, textField.getSize().width); + + // click the button for increasing size + buttons.get(0).click(); + sleep(50); + + assertEquals(100, textField.getSize().width); + } + +} -- 2.39.5