summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorelmot <elmot@vaadin.com>2016-09-12 17:58:38 +0300
committerVaadin Code Review <review@vaadin.com>2016-09-13 18:06:18 +0000
commit37e488d86b0bc59bf085a64eda3e258a01c496f0 (patch)
treea287284353b4d2c7068c0126ef773c56e0d8700e /uitest
parentd0435d5f02f93e3f5123ae54216d0062054cbe90 (diff)
downloadvaadin-framework-37e488d86b0bc59bf085a64eda3e258a01c496f0.tar.gz
vaadin-framework-37e488d86b0bc59bf085a64eda3e258a01c496f0.zip
Create a CheckBoxGroup that replaces the multi select case of OptionGroup
Change-Id: I250c60741bc65443b66498a8d0b17541edb77bf1
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxGroupTestUI.java32
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java73
2 files changed, 105 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxGroupTestUI.java b/uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxGroupTestUI.java
new file mode 100644
index 0000000000..343faf3930
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxGroupTestUI.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2000-2014 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.checkbox;
+
+import com.vaadin.tests.components.abstractlisting.AbstractListingTestUI;
+import com.vaadin.ui.CheckBoxGroup;
+
+/**
+ * Test UI for CheckBoxGroup component
+ *
+ * @author Vaadin Ltd
+ */
+public class CheckBoxGroupTestUI
+ extends AbstractListingTestUI<CheckBoxGroup<Object>> {
+ @Override
+ protected Class<CheckBoxGroup<Object>> getTestClass() {
+ return (Class) CheckBoxGroup.class;
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java
new file mode 100644
index 0000000000..9a3c2a656c
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2000-2014 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.checkboxgroup;
+
+import com.vaadin.testbench.customelements.CheckBoxGroupElement;
+import com.vaadin.tests.components.checkbox.CheckBoxGroupTestUI;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Test for CheckBoxGroup
+ *
+ * @author Vaadin Ltd
+ * @since 8.0
+ */
+public class CheckBoxGroupTest extends MultiBrowserTest {
+
+ @Before
+ public void setUp() throws Exception {
+ openTestURL();
+ }
+
+ @Test
+ public void initialLoad_containsCorrectItems() {
+ assertItems(20);
+ }
+
+ @Test
+ public void initialItems_reduceItemCount_containsCorrectItems() {
+ selectMenuPath("Component", "Data source", "Items", "5");
+ assertItems(5);
+ }
+
+ @Test
+ public void initialItems_increaseItemCount_containsCorrectItems() {
+ selectMenuPath("Component", "Data source", "Items", "100");
+ assertItems(100);
+ }
+
+ @Override
+ protected Class<?> getUIClass() {
+ return CheckBoxGroupTestUI.class;
+ }
+
+ protected CheckBoxGroupElement getSelect() {
+ return $(CheckBoxGroupElement.class).first();
+ }
+
+ protected void assertItems(int count) {
+ int i = 0;
+ for (String text : getSelect().getOptions()) {
+ assertEquals("Item " + i, text);
+ i++;
+ }
+ assertEquals("Number of items", count, i);
+ }
+}