OSDN Git Service

add test case for qAddPostRoutine() and qRemovePostRoutine()
authorIvailo Monev <xakepa10@gmail.com>
Tue, 14 Jun 2022 05:53:18 +0000 (08:53 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Tue, 14 Jun 2022 05:53:18 +0000 (08:53 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
tests/auto/qcoreapplication/tst_qcoreapplication.cpp

index 8ba9099..962a804 100644 (file)
@@ -22,6 +22,8 @@
 #include <QtCore/QtCore>
 #include <QtTest/QtTest>
 
+#include <unistd.h>
+
 class tst_QCoreApplication: public QObject
 {
     Q_OBJECT
@@ -41,6 +43,7 @@ private slots:
     void reexec();
     void execAfterExit();
     void eventLoopExecAfterExit();
+    void postRoutine();
 };
 
 class EventSpy : public QObject
@@ -556,6 +559,18 @@ void tst_QCoreApplication::eventLoopExecAfterExit()
     QCOMPARE(loop.exec(), 0);
 }
 
+void TestPostRoutine()
+{
+    ::usleep(1000);
+    // deadlock test
+    qRemovePostRoutine(TestPostRoutine);
+}
+
+void tst_QCoreApplication::postRoutine()
+{
+    qAddPostRoutine(TestPostRoutine);
+}
+
 static void createQObjectOnDestruction()
 {
     // Make sure that we can create a QObject after the last QObject has been