summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2017-03-16 11:42:14 +0200
committerHenri Sara <henri.sara@gmail.com>2017-03-16 12:32:19 +0200
commitaf6d13a22b9ed7ec04b731cab2cdeda23ac44fd4 (patch)
treed38f9e4861d5e08d72e486fe10d57e9000c7b5ad
parent833e6e3bd98ff04a35b428c35afe16c874893780 (diff)
downloadvaadin-framework-af6d13a22b9ed7ec04b731cab2cdeda23ac44fd4.tar.gz
vaadin-framework-af6d13a22b9ed7ec04b731cab2cdeda23ac44fd4.zip
Add tests for non-compatibility Grid
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/HideGridColumnWhenHavingUnsuitableHeight.java72
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/HideGridColumnWhenHavingUnsuitableHeightTest.java40
2 files changed, 112 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/HideGridColumnWhenHavingUnsuitableHeight.java b/uitest/src/main/java/com/vaadin/tests/components/grid/HideGridColumnWhenHavingUnsuitableHeight.java
new file mode 100644
index 0000000000..f3bf5c86a9
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/HideGridColumnWhenHavingUnsuitableHeight.java
@@ -0,0 +1,72 @@
+package com.vaadin.tests.components.grid;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.vaadin.annotations.Theme;
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.renderers.ButtonRenderer;
+
+@Theme("valo")
+@Widgetset("com.vaadin.DefaultWidgetSet")
+public class HideGridColumnWhenHavingUnsuitableHeight extends AbstractTestUI {
+
+ private Grid<SampleBean> grid;
+
+ public static class SampleBean {
+
+ private String col1;
+ private String col2;
+
+ public SampleBean() {
+ }
+
+ public String getCol1() {
+ return col1;
+ }
+
+ public void setCol1(String col1) {
+ this.col1 = col1;
+ }
+
+ public String getCol2() {
+ return col2;
+ }
+
+ public void setCol2(String col2) {
+ this.col2 = col2;
+ }
+ }
+
+ @Override
+ protected void setup(VaadinRequest vaadinRequest) {
+ grid = new Grid<>();
+ grid.setItems(generateData(50));
+
+ grid.addColumn(SampleBean::getCol1).setWidth(1600);
+ grid.addColumn(SampleBean::getCol2);
+ grid.addColumn(t -> "Button1").setRenderer(new ButtonRenderer<>());
+
+ grid.getColumns().forEach(c -> c.setHidable(true));
+
+ grid.setWidth("100%");
+ grid.setHeight("425px");
+
+ addComponent(grid);
+ }
+
+ private List<SampleBean> generateData(int rows) {
+ List<SampleBean> list = new ArrayList<>();
+ for (int y = 0; y < rows; ++y) {
+ SampleBean sampleBean = new SampleBean();
+ sampleBean.setCol1("Row " + y + " Column 1");
+ sampleBean.setCol2("Row " + y + " Column 2");
+ list.add(sampleBean);
+ }
+ return list;
+ }
+
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/HideGridColumnWhenHavingUnsuitableHeightTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/HideGridColumnWhenHavingUnsuitableHeightTest.java
new file mode 100644
index 0000000000..e9d465ba29
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/HideGridColumnWhenHavingUnsuitableHeightTest.java
@@ -0,0 +1,40 @@
+package com.vaadin.tests.components.grid;
+
+import java.util.List;
+import java.util.logging.Level;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.GridElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class HideGridColumnWhenHavingUnsuitableHeightTest
+ extends SingleBrowserTest {
+
+ @Test
+ public void hideAndScroll() {
+ openTestURL("debug");
+ GridElement grid = $(GridElement.class).first();
+
+ getSidebarOpenButton(grid).click();
+ // Hide first column
+ getSidebarPopup().findElements(By.tagName("td")).get(0).click();
+
+ grid.scrollToRow(25);
+ assertNoDebugMessage(Level.SEVERE);
+ }
+
+ protected WebElement getSidebarOpenButton(GridElement grid) {
+ List<WebElement> elements = grid
+ .findElements(By.className("v-grid-sidebar-button"));
+ return elements.isEmpty() ? null : elements.get(0);
+ }
+
+ protected WebElement getSidebarPopup() {
+ List<WebElement> elements = findElements(
+ By.className("v-grid-sidebar-popup"));
+ return elements.isEmpty() ? null : elements.get(0);
+ }
+}