summaryrefslogtreecommitdiffstats
path: root/tests/auto/qcoreapplication
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-11-11 12:50:53 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-11-11 13:59:01 (GMT)
commitfe0f807e1f4e7510c6d8cddd848bcbc25e358651 (patch)
tree2311eaefceb27ff6285c1a74990d219fed582e34 /tests/auto/qcoreapplication
parent791c4035c28257e5a8426e6519866546faaf5286 (diff)
downloadQt-fe0f807e1f4e7510c6d8cddd848bcbc25e358651.zip
Qt-fe0f807e1f4e7510c6d8cddd848bcbc25e358651.tar.gz
Qt-fe0f807e1f4e7510c6d8cddd848bcbc25e358651.tar.bz2
Make sure posted events are always sent when calling processEvents() on Win32
After 31f1ff910, posted events could be delayed by a previous call to processEvents(). This causes some tests to randomly fail, so bring back the invariant that processEvents() will always call sendPostedEvents() when called "manually" (i.e. not from exec()). Reviewed-by: Prasanth Ullattil
Diffstat (limited to 'tests/auto/qcoreapplication')
-rw-r--r--tests/auto/qcoreapplication/tst_qcoreapplication.cpp36
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"