Hi, I dont know if Your problem is exists yet or not, I found this solution:
void MyTest::testPasswordDialog()
{
QTimer::singleShot(500,
this,
SLOT(TimeOut
()));
QVERIFY(functionThatProducesMessageBox());
}
void MyTest::TimeOut()
{
QWidgetList allToplevelWidgets
= QApplication::topLevelWidgets();
foreach
(QWidget *w, allToplevelWidgets
) { if (w->inherits("QMessageBox")) {
QTest::keyClick(mb, Qt::Key_Enter);
}
}
}
void MyTest::testPasswordDialog()
{
QTimer::singleShot(500, this, SLOT(TimeOut()));
QVERIFY(functionThatProducesMessageBox());
}
void MyTest::TimeOut()
{
QWidgetList allToplevelWidgets = QApplication::topLevelWidgets();
foreach (QWidget *w, allToplevelWidgets) {
if (w->inherits("QMessageBox")) {
QMessageBox *mb = qobject_cast<QMessageBox *>(w);
QTest::keyClick(mb, Qt::Key_Enter);
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks