diff options
Diffstat (limited to 'tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp')
-rw-r--r-- | tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp index 74b08601b7..06175e6f2f 100644 --- a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp +++ b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QTest> @@ -9,7 +9,9 @@ #include <qeventloop.h> #include <private/qeventloop_p.h> #if defined(Q_OS_UNIX) - #include <private/qeventdispatcher_unix_p.h> + #if !defined(Q_OS_WASM) + #include <private/qeventdispatcher_unix_p.h> + #endif #include <QtCore/private/qcore_unix_p.h> #if defined(HAVE_GLIB) #include <private/qeventdispatcher_glib_p.h> @@ -138,6 +140,7 @@ class tst_QEventLoop : public QObject Q_OBJECT private slots: // This test *must* run first. See the definition for why. + void processEvents_data(); void processEvents(); void exec(); void reexec(); @@ -159,8 +162,21 @@ protected: void customEvent(QEvent *e) override; }; +void tst_QEventLoop::processEvents_data() +{ + QTest::addColumn<QString>("mode"); + +#ifdef QT_GUI_LIB + QTest::addRow("gui") << "gui"; +#else + QTest::addRow("core") << "core"; +#endif +} + void tst_QEventLoop::processEvents() { + QFETCH(QString, mode); + QSignalSpy aboutToBlockSpy(QAbstractEventDispatcher::instance(), &QAbstractEventDispatcher::aboutToBlock); QSignalSpy awakeSpy(QAbstractEventDispatcher::instance(), &QAbstractEventDispatcher::awake); @@ -174,8 +190,8 @@ void tst_QEventLoop::processEvents() // process posted events, QEventLoop::processEvents() should return // true QVERIFY(eventLoop.processEvents()); - QCOMPARE(aboutToBlockSpy.count(), 0); - QCOMPARE(awakeSpy.count(), 1); + QCOMPARE(aboutToBlockSpy.size(), 0); + QCOMPARE(awakeSpy.size(), 1); // allow any session manager to complete its handshake, so that // there are no pending events left. This tests that we are able @@ -196,8 +212,8 @@ void tst_QEventLoop::processEvents() // processEvents is entered. There is no guarantee that that the // processEvents call actually blocked, since the OS may introduce // native events at any time. - QVERIFY(awakeSpy.count() > 0); - QVERIFY(awakeSpy.count() >= aboutToBlockSpy.count()); + QVERIFY(awakeSpy.size() > 0); + QVERIFY(awakeSpy.size() >= aboutToBlockSpy.size()); killTimer(timerId); } @@ -240,7 +256,7 @@ void tst_QEventLoop::exec() QVERIFY(spy.isValid()); thread.cond.wakeOne(); thread.cond.wait(&thread.mutex); - QVERIFY(spy.count() > 0); + QVERIFY(spy.size() > 0); int v = thread.result1; QCOMPARE(v, 0); @@ -249,7 +265,7 @@ void tst_QEventLoop::exec() thread.cond.wakeOne(); thread.mutex.unlock(); thread.wait(); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); v = thread.result2; QCOMPARE(v, -1); } @@ -307,7 +323,7 @@ void tst_QEventLoop::wakeUp() QTimer::singleShot(1000, &eventLoop, SLOT(quit())); (void) eventLoop.exec(); - QVERIFY(spy.count() > 0); + QVERIFY(spy.size() > 0); thread.quit(); (void) eventLoop.exec(); @@ -400,8 +416,8 @@ public slots: dataSent = serverSocket->waitForBytesWritten(-1); if (dataSent) { - pollfd pfd = qt_make_pollfd(socket->socketDescriptor(), POLLIN); - dataReadable = (1 == qt_safe_poll(&pfd, 1, nullptr)); + pollfd pfd = qt_make_pollfd(int(socket->socketDescriptor()), POLLIN); + dataReadable = (1 == qt_safe_poll(&pfd, 1, QDeadlineTimer::Forever)); } if (!dataReadable) { @@ -486,7 +502,7 @@ void tst_QEventLoop::processEventsExcludeTimers() // but not if we exclude timers eventLoop.processEvents(QEventLoop::X11ExcludeTimers); -#if defined(Q_OS_UNIX) +#if defined(Q_OS_UNIX) && !defined(Q_OS_WASM) QAbstractEventDispatcher *eventDispatcher = QCoreApplication::eventDispatcher(); if (!qobject_cast<QEventDispatcherUNIX *>(eventDispatcher) #if defined(HAVE_GLIB) |