summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeemu Katajisto <teemu.katajisto@digia.com>2012-09-13 09:24:09 +0300
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-09-27 23:51:30 +0200
commit7615b54ce8bd3ef08587abe9efde53195b9fb1fe (patch)
tree025d61e7bb77715629c5e2c98ba2ad3ac0e8959e
parente8ca2e008f52a818884b151dd93226813832ef94 (diff)
Run application main run loop in color/font dialog test
In cocoa the timers are associated with main run loop but the way font and color dialog tests are executed the modal dialog run loop is only run in cocoa. This causes timers to not to fire and test cases to hang. Unfortunately this does not completely fix the test failure because the QTest::keyClick is not working with cocoa native dialog helpers and therefore the tests are marked with QEXPECT_FAIL. Task-number: QTBUG-24320 Task-number: QTBUG-24321 Change-Id: I88740a20ad2b794b6ca15e1b6455f436ffd39335 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
-rw-r--r--tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp34
-rw-r--r--tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp36
2 files changed, 46 insertions, 24 deletions
diff --git a/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp b/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp
index 3b36f4ee04..c4885107fe 100644
--- a/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp
+++ b/tests/auto/widgets/dialogs/qcolordialog/tst_qcolordialog.cpp
@@ -53,12 +53,10 @@ public:
tst_QColorDialog();
virtual ~tst_QColorDialog();
-#ifndef Q_OS_MAC
public slots:
void postKeyReturn();
-private slots:
- void defaultOkButton();
-#endif
+ void testGetRgba();
+ void testNativeActiveModalWidget();
public slots:
void initTestCase();
@@ -67,6 +65,7 @@ public slots:
void cleanup();
private slots:
+ void defaultOkButton();
void native_activeModalWidget();
void task247349_alpha();
};
@@ -98,11 +97,8 @@ tst_QColorDialog::~tst_QColorDialog()
{
}
-void tst_QColorDialog::native_activeModalWidget()
+void tst_QColorDialog::testNativeActiveModalWidget()
{
-#ifdef Q_OS_MAC
- QSKIP("Test hangs on Mac OS X, see QTBUG-24320");
-#endif
// Check that QApplication::activeModalWidget retruns the
// color dialog when it is executing, even when using a native
// dialog:
@@ -112,6 +108,13 @@ void tst_QColorDialog::native_activeModalWidget()
QVERIFY(&d == d.m_activeModalWidget);
}
+void tst_QColorDialog::native_activeModalWidget()
+{
+ QTimer::singleShot(3000, qApp, SLOT(quit()));
+ QTimer::singleShot(0, this, SLOT(testNativeActiveModalWidget()));
+ qApp->exec();
+}
+
void tst_QColorDialog::initTestCase()
{
}
@@ -128,8 +131,6 @@ void tst_QColorDialog::cleanup()
{
}
-#ifndef Q_OS_MAC
-//copied from QFontDialogTest
void tst_QColorDialog::postKeyReturn() {
QWidgetList list = QApplication::topLevelWidgets();
for (int i=0; i<list.count(); ++i) {
@@ -141,14 +142,23 @@ void tst_QColorDialog::postKeyReturn() {
}
}
-void tst_QColorDialog::defaultOkButton()
+void tst_QColorDialog::testGetRgba()
{
+#ifdef Q_OS_MAC
+ QEXPECT_FAIL("", "Sending QTest::keyClick to OSX color dialog helper fails, see QTBUG-24320", Continue);
+#endif
bool ok = false;
QTimer::singleShot(500, this, SLOT(postKeyReturn()));
QColorDialog::getRgba(0xffffffff, &ok);
QVERIFY(ok);
}
-#endif
+
+void tst_QColorDialog::defaultOkButton()
+{
+ QTimer::singleShot(4000, qApp, SLOT(quit()));
+ QTimer::singleShot(0, this, SLOT(testGetRgba()));
+ qApp->exec();
+}
void tst_QColorDialog::task247349_alpha()
{
diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
index b75ab4141f..2d39ddaa2c 100644
--- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
+++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp
@@ -64,6 +64,8 @@ public:
public slots:
void postKeyReturn();
+ void testGetFont();
+ void testSetFont();
public slots:
void initTestCase();
@@ -100,7 +102,6 @@ void tst_QFontDialog::cleanup()
{
}
-
void tst_QFontDialog::postKeyReturn() {
QWidgetList list = QApplication::topLevelWidgets();
for (int i=0; i<list.count(); ++i) {
@@ -112,10 +113,10 @@ void tst_QFontDialog::postKeyReturn() {
}
}
-void tst_QFontDialog::defaultOkButton()
+void tst_QFontDialog::testGetFont()
{
#ifdef Q_OS_MAC
- QSKIP("Test hangs on Mac OS X, see QTBUG-24321");
+ QEXPECT_FAIL("", "Sending QTest::keyClick to OSX font dialog helper fails, see QTBUG-24321", Continue);
#endif
bool ok = false;
QTimer::singleShot(2000, this, SLOT(postKeyReturn()));
@@ -124,15 +125,15 @@ void tst_QFontDialog::defaultOkButton()
}
-void tst_QFontDialog::setFont()
+void tst_QFontDialog::defaultOkButton()
+{
+ QTimer::singleShot(4000, qApp, SLOT(quit()));
+ QTimer::singleShot(0, this, SLOT(testGetFont()));
+ qApp->exec();
+}
+
+void tst_QFontDialog::testSetFont()
{
-#ifdef Q_OS_MAC
- QSKIP("Test hangs on Mac OS X, see QTBUG-24321");
-#endif
- /* The font should be the same before as it is after if nothing changed
- while the font dialog was open.
- Task #27662
- */
bool ok = false;
#if defined Q_OS_HPUX
QString fontName = "Courier";
@@ -151,11 +152,22 @@ void tst_QFontDialog::setFont()
QCOMPARE(QFontInfo(f2).pointSize(), QFontInfo(f1).pointSize());
}
+void tst_QFontDialog::setFont()
+{
+ /* The font should be the same before as it is after if nothing changed
+ while the font dialog was open.
+ Task #27662
+ */
+ QTimer::singleShot(4000, qApp, SLOT(quit()));
+ QTimer::singleShot(0, this, SLOT(testSetFont()));
+ qApp->exec();
+}
+
class FriendlyFontDialog : public QFontDialog
{
friend class tst_QFontDialog;
- Q_DECLARE_PRIVATE(QFontDialog);
+ Q_DECLARE_PRIVATE(QFontDialog)
};
void tst_QFontDialog::task256466_wrongStyle()