summaryrefslogtreecommitdiffstats
path: root/tests/auto/compositor/compositor/tst_compositor.cpp
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2018-12-20 11:52:12 +0100
committerJohan Helsing <johan.helsing@qt.io>2018-12-22 13:18:05 +0000
commitf2dc41b5babf0a7b51a1735f290540d7be695042 (patch)
tree316dd7b08653218e0434e3042b00cdd70000e629 /tests/auto/compositor/compositor/tst_compositor.cpp
parent1dc85b95ab0adc1e805d059e2c35c671ef790011 (diff)
Compositor: Fix crash in QWaylandSurface::waylandClient
Adds a test for customSurface which crashed without the fix. Fixes: QTBUG-72688 Change-Id: I30c50e474379c61b90b2dd294eae9a7c88c105a2 Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
Diffstat (limited to 'tests/auto/compositor/compositor/tst_compositor.cpp')
-rw-r--r--tests/auto/compositor/compositor/tst_compositor.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/compositor/compositor/tst_compositor.cpp b/tests/auto/compositor/compositor/tst_compositor.cpp
index 97e650d9..e12aa564 100644
--- a/tests/auto/compositor/compositor/tst_compositor.cpp
+++ b/tests/auto/compositor/compositor/tst_compositor.cpp
@@ -78,6 +78,7 @@ private slots:
void mapSurfaceHiDpi();
void frameCallback();
void removeOutput();
+ void customSurface();
void advertisesXdgShellSupport();
void createsXdgSurfaces();
@@ -613,6 +614,32 @@ void tst_WaylandCompositor::removeOutput()
QTRY_COMPARE(client.m_outputs.size(), 1);
}
+class CustomSurface : public QWaylandSurface {
+ Q_OBJECT
+public:
+ explicit CustomSurface() = default;
+};
+
+void tst_WaylandCompositor::customSurface()
+{
+ TestCompositor compositor;
+ QObject::connect(&compositor, &TestCompositor::surfaceRequested, this, [&compositor] (QWaylandClient *client, uint id, int version) {
+ auto *s = new CustomSurface();
+ QCOMPARE(s->waylandClient(), nullptr);
+ s->initialize(&compositor, client, id, version);
+ QCOMPARE(s->waylandClient(), client->client());
+ });
+ QObject::connect(&compositor, &TestCompositor::surfaceCreated, this, [] (QWaylandSurface *surface) {
+ auto *custom = qobject_cast<CustomSurface *>(surface);
+ QVERIFY(custom != nullptr);
+ });
+ compositor.create();
+
+ MockClient client;
+ wl_surface *surface = client.createSurface();
+ QTRY_COMPARE(compositor.surfaces.size(), 1);
+}
+
void tst_WaylandCompositor::seatCapabilities()
{
TestCompositor compositor;