summaryrefslogtreecommitdiffstats
path: root/tests/auto/wasm/qwasmwindowtreenode/tst_qwasmwindowtreenode.cpp
diff options
context:
space:
mode:
authorEven Oscar Andersen <even.oscar.andersen@qt.io>2025-05-23 12:37:25 +0200
committerEven Oscar Andersen <even.oscar.andersen@qt.io>2025-05-26 13:27:17 +0200
commite48c19449e3856661f4fe2ccd30d94ba9d61301f (patch)
tree91ca8efd1b4072dcdfc55c83eca67095a7b50de5 /tests/auto/wasm/qwasmwindowtreenode/tst_qwasmwindowtreenode.cpp
parent3ad9d5777fe0771d14e89bb5601d602f2451bd49 (diff)
wasm: Fix stacking order problem for transient parent windows
Windows with a transient parent does not reflect the relationship in the stacking order. Essentially AboveTransientParent is missing as a configuration choice. What makes this slightly convoluted is that the window stack does not depend on the window (for testability). We solve this problem by making the stack and treenode templates, and provide test class as arguments when testing. QWasmWindow and QWasmScreen are not templated as before. There is also a new order type StayAboveTransientParent. Which means that we can no longer use order type to get to the group location (Since StayAboveTransientParent can map to either of the three types). The window stack tests have been updated to handle the StayAboveTransientParent type. Finally, we do not do anything with a normal parent child relationship as this should already work correctly. Fixes: QTBUG-131699 Change-Id: Ie08e18f9e0a2339175c4a09da0a831f031df71e1 Reviewed-by: Lorn Potter <lorn.potter@qt.io>
Diffstat (limited to 'tests/auto/wasm/qwasmwindowtreenode/tst_qwasmwindowtreenode.cpp')
-rw-r--r--tests/auto/wasm/qwasmwindowtreenode/tst_qwasmwindowtreenode.cpp43
1 files changed, 30 insertions, 13 deletions
diff --git a/tests/auto/wasm/qwasmwindowtreenode/tst_qwasmwindowtreenode.cpp b/tests/auto/wasm/qwasmwindowtreenode/tst_qwasmwindowtreenode.cpp
index 763dbf9a073..62d8114befb 100644
--- a/tests/auto/wasm/qwasmwindowtreenode/tst_qwasmwindowtreenode.cpp
+++ b/tests/auto/wasm/qwasmwindowtreenode/tst_qwasmwindowtreenode.cpp
@@ -6,28 +6,33 @@
#include <QTest>
#include <emscripten/val.h>
-class QWasmWindow
+class TestQWindow
{
+public:
+ int flags() { return 0; }
+ QVariant property(const char *) { return QVariant(); }
};
+class TestWindowTreeNode;
+
using OnSubtreeChangedCallback = std::function<void(
- QWasmWindowTreeNodeChangeType changeType, QWasmWindowTreeNode *parent, QWasmWindow *child)>;
-using SetWindowZOrderCallback = std::function<void(QWasmWindow *window, int z)>;
+ QWasmWindowTreeNodeChangeType changeType, QWasmWindowTreeNode<TestWindowTreeNode> *parent, TestWindowTreeNode *child)>;
+using SetWindowZOrderCallback = std::function<void(TestWindowTreeNode *window, int z)>;
struct OnSubtreeChangedCallData
{
QWasmWindowTreeNodeChangeType changeType;
- QWasmWindowTreeNode *parent;
- QWasmWindow *child;
+ QWasmWindowTreeNode<TestWindowTreeNode> *parent;
+ TestWindowTreeNode *child;
};
struct SetWindowZOrderCallData
{
- QWasmWindow *window;
+ TestWindowTreeNode *window;
int z;
};
-class TestWindowTreeNode final : public QWasmWindowTreeNode, public QWasmWindow
+class TestWindowTreeNode final : public QWasmWindowTreeNode<TestWindowTreeNode>
{
public:
TestWindowTreeNode(OnSubtreeChangedCallback onSubtreeChangedCallback,
@@ -42,7 +47,7 @@ public:
{
auto *previous = m_parent;
m_parent = parent;
- onParentChanged(previous, parent, QWasmWindowStack::PositionPreference::Regular);
+ onParentChanged(previous, parent, QWasmWindowStack<TestWindowTreeNode>::PositionPreference::Regular);
}
void setContainerElement(emscripten::val container) { m_containerElement = container; }
@@ -51,30 +56,42 @@ public:
void sendToBottom() { QWasmWindowTreeNode::sendToBottom(); }
- const QWasmWindowStack &childStack() { return QWasmWindowTreeNode::childStack(); }
+ const QWasmWindowStack<TestWindowTreeNode> &childStack() { return QWasmWindowTreeNode::childStack(); }
emscripten::val containerElement() final { return m_containerElement; }
QWasmWindowTreeNode *parentNode() final { return m_parent; }
- QWasmWindow *asWasmWindow() final { return this; }
+ TestWindowTreeNode *asWasmWindow() final { return this; }
+ TestWindowTreeNode *transientParent() const {
+ return nullptr;
+ }
+ TestQWindow *window() { return &m_qWindow; }
+ void requestActivateWindow() { ; }
+ void setZOrder(int) { ; }
+ bool isModal() const { return false; }
+ Qt::WindowFlags windowFlags() const { return Qt::WindowFlags(); }
protected:
- void onSubtreeChanged(QWasmWindowTreeNodeChangeType changeType, QWasmWindowTreeNode *parent,
- QWasmWindow *child) final
+ void onSubtreeChanged(QWasmWindowTreeNodeChangeType changeType, QWasmWindowTreeNode<TestWindowTreeNode> *parent,
+ TestWindowTreeNode *child) final
{
m_onSubtreeChangedCallback(changeType, parent, child);
}
- void setWindowZOrder(QWasmWindow *window, int z) final { m_setWindowZOrderCallback(window, z); }
+ void setWindowZOrder(TestWindowTreeNode *window, int z) final { m_setWindowZOrderCallback(window, z); }
TestWindowTreeNode *m_parent = nullptr;
emscripten::val m_containerElement = emscripten::val::undefined();
OnSubtreeChangedCallback m_onSubtreeChangedCallback;
SetWindowZOrderCallback m_setWindowZOrderCallback;
+ TestQWindow m_qWindow;
};
+#define QWasmWindowTreeNode QWasmWindowTreeNode<TestWindowTreeNode>
+#define QWasmWindow TestWindowTreeNode
+
class tst_QWasmWindowTreeNode : public QObject
{
Q_OBJECT