summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAleksi Hietanen <aleksi@vaadin.com>2016-09-08 11:22:15 +0300
committerVaadin Code Review <review@vaadin.com>2016-09-15 09:55:22 +0000
commitc73e1833b624f931777215d0b8b14b0b1b833b9e (patch)
tree6b9ab3b567b5ace5d49b3aeaa5f1e0b4fe39ece7 /uitest
parenta6fd8bd06368da27bb97528da4a2cd7f864ea6d2 (diff)
downloadvaadin-framework-c73e1833b624f931777215d0b8b14b0b1b833b9e.tar.gz
vaadin-framework-c73e1833b624f931777215d0b8b14b0b1b833b9e.zip
Add CheckBoxRenderer
Change-Id: I32d31d758ee3c313133c7b122bb3ea8dcfcc1cc3
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridClickableRenderers.java29
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/grid/GridClickableRenderersTest.java26
2 files changed, 43 insertions, 12 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
index bb37d1d765..8a6bb5ea7c 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridClickableRenderers.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridClickableRenderers.java
@@ -6,6 +6,7 @@ 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.CheckBoxRenderer;
import com.vaadin.ui.renderers.ImageRenderer;
public class GridClickableRenderers extends AbstractTestUI {
@@ -14,24 +15,38 @@ public class GridClickableRenderers extends AbstractTestUI {
String testText;
String imageUrl;
String buttonText;
+ boolean truthValue;
- TestPOJO(String intValue, String imageUrl, String buttonText) {
+ TestPOJO(String intValue, String imageUrl, String buttonText,
+ boolean truthValue) {
testText = intValue;
this.imageUrl = imageUrl;
this.buttonText = buttonText;
+ this.truthValue = truthValue;
}
}
@Override
protected void setup(VaadinRequest request) {
- Label valueDisplayLabel = new Label();
+ Label valueDisplayLabel = new Label("button click label");
+ Label checkBoxValueLabel = new Label("checkbox click 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);
+ grid.addColumn("buttons", pojo -> pojo.buttonText,
+ new ButtonRenderer<>(event -> valueDisplayLabel
+ .setValue(event.getItem().testText + " clicked")));
+
+ CheckBoxRenderer<TestPOJO> checkBoxRenderer = new CheckBoxRenderer<>(
+ pojo -> pojo.truthValue,
+ (pojo, newTruthValue) -> pojo.truthValue = newTruthValue);
+ checkBoxRenderer.addClickListener(click -> checkBoxValueLabel.setValue(
+ click.getItem().testText + " " + click.getItem().truthValue));
+ grid.addColumn("checkboxes", pojo -> pojo.truthValue, checkBoxRenderer);
+
+ grid.setItems(new TestPOJO("first row", "", "button 1 text", true),
+ new TestPOJO("second row", "", "button 2 text", false));
+ addComponents(valueDisplayLabel, checkBoxValueLabel, 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
index 9fe2eb0047..a548bff679 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/grid/GridClickableRenderersTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/grid/GridClickableRenderersTest.java
@@ -26,12 +26,11 @@ import com.vaadin.tests.tb3.MultiBrowserTest;
public class GridClickableRenderersTest extends MultiBrowserTest {
@Test
- public void buttonAndImageRenderersPresent() {
+ public void clickableRenderersPresent() {
openTestURL();
-
Assert.assertTrue(isElementPresent(By.className("v-nativebutton")));
-
Assert.assertTrue(isElementPresent(By.className("gwt-Image")));
+ Assert.assertTrue(isElementPresent(By.className("v-checkbox")));
}
@Test
@@ -44,9 +43,26 @@ public class GridClickableRenderersTest extends MultiBrowserTest {
LabelElement label = $(LabelElement.class).get(1);
firstButton.click();
- Assert.assertEquals("first button clicked", label.getText());
+ Assert.assertEquals("first row clicked", label.getText());
secondButton.click();
- Assert.assertEquals("second button clicked", label.getText());
+ Assert.assertEquals("second row clicked", label.getText());
+ }
+
+ @Test
+ public void checkBoxRendererClick() {
+ openTestURL();
+ WebElement firstCheckBox = findElements(
+ By.cssSelector("input[type='checkbox']")).get(0);
+ WebElement secondCheckBox = findElements(
+ By.cssSelector("input[type='checkbox']")).get(1);
+
+ LabelElement label = $(LabelElement.class).get(2);
+
+ firstCheckBox.click();
+ Assert.assertEquals("first row false", label.getText());
+
+ secondCheckBox.click();
+ Assert.assertEquals("second row true", label.getText());
}
}