summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAnna Koskinen <Ansku@users.noreply.github.com>2020-05-19 13:13:25 +0300
committerGitHub <noreply@github.com>2020-05-19 13:13:25 +0300
commit0645a86e5b6951de0e5b170657a2eaf74a7e9b77 (patch)
tree9c327c0e4f21a129a8815ae796196aaf5ff3ce51 /uitest
parent667da64f804528a3e4a93dda3db708085104b844 (diff)
downloadvaadin-framework-0645a86e5b6951de0e5b170657a2eaf74a7e9b77.tar.gz
vaadin-framework-0645a86e5b6951de0e5b170657a2eaf74a7e9b77.zip
Table / TreeTable multiselect disabling of touch detection (#12014)
Added a toggle in Table (and thus TreeTable) where you can explicitly disable multiselect touch screen detection. This allows you to work around issues on hybrid devices that have both a touch screen and a keyboard where you don't want automatic simple multiselection applied. Fixes #11601, slightly modified cherry-pick of #11641
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/table/CtrlShiftMultiselect.java3
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/table/CtrlShiftMultiselectTouchDetectionDisabled.java41
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableMultiselect.java64
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/table/CtrlShiftMultiselectTouchDetectionDisabledTest.java40
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/treetable/TreeTableMultiselectTest.java38
5 files changed, 185 insertions, 1 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/CtrlShiftMultiselect.java b/uitest/src/main/java/com/vaadin/tests/components/table/CtrlShiftMultiselect.java
index 1713dddde5..0a1a1ab560 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/table/CtrlShiftMultiselect.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/table/CtrlShiftMultiselect.java
@@ -10,9 +10,10 @@ import com.vaadin.v7.ui.Table.TableDragMode;
@SuppressWarnings("serial")
public class CtrlShiftMultiselect extends TestBase {
+ protected final Table table = new Table("Multiselectable table");
+
@Override
protected void setup() {
- final Table table = new Table("Multiselectable table");
table.setContainerDataSource(createContainer());
table.setImmediate(true);
diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/CtrlShiftMultiselectTouchDetectionDisabled.java b/uitest/src/main/java/com/vaadin/tests/components/table/CtrlShiftMultiselectTouchDetectionDisabled.java
new file mode 100644
index 0000000000..318b5954e4
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/table/CtrlShiftMultiselectTouchDetectionDisabled.java
@@ -0,0 +1,41 @@
+package com.vaadin.tests.components.table;
+
+import java.util.Set;
+
+import com.vaadin.v7.data.Property;
+import com.vaadin.v7.ui.Label;
+
+public class CtrlShiftMultiselectTouchDetectionDisabled
+ extends CtrlShiftMultiselect {
+
+ protected Label label;
+
+ @Override
+ protected void setup() {
+ super.setup();
+ label = new Label("0");
+ label.setId("count");
+ label.setCaption("Amount of selected items");
+ table.setMultiSelectTouchDetectionEnabled(false);
+ table.addValueChangeListener(new Property.ValueChangeListener() {
+ @Override
+ public void valueChange(Property.ValueChangeEvent event) {
+ Property property = event.getProperty();
+ Set set = (Set) property.getValue();
+ label.setValue("" + set.size());
+ }
+ });
+ addComponent(label);
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Allow disabling multi selection's touch screen detection for hybrid devices";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 11601;
+ }
+
+} \ No newline at end of file
diff --git a/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableMultiselect.java b/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableMultiselect.java
new file mode 100644
index 0000000000..2ceae92ece
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/treetable/TreeTableMultiselect.java
@@ -0,0 +1,64 @@
+package com.vaadin.tests.components.treetable;
+
+import static com.vaadin.server.Sizeable.Unit.PIXELS;
+
+import java.util.Set;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.v7.data.Property;
+import com.vaadin.v7.ui.Label;
+import com.vaadin.v7.ui.TreeTable;
+
+public class TreeTableMultiselect extends AbstractTestUI {
+
+ protected final TreeTable tt = new TreeTable("Multiselectable treetable");
+ protected Label label;
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ label = new Label("0");
+ label.setCaption("Amount of selected items");
+ label.setId("count");
+
+ tt.setImmediate(true);
+ tt.addContainerProperty("Foo", String.class, "");
+ tt.setColumnWidth("Foo", 100);
+ tt.addContainerProperty("Bar", String.class, "");
+ tt.setColumnWidth("Bar", 100);
+ tt.setHeight(400, PIXELS);
+ Object item1 = tt.addItem(new Object[] { "Foo", "Bar" }, null);
+ Object item2 = tt.addItem(new Object[] { "Foo2", "Bar2" }, null);
+ Object item3 = tt.addItem(new Object[] { "Foo3", "Bar3" }, null);
+ tt.setParent(item2, item1);
+ tt.setParent(item3, item1);
+ tt.setCollapsed(item1, false);
+ tt.setSelectable(true);
+ tt.setMultiSelect(true);
+ tt.setMultiSelectTouchDetectionEnabled(false);
+ tt.setWidth("400px");
+ tt.setHeight("400px");
+ tt.addValueChangeListener(new Property.ValueChangeListener() {
+ @Override
+ public void valueChange(Property.ValueChangeEvent event) {
+ Property property = event.getProperty();
+ Set set = (Set) property.getValue();
+ label.setValue("" + set.size());
+ }
+ });
+
+ addComponent(tt);
+ addComponent(label);
+ }
+
+ @Override
+ public String getTestDescription() {
+ return "Allow disabling multi selection's touch screen detection for hybrid devices";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 11601;
+ }
+
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/table/CtrlShiftMultiselectTouchDetectionDisabledTest.java b/uitest/src/test/java/com/vaadin/tests/components/table/CtrlShiftMultiselectTouchDetectionDisabledTest.java
new file mode 100644
index 0000000000..7066b017f6
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/table/CtrlShiftMultiselectTouchDetectionDisabledTest.java
@@ -0,0 +1,40 @@
+package com.vaadin.tests.components.table;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.openqa.selenium.Keys;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.testbench.elements.TableElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class CtrlShiftMultiselectTouchDetectionDisabledTest
+ extends SingleBrowserTest {
+
+ @Override
+ protected boolean requireWindowFocusForIE() {
+ return true;
+ }
+
+ @Test
+ public void testSelectedCount() {
+ openTestURL();
+ clickRow(3);
+ new Actions(driver).keyDown(Keys.SHIFT).perform();
+ clickRow(8);
+ new Actions(driver).keyUp(Keys.SHIFT).perform();
+ new Actions(driver).release().perform();
+ LabelElement labelElement = $(LabelElement.class).id("count");
+ assertEquals("Unexpected amount of selected rows", "6",
+ labelElement.getText());
+
+ }
+
+ private void clickRow(int index) {
+ TableElement tableElement = $(TableElement.class).first();
+ tableElement.getRow(index).click();
+ }
+
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/treetable/TreeTableMultiselectTest.java b/uitest/src/test/java/com/vaadin/tests/components/treetable/TreeTableMultiselectTest.java
new file mode 100644
index 0000000000..36107f122e
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/treetable/TreeTableMultiselectTest.java
@@ -0,0 +1,38 @@
+package com.vaadin.tests.components.treetable;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.openqa.selenium.Keys;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.testbench.elements.TreeTableElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class TreeTableMultiselectTest extends SingleBrowserTest {
+
+ @Override
+ protected boolean requireWindowFocusForIE() {
+ return true;
+ }
+
+ @Test
+ public void testSelectedCount() {
+ openTestURL();
+ clickRow(0);
+ new Actions(driver).keyDown(Keys.SHIFT).perform();
+ clickRow(2);
+ new Actions(driver).keyUp(Keys.SHIFT).perform();
+ new Actions(driver).release().perform();
+ LabelElement labelElement = $(LabelElement.class).id("count");
+ assertEquals("Unexpected amount of selected rows", "3",
+ labelElement.getText());
+ }
+
+ private void clickRow(int index) {
+ TreeTableElement treeTable = $(TreeTableElement.class).first();
+ treeTable.getRow(index).click();
+ }
+
+}