diff options
-rw-r--r-- | test/servlet-containers/generic/reference-screenshots/finland-phantomjs.png | bin | 11577 -> 10897 bytes | |||
-rw-r--r-- | test/servlet-containers/generic/reference-screenshots/initial-phantomjs.png | bin | 10740 -> 10130 bytes | |||
-rw-r--r-- | test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/ServletIntegrationUI.java | 68 | ||||
-rw-r--r-- | test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/AbstractServletIntegrationTest.java | 4 |
4 files changed, 42 insertions, 30 deletions
diff --git a/test/servlet-containers/generic/reference-screenshots/finland-phantomjs.png b/test/servlet-containers/generic/reference-screenshots/finland-phantomjs.png Binary files differindex e372c198e2..7853307584 100644 --- a/test/servlet-containers/generic/reference-screenshots/finland-phantomjs.png +++ b/test/servlet-containers/generic/reference-screenshots/finland-phantomjs.png diff --git a/test/servlet-containers/generic/reference-screenshots/initial-phantomjs.png b/test/servlet-containers/generic/reference-screenshots/initial-phantomjs.png Binary files differindex 642759734e..8764e467f2 100644 --- a/test/servlet-containers/generic/reference-screenshots/initial-phantomjs.png +++ b/test/servlet-containers/generic/reference-screenshots/initial-phantomjs.png diff --git a/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/ServletIntegrationUI.java b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/ServletIntegrationUI.java index af20c415ad..0d4010beaa 100644 --- a/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/ServletIntegrationUI.java +++ b/test/servlet-containers/generic/src/main/java/com/vaadin/tests/integration/ServletIntegrationUI.java @@ -5,49 +5,61 @@ import com.vaadin.annotations.Widgetset; import com.vaadin.server.ClassResource; import com.vaadin.server.Resource; import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Grid; +import com.vaadin.ui.Image; import com.vaadin.ui.Label; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.declarative.Design; -import com.vaadin.v7.data.Item; -import com.vaadin.v7.data.Property.ValueChangeEvent; -import com.vaadin.v7.data.Property.ValueChangeListener; -import com.vaadin.v7.ui.Table; -@Widgetset("com.vaadin.v7.Vaadin7WidgetSet") +@Widgetset("com.vaadin.DefaultWidgetSet") public class ServletIntegrationUI extends UI { + public static class Country { + private final String name; + private final String id; + private final Resource icon; + + public Country(String name, String id, Resource icon) { + this.name = name; + this.id = id; + this.icon = icon; + } + + public String getName() { + return name; + } + + public String getId() { + return id; + } + + public Resource getIcon() { + return icon; + } + } + @Override protected void init(VaadinRequest request) { VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); setContent(layout); - final Table table = new Table(); - table.addContainerProperty("icon", Resource.class, null); - table.setItemIconPropertyId("icon"); - table.addContainerProperty("country", String.class, null); - table.setRowHeaderMode(Table.RowHeaderMode.ICON_ONLY); - table.setImmediate(true); - table.setSelectable(true); - table.setVisibleColumns(new Object[] { "country" }); - layout.addComponent(table); - table.setWidth("112px"); - - Item item = table.addItem("FI"); - item.getItemProperty("icon").setValue(new ClassResource("fi.gif")); - item.getItemProperty("country").setValue("Finland"); - item = table.addItem("SE"); - item.getItemProperty("icon").setValue(new FlagSeResource()); - item.getItemProperty("country").setValue("Sweden"); + final Grid<Country> grid = new Grid<>(); + // TODO ImageRenderer does not support ClassResource + grid.addComponentColumn(country -> new Image(null, country.getIcon())) + .setWidth(50).setCaption(""); + grid.addColumn(country -> country.getName()).setWidth(100) + .setCaption("Country"); + grid.setItems(new Country("Finland", "FI", new ClassResource("fi.gif")), + new Country("Sweden", "SE", new FlagSeResource())); + grid.setHeight("200px"); + grid.setWidth("200px"); + layout.addComponent(grid); final Label selectedLabel = new LabelFromDesign(); - table.addValueChangeListener(new ValueChangeListener() { - @Override - public void valueChange(ValueChangeEvent event) { - selectedLabel.setValue(String.valueOf(table.getValue())); - } - }); + grid.addSelectionListener(event -> selectedLabel.setValue( + event.getFirstSelectedItem().map(c -> c.getId()).orElse(""))); layout.addComponent(selectedLabel); } diff --git a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/AbstractServletIntegrationTest.java b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/AbstractServletIntegrationTest.java index fd3600df38..ddfcb9ec3b 100644 --- a/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/AbstractServletIntegrationTest.java +++ b/test/servlet-containers/generic/src/test/java/com/vaadin/tests/integration/AbstractServletIntegrationTest.java @@ -2,7 +2,7 @@ package com.vaadin.tests.integration; import org.junit.Test; -import com.vaadin.testbench.elements.TableElement; +import com.vaadin.testbench.elements.GridElement; public abstract class AbstractServletIntegrationTest extends AbstractIntegrationTest { @@ -12,7 +12,7 @@ public abstract class AbstractServletIntegrationTest // make sure no fading progress indicator from table update is lingering Thread.sleep(2000); compareScreen("initial"); - $(TableElement.class).first().getCell(0, 1).click(); + $(GridElement.class).first().getCell(0, 1).click(); // without this, table fetch might have a fading progress indicator Thread.sleep(2000); compareScreen("finland"); |