summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAleksi Hietanen <aleksi@vaadin.com>2016-09-06 11:25:50 +0300
committerAleksi Hietanen <aleksi@vaadin.com>2016-09-09 09:46:37 +0000
commit33809f43cd30f19c87c11db4bf8e9710aeac297e (patch)
treebc87705cc23fdc429d914ffcfec45aee9f6c01ee /uitest
parentdfe23f7385d8f8737747b8646299adddaaa57c8d (diff)
downloadvaadin-framework-33809f43cd30f19c87c11db4bf8e9710aeac297e.tar.gz
vaadin-framework-33809f43cd30f19c87c11db4bf8e9710aeac297e.zip
Migrate ClickableRenderer and subclasses
Change-Id: I233250d9b68052825b73bed0288fffeaf5bdd04b
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridClickableRenderers.java37
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridClickableRenderersTest.java52
2 files changed, 89 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridClickableRenderers.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridClickableRenderers.java
new file mode 100644
index 0000000000..bb37d1d765
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridClickableRenderers.java
@@ -0,0 +1,37 @@
+package com.vaadin.tests.components.grid;
+
+import com.vaadin.server.ExternalResource;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Grid;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.renderers.ButtonRenderer;
+import com.vaadin.ui.renderers.ImageRenderer;
+
+public class GridClickableRenderers extends AbstractTestUI {
+
+ private static class TestPOJO {
+ String testText;
+ String imageUrl;
+ String buttonText;
+
+ TestPOJO(String intValue, String imageUrl, String buttonText) {
+ testText = intValue;
+ this.imageUrl = imageUrl;
+ this.buttonText = buttonText;
+ }
+ }
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ Label valueDisplayLabel = new Label();
+ Grid<TestPOJO> grid = new Grid<>();
+ grid.addColumn("images", pojo -> new ExternalResource(pojo.imageUrl),
+ new ImageRenderer<>());
+ grid.addColumn("buttons", pojo -> pojo.buttonText, new ButtonRenderer<>(
+ event -> valueDisplayLabel.setValue(event.getItem().testText)));
+ grid.setItems(new TestPOJO("first button clicked", "", "button 1 text"),
+ new TestPOJO("second button clicked", "", "button 2 text"));
+ addComponents(valueDisplayLabel, grid);
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/GridClickableRenderersTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/GridClickableRenderersTest.java
new file mode 100644
index 0000000000..9fe2eb0047
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridClickableRenderersTest.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.grid;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class GridClickableRenderersTest extends MultiBrowserTest {
+
+ @Test
+ public void buttonAndImageRenderersPresent() {
+ openTestURL();
+
+ Assert.assertTrue(isElementPresent(By.className("v-nativebutton")));
+
+ Assert.assertTrue(isElementPresent(By.className("gwt-Image")));
+ }
+
+ @Test
+ public void buttonRendererReturnsCorrectItem() {
+ openTestURL();
+ WebElement firstButton = findElements(By.className("v-nativebutton"))
+ .get(0);
+ WebElement secondButton = findElements(By.className("v-nativebutton"))
+ .get(1);
+ LabelElement label = $(LabelElement.class).get(1);
+
+ firstButton.click();
+ Assert.assertEquals("first button clicked", label.getText());
+
+ secondButton.click();
+ Assert.assertEquals("second button clicked", label.getText());
+ }
+}