Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 7

Qt-interest Archive, March 2007
Simulating drag&drop?


Message 1 in thread

Hi to everyone,

does somebody know if with the QTestLib (4.2.3) it is possible to
simulate a drag & drop operation?

I've tried it with a sequence of statement like this

<snippet>
QTest::mouseMove(label);
QTest::mousePress(label, Qt::LeftButton);
QTest::mouseMove(view);
QTest::mouseRelease(view, Qt::LeftButton);
</snippet>

(where label is a QLabel and view a QGraphicsView) but it doesn't work.

Has somebody some hint to give me? :-)

Best regards,
Daniel

--
 [ signature omitted ] 

Message 2 in thread

"Daniel" <daniel.rampanelli@xxxxxxxxx> wrote in message 
news:7438b7c30703280520j29002f90s95a035e41c207b9@xxxxxxxxxxxxxxxxx
> Hi to everyone,
>
> does somebody know if with the QTestLib (4.2.3) it is possible to
> simulate a drag & drop operation?
>
> I've tried it with a sequence of statement like this
>
> <snippet>
> QTest::mouseMove(label);
> QTest::mousePress(label, Qt::LeftButton);
> QTest::mouseMove(view);
> QTest::mouseRelease(view, Qt::LeftButton);
> </snippet>
>
> (where label is a QLabel and view a QGraphicsView) but it doesn't work.
>
> Has somebody some hint to give me? :-)

Hi Daniel,

Drag'n'drop cannot be tested like this through a unit test. I.e. on Windows 
it goes through a modal system event loop (Win32 API DoDrag), and COM calls 
the target and source COM objects through IPC etc while this modal event 
loop runs. So your call to QTest::mouseMove never returns.

The best you can do with unit tests is to write a test for the code that 
handles the drop-event.

Volker


--
 [ signature omitted ] 

Message 3 in thread

Hi Daniel!

On Thursday 29 March 2007 04:21, Volker Hilsheimer wrote:
> "Daniel" <daniel.rampanelli@xxxxxxxxx> wrote in message
> news:7438b7c30703280520j29002f90s95a035e41c207b9@xxxxxxxxxxxxxxxxx
>
> > Hi to everyone,
> >
> > does somebody know if with the QTestLib (4.2.3) it is possible to
> > simulate a drag & drop operation?
> >
> > I've tried it with a sequence of statement like this
> >
> > <snippet>
> > QTest::mouseMove(label);
> > QTest::mousePress(label, Qt::LeftButton);
> > QTest::mouseMove(view);
> > QTest::mouseRelease(view, Qt::LeftButton);
> > </snippet>
> >
> > (where label is a QLabel and view a QGraphicsView) but it doesn't work.
> >
> > Has somebody some hint to give me? :-)
>
> Hi Daniel,
>
> Drag'n'drop cannot be tested like this through a unit test. I.e. on Windows
> it goes through a modal system event loop (Win32 API DoDrag), and COM calls
> the target and source COM objects through IPC etc while this modal event
> loop runs. So your call to QTest::mouseMove never returns.
>
> The best you can do with unit tests is to write a test for the code that
> handles the drop-event.

In our Qt GUI test tool Squish we actually support record and replay of Qt 3 
and Qt 4 Drag'n'Drop since version 3.0. It was very tricky to implement but 
it works.

So you might want to take a look at Squish (http://squish.froglogic.com) for 
your GUI tests including DnD.

-- 
 [ signature omitted ]