diff --git a/src/wayland/autotests/client/test_wayland_surface.cpp b/src/wayland/autotests/client/test_wayland_surface.cpp
index 123e660dcc..d13db9a8f5 100644
--- a/src/wayland/autotests/client/test_wayland_surface.cpp
+++ b/src/wayland/autotests/client/test_wayland_surface.cpp
@@ -25,6 +25,7 @@ License along with this library. If not, see .
#include "../../src/client/compositor.h"
#include "../../src/client/connection_thread.h"
#include "../../src/client/event_queue.h"
+#include "../../src/client/output.h"
#include "../../src/client/surface.h"
#include "../../src/client/region.h"
#include "../../src/client/registry.h"
@@ -59,6 +60,7 @@ private Q_SLOTS:
void testSurfaceAt();
void testDestroyAttachedBuffer();
void testDestroyWithPendingCallback();
+ void testOutput();
void testDisconnect();
private:
@@ -956,5 +958,78 @@ void TestWaylandSurface::testDisconnect()
m_queue->destroy();
}
+void TestWaylandSurface::testOutput()
+{
+ // This test verifies that the enter/leave are sent correctly to the Client
+ using namespace KWayland::Client;
+ using namespace KWayland::Server;
+ qRegisterMetaType();
+ QScopedPointer s(m_compositor->createSurface());
+ QVERIFY(!s.isNull());
+ QVERIFY(s->isValid());
+ QVERIFY(s->outputs().isEmpty());
+ QSignalSpy enteredSpy(s.data(), &Surface::outputEntered);
+ QVERIFY(enteredSpy.isValid());
+ QSignalSpy leftSpy(s.data(), &Surface::outputLeft);
+ QVERIFY(leftSpy.isValid());
+ // wait for the surface on the Server side
+ QSignalSpy surfaceCreatedSpy(m_compositorInterface, &CompositorInterface::surfaceCreated);
+ QVERIFY(surfaceCreatedSpy.isValid());
+ QVERIFY(surfaceCreatedSpy.wait());
+ auto serverSurface = surfaceCreatedSpy.first().first().value();
+ QVERIFY(serverSurface);
+ QCOMPARE(serverSurface->outputs(), QVector());
+
+ // create another registry to get notified about added outputs
+ Registry registry;
+ registry.setEventQueue(m_queue);
+ QSignalSpy allAnnounced(®istry, &Registry::interfacesAnnounced);
+ QVERIFY(allAnnounced.isValid());
+ registry.create(m_connection);
+ QVERIFY(registry.isValid());
+ registry.setup();
+ QVERIFY(allAnnounced.wait());
+ QSignalSpy outputAnnouncedSpy(®istry, &Registry::outputAnnounced);
+ QVERIFY(outputAnnouncedSpy.isValid());
+
+ auto serverOutput = m_display->createOutput(m_display);
+ serverOutput->create();
+ QVERIFY(outputAnnouncedSpy.wait());
+ QScopedPointer