summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtimer
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-09-15 09:05:06 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-09-15 09:15:37 (GMT)
commite3801c20bd3626c3c9c9fac110ee2f9e4269e3c8 (patch)
tree4e63e6c30333b28fd4cd88dc0ad58a846e50f36e /tests/auto/qtimer
parent05ab8ad1577fc038aa2b3bd96cedda54e6a64979 (diff)
downloadQt-e3801c20bd3626c3c9c9fac110ee2f9e4269e3c8.zip
Qt-e3801c20bd3626c3c9c9fac110ee2f9e4269e3c8.tar.gz
Qt-e3801c20bd3626c3c9c9fac110ee2f9e4269e3c8.tar.bz2
QEventDispatcherUnix: do not process too many timer if other events need to be processed first
Task-number: QTBUG-13633 Reviewed-by: Brad
Diffstat (limited to 'tests/auto/qtimer')
-rw-r--r--tests/auto/qtimer/tst_qtimer.cpp64
1 files changed, 61 insertions, 3 deletions
diff --git a/tests/auto/qtimer/tst_qtimer.cpp b/tests/auto/qtimer/tst_qtimer.cpp
index b651187..4ed42cf 100644
--- a/tests/auto/qtimer/tst_qtimer.cpp
+++ b/tests/auto/qtimer/tst_qtimer.cpp
@@ -87,6 +87,8 @@ private slots:
void cancelLongTimer();
void singleShotStaticFunctionZeroTimeout();
void recurseOnTimeoutAndStopTimer();
+
+ void QTBUG13633_dontBlockEvents();
};
class TimerHelper : public QObject
@@ -272,9 +274,6 @@ void tst_QTimer::livelock()
#if defined(Q_OS_MAC)
QEXPECT_FAIL("zero timer", "Posted events source are handled AFTER timers", Continue);
QEXPECT_FAIL("non-zero timer", "Posted events source are handled AFTER timers", Continue);
-#elif defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
- QEXPECT_FAIL("zero timer", "", Continue);
- QEXPECT_FAIL("non-zero timer", "", Continue);
#elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
if (QSysInfo::WindowsVersion < QSysInfo::WV_XP)
QEXPECT_FAIL("non-zero timer", "Multimedia timers are not available on Windows 2000", Continue);
@@ -668,5 +667,64 @@ void tst_QTimer::recurseOnTimeoutAndStopTimer()
QVERIFY(!t.two->isActive());
}
+
+
+class DontBlockEvents : public QObject
+{
+ Q_OBJECT
+public:
+ DontBlockEvents();
+ void timerEvent(QTimerEvent*);
+
+ int count;
+ int total;
+ QBasicTimer m_timer;
+
+public slots:
+ void paintEvent();
+
+};
+
+DontBlockEvents::DontBlockEvents()
+{
+ count = 0;
+ total = 0;
+
+ //QTBUG-13633 need few unrelated timer running to reproduce the bug.
+ (new QTimer(this))->start(2000);
+ (new QTimer(this))->start(2500);
+ (new QTimer(this))->start(3000);
+ (new QTimer(this))->start(5000);
+ (new QTimer(this))->start(1000);
+ (new QTimer(this))->start(2000);
+
+ m_timer.start(1, this);
+}
+
+void DontBlockEvents::timerEvent(QTimerEvent* event)
+{
+ if (event->timerId() == m_timer.timerId()) {
+ m_timer.start(0, this);
+ QMetaObject::invokeMethod(this, "paintEvent", Qt::QueuedConnection);
+ count++;
+ QCOMPARE(count, 1);
+ total++;
+ }
+}
+
+void DontBlockEvents::paintEvent()
+{
+ count--;
+ QCOMPARE(count, 0);
+}
+
+
+void tst_QTimer::QTBUG13633_dontBlockEvents()
+{
+ DontBlockEvents t;
+ QTest::qWait(60);
+ QVERIFY(t.total > 2);
+}
+
QTEST_MAIN(tst_QTimer)
#include "tst_qtimer.moc"