summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/dialogs
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2012-10-22 15:03:06 +0300
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-23 12:03:50 +0200
commit32cbcca91122c61a1dddf45f23916424cd65829b (patch)
treef78f87516e962dd9b2c86b5eba1fe5dd77a30d0e /tests/auto/widgets/dialogs
parent7abf6234436aee377d15f9f2f1d37ee7daf7464e (diff)
Stabilize tst_qfontdialog test case.
The delayed quit signal used as failsafe to ensure exit from event loops interfere with later test if the test case works normally, as closing the last toplevel window will also exit the event loop. Fixed by stopping the quit timer if nested application exec loop is exited. Change-Id: If87655f1f28f50e27a64f3430c9f65bb3ab7dd70 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Janne Anttila <janne.anttila@digia.com>
Diffstat (limited to 'tests/auto/widgets/dialogs')
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
index 2d39ddaa2c..958128d58e 100644
--- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
+++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
@@ -76,6 +76,9 @@ private slots:
void defaultOkButton();
void setFont();
void task256466_wrongStyle();
+
+private:
+ void runSlotWithFailsafeTimer(const char *member);
};
tst_QFontDialog::tst_QFontDialog()
@@ -124,12 +127,24 @@ void tst_QFontDialog::testGetFont()
QVERIFY(ok);
}
+void tst_QFontDialog::runSlotWithFailsafeTimer(const char *member)
+{
+ // FailSafeTimer quits the nested event loop if the dialog closing doesn't do it.
+ QTimer failSafeTimer;
+ failSafeTimer.setInterval(4000);
+ failSafeTimer.setSingleShot(true);
+ connect(&failSafeTimer, SIGNAL(timeout()), qApp, SLOT(quit()));
+ failSafeTimer.start();
+
+ QTimer::singleShot(0, this, member);
+ qApp->exec();
+
+ // FailSafeTimer stops once it goes out of scope.
+}
void tst_QFontDialog::defaultOkButton()
{
- QTimer::singleShot(4000, qApp, SLOT(quit()));
- QTimer::singleShot(0, this, SLOT(testGetFont()));
- qApp->exec();
+ runSlotWithFailsafeTimer(SLOT(testGetFont()));
}
void tst_QFontDialog::testSetFont()
@@ -158,9 +173,7 @@ void tst_QFontDialog::setFont()
while the font dialog was open.
Task #27662
*/
- QTimer::singleShot(4000, qApp, SLOT(quit()));
- QTimer::singleShot(0, this, SLOT(testSetFont()));
- qApp->exec();
+ runSlotWithFailsafeTimer(SLOT(testSetFont()));
}