Add test case for operator cast in Client::Shell

One test also adjusted to get the operator cast in ShellSurface under
coverage.
This commit is contained in:
Martin Gräßlin 2014-09-22 11:41:34 +02:00
parent bf1168db23
commit d267cdca02

View file

@ -47,6 +47,7 @@ private Q_SLOTS:
void testTitle(); void testTitle();
void testWindowClass(); void testWindowClass();
void testDestroy(); void testDestroy();
void testCast();
private: private:
KWayland::Server::Display *m_display; KWayland::Server::Display *m_display;
@ -269,7 +270,7 @@ void TestWaylandShell::testTitle()
QString testTitle = QStringLiteral("fooBar"); QString testTitle = QStringLiteral("fooBar");
QVERIFY(serverSurface->title().isNull()); QVERIFY(serverSurface->title().isNull());
wl_shell_surface_set_title(*surface, testTitle.toUtf8().constData()); wl_shell_surface_set_title(*(const KWayland::Client::ShellSurface *)surface, testTitle.toUtf8().constData());
QVERIFY(titleSpy.wait()); QVERIFY(titleSpy.wait());
QCOMPARE(serverSurface->title(), testTitle); QCOMPARE(serverSurface->title(), testTitle);
QCOMPARE(titleSpy.first().first().toString(), testTitle); QCOMPARE(titleSpy.first().first().toString(), testTitle);
@ -328,5 +329,27 @@ void TestWaylandShell::testDestroy()
surface->destroy(); surface->destroy();
} }
void TestWaylandShell::testCast()
{
using namespace KWayland::Client;
Registry registry;
QSignalSpy shellSpy(&registry, SIGNAL(shellAnnounced(quint32,quint32)));
registry.create(m_connection->display());
QVERIFY(registry.isValid());
registry.setup();
QVERIFY(shellSpy.wait());
Shell s;
auto wlShell = registry.bindShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>());
QVERIFY(wlShell);
QVERIFY(!s.isValid());
s.setup(wlShell);
QVERIFY(s.isValid());
QCOMPARE((wl_shell*)s, wlShell);
const Shell &s2(s);
QCOMPARE((wl_shell*)s2, wlShell);
}
QTEST_MAIN(TestWaylandShell) QTEST_MAIN(TestWaylandShell)
#include "test_wayland_shell.moc" #include "test_wayland_shell.moc"