diff options
author | Anna Koskinen <Ansku@users.noreply.github.com> | 2018-11-21 14:46:06 +0200 |
---|---|---|
committer | Olli Tietäväinen <ollit@vaadin.com> | 2018-11-21 14:46:06 +0200 |
commit | 62847523b58b759a571b65303f18cf67bb497d92 (patch) | |
tree | 3568bb9abd066f09df4c08a2f0064769cdf3c349 /uitest | |
parent | 124ed6d87ecfdfbb1d88ffdf615f5c8cc7f0e0b1 (diff) | |
download | vaadin-framework-62847523b58b759a571b65303f18cf67bb497d92.tar.gz vaadin-framework-62847523b58b759a571b65303f18cf67bb497d92.zip |
Fix for setting default row height for a Grid with details row(s) open. (#11326)
* Fix for setting default row height for a Grid with details row(s) open.
- Details row(s) should be taken into account when the rows are
re-positioned after getting new heights.
Fixes #11325
Diffstat (limited to 'uitest')
2 files changed, 91 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridWithInitiallyOpenDetails.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridWithInitiallyOpenDetails.java new file mode 100644 index 0000000000..418170dcca --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridWithInitiallyOpenDetails.java @@ -0,0 +1,57 @@ +package com.vaadin.tests.components.grid; + +import java.util.List; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.data.bean.Person; +import com.vaadin.ui.Grid; +import com.vaadin.ui.Grid.ItemClick; +import com.vaadin.ui.Label; +import com.vaadin.ui.components.grid.ItemClickListener; + +public class GridWithInitiallyOpenDetails extends SimpleGridUI { + private List<Person> persons; + + @Override + protected void setup(VaadinRequest request) { + addComponent(createGrid()); + } + + @Override + protected List<Person> createPersons() { + persons = super.createPersons(); + return persons; + } + + @Override + protected Grid<Person> createGrid() { + Grid<Person> grid = super.createGrid(); + + grid.setDetailsGenerator( + row -> new Label("details for " + row.getFirstName())); + + for (Person person : persons) { + grid.setDetailsVisible(person, true); + } + + grid.addItemClickListener(new ItemClickListener<Person>() { + @Override + public void itemClick(ItemClick<Person> event) { + grid.setDetailsVisible(event.getItem(), + !grid.isDetailsVisible(event.getItem())); + } + }); + + return grid; + } + + @Override + protected String getTestDescription() { + return "Initially open details rows should be taken into account in row positioning."; + } + + @Override + protected Integer getTicketNumber() { + return 11325; + } +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridWithInitiallyOpenDetailsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridWithInitiallyOpenDetailsTest.java new file mode 100644 index 0000000000..a391d00921 --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridWithInitiallyOpenDetailsTest.java @@ -0,0 +1,34 @@ +package com.vaadin.tests.components.grid; + +import static org.hamcrest.Matchers.greaterThan; +import static org.junit.Assert.assertThat; + +import org.junit.Test; +import org.openqa.selenium.By; + +import com.vaadin.testbench.elements.GridElement; +import com.vaadin.testbench.elements.GridElement.GridRowElement; +import com.vaadin.tests.tb3.MultiBrowserTest; + +public class GridWithInitiallyOpenDetailsTest extends MultiBrowserTest { + + @Test + public void testRowPositions() { + openTestURL(); + + GridElement grid = $(GridElement.class).first(); + GridRowElement row0 = grid.getRow(0); + GridRowElement row1 = grid.getRow(1); + GridRowElement row2 = grid.getRow(2); + + waitForElementPresent(By.className("v-grid-spacer")); + + assertThat("Incorrect Y-position for second row.", + row1.getLocation().getY(), greaterThan(row0.getLocation().getY() + + row0.getSize().height + 10)); + assertThat("Incorrect Y-position for third row.", + row2.getLocation().getY(), greaterThan(row1.getLocation().getY() + + row1.getSize().height + 10)); + } + +} |