diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-09-08 05:30:38 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-09-08 05:30:38 (GMT) |
commit | cad3b0bdacdbdf407dfbdda5f6dc9cb7d96fa709 (patch) | |
tree | 37a16ff73fe102ac0cd169b20f9b12135903d33a /tests/auto/qtimer/tst_qtimer.cpp | |
parent | 5305831c3b0d58a61efadc1c1d3ce9ce4d6e8c77 (diff) | |
parent | b9a924a1e77faeeba595d0619afb14e8fdbb2dd4 (diff) | |
download | Qt-cad3b0bdacdbdf407dfbdda5f6dc9cb7d96fa709.zip Qt-cad3b0bdacdbdf407dfbdda5f6dc9cb7d96fa709.tar.gz Qt-cad3b0bdacdbdf407dfbdda5f6dc9cb7d96fa709.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'tests/auto/qtimer/tst_qtimer.cpp')
-rw-r--r-- | tests/auto/qtimer/tst_qtimer.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/auto/qtimer/tst_qtimer.cpp b/tests/auto/qtimer/tst_qtimer.cpp index 57502c7..36fce76 100644 --- a/tests/auto/qtimer/tst_qtimer.cpp +++ b/tests/auto/qtimer/tst_qtimer.cpp @@ -87,6 +87,7 @@ private slots: void restartedTimerFiresTooSoon(); void timerFiresOnlyOncePerProcessEvents_data(); void timerFiresOnlyOncePerProcessEvents(); + void timerIdPersistsAfterThreadExit(); }; class TimerHelper : public QObject @@ -562,5 +563,44 @@ void tst_QTimer::timerFiresOnlyOncePerProcessEvents() QCOMPARE(longSlot.count, 1); } +class TimerIdPersistsAfterThreadExitThread : public QThread +{ +public: + QTimer *timer; + int timerId, returnValue; + + TimerIdPersistsAfterThreadExitThread() + : QThread(), timer(0), timerId(-1), returnValue(-1) + { } + ~TimerIdPersistsAfterThreadExitThread() + { + delete timer; + } + + void run() + { + QEventLoop eventLoop; + timer = new QTimer; + connect(timer, SIGNAL(timeout()), &eventLoop, SLOT(quit())); + timer->start(100); + timerId = timer->timerId(); + returnValue = eventLoop.exec(); + } +}; + +void tst_QTimer::timerIdPersistsAfterThreadExit() +{ + TimerIdPersistsAfterThreadExitThread thread; + thread.start(); + QVERIFY(thread.wait(30000)); + QCOMPARE(thread.returnValue, 0); + + // even though the thread has exited, and the event dispatcher destroyed, the timer is still + // "active", meaning the timer id should NOT be reused (i.e. the event dispatcher should not + // have unregistered it) + int timerId = thread.startTimer(100); + QVERIFY((timerId & 0xffffff) != (thread.timerId & 0xffffff)); +} + QTEST_MAIN(tst_QTimer) #include "tst_qtimer.moc" |