summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp')
-rw-r--r--tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp67
1 files changed, 29 insertions, 38 deletions
diff --git a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
index 3169cc933b..06175e6f2f 100644
--- a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
+++ b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -34,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>
@@ -163,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();
@@ -184,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);
@@ -199,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
@@ -221,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);
}
@@ -265,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);
@@ -274,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);
}
@@ -332,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();
@@ -425,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) {
@@ -511,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)