testingjavafx-2jemmyjemmyfx

Jemmy drag and drop blocks until mouse manually moved


I have a TableView with four rows and I try to test that my drag and drop implementation works. I have the following test:

TableViewDock table = ...;

//the four rows, using the first cell for the DnD
TableCellItemDock[] rows = {new TableCellItemDock(table.asTable(), 0, 0),
                            new TableCellItemDock(table.asTable(), 1, 0),
                            new TableCellItemDock(table.asTable(), 2, 0),
                            new TableCellItemDock(table.asTable(), 3, 0)};

Wrap target = rows[3].wrap();
rows[0].drag().dnd(target, target.getClickPoint());

But the call to dnd blocks: I need to manually move the mouse to "unblock" it and allow the drag and drop action to start (it then completes as expected).

What do I need to do to let dnd do its job on its own?

Note: JemmyFX version = 20120928


Solution

  • Thanks to Sergey, I managed to get it to work with the following method:

    protected void dragAndDrop(Wrap<? extends Object> from, Wrap<? extends Object> to) throws InterruptedException {
        Point start = scene.wrap().toLocal(from.toAbsolute(from.getClickPoint()));
        Point end = scene.wrap().toLocal(to.toAbsolute(to.getClickPoint()));
    
        scene.mouse().move(start);
        scene.mouse().press();
        scene.mouse().move(end);
        scene.mouse().release();
    }
    

    I haven't managed to do a progressive move with a loop as he suggested: the code gets stuck at the second iteration when move is called again.