From f21099256e02b355c8d090eb669a5b9f0ce4b7cd Mon Sep 17 00:00:00 2001 From: Anna Koskinen Date: Thu, 31 Jul 2014 11:36:44 +0300 Subject: [PATCH] TableRowScrolledBottom test upgrade (#14292) Change-Id: I382a4da5f186239c5791d1e63e9a75ece9039760 --- .../table/TableRowScrolledBottom.html | 52 ------------- .../table/TableRowScrolledBottom.java | 20 ++--- .../table/TableRowScrolledBottomTest.java | 73 +++++++++++++++++++ 3 files changed, 83 insertions(+), 62 deletions(-) delete mode 100644 uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottom.html create mode 100644 uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottomTest.java diff --git a/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottom.html b/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottom.html deleted file mode 100644 index 5116fceb49..0000000000 --- a/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottom.html +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - -New Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
New Test
open/run/com.vaadin.tests.components.table.TableRowScrolledBottom?restartApplication
clickvaadin=runcomvaadintestscomponentstableTableRowScrolledBottom::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]
pause500
assertTextvaadin=runcomvaadintestscomponentstableTableRowScrolledBottom::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[44]/VLabel[0]This is a test item with long text so that there is something to see Nr. 100. This text must be long otherwise the timing issue on Firefox does not occur. This works fine in IE
clickvaadin=runcomvaadintestscomponentstableTableRowScrolledBottom::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VButton[0]/domChild[0]/domChild[0]
pause500
assertTextvaadin=runcomvaadintestscomponentstableTableRowScrolledBottom::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VScrollTable[0]/VScrollTable$FocusableScrollContextPanel[0]/VScrollTable$VScrollTableBody[0]/VScrollTable$VScrollTableBody$VScrollTableRow[44]/VLabel[0]This is a test item with long text so that there is something to see Nr. 200. This text must be long otherwise the timing issue on Firefox does not occur. This works fine in IE
- - diff --git a/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottom.java b/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottom.java index 7d48dfa11e..e1fe4d0514 100644 --- a/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottom.java +++ b/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottom.java @@ -1,15 +1,19 @@ package com.vaadin.tests.components.table; +import com.vaadin.server.VaadinRequest; import com.vaadin.shared.ui.label.ContentMode; -import com.vaadin.tests.components.TestBase; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.Label; import com.vaadin.ui.Table; -public class TableRowScrolledBottom extends TestBase { +public class TableRowScrolledBottom extends AbstractTestUI { + + final static String part1 = "This is a test item with long text so that there is something to see Nr. "; + final static String part2 = ". This text must be long otherwise the timing issue on Firefox does not occur. This works fine in IE"; @Override - protected void setup() { + protected void setup(VaadinRequest request) { final Table table = new Table(); table.setSizeFull(); @@ -24,12 +28,8 @@ public class TableRowScrolledBottom extends TestBase { public void buttonClick(Button.ClickEvent event) { for (int j = 0; j < 100; j++) { ++i; - table.addItem( - new Object[] { new Label( - "This is a test item with long text so that there is something to see Nr. " - + i - + ". This text must be long otherwise the timing issue on Firefox does not occur. This works fine in IE", - ContentMode.HTML) }, i); + table.addItem(new Object[] { new Label(part1 + "" + i + + "" + part2, ContentMode.HTML) }, i); table.setCurrentPageFirstItemIndex(table .getContainerDataSource().size() - 1); } @@ -42,7 +42,7 @@ public class TableRowScrolledBottom extends TestBase { } @Override - protected String getDescription() { + protected String getTestDescription() { return "Table should be scrolled to bottom when adding rows and updating currentPageFirstItemIndex to last item"; } diff --git a/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottomTest.java b/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottomTest.java new file mode 100644 index 0000000000..0fad02b410 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/TableRowScrolledBottomTest.java @@ -0,0 +1,73 @@ +/* + * 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.io.IOException; +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.TableElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests that adding long labels to a Table and scrolling to the bottom works as + * intended. + * + * @author Vaadin Ltd + */ +public class TableRowScrolledBottomTest extends MultiBrowserTest { + + @Test + public void testScrolling() throws IOException, InterruptedException { + openTestURL(); + + ButtonElement button = $(ButtonElement.class).first(); + TableElement table = $(TableElement.class).first(); + + // initialise contents + button.click(); + sleep(500); + + List rows = table.findElement(By.className("v-table-body")) + .findElements(By.tagName("tr")); + + // check that the final row is the one intended + WebElement finalRow = rows.get(rows.size() - 1); + WebElement label = finalRow.findElement(By.className("v-label")); + assertEquals(TableRowScrolledBottom.part1 + 100 + + TableRowScrolledBottom.part2, label.getText()); + + // add more rows + button.click(); + sleep(500); + + rows = table.findElement(By.className("v-table-body")).findElements( + By.tagName("tr")); + + // check that the final row is the one intended + finalRow = rows.get(rows.size() - 1); + label = finalRow.findElement(By.className("v-label")); + assertEquals(TableRowScrolledBottom.part1 + 200 + + TableRowScrolledBottom.part2, label.getText()); + } + +} -- 2.39.5