summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/manual/wasm/eventloop/eventloop_auto/CMakeLists.txt26
-rw-r--r--tests/manual/wasm/eventloop/eventloop_auto/eventloop_auto_asyncify.html10
-rw-r--r--tests/manual/wasm/eventloop/eventloop_auto/main.cpp32
3 files changed, 58 insertions, 10 deletions
diff --git a/tests/manual/wasm/eventloop/eventloop_auto/CMakeLists.txt b/tests/manual/wasm/eventloop/eventloop_auto/CMakeLists.txt
index 4212cb832b..f8669c2030 100644
--- a/tests/manual/wasm/eventloop/eventloop_auto/CMakeLists.txt
+++ b/tests/manual/wasm/eventloop/eventloop_auto/CMakeLists.txt
@@ -1,13 +1,14 @@
+include_directories(../../qtwasmtestlib/)
+
+# default buid
qt_internal_add_manual_test(eventloop_auto
SOURCES
main.cpp
../../qtwasmtestlib/qtwasmtestlib.cpp
- PUBLIC_LIBRARIES
+ LIBRARIES
Qt::Core
)
-include_directories(../../qtwasmtestlib/)
-
add_custom_command(
TARGET eventloop_auto POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
@@ -19,3 +20,22 @@ add_custom_command(
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
+)
+
+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_asyncify.html b/tests/manual/wasm/eventloop/eventloop_auto/eventloop_auto_asyncify.html
new file mode 100644
index 0000000000..a277c9b9e0
--- /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(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
index c6e8bad987..b6de2310ad 100644
--- a/tests/manual/wasm/eventloop/eventloop_auto/main.cpp
+++ b/tests/manual/wasm/eventloop/eventloop_auto/main.cpp
@@ -10,8 +10,14 @@
#include <qtwasmtestlib.h>
+#include "emscripten.h"
+
const int timerTimeout = 10;
+EM_JS(bool, have_asyncify, (), {
+ return typeof Asyncify != "undefined";
+});
+
class WasmEventDispatcherTest: public QObject
{
Q_OBJECT
@@ -27,16 +33,14 @@ private slots:
void timerSecondaryThread();
#endif
-#ifdef QT_HAVE_EMSCRIPTEN_ASYNCIFY
void postEventAsyncify();
void timerAsyncify();
void postEventAsyncifyLoop();
-#endif
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) && defined(QT_HAVE_EMSCRIPTEN_ASYNCIFY)
+#if QT_CONFIG(thread)
void threadAsyncifyWait();
#endif
};
@@ -235,11 +239,14 @@ void WasmEventDispatcherTest::timerSecondaryThread()
#endif
-#ifdef QT_HAVE_EMSCRIPTEN_ASYNCIFY
-
// Post an event to the main thread and asyncify wait for it
void WasmEventDispatcherTest::postEventAsyncify()
{
+ if (!have_asyncify()) {
+ QtWasmTest::completeTestFunction(QtWasmTest::TestResult::Skip, "requires asyncify");
+ return;
+ }
+
QEventLoop loop;
QCoreApplication::postEvent(EventTarget::create([&loop](){
loop.quit();
@@ -252,6 +259,11 @@ void WasmEventDispatcherTest::postEventAsyncify()
// Create a timer on the main thread and asyncify wait for it
void WasmEventDispatcherTest::timerAsyncify()
{
+ if (!have_asyncify()) {
+ QtWasmTest::completeTestFunction(QtWasmTest::TestResult::Skip, "requires asyncify");
+ return;
+ }
+
QEventLoop loop;
QTimer::singleShot(timerTimeout, [&loop](){
loop.quit();
@@ -264,6 +276,11 @@ void WasmEventDispatcherTest::timerAsyncify()
// Asyncify wait in a loop
void WasmEventDispatcherTest::postEventAsyncifyLoop()
{
+ if (!have_asyncify()) {
+ QtWasmTest::completeTestFunction(QtWasmTest::TestResult::Skip, "requires asyncify");
+ return;
+ }
+
for (int i = 0; i < 10; ++i) {
QEventLoop loop;
QCoreApplication::postEvent(EventTarget::create([&loop]() {
@@ -279,6 +296,9 @@ void WasmEventDispatcherTest::postEventAsyncifyLoop()
// Asyncify wait for QThread::wait() / pthread_join()
void WasmEventDispatcherTest::threadAsyncifyWait()
{
+ if (!have_asyncify())
+ QtWasmTest::completeTestFunction(QtWasmTest::TestResult::Skip, "requires asyncify");
+
const int threadCount = 15;
QVector<QThread *> threads;
@@ -300,8 +320,6 @@ void WasmEventDispatcherTest::threadAsyncifyWait()
}
#endif
-#endif // QT_HAVE_EMSCRIPTEN_ASYNCIFY
-
int main(int argc, char **argv)
{
auto testObject = std::make_shared<WasmEventDispatcherTest>();