diff options
author | Anna Koskinen <anna@vaadin.com> | 2014-08-14 16:08:38 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-08-19 12:38:31 +0000 |
commit | 06f758e3916ccbd783d3277b0d17b099724dc44c (patch) | |
tree | 35124007111ae6cffcab10a172b71b500d02b25a /uitest | |
parent | b18bf1e1f3c52e41eea044faff427af9ffde5fe8 (diff) | |
download | vaadin-framework-06f758e3916ccbd783d3277b0d17b099724dc44c.tar.gz vaadin-framework-06f758e3916ccbd783d3277b0d17b099724dc44c.zip |
TreeTablePartialUpdates test upgrade (#14292)
Change-Id: I32029461c7a4eeec1b54ce8a3f0b730f22deca1b
Diffstat (limited to 'uitest')
4 files changed, 204 insertions, 116 deletions
diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTableNegativeArraySize.html b/uitest/src/com/vaadin/tests/components/treetable/TreeTableNegativeArraySize.html deleted file mode 100644 index b57c5f978e..0000000000 --- a/uitest/src/com/vaadin/tests/components/treetable/TreeTableNegativeArraySize.html +++ /dev/null @@ -1,59 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="" /> -<title>New Test</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.treetable.TreeTablePartialUpdates?restartApplication</td> - <td></td> -</tr> -<!--expand root1--> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstreetableTreeTablePartialUpdates::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTreeTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> - <td>12,4</td> -</tr> -<tr> - <td>scroll</td> - <td>vaadin=runcomvaadintestscomponentstreetableTreeTablePartialUpdates::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTreeTable[0]/domChild[1]</td> - <td>3969</td> -</tr> -<tr> - <td>pause</td> - <td>300</td> - <td></td> -</tr> -<!--expand root2--> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstreetableTreeTablePartialUpdates::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTreeTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[42]/domChild[0]/domChild[0]/domChild[0]</td> - <td>9,-183</td> -</tr> -<!--collapse root2--> -<tr> - <td>pause</td> - <td>1000</td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstreetableTreeTablePartialUpdates::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTreeTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[42]/domChild[0]/domChild[0]/domChild[0]</td> - <td>11,-182</td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>root1-expanded-scrolled-to-end</td> -</tr> -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdates-LongScroll.html b/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdates-LongScroll.html deleted file mode 100644 index 276725e6bd..0000000000 --- a/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdates-LongScroll.html +++ /dev/null @@ -1,52 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> -<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="" /> -<title>New Test</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">New Test</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.treetable.TreeTablePartialUpdates?restartApplication</td> - <td></td> -</tr> -<tr> - <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentstreetableTreeTablePartialUpdates::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTreeTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td> - <td>12,6</td> -</tr> -<tr> - <td>scroll</td> - <td>vaadin=runcomvaadintestscomponentstreetableTreeTablePartialUpdates::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTreeTable[0]/domChild[1]</td> - <td>1692</td> -</tr> -<tr> - <td>pause</td> - <td>300</td> - <td></td> -</tr> -<!-- scroll 6000 to make sure to actually hit bottom --> -<tr> - <td>scroll</td> - <td>vaadin=runcomvaadintestscomponentstreetableTreeTablePartialUpdates::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VTreeTable[0]/domChild[1]</td> - <td>6000</td> -</tr> -<tr> - <td>pause</td> - <td>300</td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td>treetable-long-scroll</td> -</tr> -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdates.java b/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdates.java index 23eaa5dfea..78d67ee090 100644 --- a/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdates.java +++ b/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdates.java @@ -2,19 +2,21 @@ package com.vaadin.tests.components.treetable; import com.vaadin.data.Container.Hierarchical; import com.vaadin.data.util.HierarchicalContainer; -import com.vaadin.tests.components.TestBase; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.TreeTable; -public class TreeTablePartialUpdates extends TestBase { +public class TreeTablePartialUpdates extends AbstractTestUI { @Override - protected void setup() { + protected void setup(VaadinRequest request) { TreeTable tt = new TreeTable(); tt.setContainerDataSource(makeHierarchicalContainer()); tt.setWidth("300px"); addComponent(tt); } + @SuppressWarnings("unchecked") private Hierarchical makeHierarchicalContainer() { HierarchicalContainer hc = new HierarchicalContainer(); hc.addContainerProperty("p1", String.class, ""); @@ -42,6 +44,7 @@ public class TreeTablePartialUpdates extends TestBase { return hc; } + @SuppressWarnings("unchecked") private void addNodesToRoot(HierarchicalContainer hc, Object root, int count) { for (int ix = 0; ix < count; ix++) { Object id = hc.addItem(); @@ -51,8 +54,8 @@ public class TreeTablePartialUpdates extends TestBase { } @Override - protected String getDescription() { - return ""; + protected String getTestDescription() { + return "Tests partial updates and how they affect cached rows and scroll position."; } @Override diff --git a/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdatesTest.java b/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdatesTest.java new file mode 100644 index 0000000000..5a55df581c --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/treetable/TreeTablePartialUpdatesTest.java @@ -0,0 +1,196 @@ +/* + * 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.treetable; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import java.io.IOException; +import java.util.List; + +import org.junit.Test; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedConditions; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.commands.TestBenchElementCommands; +import com.vaadin.testbench.elements.TreeTableElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +/** + * Tests partial updates of a TreeTable. + * + * @author Vaadin Ltd + */ +public class TreeTablePartialUpdatesTest extends MultiBrowserTest { + + @Test + public void testLongScroll() throws IOException, InterruptedException { + openTestURL(); + + TreeTableElement treeTable = $(TreeTableElement.class).first(); + List<WebElement> rows = treeTable.findElement( + By.className("v-table-body")).findElements(By.tagName("tr")); + assertEquals("unexpected row count", 4, rows.size()); + + // expand the first root element + treeTable.getCell(0, 0) + .findElement(By.className("v-treetable-treespacer")).click(); + treeTable = $(TreeTableElement.class).first(); + + // wait for the scrollposition element to disappear + waitUntilNot(ExpectedConditions.visibilityOfElementLocated(By + .className("v-table-scrollposition"))); + + rows = treeTable.findElement(By.className("v-table-body")) + .findElements(By.tagName("tr")); + assertEquals("unexpected cached row count", 46, rows.size()); + + // TODO: replace these with just treeTable.scroll(int) when #13826 has + // been fixed + TestBenchElementCommands scrollable = testBenchElement(treeTable + .findElement(By.className("v-scrollable"))); + + // scroll far enough down to drop the first row from the cache + // but not far enough to reach the last row + scrollable.scroll(1692); + + // wait for the scrollposition element to disappear + waitUntilNot(ExpectedConditions.visibilityOfElementLocated(By + .className("v-table-scrollposition"))); + + assertEquals("elements found where there should be none", 0, treeTable + .findElements(By.vaadin("#row[0]/col[0]")).size()); + assertEquals("elements found where there should be none", 0, treeTable + .findElements(By.vaadin("#row[203]/col[0]")).size()); + + // scroll 6000 to make sure to actually hit bottom + scrollable.scroll(6000); + + // wait for the scrollposition element to disappear + waitUntilNot(ExpectedConditions.visibilityOfElementLocated(By + .className("v-table-scrollposition"))); + + // check the contents + treeTable = $(TreeTableElement.class).first(); + rows = treeTable.findElement(By.className("v-table-body")) + .findElements(By.tagName("tr")); + assertEquals("unexpected cached row count", 45, rows.size()); + assertEquals("unexpected cell contents (final row expected)", "END", + treeTable.getCell(203, 0).getText()); + assertEquals("unexpected cell contents (first visible row expected)", + "188", treeTable.getCell(189, 0).getText()); + assertEquals("unexpected cell contents (first cached row expected)", + "158", treeTable.getCell(159, 0).getText()); + + assertEquals("elements found where there should be none", 0, treeTable + .findElements(By.vaadin("#row[158]/col[0]")).size()); + assertEquals("elements found where there should be none", 0, treeTable + .findElements(By.vaadin("#row[204]/col[0]")).size()); + + // check the actual visibility + compareScreen("bottom"); + } + + @Test + public void testNegativeArraySize() throws IOException, + InterruptedException { + openTestURL(); + + TreeTableElement treeTable = $(TreeTableElement.class).first(); + List<WebElement> rows = treeTable.findElement( + By.className("v-table-body")).findElements(By.tagName("tr")); + assertEquals("unexpected row count", 4, rows.size()); + + // expand the first root element + treeTable.getCell(0, 0) + .findElement(By.className("v-treetable-treespacer")).click(); + + // wait for the scrollposition element to disappear + waitUntilNot(ExpectedConditions.visibilityOfElementLocated(By + .className("v-table-scrollposition"))); + + treeTable = $(TreeTableElement.class).first(); + rows = treeTable.findElement(By.className("v-table-body")) + .findElements(By.tagName("tr")); + assertEquals("unexpected cached row count", 46, rows.size()); + + // TODO: replace these with just treeTable.scroll(int) when #13826 has + // been fixed + TestBenchElementCommands scrollable = testBenchElement(treeTable + .findElement(By.className("v-scrollable"))); + + // scroll far enough down to reach the second root item again + scrollable.scroll(3969); + + // wait for the scrollposition element to disappear + waitUntilNot(ExpectedConditions.visibilityOfElementLocated(By + .className("v-table-scrollposition"))); + + assertEquals("elements found where there should be none", 0, treeTable + .findElements(By.vaadin("#row[0]/col[0]")).size()); + assertEquals("unexpected cell contents", "root2", + treeTable.getCell(201, 0).getText()); + assertEquals("unexpected cell contents", "END", + treeTable.getCell(203, 0).getText()); + + // expand the second root element + treeTable.getCell(201, 0) + .findElement(By.className("v-treetable-treespacer")).click(); + + // wait for the scrollposition element to disappear + waitUntilNot(ExpectedConditions.visibilityOfElementLocated(By + .className("v-table-scrollposition"))); + + // ensure the last cached row isn't the final row + treeTable = $(TreeTableElement.class).first(); + rows = treeTable.findElement(By.className("v-table-body")) + .findElements(By.tagName("tr")); + String elementText = rows.get(rows.size() - 1) + .findElement(By.className("v-table-cell-wrapper")).getText(); + assertFalse("final row found when it should be beyond cache", + elementText.contains("END")); + + // collapse the second root element + treeTable.getCell(201, 0) + .findElement(By.className("v-treetable-treespacer")).click(); + + // wait for the scrollposition element to disappear + waitUntilNot(ExpectedConditions.visibilityOfElementLocated(By + .className("v-table-scrollposition"))); + + // check the contents + treeTable = $(TreeTableElement.class).first(); + rows = treeTable.findElement(By.className("v-table-body")) + .findElements(By.tagName("tr")); + assertEquals("unexpected cached row count", 45, rows.size()); + assertEquals("unexpected cell contents (final row expected)", "END", + treeTable.getCell(203, 0).getText()); + assertEquals("unexpected cell contents (first visible row expected)", + "188", treeTable.getCell(189, 0).getText()); + assertEquals("unexpected cell contents (first cached row expected)", + "158", treeTable.getCell(159, 0).getText()); + + assertEquals("elements found where there should be none", 0, treeTable + .findElements(By.vaadin("#row[158]/col[0]")).size()); + assertEquals("elements found where there should be none", 0, treeTable + .findElements(By.vaadin("#row[204]/col[0]")).size()); + + // check the actual visibility + compareScreen("bottom"); + } + +} |