summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikolaj Boc <[email protected]>2023-02-15 12:00:10 +0100
committerMikolaj Boc <[email protected]>2023-02-22 13:47:14 +0100
commita85b658469186075b6a883504877673dcc651f45 (patch)
treef9fd6aee37fa4923130dbd805725ea9ce52efdb9
parent7941d3ab3e812181830d4bd9128c959b6f8d70fc (diff)
Polish the qwasmwindow manual test
Change-Id: I9d21404bcf6da7650ec63ef41d5134bb89485a84 Reviewed-by: Edward Welbourne <[email protected]>
-rw-r--r--tests/manual/wasm/qwasmwindow/qwasmwindow_harness.cpp21
-rw-r--r--tests/manual/wasm/qwasmwindow/qwasmwindow_harness.html23
-rwxr-xr-xtests/manual/wasm/qwasmwindow/run.sh3
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 <QtCore/QEvent>
-#include <QtCore/QObject>
+#include <QtCore/qobject.h>
+#include <QtCore/qregularexpression.h>
#include <QtGui/qscreen.h>
#include <QtGui/qwindow.h>
#include <QtGui/qguiapplication.h>
@@ -15,14 +16,9 @@
#include <sstream>
#include <vector>
-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<std::string> &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];
+ }
};
})();
</script>
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
-
-
-