From fe253d89bc214c180d7eda301f42c5049faa78ae Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Sun, 15 Feb 2026 14:22:41 +0100 Subject: [PATCH] tests: cover GameCenter launch failure contract --- tests/dbus_smoketest.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/dbus_smoketest.cpp b/tests/dbus_smoketest.cpp index 61f6c25..70f7836 100644 --- a/tests/dbus_smoketest.cpp +++ b/tests/dbus_smoketest.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -84,6 +85,7 @@ private Q_SLOTS: void pingGameCenter(); void gameCenterUniqueness(); void gameCenterPolicyAndCapabilities(); + void gameCenterLaunchFailureContract(); void pingRunner(); void pingInput(); void runnerResolveLaunchNative(); @@ -349,6 +351,34 @@ void DbusSmokeTest::gameCenterPolicyAndCapabilities() } } +void DbusSmokeTest::gameCenterLaunchFailureContract() +{ + org::kde::GameCenter1 iface(QStringLiteral("org.kde.GameCenter1"), QStringLiteral("/org/kde/ALaKarte/GameCenter1"), m_bus); + QVERIFY(iface.isValid()); + iface.setTimeout(2000); + + QSignalSpy launchFailedSpy(&iface, &org::kde::GameCenter1::LaunchFailed); + QVERIFY(launchFailedSpy.isValid()); + + QVariantMap launchSpec; + launchSpec.insert(QStringLiteral("gameId"), QStringLiteral("alakarte-test-game")); + launchSpec.insert(QStringLiteral("program"), QStringLiteral("/bin/true")); + launchSpec.insert(QStringLiteral("args"), QStringList{}); + + QDBusPendingReply reply = iface.Launch(launchSpec); + reply.waitForFinished(); + QVERIFY2(!reply.isError(), qPrintable(reply.error().message())); + QVERIFY(reply.value().isEmpty()); + + QTRY_COMPARE_WITH_TIMEOUT(launchFailedSpy.count(), 1, 2000); + const QList args = launchFailedSpy.takeFirst(); + QCOMPARE(args.size(), 1); + const QVariantMap error = unwrapVariantMap(args.first()); + QVERIFY(error.contains(QStringLiteral("error"))); + QVERIFY(error.value(QStringLiteral("error")).toString().contains(QStringLiteral("systemd"), Qt::CaseInsensitive)); + QCOMPARE(error.value(QStringLiteral("gameId")).toString(), QStringLiteral("alakarte-test-game")); +} + void DbusSmokeTest::pingRunner() { org::kde::ALaKarte::Runner1 iface(QStringLiteral("org.kde.ALaKarte.Runner1"), QStringLiteral("/org/kde/ALaKarte/Runner1"), m_bus);