aboutsummaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorrogozinds <rogozinds@gmail.com>2017-01-17 06:13:06 -0800
committerDenis <denis@vaadin.com>2017-01-17 16:13:06 +0200
commit487cb4ea0c5e51e7a9b85d6bbb6ab9200f6772f7 (patch)
tree54973b0ecd2103d73190f81d224c297165c2318b /uitest
parentfd92d1f134962fdd3302cd5ad575e072a3dae7bd (diff)
downloadvaadin-framework-487cb4ea0c5e51e7a9b85d6bbb6ab9200f6772f7.tar.gz
vaadin-framework-487cb4ea0c5e51e7a9b85d6bbb6ab9200f6772f7.zip
Add getHeaderCellByCaption method to tb-api GridElement (#8248)
* Add getHeaderCellByCaption method to tb-api GridElement
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/elements/grid/GridUI.java6
-rw-r--r--uitest/src/test/java/com/vaadin/tests/elements/grid/GridUITest.java43
2 files changed, 48 insertions, 1 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/elements/grid/GridUI.java b/uitest/src/main/java/com/vaadin/tests/elements/grid/GridUI.java
index 4655eb3560..b92c667307 100644
--- a/uitest/src/main/java/com/vaadin/tests/elements/grid/GridUI.java
+++ b/uitest/src/main/java/com/vaadin/tests/elements/grid/GridUI.java
@@ -7,6 +7,7 @@ import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUI;
import com.vaadin.ui.Grid;
import com.vaadin.ui.Label;
+import com.vaadin.ui.components.grid.HeaderRow;
public class GridUI extends AbstractTestUI {
@@ -19,7 +20,10 @@ public class GridUI extends AbstractTestUI {
final Grid<Item> grid = new Grid<Item>();
grid.setItems(getMockData(rowCount));
- grid.addColumn(Item::getFoo).setCaption("foo");
+ Grid.Column<Item, String> column = grid.addColumn(Item::getFoo)
+ .setCaption("foo");
+ HeaderRow row =grid.addHeaderRowAt(1);
+ row.getCell(column).setText("extra row");
grid.addColumn(Item::getBar).setCaption("bar");
grid.setDetailsGenerator(item -> {
diff --git a/uitest/src/test/java/com/vaadin/tests/elements/grid/GridUITest.java b/uitest/src/test/java/com/vaadin/tests/elements/grid/GridUITest.java
index dc3a49eafe..8652972df1 100644
--- a/uitest/src/test/java/com/vaadin/tests/elements/grid/GridUITest.java
+++ b/uitest/src/test/java/com/vaadin/tests/elements/grid/GridUITest.java
@@ -2,6 +2,7 @@ package com.vaadin.tests.elements.grid;
import org.junit.Assert;
import org.junit.Test;
+import org.openqa.selenium.NoSuchElementException;
import com.vaadin.testbench.elements.GridElement;
import com.vaadin.testbench.elements.GridElement.GridRowElement;
@@ -41,6 +42,48 @@ public class GridUITest extends MultiBrowserTest {
Assert.assertEquals(100, checkRows());
}
+ @Test
+ public void testGetHeadersByCaptionFirstRowFirstColumn() {
+ openTestURL("rowCount=10&restartApplication");
+ GridElement grid = $(GridElement.class).first();
+ grid.getHeaderCellByCaption("foo");
+ }
+
+ @Test
+ public void testGetHeadersByCaptionFirstRowNotFirstColumn() {
+ openTestURL("rowCount=10&restartApplication");
+ GridElement grid = $(GridElement.class).first();
+ grid.getHeaderCellByCaption("bar");
+ }
+
+ @Test(expected = NoSuchElementException.class)
+ public void testGetHeadersByCaptionNoHeader() {
+ openTestURL("rowCount=10&restartApplication");
+ GridElement grid = $(GridElement.class).first();
+ grid.getHeaderCellByCaption("not existing caption");
+ }
+
+ @Test(expected = NoSuchElementException.class)
+ public void testGetHeadersByCaptionByIndexNoHeader() {
+ openTestURL("rowCount=10&restartApplication");
+ GridElement grid = $(GridElement.class).first();
+ grid.getHeaderCellByCaption(0, "not existing caption");
+ }
+
+ @Test
+ public void testGetHeadersByCaptionNotFirstRow() {
+ openTestURL("rowCount=10&restartApplication");
+ GridElement grid = $(GridElement.class).first();
+ grid.getHeaderCellByCaption("extra row");
+ }
+
+ @Test
+ public void testGetHeadersByCaptionByIndexNotFirstRow() {
+ openTestURL("rowCount=10&restartApplication");
+ GridElement grid = $(GridElement.class).first();
+ grid.getHeaderCellByCaption(1, "extra row");
+ }
+
private int checkRows() {
int rowCount = 0;
for (final GridRowElement row : getRows()) {