diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/client/fullscreenshellv1/tst_fullscreenshellv1.cpp | 3 | ||||
-rw-r--r-- | tests/auto/client/iviapplication/tst_iviapplication.cpp | 3 | ||||
-rw-r--r-- | tests/auto/client/shared/corecompositor.cpp | 1 | ||||
-rw-r--r-- | tests/auto/client/shared/coreprotocol.h | 25 | ||||
-rw-r--r-- | tests/auto/client/shared/mockcompositor.cpp | 11 | ||||
-rw-r--r-- | tests/auto/client/shared/mockcompositor.h | 1 | ||||
-rw-r--r-- | tests/auto/client/shared/xdgshell.cpp | 2 | ||||
-rw-r--r-- | tests/auto/client/shared_old/mockcompositor.cpp | 2 | ||||
-rw-r--r-- | tests/auto/client/surface/tst_surface.cpp | 41 | ||||
-rw-r--r-- | tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp | 3 |
10 files changed, 79 insertions, 13 deletions
diff --git a/tests/auto/client/fullscreenshellv1/tst_fullscreenshellv1.cpp b/tests/auto/client/fullscreenshellv1/tst_fullscreenshellv1.cpp index f93d9fbc5..55158474c 100644 --- a/tests/auto/client/fullscreenshellv1/tst_fullscreenshellv1.cpp +++ b/tests/auto/client/fullscreenshellv1/tst_fullscreenshellv1.cpp @@ -93,7 +93,8 @@ void tst_WaylandClientFullScreenShellV1::createDestroyWindow() int main(int argc, char **argv) { - setenv("XDG_RUNTIME_DIR", ".", 1); + QTemporaryDir tmpRuntimeDir; + setenv("XDG_RUNTIME_DIR", tmpRuntimeDir.path().toLocal8Bit(), 1); setenv("QT_QPA_PLATFORM", "wayland", 1); // force QGuiApplication to use wayland plugin setenv("QT_WAYLAND_SHELL_INTEGRATION", "fullscreen-shell-v1", 1); setenv("QT_WAYLAND_DISABLE_WINDOWDECORATION", "1", 1); // window decorations don't make much sense here diff --git a/tests/auto/client/iviapplication/tst_iviapplication.cpp b/tests/auto/client/iviapplication/tst_iviapplication.cpp index 59ff6f555..8d6ea6484 100644 --- a/tests/auto/client/iviapplication/tst_iviapplication.cpp +++ b/tests/auto/client/iviapplication/tst_iviapplication.cpp @@ -124,7 +124,8 @@ void tst_WaylandClientIviApplication::uniqueIviIds() int main(int argc, char **argv) { - setenv("XDG_RUNTIME_DIR", ".", 1); + QTemporaryDir tmpRuntimeDir; + setenv("XDG_RUNTIME_DIR", tmpRuntimeDir.path().toLocal8Bit(), 1); setenv("QT_QPA_PLATFORM", "wayland", 1); // force QGuiApplication to use wayland plugin setenv("QT_WAYLAND_SHELL_INTEGRATION", "ivi-shell", 1); setenv("QT_WAYLAND_DISABLE_WINDOWDECORATION", "1", 1); // window decorations don't make much sense on ivi-application diff --git a/tests/auto/client/shared/corecompositor.cpp b/tests/auto/client/shared/corecompositor.cpp index 7edb1c2d4..5c6c83baa 100644 --- a/tests/auto/client/shared/corecompositor.cpp +++ b/tests/auto/client/shared/corecompositor.cpp @@ -43,6 +43,7 @@ CoreCompositor::CoreCompositor() } }) { + qputenv("WAYLAND_DISPLAY", m_socketName); m_timer.start(); Q_ASSERT(isClean()); } diff --git a/tests/auto/client/shared/coreprotocol.h b/tests/auto/client/shared/coreprotocol.h index 5cef476c8..f92842e02 100644 --- a/tests/auto/client/shared/coreprotocol.h +++ b/tests/auto/client/shared/coreprotocol.h @@ -163,6 +163,16 @@ protected: } }; +class Subsurface : public QObject, public QtWaylandServer::wl_subsurface +{ + Q_OBJECT +public: + explicit Subsurface(wl_client *client, int id, int version) + : QtWaylandServer::wl_subsurface(client, id, version) + { + } +}; + class SubCompositor : public Global, public QtWaylandServer::wl_subcompositor { Q_OBJECT @@ -170,7 +180,20 @@ public: explicit SubCompositor(CoreCompositor *compositor, int version = 1) : QtWaylandServer::wl_subcompositor(compositor->m_display, version) {} - // TODO + QVector<Subsurface *> m_subsurfaces; + +signals: + void subsurfaceCreated(Subsurface *subsurface); + +protected: + void subcompositor_get_subsurface(Resource *resource, uint32_t id, ::wl_resource *surface, ::wl_resource *parent) override + { + QTRY_VERIFY(parent); + QTRY_VERIFY(surface); + auto *subsurface = new Subsurface(resource->client(), id, resource->version()); + m_subsurfaces.append(subsurface); // TODO: clean up? + emit subsurfaceCreated(subsurface); + } }; struct OutputMode { diff --git a/tests/auto/client/shared/mockcompositor.cpp b/tests/auto/client/shared/mockcompositor.cpp index 6b9af4295..0711c5d8e 100644 --- a/tests/auto/client/shared/mockcompositor.cpp +++ b/tests/auto/client/shared/mockcompositor.cpp @@ -58,13 +58,10 @@ DefaultCompositor::DefaultCompositor() }); }); - QObject::connect(get<XdgWmBase>(), &XdgWmBase::toplevelCreated, [&] (XdgToplevel *toplevel) { - // Needed because lambdas don't support Qt::DirectConnection - exec([&]{ - if (m_config.autoConfigure) - toplevel->sendCompleteConfigure(); - }); - }); + QObject::connect(get<XdgWmBase>(), &XdgWmBase::toplevelCreated, get<XdgWmBase>(), [&] (XdgToplevel *toplevel) { + if (m_config.autoConfigure) + toplevel->sendCompleteConfigure(); + }, Qt::DirectConnection); } Q_ASSERT(isClean()); } diff --git a/tests/auto/client/shared/mockcompositor.h b/tests/auto/client/shared/mockcompositor.h index f5264ccf6..f17c93426 100644 --- a/tests/auto/client/shared/mockcompositor.h +++ b/tests/auto/client/shared/mockcompositor.h @@ -50,6 +50,7 @@ public: // Convenience functions Output *output(int i = 0) { return getAll<Output>().value(i, nullptr); } Surface *surface(int i = 0) { return get<WlCompositor>()->m_surfaces.value(i, nullptr); } + Subsurface *subSurface(int i = 0) { return get<SubCompositor>()->m_subsurfaces.value(i, nullptr); } XdgSurface *xdgSurface(int i = 0) { return get<XdgWmBase>()->m_xdgSurfaces.value(i, nullptr); } XdgToplevel *xdgToplevel(int i = 0) { return get<XdgWmBase>()->toplevel(i); } XdgPopup *xdgPopup(int i = 0) { return get<XdgWmBase>()->popup(i); } diff --git a/tests/auto/client/shared/xdgshell.cpp b/tests/auto/client/shared/xdgshell.cpp index 13acc01e2..72582f48d 100644 --- a/tests/auto/client/shared/xdgshell.cpp +++ b/tests/auto/client/shared/xdgshell.cpp @@ -83,7 +83,7 @@ XdgSurface::XdgSurface(XdgWmBase *xdgWmBase, Surface *surface, wl_client *client { QVERIFY(!surface->m_pending.buffer); QVERIFY(!surface->m_committed.buffer); - connect(this, &XdgSurface::toplevelCreated, xdgWmBase, &XdgWmBase::toplevelCreated); + connect(this, &XdgSurface::toplevelCreated, xdgWmBase, &XdgWmBase::toplevelCreated, Qt::DirectConnection); connect(surface, &Surface::attach, this, &XdgSurface::verifyConfigured); connect(surface, &Surface::commit, this, [this] { m_committed = m_pending; diff --git a/tests/auto/client/shared_old/mockcompositor.cpp b/tests/auto/client/shared_old/mockcompositor.cpp index 0dfaef5ea..96dc059e7 100644 --- a/tests/auto/client/shared_old/mockcompositor.cpp +++ b/tests/auto/client/shared_old/mockcompositor.cpp @@ -312,9 +312,9 @@ void *MockCompositor::run(void *data) Impl::Compositor compositor(controller); controller->m_compositor = &compositor; - controller->m_waitCondition.wakeOne(); while (!controller->m_ready) { + controller->m_waitCondition.wakeOne(); controller->dispatchCommands(); compositor.dispatchEvents(20); } diff --git a/tests/auto/client/surface/tst_surface.cpp b/tests/auto/client/surface/tst_surface.cpp index dddff0866..f9dcec581 100644 --- a/tests/auto/client/surface/tst_surface.cpp +++ b/tests/auto/client/surface/tst_surface.cpp @@ -41,6 +41,10 @@ private slots: void waitForFrameCallbackRaster(); void waitForFrameCallbackGl(); void negotiateShmFormat(); + + // Subsurfaces + void createSubsurface(); + void createSubsurfaceForHiddenParent(); }; void tst_surface::createDestroySurface() @@ -154,5 +158,42 @@ void tst_surface::negotiateShmFormat() }); } +void tst_surface::createSubsurface() +{ + QRasterWindow window; + window.resize(64, 64); + window.show(); + QCOMPOSITOR_TRY_VERIFY(xdgToplevel()); + exec([=] { xdgToplevel()->sendCompleteConfigure(); }); + QCOMPOSITOR_TRY_VERIFY(xdgSurface()->m_committedConfigureSerial); + + QRasterWindow subWindow; + subWindow.setParent(&window); + subWindow.resize(64, 64); + subWindow.show(); + QCOMPOSITOR_TRY_VERIFY(subSurface()); +} + +// Used to cause a crash in libwayland (QTBUG-79674) +void tst_surface::createSubsurfaceForHiddenParent() +{ + QRasterWindow window; + window.resize(64, 64); + window.show(); + QCOMPOSITOR_TRY_VERIFY(xdgToplevel()); + exec([=] { xdgToplevel()->sendCompleteConfigure(); }); + QCOMPOSITOR_TRY_VERIFY(xdgSurface()->m_committedConfigureSerial); + + window.hide(); + + QRasterWindow subWindow; + subWindow.setParent(&window); + subWindow.resize(64, 64); + subWindow.show(); + + // Make sure the client doesn't quit before it has a chance to crash + xdgPingAndWaitForPong(); +} + QCOMPOSITOR_TEST_MAIN(tst_surface) #include "tst_surface.moc" diff --git a/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp b/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp index a397f60eb..9885ee2bc 100644 --- a/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp +++ b/tests/auto/client/xdgshellv6/tst_xdgshellv6.cpp @@ -422,7 +422,8 @@ void tst_WaylandClientXdgShellV6::dontSpamExposeEvents() int main(int argc, char **argv) { - setenv("XDG_RUNTIME_DIR", ".", 1); + QTemporaryDir tmpRuntimeDir; + setenv("XDG_RUNTIME_DIR", tmpRuntimeDir.path().toLocal8Bit(), 1); setenv("QT_QPA_PLATFORM", "wayland", 1); // force QGuiApplication to use wayland plugin setenv("QT_WAYLAND_SHELL_INTEGRATION", "xdg-shell-v6", 1); |