From a85b658469186075b6a883504877673dcc651f45 Mon Sep 17 00:00:00 2001 From: Mikolaj Boc Date: Wed, 15 Feb 2023 12:00:10 +0100 Subject: [PATCH] Polish the qwasmwindow manual test Change-Id: I9d21404bcf6da7650ec63ef41d5134bb89485a84 Reviewed-by: Edward Welbourne --- .../wasm/qwasmwindow/qwasmwindow_harness.cpp | 21 ++++++++--------- .../wasm/qwasmwindow/qwasmwindow_harness.html | 23 ++++++++++--------- tests/manual/wasm/qwasmwindow/run.sh | 3 --- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/tests/manual/wasm/qwasmwindow/qwasmwindow_harness.cpp b/tests/manual/wasm/qwasmwindow/qwasmwindow_harness.cpp index 678d60b936a..bcbcacbd151 100644 --- a/tests/manual/wasm/qwasmwindow/qwasmwindow_harness.cpp +++ b/tests/manual/wasm/qwasmwindow/qwasmwindow_harness.cpp @@ -2,7 +2,8 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include -#include +#include +#include #include #include #include @@ -15,14 +16,9 @@ #include #include -namespace qwasmwindow_harness { -namespace { -class Window : public QWindow +class DeleteOnCloseWindow : public QWindow { Q_OBJECT -public: - Window() = default; - ~Window() = default; private: void closeEvent(QCloseEvent *ev) override @@ -31,8 +27,6 @@ private: delete this; } }; -} // namespace -} // namespace qwasmwindow_harness using namespace emscripten; @@ -52,6 +46,11 @@ std::string toJSArray(const std::vector &elements) std::string toJSString(const QString &qstring) { + Q_ASSERT_X(([qstring]() { + static QRegularExpression unescapedQuoteRegex(R"re((?:^|[^\\])')re"); + return qstring.indexOf(unescapedQuoteRegex) == -1; + })(), + Q_FUNC_INFO, "Unescaped single quotes found"); return "'" + qstring.toStdString() + "'"; } @@ -121,7 +120,7 @@ void createWindow(int x, int y, int w, int h, std::string screenId, std::string return; } - auto *window = new qwasmwindow_harness::Window; + auto *window = new DeleteOnCloseWindow; window->setFlag(Qt::WindowTitleHint); window->setFlag(Qt::WindowMaximizeButtonHint); @@ -142,9 +141,7 @@ int main(int argc, char **argv) { QGuiApplication app(argc, argv); - qDebug() << "exec"; app.exec(); - qDebug() << "returning"; return 0; } diff --git a/tests/manual/wasm/qwasmwindow/qwasmwindow_harness.html b/tests/manual/wasm/qwasmwindow/qwasmwindow_harness.html index f8be66809c1..9eb82618b9c 100644 --- a/tests/manual/wasm/qwasmwindow/qwasmwindow_harness.html +++ b/tests/manual/wasm/qwasmwindow/qwasmwindow_harness.html @@ -42,20 +42,21 @@ return screenDiv; }, - initializeScreenInScrollContainer: (scrollWidth, scrollHeight, left, top, width, height) => { - const scrollContainer = document.createElement('div'); - scrollContainer.style.height = `${scrollHeight}px`; - scrollContainer.style.width = `${scrollWidth}px`; - testSandbox.appendChild(scrollContainer); + initializeScreenInScrollContainer: + (scrollWidth, scrollHeight, left, top, width, height) => { + const scrollContainer = document.createElement('div'); + scrollContainer.style.height = `${scrollHeight}px`; + scrollContainer.style.width = `${scrollWidth}px`; + testSandbox.appendChild(scrollContainer); - const screenDiv = makeSizedDiv(left, top, width, height); - scrollContainer.appendChild(screenDiv); - screenDiv.style.position = 'relative'; + const screenDiv = makeSizedDiv(left, top, width, height); + scrollContainer.appendChild(screenDiv); + screenDiv.style.position = 'relative'; - instance.qtAddContainerElement(screenDiv); + instance.qtAddContainerElement(screenDiv); - return [scrollContainer, screenDiv]; - } + return [scrollContainer, screenDiv]; + } }; })(); diff --git a/tests/manual/wasm/qwasmwindow/run.sh b/tests/manual/wasm/qwasmwindow/run.sh index 38b85e6c309..f6271d6131a 100755 --- a/tests/manual/wasm/qwasmwindow/run.sh +++ b/tests/manual/wasm/qwasmwindow/run.sh @@ -21,6 +21,3 @@ python3 qwasmwindow.py $@ echo 'Press any key to continue...' >&2 read -n 1 - - -