diff options
author | Sauli Tähkäpää <sauli@vaadin.com> | 2014-05-26 10:56:50 +0300 |
---|---|---|
committer | Sauli Tähkäpää <sauli@vaadin.com> | 2014-05-26 11:12:05 +0300 |
commit | 0b3af0fe74b790a5ac4159a97ccb4e5aeb8ad85c (patch) | |
tree | 141932264486297e1c0cf160b7fe4b5150eaa1fe | |
parent | af9dadbf3517b76e86e0e60452661dc07b178e57 (diff) | |
download | vaadin-framework-0b3af0fe74b790a5ac4159a97ccb4e5aeb8ad85c.tar.gz vaadin-framework-0b3af0fe74b790a5ac4159a97ccb4e5aeb8ad85c.zip |
Revert "Fix Push inserts producing duplicate rows in Table (#13562)"
This reverts commit ce1764fb1bad1b82462d73fbfe293b676c2a9c00.
Change-Id: I897e0f3a0876eaea4b68f0e3b75671ccb1398242
3 files changed, 55 insertions, 92 deletions
diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java index 29dc52a9a6..b4d79f304c 100644 --- a/server/src/com/vaadin/ui/Table.java +++ b/server/src/com/vaadin/ui/Table.java @@ -2954,23 +2954,15 @@ public class Table extends AbstractSelect implements Action.Container, // (row caches emptied by other event) if (!containerChangeToBeRendered) { Integer value = (Integer) variables.get("reqfirstrow"); - int tableSize = size(); if (value != null) { reqFirstRowToPaint = value.intValue(); - // Sanity check - if (reqFirstRowToPaint < 0) { - reqFirstRowToPaint = -1; - } - if (reqFirstRowToPaint >= tableSize) { - reqFirstRowToPaint = tableSize - 1; - } } value = (Integer) variables.get("reqrows"); if (value != null) { reqRowsToPaint = value.intValue(); // sanity check - if (reqFirstRowToPaint + reqRowsToPaint > tableSize) { - reqRowsToPaint = tableSize - reqFirstRowToPaint; + if (reqFirstRowToPaint + reqRowsToPaint > size()) { + reqRowsToPaint = size() - reqFirstRowToPaint; } } } diff --git a/uitest/src/com/vaadin/tests/components/table/ContainerSizeChange.html b/uitest/src/com/vaadin/tests/components/table/ContainerSizeChange.html deleted file mode 100644 index 7c2374f322..0000000000 --- a/uitest/src/com/vaadin/tests/components/table/ContainerSizeChange.html +++ /dev/null @@ -1,82 +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>ContainerSizeChange</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> -<thead> -<tr><td rowspan="1" colspan="3">ContainerSizeChange</td></tr> -</thead><tbody> -<tr> - <td>open</td> - <td>/run/com.vaadin.tests.components.table.ContainerSizeChange</td> - <td></td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentstableContainerSizeChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>vaadin=runcomvaadintestscomponentstableContainerSizeChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td> - <td></td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>scroll</td> - <td>vaadin=runcomvaadintestscomponentstableContainerSizeChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]</td> - <td>945</td> -</tr> -<tr> - <td>pause</td> - <td>300</td> - <td></td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>scroll</td> - <td>vaadin=runcomvaadintestscomponentstableContainerSizeChange::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VScrollTable[0]/domChild[1]</td> - <td>525</td> -</tr> -<tr> - <td>pause</td> - <td>300</td> - <td></td> -</tr> -<tr> - <td>waitForVaadin</td> - <td></td> - <td></td> -</tr> -<tr> - <td>screenCapture</td> - <td></td> - <td></td> -</tr> - -</tbody></table> -</body> -</html> diff --git a/uitest/src/com/vaadin/tests/components/table/ContainerSizeChangeTest.java b/uitest/src/com/vaadin/tests/components/table/ContainerSizeChangeTest.java new file mode 100644 index 0000000000..a866e4a0c5 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/table/ContainerSizeChangeTest.java @@ -0,0 +1,53 @@ +package com.vaadin.tests.components.table; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.TableElement; +import com.vaadin.tests.tb3.MultiBrowserTest; +import junit.framework.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.openqa.selenium.NoSuchElementException; + +import java.io.IOException; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +public class ContainerSizeChangeTest extends MultiBrowserTest { + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void tableShouldLoadCorrectItems() throws IOException, InterruptedException { + openTestURL(); + + ButtonElement decreaseSize = $(ButtonElement.class).caption("Decrease size").first(); + decreaseSize.click(); //decreasing container size from 50 to 40 + decreaseSize.click(); //decreasing container size from 40 to 30 + + TableElement table = $(TableElement.class).first(); + //TableElement scroll not working properly, so we need to do this. http://dev.vaadin.com/ticket/13826 + testBenchElement(table.findElement(By.className("v-scrollable"))).scroll(1000); + + //waitforvaadin not worky currently for table scroll, so we need to use thread sleep :( + Thread.sleep(1000); + + assertThatRowExists(table, 29); + assertRowDoesNotExist(table, 30); + } + + private void assertThatRowExists(TableElement table, int rowIndex) { + assertThat(table.getCell(rowIndex, 0).getText(), is(String.format("a %s", rowIndex))); + } + + private void assertRowDoesNotExist(TableElement table, int rowIndex) { + //This is a really crappy way to workaround JUnit's limitation to provide a proper assert.throws method... + thrown.expect(NoSuchElementException.class); + table.getCell(rowIndex, 0); + + Assert.fail(String.format("Row %s should not exists.", rowIndex)); + } +} |