aboutsummaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAnna Koskinen <Ansku@users.noreply.github.com>2020-04-29 10:33:54 +0300
committerGitHub <noreply@github.com>2020-04-29 10:33:54 +0300
commit4c9a5405a555785dc2b38e82b3d1cda0336491e0 (patch)
tree75ba4ed2247f48255f6a51ba076c5f702487f2dd /uitest
parent599387b330f66f0dbe6087d2fe829bc251fef6c1 (diff)
downloadvaadin-framework-4c9a5405a555785dc2b38e82b3d1cda0336491e0.tar.gz
vaadin-framework-4c9a5405a555785dc2b38e82b3d1cda0336491e0.zip
Fix the column width calculations for full width cell contents. (#11974)
Fixes #11973
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridWithFullWidthComponents.java79
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridWithFullWidthComponentsTest.java61
2 files changed, 140 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridWithFullWidthComponents.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridWithFullWidthComponents.java
new file mode 100644
index 0000000000..233a260984
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridWithFullWidthComponents.java
@@ -0,0 +1,79 @@
+package com.vaadin.tests.components.grid;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.vaadin.data.provider.DataProvider;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.CssLayout;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+
+public class GridWithFullWidthComponents extends AbstractTestUI {
+ private String s = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, "
+ + "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ getPage().getStyles()
+ .add(".v-grid .v-label, .v-grid .v-csslayout:not(:empty) { "
+ + "background-color: yellow; min-width: 300px; }");
+
+ List<Integer> content = new ArrayList<>();
+ for (int i = 0; i < 100; ++i) {
+ content.add(i);
+ }
+
+ Grid<Integer> grid = new Grid<>(DataProvider.ofCollection(content));
+ grid.setSizeFull();
+ grid.setSelectionMode(Grid.SelectionMode.NONE);
+ grid.setBodyRowHeight(70);
+ grid.addComponentColumn(this::labelResponse).setCaption("Label");
+ grid.addComponentColumn(this::hLayoutResponse)
+ .setCaption("HorizontalLayout");
+ grid.addComponentColumn(this::cssLayoutResponse)
+ .setCaption("CssLayout");
+
+ addComponent(grid);
+ }
+
+ private Label labelResponse(Integer item) {
+ Label label = new Label(s);
+ label.setWidthFull();
+ return label;
+ }
+
+ private HorizontalLayout hLayoutResponse(Integer ite) {
+ HorizontalLayout layout = new HorizontalLayout();
+ layout.setWidthFull();
+ for (int i = 0; i < 5; ++i) {
+ layout.addComponent(new Button("Button" + i));
+ }
+ return layout;
+ }
+
+ private CssLayout cssLayoutResponse(Integer ite) {
+ CssLayout layout = new CssLayout();
+ layout.setWidthFull();
+ for (int i = 0; i < 5; ++i) {
+ layout.addComponent(new Button("Button" + i));
+ }
+ return layout;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "All column contents are components with 100% width, "
+ + "in first and third column the contents are styled "
+ + "to have background color and minimum width of 300px. "
+ + "Initial render and browser resize should behave accordingly.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 11973;
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridWithFullWidthComponentsTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridWithFullWidthComponentsTest.java
new file mode 100644
index 0000000000..21285f3ed0
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridWithFullWidthComponentsTest.java
@@ -0,0 +1,61 @@
+package com.vaadin.tests.components.grid;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.openqa.selenium.Dimension;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.By;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class GridWithFullWidthComponentsTest extends MultiBrowserTest {
+
+ @Test
+ public void testResizeUpAndDown() {
+ openTestURL();
+
+ WebElement hScrollBar = findElement(
+ By.className("v-grid-scroller-horizontal"));
+ assertEquals("Unexpected horizontal scrollbar visibility", "none",
+ hScrollBar.getCssValue("display"));
+
+ // increase the browser size
+ getDriver().manage().window().setSize(new Dimension(2000, 850));
+ sleep(300);
+
+ assertEquals("Unexpected horizontal scrollbar visibility", "none",
+ hScrollBar.getCssValue("display"));
+
+ // scale back again
+ getDriver().manage().window().setSize(new Dimension(1500, 850));
+ sleep(300);
+
+ assertEquals("Unexpected horizontal scrollbar visibility", "none",
+ hScrollBar.getCssValue("display"));
+ }
+
+ @Test
+ public void testResizeDownAndUp() {
+ openTestURL();
+
+ WebElement hScrollBar = findElement(
+ By.className("v-grid-scroller-horizontal"));
+ assertEquals("Unexpected horizontal scrollbar visibility", "none",
+ hScrollBar.getCssValue("display"));
+
+ // decrease the browser size far enough that scrollbars are needed
+ getDriver().manage().window().setSize(new Dimension(800, 850));
+ sleep(300);
+
+ assertEquals("Unexpected horizontal scrollbar visibility", "block",
+ hScrollBar.getCssValue("display"));
+
+ // scale back again
+ getDriver().manage().window().setSize(new Dimension(1500, 850));
+ sleep(300);
+
+ assertEquals("Unexpected horizontal scrollbar visibility", "none",
+ hScrollBar.getCssValue("display"));
+ }
+}