Commit 66b0f5b8 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

Allow accepting client connections on multiple sockets

libwayland-server allows the wl_display accept client connections on
more than one socket. We currently don't listen on multiple sockets,
but it would be nice if Display supported such operation mode.
parent 96d562dc
Pipeline #43479 passed with stage
in 6 minutes and 9 seconds
......@@ -53,7 +53,7 @@ void TestCompositor::init()
using namespace KWaylandServer;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -67,7 +67,7 @@ void TestDataDevice::init()
using namespace KWaylandServer;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -49,7 +49,7 @@ void TestDataSource::init()
using namespace KWaylandServer;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -67,7 +67,7 @@ void TestDragAndDrop::init()
using namespace KWayland::Client;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -50,7 +50,7 @@ void ErrorTest::init()
{
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
m_display->createShm();
......
......@@ -57,7 +57,7 @@ void FakeInputTest::init()
{
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
m_display->createShm();
......
......@@ -49,7 +49,7 @@ void IdleTest::init()
{
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
m_display->createShm();
......
......@@ -77,7 +77,7 @@ void TestVirtualDesktop::init()
using namespace KWaylandServer;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -96,7 +96,7 @@ void PlasmaWindowModelTest::init()
{
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
m_display->createShm();
......
......@@ -60,7 +60,7 @@ void TestPlasmaShell::init()
{
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -63,7 +63,7 @@ void TestPointerConstraints::init()
{
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
m_display->createShm();
......
......@@ -63,7 +63,7 @@ void SelectionTest::init()
{
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
m_display->createShm();
......
......@@ -58,7 +58,7 @@ void TestServerSideDecoration::init()
using namespace KWayland::Client;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -61,7 +61,7 @@ void TestServerSideDecorationPalette::init()
using namespace KWaylandServer;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -52,7 +52,7 @@ void ShadowTest::init()
{
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
m_display->createShm();
......
......@@ -60,7 +60,7 @@ void TestShmPool::init()
using namespace KWaylandServer;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -71,7 +71,7 @@ void TextInputTest::init()
{
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
m_display->createShm();
......
......@@ -64,7 +64,7 @@ void TestAppmenu::init()
qRegisterMetaType<AppMenuInterface::InterfaceAddress>();
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -61,7 +61,7 @@ void TestBlur::init()
using namespace KWaylandServer;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -64,7 +64,7 @@ void TestContrast::init()
using namespace KWaylandServer;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -77,7 +77,7 @@ void TestFilter::init()
using namespace KWaylandServer;
delete m_display;
m_display = new TestDisplay(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -66,7 +66,7 @@ void TestWaylandOutput::init()
using namespace KWaylandServer;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -78,7 +78,7 @@ void TestWaylandOutputDevice::init()
using namespace KWaylandServer;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -91,7 +91,7 @@ void TestWaylandOutputManagement::init()
using namespace KWaylandServer;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -59,7 +59,7 @@ void TestRegion::init()
using namespace KWaylandServer;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -123,7 +123,7 @@ void TestWaylandSeat::init()
using namespace KWaylandServer;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
m_display->createShm();
......
......@@ -61,7 +61,7 @@ void TestSlide::init()
using namespace KWaylandServer;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -52,7 +52,7 @@ void TestSubCompositor::init()
using namespace KWaylandServer;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -84,7 +84,7 @@ void TestSubSurface::init()
using namespace KWaylandServer;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
m_display->createShm();
......
......@@ -83,7 +83,7 @@ void TestWaylandSurface::init()
using namespace KWaylandServer;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
m_display->createShm();
......
......@@ -95,7 +95,7 @@ void TestWindowManagement::init()
qRegisterMetaType<KWaylandServer::PlasmaWindowManagementInterface::ShowingDesktopState>("ShowingDesktopState");
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -63,7 +63,7 @@ void TestXdgDecoration::init()
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -82,7 +82,7 @@ void TestForeign::init()
using namespace KWaylandServer;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -54,7 +54,7 @@ void TestXdgOutput::init()
using namespace KWaylandServer;
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -89,7 +89,7 @@ void XdgShellTest::init()
{
delete m_display;
m_display = new Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
m_display->createShm();
......
......@@ -158,8 +158,8 @@ static const QString s_socketName = QStringLiteral("kwin-wayland-datacontrol-tes
void DataControlInterfaceTest::init()
{
m_display = new Display;
m_display->setSocketName(s_socketName);
m_display = new Display();
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -35,17 +35,16 @@ private Q_SLOTS:
void TestWaylandServerDisplay::testSocketName()
{
Display display;
QSignalSpy changedSpy(&display, SIGNAL(socketNameChanged(QString)));
QSignalSpy changedSpy(&display, &Display::socketNamesChanged);
QVERIFY(changedSpy.isValid());
QCOMPARE(display.socketName(), QStringLiteral("wayland-0"));
QCOMPARE(display.socketNames(), QStringList());
const QString testSName = QStringLiteral("fooBar");
display.setSocketName(testSName);
QCOMPARE(display.socketName(), testSName);
display.addSocketName(testSName);
QCOMPARE(display.socketNames(), QStringList { testSName });
QCOMPARE(changedSpy.count(), 1);
QCOMPARE(changedSpy.first().first().toString(), testSName);
// changing to same name again should not emit signal
display.setSocketName(testSName);
display.addSocketName(testSName);
QCOMPARE(changedSpy.count(), 1);
}
......@@ -59,7 +58,7 @@ void TestWaylandServerDisplay::testStartStop()
QScopedPointer<Display> display(new Display);
QSignalSpy runningSpy(display.data(), SIGNAL(runningChanged(bool)));
QVERIFY(runningSpy.isValid());
display->setSocketName(testSocketName);
display->addSocketName(testSocketName);
QVERIFY(!display->isRunning());
display->start();
// QVERIFY(runningSpy.wait());
......@@ -75,7 +74,7 @@ void TestWaylandServerDisplay::testStartStop()
void TestWaylandServerDisplay::testAddRemoveOutput()
{
Display display;
display.setSocketName(QStringLiteral("kwin-wayland-server-display-test-output-0"));
display.addSocketName(QStringLiteral("kwin-wayland-server-display-test-output-0"));
display.start();
OutputInterface *output = display.createOutput();
......@@ -98,7 +97,7 @@ void TestWaylandServerDisplay::testAddRemoveOutput()
void TestWaylandServerDisplay::testClientConnection()
{
Display display;
display.setSocketName(QStringLiteral("kwin-wayland-server-display-test-client-connection"));
display.addSocketName(QStringLiteral("kwin-wayland-server-display-test-client-connection"));
display.start();
QSignalSpy connectedSpy(&display, SIGNAL(clientConnected(KWaylandServer::ClientConnection*)));
QVERIFY(connectedSpy.isValid());
......@@ -174,7 +173,7 @@ void TestWaylandServerDisplay::testClientConnection()
void TestWaylandServerDisplay::testConnectNoSocket()
{
Display display;
display.start(Display::StartMode::ConnectClientsOnly);
display.start();
QVERIFY(display.isRunning());
// let's try connecting a client
......@@ -191,7 +190,7 @@ void TestWaylandServerDisplay::testConnectNoSocket()
void TestWaylandServerDisplay::testOutputManagement()
{
Display display;
display.setSocketName("kwayland-test-0");
display.addSocketName("kwayland-test-0");
display.start();
auto kwin = display.createOutputManagement(this);
kwin->create();
......@@ -205,20 +204,20 @@ void TestWaylandServerDisplay::testAutoSocketName()
QVERIFY(qputenv("XDG_RUNTIME_DIR", runtimeDir.path().toUtf8()));
Display display0;
display0.setAutomaticSocketNaming(true);
QSignalSpy socketNameChangedSpy0(&display0, SIGNAL(socketNameChanged(QString)));
QSignalSpy socketNameChangedSpy0(&display0, &Display::socketNamesChanged);
QVERIFY(socketNameChangedSpy0.isValid());
QVERIFY(display0.addSocketName());
display0.start();
QVERIFY(display0.isRunning());
QCOMPARE(socketNameChangedSpy0.count(), 0);
QCOMPARE(display0.socketName(), QStringLiteral("wayland-0"));
QCOMPARE(socketNameChangedSpy0.count(), 1);
Display display1;
display1.setAutomaticSocketNaming(true);
QSignalSpy socketNameChangedSpy1(&display1, SIGNAL(socketNameChanged(QString)));
QSignalSpy socketNameChangedSpy1(&display1, &Display::socketNamesChanged);
QVERIFY(socketNameChangedSpy1.isValid());
QVERIFY(display1.addSocketName());
display1.start();
QVERIFY(display1.isRunning());
QCOMPARE(socketNameChangedSpy1.count(), 1);
QCOMPARE(display1.socketName(), QStringLiteral("wayland-1"));
}
......
......@@ -172,7 +172,7 @@ static const QString s_socketName = QStringLiteral("kwin-wayland-server-inputmet
void TestInputMethodInterface::initTestCase()
{
m_display.setSocketName(s_socketName);
m_display.addSocketName(s_socketName);
m_display.start();
QVERIFY(m_display.isRunning());
......
......@@ -95,7 +95,7 @@ static const QString s_socketName = QStringLiteral("kwin-wayland-server-keyboard
void TestKeyboardShortcutsInhibitorInterface::initTestCase()
{
m_display.setSocketName(s_socketName);
m_display.addSocketName(s_socketName);
m_display.start();
QVERIFY(m_display.isRunning());
......
......@@ -102,7 +102,7 @@ static const QString s_socketName = QStringLiteral("kwin-wayland-server-layer-sh
void TestLayerShellV1Interface::initTestCase()
{
m_display.setSocketName(s_socketName);
m_display.addSocketName(s_socketName);
m_display.start();
QVERIFY(m_display.isRunning());
......
......@@ -31,10 +31,8 @@ void NoXdgRuntimeDirTest::testCreate()
Display display;
QSignalSpy runningSpy(&display, &Display::runningChanged);
QVERIFY(runningSpy.isValid());
display.setSocketName(testSocketName);
QVERIFY(!display.isRunning());
QVERIFY(!display.addSocketName(testSocketName));
display.start();
QVERIFY(!display.isRunning());
// call into dispatchEvents should not crash
display.dispatchEvents();
......
......@@ -93,7 +93,7 @@ void TestScreencastV1Interface::initTestCase()
{
delete m_display;
m_display = new KWaylandServer::Display(this);
m_display->setSocketName(s_socketName);
m_display->addSocketName(s_socketName);
m_display->start();
QVERIFY(m_display->isRunning());
......
......@@ -30,7 +30,7 @@ static const QString s_socketName = QStringLiteral("kwin-wayland-server-seat-tes
void TestWaylandServerSeat::testCapabilities()
{
Display display;
display.setSocketName(s_socketName);
display.addSocketName(s_socketName);
display.start();
SeatInterface *seat = display.createSeat();
QVERIFY(!seat->hasKeyboard());
......@@ -80,7 +80,7 @@ void TestWaylandServerSeat::testCapabilities()
void TestWaylandServerSeat::testName()
{
Display display;
display.setSocketName(s_socketName);
display.addSocketName(s_socketName);
display.start();
SeatInterface *seat = display.createSeat();
QCOMPARE(seat->name(), QString());
......@@ -99,7 +99,7 @@ void TestWaylandServerSeat::testName()
void TestWaylandServerSeat::testPointerButton()
{
Display display;
display.setSocketName(s_socketName);
display.addSocketName(s_socketName);
display.start();
SeatInterface *seat = display.createSeat();
PointerInterface *pointer = seat->focusedPointer();
......@@ -129,7 +129,7 @@ void TestWaylandServerSeat::testPointerButton()
void TestWaylandServerSeat::testPointerPos()
{
Display display;
display.setSocketName(s_socketName);
display.addSocketName(s_socketName);
display.start();
SeatInterface *seat = display.createSeat();
QSignalSpy seatPosSpy(seat, SIGNAL(pointerPosChanged(QPointF)));
......@@ -157,7 +157,7 @@ void TestWaylandServerSeat::testPointerPos()
void TestWaylandServerSeat::testRepeatInfo()
{
Display display;
display.setSocketName(s_socketName);
display.addSocketName(s_socketName);
display.start();
SeatInterface *seat = display.createSeat();
seat->setHasKeyboard(true);
......@@ -175,7 +175,7 @@ void TestWaylandServerSeat::testRepeatInfo()
void TestWaylandServerSeat::testMultiple()
{
Display display;
display.setSocketName(s_socketName);
display.addSocketName(s_socketName);
display.start();
QVERIFY(display.seats().isEmpty());
SeatInterface *seat1 = display.createSeat();
......
......@@ -137,7 +137,7 @@ static const QString s_socketName = QStringLiteral("kwin-wayland-server-tablet-t
void TestTabletInterface::initTestCase()
{
m_display.setSocketName(s_socketName);
m_display.addSocketName(s_socketName);
m_display.start();
QVERIFY(m_display.isRunning());
......
......@@ -115,7 +115,7 @@ static const QString s_socketName = QStringLiteral("kwin-wayland-server-text-inp
void TestTextInputV3Interface::initTestCase()
{
m_display.setSocketName(s_socketName);
m_display.addSocketName(s_socketName);
m_display.start();
QVERIFY(m_display.isRunning());
......
......@@ -58,7 +58,7 @@ static const QString s_socketName = QStringLiteral("kwin-wayland-server-viewport
void TestViewporterInterface::initTestCase()
{
m_display.setSocketName(s_socketName);
m_display.addSocketName(s_socketName);