diff options
author | Juuso Valli <juuso@vaadin.com> | 2014-05-26 17:22:18 +0300 |
---|---|---|
committer | Sauli Tähkäpää <sauli@vaadin.com> | 2014-05-27 10:41:03 +0300 |
commit | 2ae7c9aa3f2e48091e859d9ffe8c9136e1570c8f (patch) | |
tree | 667e591726201114f5c8c9aab54ac0810de29d40 | |
parent | 7ea9571a6bfdf292eb1b085d4040c558dc66a9c7 (diff) | |
download | vaadin-framework-2ae7c9aa3f2e48091e859d9ffe8c9136e1570c8f.tar.gz vaadin-framework-2ae7c9aa3f2e48091e859d9ffe8c9136e1570c8f.zip |
Fix Push update race condition (#13562)
Change-Id: I50094bc2d236f6dbb02a8b82d6cc9b5f7e4733a5
Conflicts:
uitest/src/com/vaadin/tests/components/table/ContainerSizeChangeTest.java
-rw-r--r-- | server/src/com/vaadin/ui/Table.java | 11 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/table/ContainerSizeChangeTest.java | 40 |
2 files changed, 33 insertions, 18 deletions
diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java index b4d79f304c..a8265662ea 100644 --- a/server/src/com/vaadin/ui/Table.java +++ b/server/src/com/vaadin/ui/Table.java @@ -2957,12 +2957,19 @@ public class Table extends AbstractSelect implements Action.Container, if (value != null) { reqFirstRowToPaint = value.intValue(); } + value = (Integer) variables.get("reqrows"); if (value != null) { reqRowsToPaint = value.intValue(); + int size = size(); // sanity check - if (reqFirstRowToPaint + reqRowsToPaint > size()) { - reqRowsToPaint = size() - reqFirstRowToPaint; + + if (reqFirstRowToPaint >= size) { + reqFirstRowToPaint = size; + } + + if (reqFirstRowToPaint + reqRowsToPaint > size) { + reqRowsToPaint = size - reqFirstRowToPaint; } } } diff --git a/uitest/src/com/vaadin/tests/components/table/ContainerSizeChangeTest.java b/uitest/src/com/vaadin/tests/components/table/ContainerSizeChangeTest.java index 08cc1eb382..e0777324ad 100644 --- a/uitest/src/com/vaadin/tests/components/table/ContainerSizeChangeTest.java +++ b/uitest/src/com/vaadin/tests/components/table/ContainerSizeChangeTest.java @@ -1,19 +1,21 @@ 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 static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.io.IOException; + 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; +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.TableElement; +import com.vaadin.tests.tb3.MultiBrowserTest; public class ContainerSizeChangeTest extends MultiBrowserTest { @@ -21,29 +23,35 @@ public class ContainerSizeChangeTest extends MultiBrowserTest { public ExpectedException thrown = ExpectedException.none(); @Test - public void tableShouldLoadCorrectItems() throws IOException, InterruptedException { + 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 + 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); + // waitforvaadin not worky currently for table scroll, so we need to use + // thread sleep :( + Thread.sleep(1500); 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))); + 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... + // 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); |