summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAdam Wagner <wbadam@users.noreply.github.com>2017-07-03 13:36:17 +0200
committerHenri Sara <henri.sara@gmail.com>2017-07-03 14:36:17 +0300
commit6ecef502864ed201b468a68c00676beb401f21c7 (patch)
tree2f96341ebcb02bced9092e4d3196266ee2eb2740 /uitest
parent4d085fd8b3589db4fbbdcd52643cee4b20f70e31 (diff)
downloadvaadin-framework-6ecef502864ed201b468a68c00676beb401f21c7.tar.gz
vaadin-framework-6ecef502864ed201b468a68c00676beb401f21c7.zip
Add criteria API to make it easier to set acceptance criteria for drag and drop (#9605)
Fixes #9600
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/dnd/DragAndDropCardShuffle.java28
1 files changed, 18 insertions, 10 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/dnd/DragAndDropCardShuffle.java b/uitest/src/main/java/com/vaadin/tests/dnd/DragAndDropCardShuffle.java
index 493b57226e..8f04ed1835 100644
--- a/uitest/src/main/java/com/vaadin/tests/dnd/DragAndDropCardShuffle.java
+++ b/uitest/src/main/java/com/vaadin/tests/dnd/DragAndDropCardShuffle.java
@@ -22,6 +22,7 @@ import com.vaadin.annotations.Theme;
import com.vaadin.annotations.Widgetset;
import com.vaadin.server.Page;
import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.dnd.criteria.ComparisonOperator;
import com.vaadin.shared.ui.dnd.DropEffect;
import com.vaadin.shared.ui.dnd.EffectAllowed;
import com.vaadin.tests.components.AbstractTestUIWithLog;
@@ -86,20 +87,20 @@ public class DragAndDropCardShuffle extends AbstractTestUIWithLog {
// Create UI and add extensions
ace.setStyleName("card");
- addDragSourceExtension(ace);
- addDropTargetExtension(ace);
+ addDragSourceExtension(ace, 14);
+ addDropTargetExtension(ace, 14);
jack.setStyleName("card");
- addDragSourceExtension(jack);
- addDropTargetExtension(jack);
+ addDragSourceExtension(jack, 11);
+ addDropTargetExtension(jack, 11);
queen.setStyleName("card");
- addDragSourceExtension(queen);
- addDropTargetExtension(queen);
+ addDragSourceExtension(queen, 12);
+ addDropTargetExtension(queen, 12);
king.setStyleName("card");
- addDragSourceExtension(king);
- addDropTargetExtension(king);
+ addDragSourceExtension(king, 13);
+ addDropTargetExtension(king, 13);
}
private void removeExtensions() {
@@ -116,11 +117,14 @@ public class DragAndDropCardShuffle extends AbstractTestUIWithLog {
king.removeExtension(king.getExtensions().iterator().next());
}
- private void addDragSourceExtension(Label source) {
+ private void addDragSourceExtension(Label source, int cardValue) {
// Create and attach extension
DragSourceExtension<Label> dragSource = new DragSourceExtension<>(
source);
+ // Set card value via criteria API for acceptance criteria
+ dragSource.setPayload("card_value", cardValue);
+
// Add listeners
dragSource.addDragStartListener(event -> {
log(event.getComponent().getValue() + " dragstart, effectsAllowed="
@@ -135,11 +139,15 @@ public class DragAndDropCardShuffle extends AbstractTestUIWithLog {
sources.add(dragSource);
}
- private void addDropTargetExtension(Label target) {
+ private void addDropTargetExtension(Label target, int cardValue) {
// Create and attach extension
DropTargetExtension<Label> dropTarget = new DropTargetExtension<>(
target);
+ // Cards can be dropped onto others with smaller value
+ dropTarget.setDropCriterion("card_value", ComparisonOperator.SMALLER_THAN,
+ cardValue);
+
// Add listener
dropTarget.addDropListener(event -> {
event.getDragSourceExtension().ifPresent(dragSource -> {