From 0848113845547b9ec9838496b61c50382ff7c099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 26 Aug 2014 16:07:39 +0200 Subject: [PATCH] [kwin_wayland] Initial addition of the WaylandServer module So far this new module contains: * Display * OutputInterface Display manages the server socket and server event loop. In general it's the entry point to any part of the server. OutputInterface is the abstraction for the wl_output interface on server side. An OutputInterface is created through the Display. The auto tests for ConnectionThread and Output are adjusted to use the internal server instead of starting Weston. Especially the Output test could be extended to test much more as we have absolute control over the server now. --- src/wayland/test_display.cpp | 80 ++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 src/wayland/test_display.cpp diff --git a/src/wayland/test_display.cpp b/src/wayland/test_display.cpp new file mode 100644 index 0000000000..d9a739cfa6 --- /dev/null +++ b/src/wayland/test_display.cpp @@ -0,0 +1,80 @@ +/******************************************************************** +KWin - the KDE window manager +This file is part of the KDE project. + +Copyright (C) 2014 Martin Gräßlin + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*********************************************************************/ +// Qt +#include +// WaylandServer +#include "../../wayland_server/display.h" + +using namespace KWin::WaylandServer; + +class TestWaylandServerDisplay : public QObject +{ + Q_OBJECT +private Q_SLOTS: + void testSocketName(); + void testStartStop(); +}; + +void TestWaylandServerDisplay::testSocketName() +{ + Display display; + QSignalSpy changedSpy(&display, SIGNAL(socketNameChanged(QString))); + QVERIFY(changedSpy.isValid()); + QCOMPARE(display.socketName(), QStringLiteral("wayland-0")); + const QString testSName = QStringLiteral("fooBar"); + display.setSocketName(testSName); + QCOMPARE(display.socketName(), testSName); + QCOMPARE(changedSpy.count(), 1); + QCOMPARE(changedSpy.first().first().toString(), testSName); + + // changing to same name again should not emit signal + display.setSocketName(testSName); + QCOMPARE(changedSpy.count(), 1); +} + +void TestWaylandServerDisplay::testStartStop() +{ + const QString testSocketName = QStringLiteral("kwin-wayland-server-display-test-0"); + QDir runtimeDir(qgetenv("XDG_RUNTIME_DIR")); + QVERIFY(runtimeDir.exists()); + QVERIFY(!runtimeDir.exists(testSocketName)); + + Display display; + QSignalSpy runningSpy(&display, SIGNAL(runningChanged(bool))); + QVERIFY(runningSpy.isValid()); + display.setSocketName(testSocketName); + QVERIFY(!display.isRunning()); + display.start(); +// QVERIFY(runningSpy.wait()); + QCOMPARE(runningSpy.count(), 1); + QVERIFY(runningSpy.first().first().toBool()); + QVERIFY(display.isRunning()); + QVERIFY(runtimeDir.exists(testSocketName)); + + display.terminate(); + QVERIFY(!display.isRunning()); + QCOMPARE(runningSpy.count(), 2); + QVERIFY(runningSpy.first().first().toBool()); + QVERIFY(!runningSpy.last().first().toBool()); + QVERIFY(!runtimeDir.exists(testSocketName)); +} + +QTEST_MAIN(TestWaylandServerDisplay) +#include "test_display.moc"