summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtimer
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2010-03-08 14:21:38 (GMT)
committerMarkus Goetz <Markus.Goetz@nokia.com>2010-03-09 08:42:42 (GMT)
commit7a52e5948c0305ca41a9b66d591a12d171fd2bae (patch)
tree02a840f0a5b2bd2c4798e1b6732d2f9a6ae540fe /tests/auto/qtimer
parent8870d7173fce840277d15cab9daf75aa1b587a87 (diff)
downloadQt-7a52e5948c0305ca41a9b66d591a12d171fd2bae.zip
Qt-7a52e5948c0305ca41a9b66d591a12d171fd2bae.tar.gz
Qt-7a52e5948c0305ca41a9b66d591a12d171fd2bae.tar.bz2
Improve performance of QTimer::singleShot
Avoid allocation of QObject and OS timer. Reviewed-by: Olivier Goffart
Diffstat (limited to 'tests/auto/qtimer')
-rw-r--r--tests/auto/qtimer/tst_qtimer.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/auto/qtimer/tst_qtimer.cpp b/tests/auto/qtimer/tst_qtimer.cpp
index cc97e4e..a0408ef 100644
--- a/tests/auto/qtimer/tst_qtimer.cpp
+++ b/tests/auto/qtimer/tst_qtimer.cpp
@@ -85,6 +85,7 @@ private slots:
void timerFiresOnlyOncePerProcessEvents();
void timerIdPersistsAfterThreadExit();
void cancelLongTimer();
+ void singleShotStaticFunctionZeroTimeout();
};
class TimerHelper : public QObject
@@ -611,5 +612,16 @@ void tst_QTimer::cancelLongTimer()
QVERIFY(!timer.isActive());
}
+void tst_QTimer::singleShotStaticFunctionZeroTimeout()
+{
+ TimerHelper helper;
+
+ QTimer::singleShot(0, &helper, SLOT(timeout()));
+ QTest::qWait(500);
+ QCOMPARE(helper.count, 1);
+ QTest::qWait(500);
+ QCOMPARE(helper.count, 1);
+}
+
QTEST_MAIN(tst_QTimer)
#include "tst_qtimer.moc"