summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/table/ContainerSizeChange.html82
-rw-r--r--uitest/src/com/vaadin/tests/components/table/ContainerSizeChangeTest.java53
2 files changed, 53 insertions, 82 deletions
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));
+ }
+}