@@ -19,16 +19,13 @@
1919
2020#include "AccountsService.h"
2121#include "AccountsServiceDBusAdaptor.h"
22+#include "types.h"
2223#include <QSignalSpy>
2324#include <QTest>
2425#include <QDebug>
2526#include <QDBusReply>
2627#include <QDBusMetaType>
2728
28−using StringMap = QMap<QString,QString>;
29−using StringMapList = QList<StringMap>;
30−Q_DECLARE_METATYPE(StringMapList)
31−
3229template <class T>
3330QVariant dbusVariant(const T& value) { return QVariant::fromValue(QDBusVariant(value)); }
3431
@@ -263,10 +260,13 @@ private Q_SLOTS:
263260 AccountsService session(this, QTest::currentTestFunction());
264261
265262 QCOMPARE(session.backgroundFile(), QString());
266− ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
267− "org.freedesktop.Accounts.User",
268− "BackgroundFile",
269− dbusVariant("/test/BackgroundFile")));
263+
264+ QDBusInterface accountsIface(m_userInterface->service(),
265+ m_userInterface->path(),
266+ "org.freedesktop.Accounts.User");
267+ ASSERT_DBUS_CALL(accountsIface.asyncCall("SetBackgroundFile",
268+ "/test/BackgroundFile"));
269+
270270 QTRY_COMPARE(session.backgroundFile(), QString("/test/BackgroundFile"));
271271 }
272272
@@ -311,6 +311,39 @@ private Q_SLOTS:
311311 QCOMPARE(arguments.at(0).toInt(), 0);
312312 }
313313
314+ void testSetRealName()
315+ {
316+ AccountsService session(this, QTest::currentTestFunction());
317+
318+ // Just confirm that we can't set normal way
319+ auto message = m_userInterface->call("Set",
320+ "org.freedesktop.Accounts.User",
321+ "RealName",
322+ dbusVariant("Stallman"));
323+ QCOMPARE(message.type(), QDBusMessage::ErrorMessage);
324+ QCOMPARE(message.errorName(), QStringLiteral("org.freedesktop.DBus.Error.InvalidArgs"));
325+
326+ message = m_userInterface->call("Get",
327+ "org.freedesktop.Accounts.User",
328+ "RealName");
329+ QCOMPARE(message.type(), QDBusMessage::ReplyMessage);
330+ auto response = message.arguments().first().value<QDBusVariant>().variant().toString();
331+ QCOMPARE(response, QStringLiteral(""));
332+
333+ // Now try it via our AS wrapper and confirm it did get through, unlike above
334+ session.setRealName("Stallman");
335+
336+ QCOMPARE(session.realName(), QStringLiteral("Stallman"));
337+
338+ message = m_userInterface->call("Get",
339+ "org.freedesktop.Accounts.User",
340+ "RealName");
341+ QCOMPARE(message.type(), QDBusMessage::ReplyMessage);
342+ response = message.arguments().first().value<QDBusVariant>().variant().toString();
343+ QCOMPARE(response, QStringLiteral("Stallman"));
344+
345+ }
346+
314347 void testAsynchronousChangeForKeymaps()
315348 {
316349 AccountsService session(this, QTest::currentTestFunction());
@@ -325,10 +358,11 @@ private Q_SLOTS:
325358 map2.insert("xkb", "fr");
326359 inputSources.append(map2);
327360
328− ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
329− "org.freedesktop.Accounts.User",
330− "InputSources",
331− QVariant::fromValue(QDBusVariant(QVariant::fromValue(inputSources)))));
361+ QDBusInterface accountsIface(m_userInterface->service(),
362+ m_userInterface->path(),
363+ "org.freedesktop.Accounts.User");
364+ ASSERT_DBUS_CALL(accountsIface.asyncCall("SetInputSources",
365+ QVariant::fromValue(inputSources)));
332366 QStringList result = {"cz+qwerty", "fr"};
333367 QTRY_COMPARE(session.keymaps(), result);
334368 }