summaryrefslogtreecommitdiffstats
path: root/tests/manual/wasm/eventloop
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manual/wasm/eventloop')
-rw-r--r--tests/manual/wasm/eventloop/CMakeLists.txt4
-rw-r--r--tests/manual/wasm/eventloop/README.md1
-rw-r--r--tests/manual/wasm/eventloop/asyncify_exec/CMakeLists.txt8
-rw-r--r--tests/manual/wasm/eventloop/asyncify_exec/main.cpp61
-rw-r--r--tests/manual/wasm/eventloop/dialog_exec/CMakeLists.txt5
-rw-r--r--tests/manual/wasm/eventloop/dialog_exec/main.cpp51
-rw-r--r--tests/manual/wasm/eventloop/eventloop_auto/CMakeLists.txt43
-rw-r--r--tests/manual/wasm/eventloop/eventloop_auto/eventloop_auto.html10
-rw-r--r--tests/manual/wasm/eventloop/eventloop_auto/eventloop_auto_asyncify.html10
-rw-r--r--tests/manual/wasm/eventloop/eventloop_auto/main.cpp327
-rw-r--r--tests/manual/wasm/eventloop/main_exec/CMakeLists.txt5
-rw-r--r--tests/manual/wasm/eventloop/main_exec/main.cpp51
-rw-r--r--tests/manual/wasm/eventloop/main_noexec/CMakeLists.txt5
-rw-r--r--tests/manual/wasm/eventloop/main_noexec/main.cpp51
-rw-r--r--tests/manual/wasm/eventloop/thread_exec/CMakeLists.txt5
-rw-r--r--tests/manual/wasm/eventloop/thread_exec/main.cpp51
16 files changed, 430 insertions, 258 deletions
diff --git a/tests/manual/wasm/eventloop/CMakeLists.txt b/tests/manual/wasm/eventloop/CMakeLists.txt
index 96c7fd45bb..132fd15dbb 100644
--- a/tests/manual/wasm/eventloop/CMakeLists.txt
+++ b/tests/manual/wasm/eventloop/CMakeLists.txt
@@ -1,4 +1,8 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
add_subdirectory(asyncify_exec)
+add_subdirectory(eventloop_auto)
add_subdirectory(main_exec)
add_subdirectory(main_noexec)
add_subdirectory(thread_exec)
diff --git a/tests/manual/wasm/eventloop/README.md b/tests/manual/wasm/eventloop/README.md
index e5d4b92306..e1a5a1a3b7 100644
--- a/tests/manual/wasm/eventloop/README.md
+++ b/tests/manual/wasm/eventloop/README.md
@@ -12,3 +12,4 @@ Contents
main_noexec Qt main() without QApplication::exec()
dialog_exec Shows how QDialog::exec() also does not return
thread_exec Shows how to use QThread::exec()
+ eventloop_auto Event loop autotest (manually run)
diff --git a/tests/manual/wasm/eventloop/asyncify_exec/CMakeLists.txt b/tests/manual/wasm/eventloop/asyncify_exec/CMakeLists.txt
index 09b5cdb1e9..fe7cfb9030 100644
--- a/tests/manual/wasm/eventloop/asyncify_exec/CMakeLists.txt
+++ b/tests/manual/wasm/eventloop/asyncify_exec/CMakeLists.txt
@@ -1,6 +1,12 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
qt_internal_add_manual_test(asyncify_exec
SOURCES
main.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Core
)
+
+# Enable asyncify for this test. Also enable optimizations in order to reduce the binary size.
+target_link_options(asyncify_exec PUBLIC -sASYNCIFY -Os)
diff --git a/tests/manual/wasm/eventloop/asyncify_exec/main.cpp b/tests/manual/wasm/eventloop/asyncify_exec/main.cpp
index d2b6d83474..f09163184d 100644
--- a/tests/manual/wasm/eventloop/asyncify_exec/main.cpp
+++ b/tests/manual/wasm/eventloop/asyncify_exec/main.cpp
@@ -1,62 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore>
-// This test shows how to asyncify enables blocking
-// the main thread on QEventLoop::exec(), while event
-// provessing continues.
+// This test shows how to use asyncify to enable blocking the main
+// thread on QEventLoop::exec(), while event processing continues.
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
-#ifdef QT_HAVE_EMSCRIPTEN_ASYNCIFY
QTimer::singleShot(1000, []() {
QEventLoop loop;
@@ -69,10 +20,6 @@ int main(int argc, char **argv)
loop.exec();
qDebug() << "Returned from QEventLoop::exec()";
});
-#else
- qDebug() << "This test requires Emscripten asyncify. To enable,"
- << "configure Qt with -device-option QT_EMSCRIPTEN_ASYNCIFY=1";
-#endif
app.exec();
}
diff --git a/tests/manual/wasm/eventloop/dialog_exec/CMakeLists.txt b/tests/manual/wasm/eventloop/dialog_exec/CMakeLists.txt
index 00bbca0b9d..ac18643c63 100644
--- a/tests/manual/wasm/eventloop/dialog_exec/CMakeLists.txt
+++ b/tests/manual/wasm/eventloop/dialog_exec/CMakeLists.txt
@@ -1,8 +1,11 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
qt_internal_add_manual_test(dialog_exec
GUI
SOURCES
main.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Core
Qt::Gui
Qt::Widgets
diff --git a/tests/manual/wasm/eventloop/dialog_exec/main.cpp b/tests/manual/wasm/eventloop/dialog_exec/main.cpp
index d10230262d..f5b072fc0b 100644
--- a/tests/manual/wasm/eventloop/dialog_exec/main.cpp
+++ b/tests/manual/wasm/eventloop/dialog_exec/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtGui>
#include <QtWidgets>
diff --git a/tests/manual/wasm/eventloop/eventloop_auto/CMakeLists.txt b/tests/manual/wasm/eventloop/eventloop_auto/CMakeLists.txt
new file mode 100644
index 0000000000..9bfa875be7
--- /dev/null
+++ b/tests/manual/wasm/eventloop/eventloop_auto/CMakeLists.txt
@@ -0,0 +1,43 @@
+include_directories(../../qtwasmtestlib/)
+
+# default buid
+qt_internal_add_manual_test(eventloop_auto
+ SOURCES
+ main.cpp
+ ../../qtwasmtestlib/qtwasmtestlib.cpp
+ LIBRARIES
+ Qt::Core
+ Qt::CorePrivate
+)
+
+add_custom_command(
+ TARGET eventloop_auto POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${CMAKE_CURRENT_SOURCE_DIR}/eventloop_auto.html
+ ${CMAKE_CURRENT_BINARY_DIR}/eventloop_auto.html)
+
+add_custom_command(
+ TARGET eventloop_auto POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../qtwasmtestlib/qtwasmtestlib.js
+ ${CMAKE_CURRENT_BINARY_DIR}/qtwasmtestlib.js)
+
+# asyncify enabled build
+qt_internal_add_manual_test(eventloop_auto_asyncify
+ SOURCES
+ main.cpp
+ ../../qtwasmtestlib/qtwasmtestlib.cpp
+ LIBRARIES
+ Qt::Core
+ Qt::CorePrivate
+)
+
+target_link_options(eventloop_auto_asyncify PRIVATE -sASYNCIFY -Os)
+
+add_custom_command(
+ TARGET eventloop_auto_asyncify POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${CMAKE_CURRENT_SOURCE_DIR}/eventloop_auto_asyncify.html
+ ${CMAKE_CURRENT_BINARY_DIR}/eventloop_auto_asyncify.html)
+
+
diff --git a/tests/manual/wasm/eventloop/eventloop_auto/eventloop_auto.html b/tests/manual/wasm/eventloop/eventloop_auto/eventloop_auto.html
new file mode 100644
index 0000000000..e8e35abcbb
--- /dev/null
+++ b/tests/manual/wasm/eventloop/eventloop_auto/eventloop_auto.html
@@ -0,0 +1,10 @@
+<!doctype html>
+<script type="text/javascript" src="qtwasmtestlib.js"></script>
+<script type="text/javascript" src="eventloop_auto.js"></script>
+<script>
+ window.onload = () => {
+ runTestCase(eventloop_auto_entry, document.getElementById("log"));
+ };
+</script>
+<p>Running event dispatcher auto test.</p>
+<div id="log"></div>
diff --git a/tests/manual/wasm/eventloop/eventloop_auto/eventloop_auto_asyncify.html b/tests/manual/wasm/eventloop/eventloop_auto/eventloop_auto_asyncify.html
new file mode 100644
index 0000000000..f09b29d85b
--- /dev/null
+++ b/tests/manual/wasm/eventloop/eventloop_auto/eventloop_auto_asyncify.html
@@ -0,0 +1,10 @@
+<!doctype html>
+<script type="text/javascript" src="qtwasmtestlib.js"></script>
+<script type="text/javascript" src="eventloop_auto_asyncify.js"></script>
+<script>
+ window.onload = () => {
+ runTestCase(eventloop_auto_asyncify_entry, document.getElementById("log"));
+ };
+</script>
+<p>Running event dispatcher auto test.</p>
+<div id="log"></div>
diff --git a/tests/manual/wasm/eventloop/eventloop_auto/main.cpp b/tests/manual/wasm/eventloop/eventloop_auto/main.cpp
new file mode 100644
index 0000000000..32af372b62
--- /dev/null
+++ b/tests/manual/wasm/eventloop/eventloop_auto/main.cpp
@@ -0,0 +1,327 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QtCore/QCoreApplication>
+#include <QtCore/QEvent>
+#include <QtCore/QMutex>
+#include <QtCore/QObject>
+#include <QtCore/QThread>
+#include <QtCore/QTimer>
+#include <QtCore/private/qstdweb_p.h>
+
+#include <qtwasmtestlib.h>
+
+#include "emscripten.h"
+
+const int timerTimeout = 10;
+
+class WasmEventDispatcherTest: public QObject
+{
+ Q_OBJECT
+private slots:
+ void postEventMainThread();
+ void timerMainThread();
+ void timerMainThreadMultiple();
+
+#if QT_CONFIG(thread)
+ void postEventSecondaryThread();
+ void postEventSecondaryThreads();
+ void postEventToSecondaryThread();
+ void timerSecondaryThread();
+#endif
+
+ void postEventAsyncify();
+ void timerAsyncify();
+ void postEventAsyncifyLoop();
+
+private:
+// Disabled test function: Asyncify wait on pthread_join is not supported,
+// see https://github.com/emscripten-core/emscripten/issues/9910
+#if QT_CONFIG(thread)
+ void threadAsyncifyWait();
+#endif
+};
+
+class EventTarget : public QObject
+{
+ Q_OBJECT
+
+public:
+ static EventTarget *create(std::function<void()> callback)
+ {
+ return new EventTarget(callback);
+ }
+
+ static QEvent *createEvent()
+ {
+ return new QEvent(QEvent::User);
+ }
+
+protected:
+ EventTarget(std::function<void()> callback)
+ : m_callback(callback) { }
+
+ bool event(QEvent *evt)
+ {
+ if (evt->type() == QEvent::User) {
+ m_callback();
+ deleteLater();
+ return true;
+ }
+ return QObject::event(evt);
+ }
+
+private:
+ std::function<void()> m_callback;
+};
+
+class CompleteTestFunctionRefGuard {
+public:
+ CompleteTestFunctionRefGuard(CompleteTestFunctionRefGuard const&) = delete;
+ CompleteTestFunctionRefGuard& operator=(CompleteTestFunctionRefGuard const&) = delete;
+
+ static CompleteTestFunctionRefGuard *create() {
+ return new CompleteTestFunctionRefGuard();
+ }
+
+ void ref() {
+ QMutexLocker lock(&mutex);
+ ++m_counter;
+ }
+
+ void deref() {
+ const bool finalDeref = [this] {
+ QMutexLocker lock(&mutex);
+ return --m_counter == 0;
+ }();
+
+ if (finalDeref)
+ QtWasmTest::completeTestFunction();
+ }
+private:
+ CompleteTestFunctionRefGuard() { };
+
+ QMutex mutex;
+ int m_counter = 0;
+};
+
+#if QT_CONFIG(thread)
+
+class TestThread : public QThread
+{
+public:
+ static QThread *create(std::function<void()> started, std::function<void()> finished)
+ {
+ TestThread *thread = new TestThread();
+ connect(thread, &QThread::started, [started]() {
+ started();
+ });
+ connect(thread, &QThread::finished, [thread, finished]() {
+ finished();
+ thread->deleteLater();
+ });
+ thread->start();
+ return thread;
+ }
+};
+
+#endif
+
+// Post event to the main thread and verify that it is processed.
+void WasmEventDispatcherTest::postEventMainThread()
+{
+ QCoreApplication::postEvent(EventTarget::create([](){
+ QtWasmTest::completeTestFunction();
+ }), EventTarget::createEvent());
+}
+
+// Create a timer on the main thread and verify that it fires
+void WasmEventDispatcherTest::timerMainThread()
+{
+ QTimer::singleShot(timerTimeout, [](){
+ QtWasmTest::completeTestFunction();
+ });
+}
+
+void WasmEventDispatcherTest::timerMainThreadMultiple()
+{
+ CompleteTestFunctionRefGuard *completeGuard = CompleteTestFunctionRefGuard::create();
+ int timers = 10;
+ for (int i = 0; i < timers; ++i) {
+ completeGuard->ref();
+ QTimer::singleShot(timerTimeout * i, [completeGuard](){
+ completeGuard->deref();
+ });
+ }
+}
+
+#if QT_CONFIG(thread)
+
+// Post event on a secondary thread and verify that it is processed.
+void WasmEventDispatcherTest::postEventSecondaryThread()
+{
+ auto started = [](){
+ QCoreApplication::postEvent(EventTarget::create([](){
+ QThread::currentThread()->quit();
+ }), EventTarget::createEvent());
+ };
+
+ auto finished = [](){
+ QtWasmTest::completeTestFunction();
+ };
+
+ TestThread::create(started, finished);
+}
+
+// Post event _to_ a secondary thread and verify that it is processed.
+void WasmEventDispatcherTest::postEventToSecondaryThread()
+{
+ auto started = [](){};
+ auto finished = [](){
+ QtWasmTest::completeTestFunction();
+ };
+
+ QThread *t = TestThread::create(started, finished);
+ EventTarget *target = EventTarget::create([](){
+ QThread::currentThread()->quit();
+ });
+ target->moveToThread(t);
+ QCoreApplication::postEvent(target, EventTarget::createEvent());
+}
+
+// Post events to many secondary threads and verify that they are processed.
+void WasmEventDispatcherTest::postEventSecondaryThreads()
+{
+ // This test completes afer all threads has finished
+ CompleteTestFunctionRefGuard *completeGuard = CompleteTestFunctionRefGuard::create();
+ completeGuard->ref(); // including this thread
+
+ auto started = [](){
+ QCoreApplication::postEvent(EventTarget::create([](){
+ QThread::currentThread()->quit();
+ }), EventTarget::createEvent());
+ };
+
+ auto finished = [completeGuard](){
+ completeGuard->deref();
+ };
+
+ // Start a nymber of threads in parallel, keeping in mind that the browser
+ // has some max number of concurrent web workers (maybe 20), and that starting
+ // a new web worker requires completing a GET network request for the worker's JS.
+ const int numThreads = 10;
+ for (int i = 0; i < numThreads; ++i) {
+ completeGuard->ref();
+ TestThread::create(started, finished);
+ }
+
+ completeGuard->deref();
+}
+
+// Create a timer a secondary thread and verify that it fires
+void WasmEventDispatcherTest::timerSecondaryThread()
+{
+ auto started = [](){
+ QTimer::singleShot(timerTimeout, [](){
+ QThread::currentThread()->quit();
+ });
+ };
+
+ auto finished = [](){
+ QtWasmTest::completeTestFunction();
+ };
+
+ TestThread::create(started, finished);
+}
+
+#endif
+
+// Post an event to the main thread and asyncify wait for it
+void WasmEventDispatcherTest::postEventAsyncify()
+{
+ if (!qstdweb::haveAsyncify()) {
+ QtWasmTest::completeTestFunction(QtWasmTest::TestResult::Skip, "requires asyncify");
+ return;
+ }
+
+ QEventLoop loop;
+ QCoreApplication::postEvent(EventTarget::create([&loop](){
+ loop.quit();
+ }), EventTarget::createEvent());
+ loop.exec();
+
+ QtWasmTest::completeTestFunction();
+}
+
+// Create a timer on the main thread and asyncify wait for it
+void WasmEventDispatcherTest::timerAsyncify()
+{
+ if (!qstdweb::haveAsyncify()) {
+ QtWasmTest::completeTestFunction(QtWasmTest::TestResult::Skip, "requires asyncify");
+ return;
+ }
+
+ QEventLoop loop;
+ QTimer::singleShot(timerTimeout, [&loop](){
+ loop.quit();
+ });
+ loop.exec();
+
+ QtWasmTest::completeTestFunction();
+}
+
+// Asyncify wait in a loop
+void WasmEventDispatcherTest::postEventAsyncifyLoop()
+{
+ if (!qstdweb::haveAsyncify()) {
+ QtWasmTest::completeTestFunction(QtWasmTest::TestResult::Skip, "requires asyncify");
+ return;
+ }
+
+ for (int i = 0; i < 10; ++i) {
+ QEventLoop loop;
+ QCoreApplication::postEvent(EventTarget::create([&loop]() {
+ loop.quit();
+ }), EventTarget::createEvent());
+ loop.exec();
+ }
+
+ QtWasmTest::completeTestFunction();
+}
+
+#if QT_CONFIG(thread)
+// Asyncify wait for QThread::wait() / pthread_join()
+void WasmEventDispatcherTest::threadAsyncifyWait()
+{
+ if (!qstdweb::haveAsyncify())
+ QtWasmTest::completeTestFunction(QtWasmTest::TestResult::Skip, "requires asyncify");
+
+ const int threadCount = 15;
+
+ QVector<QThread *> threads;
+ threads.reserve(threadCount);
+
+ for (int i = 0; i < threadCount; ++i) {
+ QThread *thread = new QThread();
+ threads.push_back(thread);
+ thread->start();
+ }
+
+ for (int i = 0; i < threadCount; ++i) {
+ QThread *thread = threads[i];
+ thread->wait();
+ delete thread;
+ }
+
+ QtWasmTest::completeTestFunction();
+}
+#endif
+
+int main(int argc, char **argv)
+{
+ auto testObject = std::make_shared<WasmEventDispatcherTest>();
+ QtWasmTest::initTestCase<QCoreApplication>(argc, argv, testObject);
+ return 0;
+}
+
+#include "main.moc"
diff --git a/tests/manual/wasm/eventloop/main_exec/CMakeLists.txt b/tests/manual/wasm/eventloop/main_exec/CMakeLists.txt
index b5d987f8cb..1f263ddbcf 100644
--- a/tests/manual/wasm/eventloop/main_exec/CMakeLists.txt
+++ b/tests/manual/wasm/eventloop/main_exec/CMakeLists.txt
@@ -1,8 +1,11 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
qt_internal_add_manual_test(main_exec
GUI
SOURCES
main.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Core
Qt::Gui
)
diff --git a/tests/manual/wasm/eventloop/main_exec/main.cpp b/tests/manual/wasm/eventloop/main_exec/main.cpp
index d1eeaeaae3..17eccafe18 100644
--- a/tests/manual/wasm/eventloop/main_exec/main.cpp
+++ b/tests/manual/wasm/eventloop/main_exec/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtGui>
// This example demonstrates how the standard Qt main()
diff --git a/tests/manual/wasm/eventloop/main_noexec/CMakeLists.txt b/tests/manual/wasm/eventloop/main_noexec/CMakeLists.txt
index 23d48b626f..e929089479 100644
--- a/tests/manual/wasm/eventloop/main_noexec/CMakeLists.txt
+++ b/tests/manual/wasm/eventloop/main_noexec/CMakeLists.txt
@@ -1,8 +1,11 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
qt_internal_add_manual_test(main_noexec
GUI
SOURCES
main.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Core
Qt::Gui
)
diff --git a/tests/manual/wasm/eventloop/main_noexec/main.cpp b/tests/manual/wasm/eventloop/main_noexec/main.cpp
index 16f5a2b026..6ddd88bd14 100644
--- a/tests/manual/wasm/eventloop/main_noexec/main.cpp
+++ b/tests/manual/wasm/eventloop/main_noexec/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtGui>
// This example demonstrates how to create QGuiApplication
diff --git a/tests/manual/wasm/eventloop/thread_exec/CMakeLists.txt b/tests/manual/wasm/eventloop/thread_exec/CMakeLists.txt
index 1c845510df..765ccee4f1 100644
--- a/tests/manual/wasm/eventloop/thread_exec/CMakeLists.txt
+++ b/tests/manual/wasm/eventloop/thread_exec/CMakeLists.txt
@@ -1,8 +1,11 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
qt_internal_add_manual_test(thread_exec
GUI
SOURCES
main.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Core
Qt::Gui
)
diff --git a/tests/manual/wasm/eventloop/thread_exec/main.cpp b/tests/manual/wasm/eventloop/thread_exec/main.cpp
index fb477843d8..589066b34d 100644
--- a/tests/manual/wasm/eventloop/thread_exec/main.cpp
+++ b/tests/manual/wasm/eventloop/thread_exec/main.cpp
@@ -1,52 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtGui>
class EventTarget : public QObject