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>
This commit is contained in:
parent
7abf623443
commit
32cbcca911
@ -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()));
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user