diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-11-13 09:25:20 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-11-13 09:25:20 (GMT) |
commit | b664d54867139b371e158f1c63076c4a970cbb2a (patch) | |
tree | 455de47287676160557b40fc67ea3d6c0f15f209 /tests/auto | |
parent | 99b19431e6846a36a65f23d21a95140a081d1f1a (diff) | |
parent | c785d92153d23b836451b0643424b9871bcc4be9 (diff) | |
download | Qt-b664d54867139b371e158f1c63076c4a970cbb2a.zip Qt-b664d54867139b371e158f1c63076c4a970cbb2a.tar.gz Qt-b664d54867139b371e158f1c63076c4a970cbb2a.tar.bz2 |
Merge commit 'c785d92153d23b836451b0643424b9871bcc4be9' into 4.6-upstream
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qcoreapplication/tst_qcoreapplication.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/auto/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/qcoreapplication/tst_qcoreapplication.cpp index c5f06e2..3c61f81 100644 --- a/tests/auto/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/qcoreapplication/tst_qcoreapplication.cpp @@ -58,6 +58,7 @@ private slots: #endif void applicationPid(); void globalPostedEventsCount(); + void processEventsAlwaysSendsPostedEvents(); }; class EventSpy : public QObject @@ -488,5 +489,40 @@ void tst_QCoreApplication::globalPostedEventsCount() QCOMPARE(x.globalPostedEventsCount, expected); } +class ProcessEventsAlwaysSendsPostedEventsObject : public QObject +{ +public: + int counter; + + inline ProcessEventsAlwaysSendsPostedEventsObject() + : counter(0) + { } + + bool event(QEvent *event) + { + if (event->type() == QEvent::User) + ++counter; + return QObject::event(event); + } +}; + +void tst_QCoreApplication::processEventsAlwaysSendsPostedEvents() +{ + int argc = 1; + char *argv[] = { "tst_qcoreapplication" }; + QCoreApplication app(argc, argv); + + ProcessEventsAlwaysSendsPostedEventsObject object; + QTime t; + t.start(); + int i = 1; + do { + QCoreApplication::postEvent(&object, new QEvent(QEvent::User)); + QCoreApplication::processEvents(); + QCOMPARE(object.counter, i); + ++i; + } while (t.elapsed() < 3000); +} + QTEST_APPLESS_MAIN(tst_QCoreApplication) #include "tst_qcoreapplication.moc" |