diff options
author | Johan Klokkhammer Helsing <johan.helsing@qt.io> | 2018-06-05 16:16:13 +0200 |
---|---|---|
committer | Johan Helsing <johan.helsing@qt.io> | 2018-06-07 07:57:16 +0000 |
commit | aaedbabcc9096e458b2bef6c2b03586939de6871 (patch) | |
tree | 51b090a1e03f6d650ce525c941533594ee803830 /tests | |
parent | 6b65b9da479974b88dc00dfe8ebb67f94eca9e35 (diff) | |
download | qtwayland-aaedbabcc9096e458b2bef6c2b03586939de6871.tar.gz |
Client: Add tests for xdg-shell v6 window geometry
Change-Id: Ifb7a1d63a136349cd99d516e63732b4393967468
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/client/shared/mockcompositor.h | 1 | ||||
-rw-r--r-- | tests/auto/client/shared/mockxdgshellv6.cpp | 8 | ||||
-rw-r--r-- | tests/auto/client/shared/mockxdgshellv6.h | 1 | ||||
-rw-r--r-- | tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp | 43 |
4 files changed, 53 insertions, 0 deletions
diff --git a/tests/auto/client/shared/mockcompositor.h b/tests/auto/client/shared/mockcompositor.h index d3568c16..51b6f4bf 100644 --- a/tests/auto/client/shared/mockcompositor.h +++ b/tests/auto/client/shared/mockcompositor.h @@ -189,6 +189,7 @@ signals: uint unsetMaximizedRequested(); uint setFullscreenRequested(); uint unsetFullscreenRequested(); + void windowGeometryRequested(QRect geometry); // NOTE: This is really an xdg surface event private: MockXdgToplevelV6(Impl::XdgToplevelV6 *toplevel) : m_toplevel(toplevel) {} diff --git a/tests/auto/client/shared/mockxdgshellv6.cpp b/tests/auto/client/shared/mockxdgshellv6.cpp index 6f6f0b90..014a24be 100644 --- a/tests/auto/client/shared/mockxdgshellv6.cpp +++ b/tests/auto/client/shared/mockxdgshellv6.cpp @@ -57,6 +57,14 @@ void XdgSurfaceV6::zxdg_surface_v6_get_toplevel(QtWaylandServer::zxdg_surface_v6 m_toplevel = new XdgToplevelV6(this, resource->client(), id, version); } +void XdgSurfaceV6::zxdg_surface_v6_set_window_geometry(QtWaylandServer::zxdg_surface_v6::Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) +{ + if (m_toplevel) { + QRect geometry(x, y, width, height); + emit m_toplevel->mockToplevel()->windowGeometryRequested(geometry); + } +} + void XdgSurfaceV6::zxdg_surface_v6_destroy(QtWaylandServer::zxdg_surface_v6::Resource *resource) { Q_ASSERT(!m_toplevel); diff --git a/tests/auto/client/shared/mockxdgshellv6.h b/tests/auto/client/shared/mockxdgshellv6.h index faadb785..bd5e1306 100644 --- a/tests/auto/client/shared/mockxdgshellv6.h +++ b/tests/auto/client/shared/mockxdgshellv6.h @@ -52,6 +52,7 @@ public: protected: void zxdg_surface_v6_destroy_resource(Resource *) override { delete this; } void zxdg_surface_v6_get_toplevel(Resource *resource, uint32_t id) override; + void zxdg_surface_v6_set_window_geometry(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; void zxdg_surface_v6_destroy(Resource *resource) override; private: diff --git a/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp b/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp index 070a9a34..91679cb5 100644 --- a/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp +++ b/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp @@ -99,6 +99,8 @@ private slots: void unsetMaximized(); void focusWindowFollowsConfigure(); void windowStateChangedEvents(); + void windowGeometrySimple(); + void windowGeometryFixed(); private: MockCompositor *m_compositor = nullptr; @@ -317,6 +319,47 @@ void tst_WaylandClientXdgShellV6::windowStateChangedEvents() } } +void tst_WaylandClientXdgShellV6::windowGeometrySimple() +{ + QWindow window; + window.show(); + + QSharedPointer<MockXdgToplevelV6> toplevel; + QTRY_VERIFY(toplevel = m_compositor->xdgToplevelV6()); + QSignalSpy geometrySpy(toplevel.data(), SIGNAL(windowGeometryRequested(QRect))); + + m_compositor->sendXdgToplevelV6Configure(toplevel); + QTRY_COMPARE(geometrySpy.count(), 1); + QCOMPARE(geometrySpy.takeFirst().at(0).toRect().size(), window.frameGeometry().size()); + + m_compositor->sendXdgToplevelV6Configure(toplevel, QSize(123, 456)); + QTRY_COMPARE(geometrySpy.count(), 1); + QCOMPARE(geometrySpy.takeFirst().at(0).toRect().size(), QSize(123, 456)); +} + +void tst_WaylandClientXdgShellV6::windowGeometryFixed() +{ + QWindow window; + window.resize(QSize(1337, 137)); + window.setMaximumSize(window.size()); + window.setMinimumSize(window.size()); + window.show(); + + QSharedPointer<MockXdgToplevelV6> toplevel; + QTRY_VERIFY(toplevel = m_compositor->xdgToplevelV6()); + QSignalSpy geometrySpy(toplevel.data(), SIGNAL(windowGeometryRequested(QRect))); + + m_compositor->sendXdgToplevelV6Configure(toplevel); + QTRY_COMPARE(geometrySpy.count(), 1); + QRect initialWindowGeometry = geometrySpy.takeFirst().at(0).toRect(); + QCOMPARE(initialWindowGeometry.size(), window.frameGeometry().size()); + + m_compositor->sendXdgToplevelV6Configure(toplevel, QSize(123, 456)); + QTRY_COMPARE(geometrySpy.count(), 1); + // Configuring the window should not change the window geometry + QCOMPARE(geometrySpy.takeFirst().at(0).toRect().size(), initialWindowGeometry.size()); +} + int main(int argc, char **argv) { setenv("XDG_RUNTIME_DIR", ".", 1); |