I need to automate gui tests in c++ qt using qtest (in eclipse) I have given a function that adds some tabs to a tabwidget (up to max 9) and if you try to open a 10th tab, a QMessageBox appears:
QMessageBox::critical(this, "MAX9",
tr("Only a maximum of 9 tabs can be opened.\n"));
Because the whole menu with the "add tab" function and everything is private, I had to access the method using slots and signals from my testclass.
Now my question is, is there a way I can check whether there are ANY QMessageBoxes open and if yes, automatically close them?
EDIT: SOLVED I put vahancho's solution into a method (CloseMessageBoxes) and I've created a timer in my testmethod that calls CloseMessageBoxes() method then:
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(CloseMessageBoxes()));
timer->start(5000);
There are multiple messageboxes appearing but all are closing themselves after 5 seconds.