Search in sources :

Example 1 with DropTargetDropEventBuilder

use of com.android.tools.idea.uibuilder.fixtures.DropTargetDropEventBuilder 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);
}
Also used : DropTargetListener(java.awt.dnd.DropTargetListener) DropTargetContext(java.awt.dnd.DropTargetContext) DropTargetDragEventBuilder(com.android.tools.idea.uibuilder.fixtures.DropTargetDragEventBuilder) DropTargetDropEventBuilder(com.android.tools.idea.uibuilder.fixtures.DropTargetDropEventBuilder) DropTargetDropEvent(java.awt.dnd.DropTargetDropEvent)

Aggregations

DropTargetDragEventBuilder (com.android.tools.idea.uibuilder.fixtures.DropTargetDragEventBuilder)1 DropTargetDropEventBuilder (com.android.tools.idea.uibuilder.fixtures.DropTargetDropEventBuilder)1 DropTargetContext (java.awt.dnd.DropTargetContext)1 DropTargetDropEvent (java.awt.dnd.DropTargetDropEvent)1 DropTargetListener (java.awt.dnd.DropTargetListener)1