-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for non-compatibility Grid
- Loading branch information
1 parent
67001c7
commit e45f12c
Showing
2 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
.../main/java/com/vaadin/tests/components/grid/HideGridColumnWhenHavingUnsuitableHeight.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...t/java/com/vaadin/tests/components/grid/HideGridColumnWhenHavingUnsuitableHeightTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |