From 7e27f2fc0cfa678acd1072942acd4c6a2733505b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 3 Sep 2014 20:01:54 +0200 Subject: [PATCH] [kwin_wayland] Test adding/removing Outputs in TestWaylandServerDisplay --- autotests/wayland_server/test_display.cpp | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/autotests/wayland_server/test_display.cpp b/autotests/wayland_server/test_display.cpp index d9a739cfa6..0c60693e0e 100644 --- a/autotests/wayland_server/test_display.cpp +++ b/autotests/wayland_server/test_display.cpp @@ -21,6 +21,7 @@ along with this program. If not, see . #include // WaylandServer #include "../../wayland_server/display.h" +#include "../../wayland_server/output_interface.h" using namespace KWin::WaylandServer; @@ -30,6 +31,7 @@ class TestWaylandServerDisplay : public QObject private Q_SLOTS: void testSocketName(); void testStartStop(); + void testAddRemoveOutput(); }; void TestWaylandServerDisplay::testSocketName() @@ -76,5 +78,28 @@ void TestWaylandServerDisplay::testStartStop() QVERIFY(!runtimeDir.exists(testSocketName)); } +void TestWaylandServerDisplay::testAddRemoveOutput() +{ + Display display; + display.setSocketName(QStringLiteral("kwin-wayland-server-display-test-output-0")); + display.start(); + + OutputInterface *output = display.createOutput(); + QCOMPARE(display.outputs().size(), 1); + QCOMPARE(display.outputs().first(), output); + // create a second output + OutputInterface *output2 = display.createOutput(); + QCOMPARE(display.outputs().size(), 2); + QCOMPARE(display.outputs().first(), output); + QCOMPARE(display.outputs().last(), output2); + // remove the first output + display.removeOutput(output); + QCOMPARE(display.outputs().size(), 1); + QCOMPARE(display.outputs().first(), output2); + // and delete the second + delete output2; + QVERIFY(display.outputs().isEmpty()); +} + QTEST_MAIN(TestWaylandServerDisplay) #include "test_display.moc"