@@ -27,8 +27,26 @@ class GreeterDBusTest : public QObject
31+ void PropertiesChangedRelay(const QString &interface, const QVariantMap &changed, const QStringList &invalidated);
30private Q_SLOTS:
33private Q_SLOTS:
37+ // Qt doesn't like us connecting to PropertiesChanged using normal
38+ // SIGNAL method, because QtDBus doesn't know about PropertiesChanged.
39+ // So we connect the hard way for the benefit of any tests that want
41+ QDBusConnection::sessionBus().connect(
42+ "com.canonical.UnityGreeter",
44+ "org.freedesktop.DBus.Properties",
47+ SIGNAL(PropertiesChangedRelay(const QString&, const QVariantMap&, const QStringList&)));
32 void init()
50 void init()
34 view = new QQuickView();
52 view = new QQuickView();
@@ -100,13 +118,41 @@ private Q_SLOTS:
100 QVERIFY(arguments.at(0).toString() == "has-password");
118 QVERIFY(arguments.at(0).toString() == "has-password");
103− void testEntryIsLockedGet()
121+ void testActiveEntryChanged()
123+ QSignalSpy spy(this, SIGNAL(PropertiesChangedRelay(QString, QVariantMap, QStringList)));
105 greeter->authenticate("has-password");
124 greeter->authenticate("has-password");
127+ QCOMPARE(spy.count(), 1);
128+ QList<QVariant> arguments = spy.takeFirst();
129+ QVERIFY(arguments.at(0).toString() == "com.canonical.UnityGreeter.List");
130+ QVERIFY(arguments.at(1).toMap().contains("ActiveEntry"));
131+ QVERIFY(arguments.at(1).toMap()["ActiveEntry"] == "has-password");
134+ void testEntryIsLockedGet()
106 QVERIFY(dbusList->property("EntryIsLocked").toBool());
136 QVERIFY(dbusList->property("EntryIsLocked").toBool());
108 greeter->authenticate("no-password");
138 greeter->authenticate("no-password");
109 QVERIFY(!dbusList->property("EntryIsLocked").toBool());
139 QVERIFY(!dbusList->property("EntryIsLocked").toBool());
141+ greeter->authenticate("has-password");
142+ QVERIFY(dbusList->property("EntryIsLocked").toBool());
145+ void testEntryIsLockedChanged()
147+ QSignalSpy spy(this, SIGNAL(PropertiesChangedRelay(QString, QVariantMap, QStringList)));
148+ greeter->authenticate("no-password");
151+ QCOMPARE(spy.count(), 2); // once for locked, once for user; first will be locked mode
152+ QList<QVariant> arguments = spy.takeFirst();
153+ QVERIFY(arguments.at(0).toString() == "com.canonical.UnityGreeter.List");
154+ QVERIFY(arguments.at(1).toMap().contains("EntryIsLocked"));
155+ QVERIFY(arguments.at(1).toMap()["EntryIsLocked"] == false);