From 2c8c2dec3c985332c6b717f5800a5110cc941a6b Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Thu, 20 Jul 2017 14:38:09 +0300 Subject: Add test for Components in Grid Header (#9696) Closes #9694 --- .../com/vaadin/tests/components/grid/GridComponents.java | 4 +++- .../vaadin/tests/components/grid/GridComponentsTest.java | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'uitest') 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 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()); } -- cgit v1.2.3