summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAdam Wagner <wbadam@users.noreply.github.com>2017-05-17 07:47:59 +0300
committerPekka Hyvönen <pekka@vaadin.com>2017-05-17 07:47:59 +0300
commit9dd70e13cd49639549645f23b1b5ef63a36d84cc (patch)
tree767062d89ac9c8faa256fcc3c24b5df82cc1dec4 /uitest
parent9b725e2bd7f747ee5ddcef17e61233ad575ae999 (diff)
downloadvaadin-framework-9dd70e13cd49639549645f23b1b5ef63a36d84cc.tar.gz
vaadin-framework-9dd70e13cd49639549645f23b1b5ef63a36d84cc.zip
Make it possible for grid drop target to accept dragged data when grid is empty (#9332)
* Make it possible for grid drop target to accept dragged data when grid is empty (#9068) * Make return type of getDropTargetRow() optional
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/grid/GridDragAndDrop.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridDragAndDrop.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridDragAndDrop.java
index 9bda8c3a05..ad13e2177a 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridDragAndDrop.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridDragAndDrop.java
@@ -55,7 +55,7 @@ public class GridDragAndDrop extends AbstractTestUIWithLog {
GridDragSource<Person> dragSource = applyDragSource(left);
// Drop target Grid
- Grid<Person> right = createGridAndFillWithData(5);
+ Grid<Person> right = createGridAndFillWithData(0);
GridDropTarget<Person> dropTarget = applyDropTarget(right);
// Layout the two grids
@@ -158,9 +158,12 @@ public class GridDragAndDrop extends AbstractTestUIWithLog {
List<Person> items = (List<Person>) dataProvider.getItems();
// Calculate the target row's index
- int index = items.indexOf(event.getDropTargetRow())
- + (event.getDropLocation() == DropLocation.BELOW ? 1
- : 0);
+ int index = items.size();
+ if (event.getDropTargetRow().isPresent()) {
+ index = items.indexOf(event.getDropTargetRow().get())
+ + (event.getDropLocation() == DropLocation.BELOW
+ ? 1 : 0);
+ }
// Add dragged items to the target Grid
items.addAll(index, draggedItems);
@@ -170,8 +173,10 @@ public class GridDragAndDrop extends AbstractTestUIWithLog {
+ ", dragDataJson="
+ event.getDataTransferData("application/json")
+ ", target="
- + event.getDropTargetRow().getFirstName() + " "
- + event.getDropTargetRow().getLastName()
+ + (event.getDropTargetRow().isPresent() ?
+ event.getDropTargetRow().get().getFirstName() + " "
+ + event.getDropTargetRow().get()
+ .getLastName() : "[BODY]")
+ ", location=" + event.getDropLocation());
}
});