Sfoglia il codice sorgente

Revert "Fix Push inserts producing duplicate rows in Table (#13562)"

This reverts commit ce1764fb1b.

Change-Id: I897e0f3a0876eaea4b68f0e3b75671ccb1398242
tags/7.3.0.alpha3
Sauli Tähkäpää 10 anni fa
parent
commit
0b3af0fe74

+ 2
- 10
server/src/com/vaadin/ui/Table.java Vedi File

@@ -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;
}
}
}

+ 0
- 82
uitest/src/com/vaadin/tests/components/table/ContainerSizeChange.html Vedi File

@@ -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>

+ 53
- 0
uitest/src/com/vaadin/tests/components/table/ContainerSizeChangeTest.java Vedi File

@@ -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));
}
}

Loading…
Annulla
Salva