PDA

View Full Version : QTest::moseClick - problem



woskov
17th March 2016, 12:47
Hi

I have 2 problems with testing my gui
1) while trying :

QTestEventList list1;
list1.addMouseMove(pt);// pt is point in the button- yes I see cursour on it
list1.addMouseClick(Qt::LeftButton);
list1.simulate(&mw);// mw is main window of my app

not working but if I do :

QTest::mouseClick(mw.ui->button,Qt::LeftButton); work's fine( function create's dialog ... )

2)
while :
QTest::moseMove(mw.window(),pt1); //pt1 is point pt in global scope
QTest::mouseClick(mw.ui->treeView,Qt::LeftButton,0,pt); //pt is point in the view - I had checked
nothing happens(it should change direction of sorting or check all row - if it's on record) - sorry - coursor only move to position

im using: windows 10 32 bit , Qt 5.5.1 +mingw32

wysota
17th March 2016, 14:54
You need to direct the event to appropriate widget. If you direct click event to QMainWindow (subclass) object then you would have to reimplement mouse events for that QMainWindow derived class. The button positioned on the form attached to the main window will not receive the event. The same goes for the tree view -- you should rather direct the event to the header widget or maybe to the viewport of the view.

woskov
18th March 2016, 07:20
Thank you for your replay.
It was very helpful. But I still have some problems:
1)


QTestEventList list1;
list1.addDelay(3000);
list1.addMouseMove(QPoint(10,10));
list1.addDelay(1000);
list1.addMousePress(Qt::LeftButton,0,QPoint(10,10) );
list1.simulate(mw.ui->search_btn);

coursor move to proper position, mark the button but action( open new dialog) is not executed


2)


QTest::mouseMove(mw.ui->tableView->viewport(),QPoint(20,10));
QTest::mouseClick(mw.ui->tableView->viewport(),Qt::LeftButton,0,QPoint(20,10)); //works fine

QTest::mouseMove(mw.ui->tableView->viewport(),QPoint(20,10));
QTest::mouseClick(mw.ui->tableView->viewport(),Qt::RightButton,0,QPoint(20,10)); //should open context menu but only mark one field in view



3) on button search_btn should open new dialog - how i can check if it hapens?
i've tried: QApplication::activeWindow()->windowTitle();
but while it is present, program goes to dialog and I need to manually exit from dialog to continue

4) where can I find some more info about GUI testing using Qt tests