@@ -14,6 +14,8 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+#include "MockController.h"
17#include "UsersModel.h"
19#include "UsersModel.h"
19#include <QLightDM/UsersModel>
21#include <QLightDM/UsersModel>
@@ -40,17 +42,25 @@ private:
40 return model->data(model->index(i, 0), role).toString();
42 return model->data(model->index(i, 0), role).toString();
50+ model = new UsersModel();
43private Q_SLOTS:
54private Q_SLOTS:
45 void init()
56 void init()
47− model = new UsersModel();
58+ recreateModel();
51 void cleanup()
61 void cleanup()
53− delete model;
63+ QLightDM::MockController::instance()->reset();
56 void testMangleColor()
66 void testMangleColor()
@@ -65,8 +75,30 @@ private Q_SLOTS:
65 QVERIFY(name == "empty-name");
75 QVERIFY(name == "empty-name");
80+ // sanity check that it doesn't start already present
81+ QCOMPARE(findName(model, QStringLiteral("*guest")), -1);
83+ QLightDM::MockController::instance()->setHasGuestAccountHint(true);
86+ int i = findName(model, QStringLiteral("*guest"));
88+ QCOMPARE(i, model->count() - 1);
90+ auto realName = model->data(i, QLightDM::UsersModel::RealNameRole).toString();
91+ QCOMPARE(realName, QStringLiteral("Guest Session"));
93+ auto loggedIn = model->data(i, QLightDM::UsersModel::LoggedInRole).toBool();
96+ auto session = model->data(i, QLightDM::UsersModel::SessionRole).toString();
97+ QCOMPARE(session, Greeter::instance()->defaultSessionHint());
69− UsersModel *model;
101+ UsersModel *model = nullptr;
72QTEST_MAIN(GreeterUsersModelTest)
104QTEST_MAIN(GreeterUsersModelTest)