From 64a4216254a49ae0ba946717599c4f52dac978c5 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Wed, 24 May 2017 16:06:28 +0200 Subject: [PATCH] tst_QFiledialog: use escape to close dialogs instead of timer This makes the test a lot faster and perhaps more reliable. Change-Id: I055cfde627c75f71735eabbf01af2a196bd8b00a Reviewed-by: Friedemann Kleint --- tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index 44cb5a5bf8..8d209fc241 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -1463,10 +1463,7 @@ class DialogRejecter : public QObject public: DialogRejecter() { - QTimer *timer = new QTimer(this); - timer->setInterval(1000); - connect(timer, &QTimer::timeout, this, &DialogRejecter::rejectFileDialog); - timer->start(); + connect(qApp, &QApplication::focusChanged, this, &DialogRejecter::rejectFileDialog); } public slots: @@ -1474,7 +1471,7 @@ public slots: { if (QWidget *w = QApplication::activeModalWidget()) if (QDialog *d = qobject_cast(w)) - d->reject(); + QTest::keyClick(d, Qt::Key_Escape); } };