diff options
author | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2017-07-20 14:38:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-20 14:38:09 +0300 |
commit | 2c8c2dec3c985332c6b717f5800a5110cc941a6b (patch) | |
tree | b793079692dc103e016952d14ac3066c11786bae /uitest | |
parent | d390b2692af389ecca4115a0ea4bb3608ca37202 (diff) | |
download | vaadin-framework-2c8c2dec3c985332c6b717f5800a5110cc941a6b.tar.gz vaadin-framework-2c8c2dec3c985332c6b717f5800a5110cc941a6b.zip |
Add test for Components in Grid Header (#9696)
Closes #9694
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/main/java/com/vaadin/tests/components/grid/GridComponents.java | 4 | ||||
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java | 16 |
2 files changed, 18 insertions, 2 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridComponents.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridComponents.java index e1bf0f354a..92ba75869c 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridComponents.java +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridComponents.java @@ -26,7 +26,9 @@ public class GridComponents extends AbstractTestUIWithLog { protected void setup(VaadinRequest request) { Grid<String> grid = new Grid<>(); grid.addColumn(string -> new Label(string), new ComponentRenderer()) - .setCaption("Label"); + .setId("label").setCaption("Column 0"); + grid.getDefaultHeaderRow().getCell("label") + .setComponent(new Label("Label")); grid.addComponentColumn(string -> { if (textFields.containsKey(string)) { log("Reusing old text field for: " + string); diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java index 70966b373e..045d205f87 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridComponentsTest.java @@ -12,6 +12,7 @@ import com.vaadin.testbench.elements.ButtonElement; import com.vaadin.testbench.elements.GridElement; import com.vaadin.testbench.elements.GridElement.GridCellElement; import com.vaadin.testbench.elements.GridElement.GridRowElement; +import com.vaadin.testbench.elements.LabelElement; import com.vaadin.testbench.elements.NotificationElement; import com.vaadin.tests.tb3.MultiBrowserTest; @@ -108,11 +109,24 @@ public class GridComponentsTest extends MultiBrowserTest { IntStream.range(300, 310).forEach(this::assertNoButton); } + @Test(expected = AssertionError.class) + public void testRow31() { + openTestURL(); + // There is a button on row 31. This should fail. + assertNoButton(31); + } + @Test public void testHeaders() { openTestURL(); GridElement grid = $(GridElement.class).first(); - Assert.assertEquals("Label", grid.getHeaderCell(0, 0).getText()); + GridCellElement headerCell = grid.getHeaderCell(0, 0); + Assert.assertTrue("First header should contain a Label", + headerCell.isElementPresent(LabelElement.class)); + Assert.assertEquals("Label", + headerCell.$(LabelElement.class).first().getText()); + Assert.assertFalse("Second header should not contain a component", + grid.getHeaderCell(0, 1).isElementPresent(LabelElement.class)); Assert.assertEquals("Other Components", grid.getHeaderCell(0, 1).getText()); } |