use of com.android.tools.idea.uibuilder.fixtures.DropTargetDragEventBuilder in project android by JetBrains.
the class LayoutTestUtilities method dragDrop.
public static void dragDrop(InteractionManager manager, int x1, int y1, int x2, int y2, Transferable transferable) {
Object listener = manager.getListener();
assertTrue(listener instanceof DropTargetListener);
DropTargetListener dropListener = (DropTargetListener) listener;
int frames = 5;
double x = x1;
double y = y1;
double xSlope = (x2 - x) / frames;
double ySlope = (y2 - y) / frames;
DropTargetContext context = createDropTargetContext();
dropListener.dragEnter(new DropTargetDragEventBuilder(context, (int) x, (int) y, transferable).build());
for (int i = 0; i < frames + 1; i++) {
dropListener.dragOver(new DropTargetDragEventBuilder(context, (int) x, (int) y, transferable).build());
x += xSlope;
y += ySlope;
}
DropTargetDropEvent dropEvent = new DropTargetDropEventBuilder(context, (int) x, (int) y, transferable).build();
dropListener.drop(dropEvent);
verify(dropEvent, times(1)).acceptDrop(anyInt());
verify(dropEvent, times(1)).dropComplete(true);
}
Aggregations