@@ -34,6 +34,10 @@
34#include <QDBusMetaType>
34#include <QDBusMetaType>
35#include <QDomDocument>
35#include <QDomDocument>
38+#include <sys/types.h>
37// This is a mock, specifically to test the LauncherModel
41// This is a mock, specifically to test the LauncherModel
38class MockApp: public unity::shell::application::ApplicationInfoInterface
42class MockApp: public unity::shell::application::ApplicationInfoInterface
@@ -72,6 +76,11 @@ private:
72 bool m_focused;
76 bool m_focused;
79+QString getUsername () {
80+ auto pw = getpwuid(getuid());
75// This is a mock, specifically to test the LauncherModel
84// This is a mock, specifically to test the LauncherModel
76class MockAppManager: public unity::shell::application::ApplicationManagerInterface
85class MockAppManager: public unity::shell::application::ApplicationManagerInterface
@@ -142,7 +151,7 @@ private:
143 QList<QVariantMap> getASConfig() {
152 QList<QVariantMap> getASConfig() {
144 AccountsServiceDBusAdaptor *as = launcherModel->m_asAdapter->m_accounts;
153 AccountsServiceDBusAdaptor *as = launcherModel->m_asAdapter->m_accounts;
145− QDBusReply<QVariant> reply = as->getUserPropertyAsync(QString(qgetenv("USER")),
154+ QDBusReply<QVariant> reply = as->getUserPropertyAsync(getUsername(),
146 "com.canonical.unity.AccountsService",
155 "com.canonical.unity.AccountsService",
147 "LauncherItems");
156 "LauncherItems");
148 return qdbus_cast<QList<QVariantMap>>(reply.value().value<QDBusArgument>());
157 return qdbus_cast<QList<QVariantMap>>(reply.value().value<QDBusArgument>());
@@ -167,7 +176,7 @@ private Q_SLOTS:
167 QStringLiteral("/org/freedesktop/Accounts"),
176 QStringLiteral("/org/freedesktop/Accounts"),
168 QStringLiteral("org.freedesktop.Accounts"));
177 QStringLiteral("org.freedesktop.Accounts"));
169 QDBusReply<bool> addReply = accountsInterface.call(QStringLiteral("AddUser"),
178 QDBusReply<bool> addReply = accountsInterface.call(QStringLiteral("AddUser"),
170− QString(qgetenv("USER")));
179+ getUsername());
171 QVERIFY(addReply.isValid());
180 QVERIFY(addReply.isValid());
172 QCOMPARE(addReply.value(), true);
181 QCOMPARE(addReply.value(), true);
@@ -193,7 +202,7 @@ private Q_SLOTS:
193 QStringLiteral("/org/freedesktop/Accounts"),
202 QStringLiteral("/org/freedesktop/Accounts"),
194 QStringLiteral("org.freedesktop.Accounts"));
203 QStringLiteral("org.freedesktop.Accounts"));
195 QDBusReply<bool> removeReply = accountsInterface.call(QStringLiteral("RemoveUser"),
204 QDBusReply<bool> removeReply = accountsInterface.call(QStringLiteral("RemoveUser"),
196− QString(qgetenv("USER")));
205+ getUsername());
197 QVERIFY(removeReply.isValid());
206 QVERIFY(removeReply.isValid());
198 QCOMPARE(removeReply.value(), true);
207 QCOMPARE(removeReply.value(), true);