@@ -0,0 +1,120 @@
2+ * Copyright (C) 2013 Canonical, Ltd.
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+#include <QDBusInterface>
26+class GreeterDBusTest : public QObject
34+ view = new QQuickView();
35+ view->setSource(QUrl::fromLocalFile(CURRENT_SOURCE_DIR "/greeter.qml"));
36+ greeter = dynamic_cast<Greeter*>(view->rootObject()->property("greeter").value<QObject*>());
38+ QVERIFY(greeter->authenticationUser() == "");
40+ QTest::qWaitForWindowExposed(view);
42+ dbusList = new QDBusInterface("com.canonical.UnityGreeter",
44+ "com.canonical.UnityGreeter.List",
45+ QDBusConnection::sessionBus(), view);
46+ QVERIFY(dbusList->isValid());
54+ void testGetActiveEntry()
56+ greeter->authenticate("has-password");
58+ QDBusReply<QString> reply = dbusList->call("GetActiveEntry");
59+ QVERIFY(reply.isValid());
60+ QVERIFY(reply.value() == "has-password");
63+ void testSetActiveEntry()
65+ QSignalSpy spy(greeter, SIGNAL(requestAuthenticationUser(QString)));
66+ QDBusReply<void> reply = dbusList->call("SetActiveEntry", "has-password");
67+ QVERIFY(reply.isValid());
70+ QCOMPARE(spy.count(), 1);
71+ QList<QVariant> arguments = spy.takeFirst();
72+ QVERIFY(arguments.at(0).toString() == "has-password");
75+ void testEntrySelectedSignal()
77+ QSignalSpy spy(dbusList, SIGNAL(EntrySelected(QString)));
78+ greeter->authenticate("has-password");
81+ QCOMPARE(spy.count(), 1);
82+ QList<QVariant> arguments = spy.takeFirst();
83+ QVERIFY(arguments.at(0).toString() == "has-password");
86+ void testActiveEntryGet()
88+ greeter->authenticate("has-password");
89+ QVERIFY(dbusList->property("ActiveEntry").toString() == "has-password");
92+ void testActiveEntrySet()
94+ QSignalSpy spy(greeter, SIGNAL(requestAuthenticationUser(QString)));
95+ QVERIFY(dbusList->setProperty("ActiveEntry", "has-password"));
98+ QCOMPARE(spy.count(), 1);
99+ QList<QVariant> arguments = spy.takeFirst();
100+ QVERIFY(arguments.at(0).toString() == "has-password");
103+ void testEntryIsLockedGet()
105+ greeter->authenticate("has-password");
106+ QVERIFY(dbusList->property("EntryIsLocked").toBool());
108+ greeter->authenticate("no-password");
109+ QVERIFY(!dbusList->property("EntryIsLocked").toBool());
115+ QDBusInterface *dbusList;
118+QTEST_MAIN(GreeterDBusTest)