aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/BasicEscalator.html176
-rw-r--r--uitest/src/com/vaadin/tests/components/grid/BasicEscalatorTest.java107
-rw-r--r--uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java37
3 files changed, 126 insertions, 194 deletions
diff --git a/uitest/src/com/vaadin/tests/components/grid/BasicEscalator.html b/uitest/src/com/vaadin/tests/components/grid/BasicEscalator.html
deleted file mode 100644
index 70aa0fe195..0000000000
--- a/uitest/src/com/vaadin/tests/components/grid/BasicEscalator.html
+++ /dev/null
@@ -1,176 +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="http://localhost:8888/" />
-<title>BasicEscalator</title>
-</head>
-<body>
-<table cellpadding="1" cellspacing="1" border="1">
-<thead>
-<tr><td rowspan="1" colspan="3">BasicEscalator</td></tr>
-</thead><tbody>
-<tr>
- <td>open</td>
- <td>/run/com.vaadin.tests.components.grid.BasicEscalator?restartApplication</td>
- <td></td>
-</tr>
-<tr>
- <td>verifyText</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td>
- <td>Row 0: 0,0 (0)</td>
-</tr>
-<tr>
- <td>verifyText</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[17]/domChild[9]</td>
- <td>Cell: 9,17 (179)</td>
-</tr>
-<tr>
- <td>verifyTextNotPresent</td>
- <td>Cell: 0,100</td>
- <td></td>
-</tr>
-<tr>
- <td>verifyTextNotPresent</td>
- <td>Cell: 0,101</td>
- <td></td>
-</tr>
-<tr>
- <td>type</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VTextField[0]</td>
- <td>0</td>
-</tr>
-<tr>
- <td>type</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[1]/VTextField[0]</td>
- <td>1</td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>verifyText</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[18]/domChild[0]</td>
- <td>Row 0: 0,100 (190)</td>
-</tr>
-<tr>
- <td>type</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VTextField[0]</td>
- <td>11</td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>verifyText</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[17]/domChild[0]</td>
- <td>Row 11: 0,101 (200)</td>
-</tr>
-<tr>
- <td>type</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[0]/VTextField[0]</td>
- <td>0</td>
-</tr>
-<tr>
- <td>type</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[1]/VTextField[0]</td>
- <td>100</td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VHorizontalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>verifyText</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[16]/domChild[0]</td>
- <td>Row 0: 0,102 (210)</td>
-</tr>
-<tr>
- <td>verifyText</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[0]</td>
- <td>Row 16: 0,118 (370)</td>
-</tr>
-<tr>
- <td>scroll</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[0]</td>
- <td>1109</td>
-</tr>
-<tr>
- <td>verifyTextPresent</td>
- <td>Row 56: 0,158</td>
- <td></td>
-</tr>
-<tr>
- <td>verifyTextPresent</td>
- <td>Row 72: 0,174</td>
- <td></td>
-</tr>
-<tr>
- <td>scroll</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[0]</td>
- <td>3690</td>
-</tr>
-<tr>
- <td>verifyTextPresent</td>
- <td>Row 201: 0,99</td>
- <td></td>
-</tr>
-<tr>
- <td>type</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VHorizontalLayout[0]/Slot[0]/VTextField[0]</td>
- <td>201</td>
-</tr>
-<tr>
- <td>type</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VHorizontalLayout[0]/Slot[1]/VTextField[0]</td>
- <td>1</td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[2]/VHorizontalLayout[0]/Slot[2]/VButton[0]/domChild[0]/domChild[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>verifyText</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[0]</td>
- <td>Row 200: 0,98 (960)</td>
-</tr>
-<tr>
- <td>verifyTextNotPresent</td>
- <td>Row 201:</td>
- <td></td>
-</tr>
-<tr>
- <td>type</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VHorizontalLayout[0]/Slot[0]/VTextField[0]</td>
- <td>0</td>
-</tr>
-<tr>
- <td>type</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VHorizontalLayout[0]/Slot[1]/VTextField[0]</td>
- <td>2</td>
-</tr>
-<tr>
- <td>click</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[3]/VHorizontalLayout[0]/Slot[2]/VButton[0]</td>
- <td></td>
-</tr>
-<tr>
- <td>verifyText</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[16]/domChild[0]</td>
- <td>Row 184: 10,82 (974)</td>
-</tr>
-<tr>
- <td>verifyText</td>
- <td>vaadin=runcomvaadintestscomponentsgridBasicEscalator::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VTestGrid[0]/domChild[1]/domChild[0]/domChild[1]/domChild[1]/domChild[0]</td>
- <td>Row 200: 10,98 (1006)</td>
-</tr>
-</tbody></table>
-</body>
-</html>
diff --git a/uitest/src/com/vaadin/tests/components/grid/BasicEscalatorTest.java b/uitest/src/com/vaadin/tests/components/grid/BasicEscalatorTest.java
index 5afe826196..bd1a580c73 100644
--- a/uitest/src/com/vaadin/tests/components/grid/BasicEscalatorTest.java
+++ b/uitest/src/com/vaadin/tests/components/grid/BasicEscalatorTest.java
@@ -15,8 +15,15 @@
*/
package com.vaadin.tests.components.grid;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
import org.junit.Test;
import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.NoSuchElementException;
+import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
@@ -24,20 +31,88 @@ import com.vaadin.tests.tb3.MultiBrowserTest;
public class BasicEscalatorTest extends MultiBrowserTest {
@Test
- public void testNormalHeight() throws Exception {
+ public void testInitialState() throws Exception {
+ openTestURL();
+
+ WebElement cell1 = getBodyRowCell(0, 0);
+ assertEquals("Top left body cell had unexpected content", "Row 0: 0,0",
+ cell1.getText());
+
+ WebElement cell2 = getBodyRowCell(15, 3);
+ assertEquals("Lower merged cell had unexpected content", "Cell: 3,15",
+ cell2.getText());
+ }
+
+ @Test
+ public void testScroll() throws Exception {
+ openTestURL();
+
+ /*
+ * let the DOM stabilize itself. TODO: remove once waitForVaadin
+ * supports lazy loaded components
+ */
+ Thread.sleep(100);
+
+ scrollEscalatorVerticallyTo(1000);
+ assertBodyCellWithContentIsFound("Row 50: 0,50");
+ }
+
+ @Test
+ public void testLastRow() throws Exception {
+ openTestURL();
+
+ /*
+ * let the DOM stabilize itself. TODO: remove once waitForVaadin
+ * supports lazy loaded components
+ */
+ Thread.sleep(100);
+
+ // scroll to bottom
+ scrollEscalatorVerticallyTo(100000000);
+
+ /*
+ * this test does not test DOM reordering, therefore we don't rely on
+ * child indices - we simply seek by content.
+ */
+ assertBodyCellWithContentIsFound("Row 99: 0,99");
+ }
+
+ @Test
+ public void testNormalRowHeight() throws Exception {
+ /*
+ * This is tested with screenshots instead of CSS queries, since some
+ * browsers report dimensions differently from each other, which is
+ * uninteresting for our purposes
+ */
openTestURL();
compareScreen("normalHeight");
}
@Test
- public void testModifiedHeight() throws Exception {
+ public void testModifiedRowHeight() throws Exception {
+ /*
+ * This is tested with screenshots instead of CSS queries, since some
+ * browsers report dimensions differently from each other, which is
+ * uninteresting for our purposes
+ */
openTestURLWithTheme("reindeer-tests");
compareScreen("modifiedHeight");
}
- private WebElement getFirstBodyRowCell() {
+ private void assertBodyCellWithContentIsFound(String cellContent) {
+ String xpath = "//tbody/tr/td[.='" + cellContent + "']";
+ try {
+ assertNotNull("received a null element with \"" + xpath + "\"",
+ getDriver().findElement(By.xpath(xpath)));
+ } catch (NoSuchElementException e) {
+ fail("Could not find '" + xpath + "'");
+ }
+ }
+
+ private WebElement getBodyRowCell(int row, int col) {
return getDriver().findElement(
- By.xpath("//tbody/tr[@class='v-escalator-row'][1]/td[1]"));
+ By.xpath("//tbody/tr[@class='v-escalator-row'][" + (row + 1)
+ + "]/td[" + (col + 1) + "]"));
}
private void openTestURLWithTheme(String themeName) {
@@ -46,4 +121,28 @@ public class BasicEscalatorTest extends MultiBrowserTest {
testUrl += "theme=" + themeName;
getDriver().get(testUrl);
}
+
+ private void scrollEscalatorVerticallyTo(double px) {
+ executeScript("arguments[0].scrollTop = " + px,
+ getGridVerticalScrollbar());
+ }
+
+ private Object executeScript(String script, WebElement element) {
+ @SuppressWarnings("hiding")
+ final WebDriver driver = getDriver();
+ if (driver instanceof JavascriptExecutor) {
+ final JavascriptExecutor je = (JavascriptExecutor) driver;
+ return je.executeScript(script, element);
+ } else {
+ throw new IllegalStateException("current driver "
+ + getDriver().getClass().getName() + " is not a "
+ + JavascriptExecutor.class.getSimpleName());
+ }
+ }
+
+ private WebElement getGridVerticalScrollbar() {
+ return getDriver()
+ .findElement(
+ By.xpath("//div[contains(@class, \"v-escalator-scroller-vertical\")]"));
+ }
}
diff --git a/uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java b/uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java
index 28e650edc1..bdbff4a6f0 100644
--- a/uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java
+++ b/uitest/src/com/vaadin/tests/widgetset/client/grid/VTestGrid.java
@@ -3,6 +3,7 @@ package com.vaadin.tests.widgetset.client.grid;
import java.util.ArrayList;
import java.util.List;
+import com.google.gwt.user.client.Window.Location;
import com.google.gwt.user.client.ui.Composite;
import com.vaadin.client.ui.grid.Cell;
import com.vaadin.client.ui.grid.ColumnConfiguration;
@@ -81,8 +82,10 @@ public class VTestGrid extends Composite {
public void renderCell(final Cell cell) {
final Integer columnName = columns.get(cell.getColumn());
final Integer rowName = rows.get(cell.getRow());
- final String cellInfo = columnName + "," + rowName + " ("
- + i + ")";
+ String cellInfo = columnName + "," + rowName;
+ if (shouldRenderPretty()) {
+ cellInfo += " (" + i + ")";
+ }
if (cell.getColumn() > 0) {
cell.getElement().setInnerText("Cell: " + cellInfo);
@@ -95,23 +98,29 @@ public class VTestGrid extends Composite {
cell.setColSpan(3);
}
- final double c = i * .1;
- final int r = (int) ((Math.cos(c) + 1) * 128);
- final int g = (int) ((Math.cos(c / Math.PI) + 1) * 128);
- final int b = (int) ((Math.cos(c / (Math.PI * 2)) + 1) * 128);
- cell.getElement()
- .getStyle()
- .setBackgroundColor(
- "rgb(" + r + "," + g + "," + b + ")");
- if ((r * .8 + g * 1.3 + b * .9) / 3 < 127) {
- cell.getElement().getStyle().setColor("white");
- } else {
- cell.getElement().getStyle().clearColor();
+ if (shouldRenderPretty()) {
+ final double c = i * .1;
+ final int r = (int) ((Math.cos(c) + 1) * 128);
+ final int g = (int) ((Math.cos(c / Math.PI) + 1) * 128);
+ final int b = (int) ((Math.cos(c / (Math.PI * 2)) + 1) * 128);
+ cell.getElement()
+ .getStyle()
+ .setBackgroundColor(
+ "rgb(" + r + "," + g + "," + b + ")");
+ if ((r * .8 + g * 1.3 + b * .9) / 3 < 127) {
+ cell.getElement().getStyle().setColor("white");
+ } else {
+ cell.getElement().getStyle().clearColor();
+ }
}
i++;
}
+ private boolean shouldRenderPretty() {
+ return Location.getQueryString().contains("pretty");
+ }
+
@Override
public void updateCells(final Row row,
final Iterable<Cell> cellsToUpdate) {