@@ -34,6 +34,10 @@
3434#include <QDBusMetaType>
3535#include <QDomDocument>
3636
37+#include <unistd.h>
38+#include <sys/types.h>
39+#include <pwd.h>
40+
3741// This is a mock, specifically to test the LauncherModel
3842class MockApp: public unity::shell::application::ApplicationInfoInterface
3943{
@@ -72,6 +76,11 @@ private:
7276 bool m_focused;
7377};
7478
79+QString getUsername () {
80+ auto pw = getpwuid(getuid());
81+ return pw->pw_name;
82+}
83+
7584// This is a mock, specifically to test the LauncherModel
7685class MockAppManager: public unity::shell::application::ApplicationManagerInterface
7786{
@@ -142,7 +151,7 @@ private:
142151
143152 QList<QVariantMap> getASConfig() {
144153 AccountsServiceDBusAdaptor *as = launcherModel->m_asAdapter->m_accounts;
145− QDBusReply<QVariant> reply = as->getUserPropertyAsync(QString(qgetenv("USER")),
154+ QDBusReply<QVariant> reply = as->getUserPropertyAsync(getUsername(),
146155 "com.canonical.unity.AccountsService",
147156 "LauncherItems");
148157 return qdbus_cast<QList<QVariantMap>>(reply.value().value<QDBusArgument>());
@@ -167,7 +176,7 @@ private Q_SLOTS:
167176 QStringLiteral("/org/freedesktop/Accounts"),
168177 QStringLiteral("org.freedesktop.Accounts"));
169178 QDBusReply<bool> addReply = accountsInterface.call(QStringLiteral("AddUser"),
170− QString(qgetenv("USER")));
179+ getUsername());
171180 QVERIFY(addReply.isValid());
172181 QCOMPARE(addReply.value(), true);
173182
@@ -193,7 +202,7 @@ private Q_SLOTS:
193202 QStringLiteral("/org/freedesktop/Accounts"),
194203 QStringLiteral("org.freedesktop.Accounts"));
195204 QDBusReply<bool> removeReply = accountsInterface.call(QStringLiteral("RemoveUser"),
196− QString(qgetenv("USER")));
205+ getUsername());
197206 QVERIFY(removeReply.isValid());
198207 QCOMPARE(removeReply.value(), true);
199208 }