PDA

View Full Version : GUI Event testing using QTestLib



vels
23rd April 2010, 10:50
Hi,

How to unit test qt GUI events (keypress, keyrelease,mouseclick)?

I already gone through http://doc.trolltech.com/4.6/qtestlib-manual.html#creating-a-test

Are there any reference material/samples to start with event testing?

Thanks
Vels

wysota
23rd April 2010, 11:05
Chapter 3: Simulating GUI Events

vels
23rd April 2010, 11:29
Hi,

I am using keypress event on mywindow


void TestGui::testGui()
{
QMainWindow mywindow;
QTest::keyPress(&mywindow, Qt::Key_Backspace);

//how to verify keypress event

}


how to verify the event?

Thanks
Vels

wysota
23rd April 2010, 11:31
What do you mean by "verify" in this context? I don't know what the backspace key is supposed to do in your case but you have to use the API of your window class to check if it did that. Use the macros provided by QTestLib for the comparison itself.