Testing Jemmy拖放块,直到手动移动鼠标

Testing Jemmy拖放块,直到手动移动鼠标,testing,javafx-2,jemmy,jemmyfx,Testing,Javafx 2,Jemmy,Jemmyfx,我有一个四行的TableView,我尝试测试我的拖放实现是否有效。我有以下测试: TableViewDock table = ...; //the four rows, using the first cell for the DnD TableCellItemDock[] rows = {new TableCellItemDock(table.asTable(), 0, 0), new TableCellItemDock(table.a

我有一个四行的TableView,我尝试测试我的拖放实现是否有效。我有以下测试:

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());
但是对
dnd
的调用会阻塞:我需要手动移动鼠标“解锁”它,并允许拖放操作开始(然后按预期完成)

我需要做什么才能让
dnd
自己完成工作

注意:JemmyFX version=20120928

产品中存在一个问题,该问题阻止jemmy在某些平台上正确使用拖放功能。现在恐怕您需要使用鼠标移动和按下/释放的解决方法:

rows[0].mouse().move();
rows[0].mouse().press();
Point from = rows[0].wrap().getClickPoint();
Point to = target.getClickPoint();
int steps = 10;
for(int i = 1; i<= steps; i++) {
    rows[0].mouse().move(new Point(
        from.x + i*(to.x - from.x)/steps, 
        from.y + i*(to.y - from.y)/steps));
}
rows[0].mouse().release();
行[0]。鼠标().move();
行[0]。鼠标()。按();
Point from=行[0]。换行().getClickPoint();
指向=目标。getClickPoint();
int步数=10;

对于(int i=1;i,多亏了Sergey,我设法用以下方法使它工作:

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();
}

protectedvoid dragandrop(wrapi如果这不起作用,您可以使用AWT
Robot
执行相同的逻辑。谢谢。但有一个问题:
target.getClickPoint()
返回与
中的
相同的点。不确定原因(如果我选择行[0]或目标,我肯定可以看到它们是不同的行)查看我的答案。我用
点from=table.wrap().toLocal(行[0].wrap().toAbsolute(行[0].wrap().getClickPoint());
(与to相同)修复了它,然后用
表.mouse().move(…)
-但是它仍然不起作用:代码在第一次循环迭代后阻塞(我可以看到一个拖动检测到的事件)。按一个键将取消阻止移动,循环的其余部分将执行。