From cd232533869fb1a250c2695ac8c0ac09cec3478d Mon Sep 17 00:00:00 2001 From: Marco Allegretti Date: Sun, 15 Feb 2026 14:47:03 +0100 Subject: [PATCH] tests: use generated Input1 proxy and cover profile CRUD --- tests/CMakeLists.txt | 5 +++ tests/dbus_smoketest.cpp | 71 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 70 insertions(+), 6 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 9d36b19..ef8d00e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -20,6 +20,11 @@ qt_add_dbus_interface(alakarte_dbus_smoketest_dbus_sources runner1interface ) +qt_add_dbus_interface(alakarte_dbus_smoketest_dbus_sources + ${CMAKE_SOURCE_DIR}/src/input/dbus/org.kde.ALaKarte.Input1.xml + input1interface +) + target_sources(alakarte_dbus_smoketest PRIVATE ${alakarte_dbus_smoketest_dbus_sources} ) diff --git a/tests/dbus_smoketest.cpp b/tests/dbus_smoketest.cpp index 0be58fd..942c6b2 100644 --- a/tests/dbus_smoketest.cpp +++ b/tests/dbus_smoketest.cpp @@ -20,6 +20,7 @@ #include #include "gamecenter1interface.h" +#include "input1interface.h" #include "runner1interface.h" namespace @@ -90,6 +91,7 @@ private Q_SLOTS: void pingRunner(); void runnerVersionAndListRunners(); void pingInput(); + void inputProfilesCrud(); void runnerResolveLaunchNative(); void runnerGameProfiles(); @@ -429,18 +431,75 @@ void DbusSmokeTest::runnerVersionAndListRunners() void DbusSmokeTest::pingInput() { - QDBusInterface iface(QStringLiteral("org.kde.ALaKarte.Input1"), - QStringLiteral("/org/kde/ALaKarte/Input1"), - QStringLiteral("org.kde.ALaKarte.Input1"), - m_bus); + org::kde::ALaKarte::Input1 iface(QStringLiteral("org.kde.ALaKarte.Input1"), QStringLiteral("/org/kde/ALaKarte/Input1"), m_bus); QVERIFY(iface.isValid()); iface.setTimeout(2000); - const QDBusReply reply = iface.call(QStringLiteral("Ping")); - QVERIFY(reply.isValid()); + QDBusPendingReply reply = iface.Ping(); + reply.waitForFinished(); + QVERIFY2(!reply.isError(), qPrintable(reply.error().message())); QCOMPARE(reply.value(), QStringLiteral("ok")); } +void DbusSmokeTest::inputProfilesCrud() +{ + org::kde::ALaKarte::Input1 iface(QStringLiteral("org.kde.ALaKarte.Input1"), QStringLiteral("/org/kde/ALaKarte/Input1"), m_bus); + QVERIFY(iface.isValid()); + iface.setTimeout(2000); + + QDBusPendingReply createReply = iface.CreateProfile(QStringLiteral("Test Profile")); + createReply.waitForFinished(); + QVERIFY2(!createReply.isError(), qPrintable(createReply.error().message())); + const QString profileId = createReply.value(); + QVERIFY(!profileId.isEmpty()); + + { + QDBusPendingReply listReply = iface.ListProfiles(); + listReply.waitForFinished(); + QVERIFY2(!listReply.isError(), qPrintable(listReply.error().message())); + const QVariantList list = listReply.value(); + + bool found = false; + for (const QVariant &v : list) { + const QVariantMap m = unwrapVariantMap(v); + if (m.value(QStringLiteral("id")).toString() == profileId) { + found = true; + QCOMPARE(m.value(QStringLiteral("name")).toString(), QStringLiteral("Test Profile")); + break; + } + } + QVERIFY(found); + } + + { + QDBusPendingReply getReply = iface.GetProfile(profileId); + getReply.waitForFinished(); + QVERIFY2(!getReply.isError(), qPrintable(getReply.error().message())); + const QVariantMap m = getReply.value(); + QCOMPARE(m.value(QStringLiteral("id")).toString(), profileId); + QCOMPARE(m.value(QStringLiteral("name")).toString(), QStringLiteral("Test Profile")); + } + + { + QDBusPendingReply delReply = iface.DeleteProfile(profileId); + delReply.waitForFinished(); + QVERIFY2(!delReply.isError(), qPrintable(delReply.error().message())); + QVERIFY(delReply.value()); + } + + { + QDBusPendingReply listReply = iface.ListProfiles(); + listReply.waitForFinished(); + QVERIFY2(!listReply.isError(), qPrintable(listReply.error().message())); + const QVariantList list = listReply.value(); + + for (const QVariant &v : list) { + const QVariantMap m = unwrapVariantMap(v); + QVERIFY(m.value(QStringLiteral("id")).toString() != profileId); + } + } +} + void DbusSmokeTest::runnerResolveLaunchNative() { org::kde::ALaKarte::Runner1 iface(QStringLiteral("org.kde.ALaKarte.Runner1"), QStringLiteral("/org/kde/ALaKarte/Runner1"), m_bus);