From eef9f34e58465458420f6e1295bdce4a59702c54 Mon Sep 17 00:00:00 2001 From: Pier Luigi Fiorini Date: Sun, 13 Jan 2019 23:28:06 +0100 Subject: Client: Test for xdg surface window geometry Change-Id: I2f336a81682317b1f7dc939d911906b4db60a386 Reviewed-by: Johan Helsing --- tests/auto/client/shared/xdgshell.cpp | 10 ++++++++++ tests/auto/client/shared/xdgshell.h | 4 ++++ tests/auto/client/xdgshell/tst_xdgshell.cpp | 16 ++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/tests/auto/client/shared/xdgshell.cpp b/tests/auto/client/shared/xdgshell.cpp index 4cabd3d87..6bc303020 100644 --- a/tests/auto/client/shared/xdgshell.cpp +++ b/tests/auto/client/shared/xdgshell.cpp @@ -86,6 +86,8 @@ XdgSurface::XdgSurface(XdgWmBase *xdgWmBase, Surface *surface, wl_client *client connect(this, &XdgSurface::toplevelCreated, xdgWmBase, &XdgWmBase::toplevelCreated); connect(surface, &Surface::attach, this, &XdgSurface::verifyConfigured); connect(surface, &Surface::commit, this, [this] { + m_committed = m_pending; + if (m_ackedConfigureSerial != m_committedConfigureSerial) { m_committedConfigureSerial = m_ackedConfigureSerial; emit configureCommitted(m_committedConfigureSerial); @@ -133,6 +135,14 @@ void XdgSurface::xdg_surface_destroy_resource(Resource *resource) delete this; } +void XdgSurface::xdg_surface_set_window_geometry(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) +{ + Q_UNUSED(resource); + QRect rect(x, y, width, height); + QVERIFY(rect.isValid()); + m_pending.windowGeometry = rect; +} + void XdgSurface::xdg_surface_ack_configure(Resource *resource, uint32_t serial) { Q_UNUSED(resource); diff --git a/tests/auto/client/shared/xdgshell.h b/tests/auto/client/shared/xdgshell.h index 037de20d1..1a01ea1ea 100644 --- a/tests/auto/client/shared/xdgshell.h +++ b/tests/auto/client/shared/xdgshell.h @@ -83,6 +83,9 @@ public: QVector m_pendingConfigureSerials; uint m_ackedConfigureSerial = 0; uint m_committedConfigureSerial = 0; + struct DoubleBufferedState { + QRect windowGeometry = {0, 0, 0, 0}; + } m_pending, m_committed; public slots: void verifyConfigured() { QVERIFY(m_configureSent); } @@ -96,6 +99,7 @@ protected: void xdg_surface_get_popup(Resource *resource, uint32_t id, ::wl_resource *parent, ::wl_resource *positioner) override; void xdg_surface_destroy_resource(Resource *resource) override; void xdg_surface_destroy(Resource *resource) override { wl_resource_destroy(resource->handle); } + void xdg_surface_set_window_geometry(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override; void xdg_surface_ack_configure(Resource *resource, uint32_t serial) override; }; diff --git a/tests/auto/client/xdgshell/tst_xdgshell.cpp b/tests/auto/client/xdgshell/tst_xdgshell.cpp index 1bfabe55f..de0341014 100644 --- a/tests/auto/client/xdgshell/tst_xdgshell.cpp +++ b/tests/auto/client/xdgshell/tst_xdgshell.cpp @@ -44,6 +44,7 @@ private slots: void popup(); void pongs(); void minMaxSize(); + void windowGeometry(); }; void tst_xdgshell::showMinimized() @@ -287,5 +288,20 @@ void tst_xdgshell::minMaxSize() QCOMPOSITOR_TRY_COMPARE(xdgToplevel()->m_committed.minSize, QSize(50, 40)); } +void tst_xdgshell::windowGeometry() +{ + QRasterWindow window; + window.resize(400, 320); + window.show(); + QCOMPOSITOR_TRY_VERIFY(xdgToplevel()); + + exec([=] { xdgToplevel()->sendCompleteConfigure(); }); + + QCOMPOSITOR_TRY_COMPARE(xdgSurface()->m_committed.windowGeometry, QRect(QPoint(0, 0), window.frameGeometry().size())); + + window.resize(800, 600); + QCOMPOSITOR_TRY_COMPARE(xdgSurface()->m_committed.windowGeometry, QRect(QPoint(0, 0), window.frameGeometry().size())); +} + QCOMPOSITOR_TEST_MAIN(tst_xdgshell) #include "tst_xdgshell.moc" -- cgit v1.2.3