@@ -15,6 +15,7 @@
17#include "Greeter.h"
17#include "Greeter.h"
18+#include "PromptsModel.h"
19#include <QCoreApplication>
20#include <QCoreApplication>
20#include <QDBusInterface>
21#include <QDBusInterface>
@@ -137,11 +138,13 @@ private Q_SLOTS:
137 void testActiveEntryChanged()
138 void testActiveEntryChanged()
139 QSignalSpy spy(this, &GreeterDBusTest::PropertiesChangedRelay);
140 QSignalSpy spy(this, &GreeterDBusTest::PropertiesChangedRelay);
140 greeter->authenticate("has-password");
142 greeter->authenticate("has-password");
144+ // EntryIsLocked's default is true, thus only single property change.
142− QTRY_COMPARE(spy.count(), 2); // EntryIsLocked then ActiveEntry
145+ QTRY_COMPARE(spy.count(), 1);
144− QList<QVariant> arguments = spy[1];
147+ QList<QVariant> arguments = spy[0];
145 QVERIFY(arguments.at(0).toString() == "com.canonical.UnityGreeter.List");
148 QVERIFY(arguments.at(0).toString() == "com.canonical.UnityGreeter.List");
146 QVERIFY(arguments.at(1).toMap().contains("ActiveEntry"));
149 QVERIFY(arguments.at(1).toMap().contains("ActiveEntry"));
147 QVERIFY(arguments.at(1).toMap()["ActiveEntry"] == "has-password");
150 QVERIFY(arguments.at(1).toMap()["ActiveEntry"] == "has-password");
@@ -154,19 +157,29 @@ private Q_SLOTS:
154 greeter->authenticate("no-password");
157 greeter->authenticate("no-password");
155 QTRY_VERIFY(!dbusList->property("EntryIsLocked").toBool());
158 QTRY_VERIFY(!dbusList->property("EntryIsLocked").toBool());
160+ QSignalSpy promptSpy(greeter->promptsModel(), &PromptsModel::countChanged);
161+ QSignalSpy successSpy(greeter, &Greeter::loginSuccess);
157 greeter->authenticate("has-password");
163 greeter->authenticate("has-password");
158 QTRY_VERIFY(dbusList->property("EntryIsLocked").toBool());
164 QTRY_VERIFY(dbusList->property("EntryIsLocked").toBool());
165+ // Make sure that EntryIsLocked stays `true` after authenticated.
166+ // Regression test for https://github.com/ubports/ubuntu-touch/issues/1406
168+ greeter->respond(QStringLiteral("password"));
170+ QVERIFY(dbusList->property("EntryIsLocked").toBool());
161 void testEntryIsLockedChanged()
173 void testEntryIsLockedChanged()
163 QSignalSpy spy(this, &GreeterDBusTest::PropertiesChangedRelay);
175 QSignalSpy spy(this, &GreeterDBusTest::PropertiesChangedRelay);
164 greeter->authenticate("no-password");
177 greeter->authenticate("no-password");
166− // EntryIsLocked=true, ActiveEntry, then EntryIsLocked=false
179+ // ActiveEntry, then EntryIsLocked=false
167− QTRY_COMPARE(spy.count(), 3);
180+ QTRY_COMPARE(spy.count(), 2);
169− QList<QVariant> arguments = spy[2];
182+ QList<QVariant> arguments = spy[1];
170 QVERIFY(arguments.at(0).toString() == "com.canonical.UnityGreeter.List");
183 QVERIFY(arguments.at(0).toString() == "com.canonical.UnityGreeter.List");
171 QVERIFY(arguments.at(1).toMap().contains("EntryIsLocked"));
184 QVERIFY(arguments.at(1).toMap().contains("EntryIsLocked"));
172 QVERIFY(arguments.at(1).toMap()["EntryIsLocked"] == false);
185 QVERIFY(arguments.at(1).toMap()["EntryIsLocked"] == false);