From b1b61636b374c544ab6d09a876af73cb8beb6b4a Mon Sep 17 00:00:00 2001 From: Mikolaj Boc Date: Fri, 16 Sep 2022 16:09:53 +0200 Subject: Introduce centralized means of checking for asyncify MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new function has an advantage of not requring EM_JS. Change-Id: Ib9ad0e6b59cfe2e6864697a14b5cfdb39f62af2d Reviewed-by: David Skoland Reviewed-by: Morten Johan Sørvig --- tests/manual/wasm/eventloop/eventloop_auto/CMakeLists.txt | 2 ++ tests/manual/wasm/eventloop/eventloop_auto/main.cpp | 13 +++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'tests/manual/wasm') diff --git a/tests/manual/wasm/eventloop/eventloop_auto/CMakeLists.txt b/tests/manual/wasm/eventloop/eventloop_auto/CMakeLists.txt index f8669c2030..9bfa875be7 100644 --- a/tests/manual/wasm/eventloop/eventloop_auto/CMakeLists.txt +++ b/tests/manual/wasm/eventloop/eventloop_auto/CMakeLists.txt @@ -7,6 +7,7 @@ qt_internal_add_manual_test(eventloop_auto ../../qtwasmtestlib/qtwasmtestlib.cpp LIBRARIES Qt::Core + Qt::CorePrivate ) add_custom_command( @@ -28,6 +29,7 @@ qt_internal_add_manual_test(eventloop_auto_asyncify ../../qtwasmtestlib/qtwasmtestlib.cpp LIBRARIES Qt::Core + Qt::CorePrivate ) target_link_options(eventloop_auto_asyncify PRIVATE -sASYNCIFY -Os) diff --git a/tests/manual/wasm/eventloop/eventloop_auto/main.cpp b/tests/manual/wasm/eventloop/eventloop_auto/main.cpp index b6de2310ad..b2ff6779fd 100644 --- a/tests/manual/wasm/eventloop/eventloop_auto/main.cpp +++ b/tests/manual/wasm/eventloop/eventloop_auto/main.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include @@ -14,10 +15,6 @@ const int timerTimeout = 10; -EM_JS(bool, have_asyncify, (), { - return typeof Asyncify != "undefined"; -}); - class WasmEventDispatcherTest: public QObject { Q_OBJECT @@ -242,7 +239,7 @@ void WasmEventDispatcherTest::timerSecondaryThread() // Post an event to the main thread and asyncify wait for it void WasmEventDispatcherTest::postEventAsyncify() { - if (!have_asyncify()) { + if (!qstdweb::haveAsyncify()) { QtWasmTest::completeTestFunction(QtWasmTest::TestResult::Skip, "requires asyncify"); return; } @@ -259,7 +256,7 @@ void WasmEventDispatcherTest::postEventAsyncify() // Create a timer on the main thread and asyncify wait for it void WasmEventDispatcherTest::timerAsyncify() { - if (!have_asyncify()) { + if (!qstdweb::haveAsyncify()) { QtWasmTest::completeTestFunction(QtWasmTest::TestResult::Skip, "requires asyncify"); return; } @@ -276,7 +273,7 @@ void WasmEventDispatcherTest::timerAsyncify() // Asyncify wait in a loop void WasmEventDispatcherTest::postEventAsyncifyLoop() { - if (!have_asyncify()) { + if (!qstdweb::haveAsyncify()) { QtWasmTest::completeTestFunction(QtWasmTest::TestResult::Skip, "requires asyncify"); return; } @@ -296,7 +293,7 @@ void WasmEventDispatcherTest::postEventAsyncifyLoop() // Asyncify wait for QThread::wait() / pthread_join() void WasmEventDispatcherTest::threadAsyncifyWait() { - if (!have_asyncify()) + if (!qstdweb::haveAsyncify()) QtWasmTest::completeTestFunction(QtWasmTest::TestResult::Skip, "requires asyncify"); const int threadCount = 15; -- cgit v1.2.3