[kwin_wayland] Test adding/removing Outputs in TestWaylandServerDisplay

This commit is contained in:
Martin Gräßlin 2014-09-03 20:01:54 +02:00
parent c061cc5fd9
commit 7e27f2fc0c

View file

@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QtTest/QtTest>
// 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"