aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src
diff options
context:
space:
mode:
Diffstat (limited to 'uitest/src')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupReadOnly.java30
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupReadOnlyTest.java46
2 files changed, 76 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupReadOnly.java b/uitest/src/main/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupReadOnly.java
new file mode 100644
index 0000000000..8c0caf3ac3
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupReadOnly.java
@@ -0,0 +1,30 @@
+package com.vaadin.tests.components.checkboxgroup;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.CheckBoxGroup;
+import com.vaadin.ui.Button;
+
+@Widgetset("com.vaadin.DefaultWidgetSet")
+public class CheckBoxGroupReadOnly extends AbstractTestUI {
+ @Override
+ protected void setup(VaadinRequest request) {
+ CheckBoxGroup<Integer> cbg = new CheckBoxGroup<>();
+ cbg.setId("cbg");
+ cbg.setItems(1, 2, 3, 4);
+ cbg.setReadOnly(true);
+ addComponent(cbg);
+
+ Button changeReadOnly = new Button("Change Read-Only", e -> {
+ cbg.setReadOnly(!cbg.isReadOnly());
+ });
+ changeReadOnly.setId("changeReadOnly");
+ Button changeEnabled = new Button("Change Enabled", e -> {
+ cbg.setEnabled(!cbg.isEnabled());
+ });
+ changeEnabled.setId("changeEnabled");
+ addComponent(changeReadOnly);
+ addComponent(changeEnabled);
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupReadOnlyTest.java b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupReadOnlyTest.java
new file mode 100644
index 0000000000..ad0fb4fbac
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupReadOnlyTest.java
@@ -0,0 +1,46 @@
+package com.vaadin.tests.components.checkboxgroup;
+
+import com.vaadin.testbench.elements.CheckBoxGroupElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import java.util.List;
+
+import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertTrue;
+
+public class CheckBoxGroupReadOnlyTest extends MultiBrowserTest {
+
+ @Test
+ public void itemsAreReadOnly() {
+ openTestURL();
+ // Initially components are read-only
+ assertTrue(getSelect().isReadOnly());
+ assertEquals(4, findReadOnlyCheckboxes().size());
+ // Should not contain v-readonly
+ findElement(By.id("changeReadOnly")).click();
+ assertEquals(0, findReadOnlyCheckboxes().size());
+
+ // Should not contain v-readonly
+ findElement(By.id("changeEnabled")).click();
+ assertEquals(0, findReadOnlyCheckboxes().size());
+
+ // make read-only
+ findElement(By.id("changeReadOnly")).click();
+ // enable
+ findElement(By.id("changeEnabled")).click();
+ // Should contain v-readonly
+ assertEquals(4, findReadOnlyCheckboxes().size());
+ }
+
+ protected CheckBoxGroupElement getSelect() {
+ return $(CheckBoxGroupElement.class).first();
+ }
+
+ private List<WebElement> findReadOnlyCheckboxes() {
+ return findElement(By.id("cbg"))
+ .findElements(By.cssSelector("span.v-readonly.v-checkbox"));
+ }
+}