Polish the qwasmwindow manual test

Change-Id: I9d21404bcf6da7650ec63ef41d5134bb89485a84
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Mikolaj Boc 2023-02-15 12:00:10 +01:00
parent 7941d3ab3e
commit a85b658469
3 changed files with 21 additions and 26 deletions

View File

@ -2,7 +2,8 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <QtCore/QEvent> #include <QtCore/QEvent>
#include <QtCore/QObject> #include <QtCore/qobject.h>
#include <QtCore/qregularexpression.h>
#include <QtGui/qscreen.h> #include <QtGui/qscreen.h>
#include <QtGui/qwindow.h> #include <QtGui/qwindow.h>
#include <QtGui/qguiapplication.h> #include <QtGui/qguiapplication.h>
@ -15,14 +16,9 @@
#include <sstream> #include <sstream>
#include <vector> #include <vector>
namespace qwasmwindow_harness { class DeleteOnCloseWindow : public QWindow
namespace {
class Window : public QWindow
{ {
Q_OBJECT Q_OBJECT
public:
Window() = default;
~Window() = default;
private: private:
void closeEvent(QCloseEvent *ev) override void closeEvent(QCloseEvent *ev) override
@ -31,8 +27,6 @@ private:
delete this; delete this;
} }
}; };
} // namespace
} // namespace qwasmwindow_harness
using namespace emscripten; using namespace emscripten;
@ -52,6 +46,11 @@ std::string toJSArray(const std::vector<std::string> &elements)
std::string toJSString(const QString &qstring) 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() + "'"; return "'" + qstring.toStdString() + "'";
} }
@ -121,7 +120,7 @@ void createWindow(int x, int y, int w, int h, std::string screenId, std::string
return; return;
} }
auto *window = new qwasmwindow_harness::Window; auto *window = new DeleteOnCloseWindow;
window->setFlag(Qt::WindowTitleHint); window->setFlag(Qt::WindowTitleHint);
window->setFlag(Qt::WindowMaximizeButtonHint); window->setFlag(Qt::WindowMaximizeButtonHint);
@ -142,9 +141,7 @@ int main(int argc, char **argv)
{ {
QGuiApplication app(argc, argv); QGuiApplication app(argc, argv);
qDebug() << "exec";
app.exec(); app.exec();
qDebug() << "returning";
return 0; return 0;
} }

View File

@ -42,7 +42,8 @@
return screenDiv; return screenDiv;
}, },
initializeScreenInScrollContainer: (scrollWidth, scrollHeight, left, top, width, height) => { initializeScreenInScrollContainer:
(scrollWidth, scrollHeight, left, top, width, height) => {
const scrollContainer = document.createElement('div'); const scrollContainer = document.createElement('div');
scrollContainer.style.height = `${scrollHeight}px`; scrollContainer.style.height = `${scrollHeight}px`;
scrollContainer.style.width = `${scrollWidth}px`; scrollContainer.style.width = `${scrollWidth}px`;

View File

@ -21,6 +21,3 @@ python3 qwasmwindow.py $@
echo 'Press any key to continue...' >&2 echo 'Press any key to continue...' >&2
read -n 1 read -n 1