on xenial help sign in
Add mocks and a quick test for our passthrough to lightdm and logind
1dbcfc3Michael Terry
plugins/Unity/Session/CMakeLists.txt+2
@@ -6,6 +6,8 @@ include_directories(
6 ${libunity8-private_SOURCE_DIR}
6 ${libunity8-private_SOURCE_DIR}
7)
7)
8
8
9+add_definitions(-DSM_BUSNAME=systemBus)
10+
9set(QMLSESSIONPLUGIN_SRC
11set(QMLSESSIONPLUGIN_SRC
10 plugin.cpp
12 plugin.cpp
11 dbusunitysessionservice.cpp
13 dbusunitysessionservice.cpp
plugins/Unity/Session/dbusunitysessionservice.cpp+20−16
@@ -64,19 +64,19 @@ public:
64 QStringLiteral("GetSessionByPID"));
64 QStringLiteral("GetSessionByPID"));
65 msg << (quint32) getpid();
65 msg << (quint32) getpid();
66
66
67− QDBusReply<QDBusObjectPath> reply = QDBusConnection::systemBus().call(msg);
67+ QDBusReply<QDBusObjectPath> reply = QDBusConnection::SM_BUSNAME().call(msg);
68 if (reply.isValid()) {
68 if (reply.isValid()) {
69 logindSessionPath = reply.value().path();
69 logindSessionPath = reply.value().path();
70
70
71 // start watching the Active property
71 // start watching the Active property
72− QDBusConnection::systemBus().connect(LOGIN1_SERVICE, logindSessionPath, QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("PropertiesChanged"),
72+ QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, logindSessionPath, QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("PropertiesChanged"),
73− this, SLOT(onPropertiesChanged(QString,QVariantMap,QStringList)));
73+ this, SLOT(onPropertiesChanged(QString,QVariantMap,QStringList)));
74
74
75 setupSystemdInhibition();
75 setupSystemdInhibition();
76
76
77 // re-enable the inhibition upon resume from sleep
77 // re-enable the inhibition upon resume from sleep
78− QDBusConnection::systemBus().connect(LOGIN1_SERVICE, LOGIN1_PATH, LOGIN1_IFACE, QStringLiteral("PrepareForSleep"),
78+ QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, LOGIN1_PATH, LOGIN1_IFACE, QStringLiteral("PrepareForSleep"),
79− this, SLOT(onResuming(bool)));
79+ this, SLOT(onResuming(bool)));
80 } else {
80 } else {
81 qWarning() << "Failed to get logind session path" << reply.error().message();
81 qWarning() << "Failed to get logind session path" << reply.error().message();
82 }
82 }
@@ -96,7 +96,7 @@ public:
96 msg << "Unity8 handles power events"; // why
96 msg << "Unity8 handles power events"; // why
97 msg << "block"; // mode
97 msg << "block"; // mode
98
98
99− QDBusPendingCall pendingCall = QDBusConnection::systemBus().asyncCall(msg);
99+ QDBusPendingCall pendingCall = QDBusConnection::SM_BUSNAME().asyncCall(msg);
100 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
100 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
101 connect(watcher, &QDBusPendingCallWatcher::finished,
101 connect(watcher, &QDBusPendingCallWatcher::finished,
102 this, [this](QDBusPendingCallWatcher* watcher) {
102 this, [this](QDBusPendingCallWatcher* watcher) {
@@ -114,7 +114,7 @@ public:
114 bool checkLogin1Call(const QString &method) const
114 bool checkLogin1Call(const QString &method) const
115 {
115 {
116 QDBusMessage msg = QDBusMessage::createMethodCall(LOGIN1_SERVICE, LOGIN1_PATH, LOGIN1_IFACE, method);
116 QDBusMessage msg = QDBusMessage::createMethodCall(LOGIN1_SERVICE, LOGIN1_PATH, LOGIN1_IFACE, method);
117− QDBusReply<QString> reply = QDBusConnection::systemBus().call(msg);
117+ QDBusReply<QString> reply = QDBusConnection::SM_BUSNAME().call(msg);
118 return reply.isValid() && (reply == QStringLiteral("yes") || reply == QStringLiteral("challenge"));
118 return reply.isValid() && (reply == QStringLiteral("yes") || reply == QStringLiteral("challenge"));
119 }
119 }
120
120
@@ -125,7 +125,7 @@ public:
125 LOGIN1_IFACE,
125 LOGIN1_IFACE,
126 method);
126 method);
127 msg.setArguments(args);
127 msg.setArguments(args);
128− QDBusConnection::systemBus().asyncCall(msg);
128+ QDBusConnection::SM_BUSNAME().asyncCall(msg);
129 }
129 }
130
130
131 void setActive(bool active)
131 void setActive(bool active)
@@ -157,7 +157,7 @@ public:
157 msg << LOGIN1_SESSION_IFACE;
157 msg << LOGIN1_SESSION_IFACE;
158 msg << ACTIVE_KEY;
158 msg << ACTIVE_KEY;
159
159
160− QDBusPendingCall pendingCall = QDBusConnection::systemBus().asyncCall(msg);
160+ QDBusPendingCall pendingCall = QDBusConnection::SM_BUSNAME().asyncCall(msg);
161 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
161 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
162 connect(watcher, &QDBusPendingCallWatcher::finished,
162 connect(watcher, &QDBusPendingCallWatcher::finished,
163 this, [this](QDBusPendingCallWatcher* watcher) {
163 this, [this](QDBusPendingCallWatcher* watcher) {
@@ -191,7 +191,7 @@ public:
191 msg << LOGIN1_SESSION_IFACE;
191 msg << LOGIN1_SESSION_IFACE;
192 msg << IDLE_SINCE_KEY;
192 msg << IDLE_SINCE_KEY;
193
193
194− QDBusReply<QVariant> reply = QDBusConnection::systemBus().call(msg);
194+ QDBusReply<QVariant> reply = QDBusConnection::SM_BUSNAME().call(msg);
195 if (reply.isValid()) {
195 if (reply.isValid()) {
196 return reply.value().value<quint64>();
196 return reply.value().value<quint64>();
197 } else {
197 } else {
@@ -208,7 +208,7 @@ public:
208 LOGIN1_SESSION_IFACE,
208 LOGIN1_SESSION_IFACE,
209 QStringLiteral("SetIdleHint"));
209 QStringLiteral("SetIdleHint"));
210 msg << idle;
210 msg << idle;
211− QDBusConnection::systemBus().asyncCall(msg);
211+ QDBusConnection::SM_BUSNAME().asyncCall(msg);
212 }
212 }
213
213
214private Q_SLOTS:
214private Q_SLOTS:
@@ -244,10 +244,10 @@ DBusUnitySessionService::DBusUnitySessionService()
244{
244{
245 if (!d->logindSessionPath.isEmpty()) {
245 if (!d->logindSessionPath.isEmpty()) {
246 // connect our PromptLock() slot to the logind's session Lock() signal
246 // connect our PromptLock() slot to the logind's session Lock() signal
247− QDBusConnection::systemBus().connect(LOGIN1_SERVICE, d->logindSessionPath, LOGIN1_SESSION_IFACE, QStringLiteral("Lock"), this, SLOT(PromptLock()));
247+ QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, d->logindSessionPath, LOGIN1_SESSION_IFACE, QStringLiteral("Lock"), this, SLOT(PromptLock()));
248 // ... and our Unlocked() signal to the logind's session Unlock() signal
248 // ... and our Unlocked() signal to the logind's session Unlock() signal
249 // (lightdm handles the unlocking by calling logind's Unlock method which in turn emits this signal we connect to)
249 // (lightdm handles the unlocking by calling logind's Unlock method which in turn emits this signal we connect to)
250− QDBusConnection::systemBus().connect(LOGIN1_SERVICE, d->logindSessionPath, LOGIN1_SESSION_IFACE, QStringLiteral("Unlock"), this, SIGNAL(Unlocked()));
250+ QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, d->logindSessionPath, LOGIN1_SESSION_IFACE, QStringLiteral("Unlock"), this, SIGNAL(Unlocked()));
251 connect(d, &DBusUnitySessionServicePrivate::prepareForSleep, this, &DBusUnitySessionService::PromptLock);
251 connect(d, &DBusUnitySessionServicePrivate::prepareForSleep, this, &DBusUnitySessionService::PromptLock);
252 } else {
252 } else {
253 qWarning() << "Failed to connect to logind's session Lock/Unlock signals";
253 qWarning() << "Failed to connect to logind's session Lock/Unlock signals";
@@ -332,14 +332,18 @@ QString DBusUnitySessionService::HostName() const
332
332
333void DBusUnitySessionService::PromptLock()
333void DBusUnitySessionService::PromptLock()
334{
334{
335− // Fast lock (no animation)
335+ // Prompt as in quick. No locking animation needed. Usually used by
336+ // indicator-session in combination with a switch to greeter or other
337+ // user session.
336 Q_EMIT LockRequested();
338 Q_EMIT LockRequested();
337 Q_EMIT lockRequested();
339 Q_EMIT lockRequested();
338}
340}
339
341
340void DBusUnitySessionService::Lock()
342void DBusUnitySessionService::Lock()
341{
343{
342− // Slower lock (with animation)
344+ // Normal lock (with animation, as compared to PromptLock above). Usually
345+ // used by indicator-session to lock the session in place.
346+ //
343 // FIXME: We also -- as a bit of a hack around indicator-session not fully
347 // FIXME: We also -- as a bit of a hack around indicator-session not fully
344 // supporting a phone profile -- switch to greeter here. The unity7 flow is
348 // supporting a phone profile -- switch to greeter here. The unity7 flow is
345 // that the user chooses "Lock/Switch" from the indicator, and then can go
349 // that the user chooses "Lock/Switch" from the indicator, and then can go
@@ -371,7 +375,7 @@ void DBusUnitySessionService::switchToGreeter()
371 QStringLiteral("org.freedesktop.DisplayManager.Session"),
375 QStringLiteral("org.freedesktop.DisplayManager.Session"),
372 QStringLiteral("Lock"));
376 QStringLiteral("Lock"));
373
377
374− QDBusPendingCall pendingCall = QDBusConnection::systemBus().asyncCall(msg);
378+ QDBusPendingCall pendingCall = QDBusConnection::SM_BUSNAME().asyncCall(msg);
375 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
379 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
376 connect(watcher, &QDBusPendingCallWatcher::finished,
380 connect(watcher, &QDBusPendingCallWatcher::finished,
377 this, [this](QDBusPendingCallWatcher* watcher) {
381 this, [this](QDBusPendingCallWatcher* watcher) {
tests/CMakeLists.txt+6
@@ -126,6 +126,12 @@ function(add_unity8_qmlbenchmark PATH COMPONENT_NAME ITERATIONS)
126 add_unity8_qmltest(${PATH} ${COMPONENT_NAME} ITERATIONS ${ITERATIONS} ${ARGN})
126 add_unity8_qmltest(${PATH} ${COMPONENT_NAME} ITERATIONS ${ITERATIONS} ${ARGN})
127endfunction()
127endfunction()
128
128
129+# used to make dbus adaptor classes from xml to mock system services
130+if(DEFINED ENV{DEB_BUILD_MULTIARCH})
131+ set(QDBUSXML2CPP_EXECUTABLE "/usr/lib/$ENV{DEB_BUILD_MULTIARCH}/qt5/bin/qdbusxml2cpp")
132+else()
133+ FIND_PROGRAM(QDBUSXML2CPP_EXECUTABLE qdbusxml2cpp)
134+endif()
129
135
130# Actual test definitions
136# Actual test definitions
131add_subdirectory(plugins)
137add_subdirectory(plugins)
tests/plugins/AccountsService/CMakeLists.txt−5
@@ -1,8 +1,3 @@
1−if(DEFINED ENV{DEB_BUILD_MULTIARCH})
2− set(QDBUSXML2CPP_EXECUTABLE "/usr/lib/$ENV{DEB_BUILD_MULTIARCH}/qt5/bin/qdbusxml2cpp")
3−else()
4− FIND_PROGRAM(QDBUSXML2CPP_EXECUTABLE qdbusxml2cpp)
5−endif()
6macro(make_dbus_class NAME INTERFACE)
1macro(make_dbus_class NAME INTERFACE)
7 if(${CMAKE_CURRENT_SOURCE_DIR}/interfaces.xml IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/${NAME}Adaptor.h)
2 if(${CMAKE_CURRENT_SOURCE_DIR}/interfaces.xml IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/${NAME}Adaptor.h)
8 execute_process(COMMAND ${QDBUSXML2CPP_EXECUTABLE} -c ${NAME}Adaptor -i types.h -a ${CMAKE_CURRENT_BINARY_DIR}/${NAME}Adaptor ${CMAKE_CURRENT_SOURCE_DIR}/interfaces.xml ${INTERFACE})
3 execute_process(COMMAND ${QDBUSXML2CPP_EXECUTABLE} -c ${NAME}Adaptor -i types.h -a ${CMAKE_CURRENT_BINARY_DIR}/${NAME}Adaptor ${CMAKE_CURRENT_SOURCE_DIR}/interfaces.xml ${INTERFACE})
tests/plugins/Unity/Session/CMakeLists.txt+29−1
@@ -1,3 +1,13 @@
1+macro(make_dbus_class NAME INTERFACE)
2+ if(${CMAKE_CURRENT_SOURCE_DIR}/interfaces.xml IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/${NAME}Adaptor.h)
3+ execute_process(COMMAND ${QDBUSXML2CPP_EXECUTABLE} -c ${NAME}Adaptor -a ${CMAKE_CURRENT_BINARY_DIR}/${NAME}Adaptor ${CMAKE_CURRENT_SOURCE_DIR}/interfaces.xml ${INTERFACE})
4+ endif()
5+endmacro(make_dbus_class)
6+
7+make_dbus_class(LightDMSession org.freedesktop.DisplayManager.Session)
8+make_dbus_class(LogindManager org.freedesktop.login1.Manager)
9+make_dbus_class(LogindSession org.freedesktop.login1.Session)
10+
1include_directories(
11include_directories(
2 ${CMAKE_CURRENT_BINARY_DIR}
12 ${CMAKE_CURRENT_BINARY_DIR}
3 ${CMAKE_SOURCE_DIR}/plugins/Unity/Session
13 ${CMAKE_SOURCE_DIR}/plugins/Unity/Session
@@ -9,6 +19,17 @@ add_definitions(-DSM_BUSNAME=sessionBus)
9add_definitions(-DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
19add_definitions(-DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
10add_definitions(-DSESSION_TESTING)
20add_definitions(-DSESSION_TESTING)
11
21
22+### LightDMServer
23+add_executable(LightDMServer
24+ ${CMAKE_CURRENT_BINARY_DIR}/LightDMSessionAdaptor.cpp
25+ ${CMAKE_CURRENT_BINARY_DIR}/LogindManagerAdaptor.cpp
26+ ${CMAKE_CURRENT_BINARY_DIR}/LogindSessionAdaptor.cpp
27+ LightDMServer.cpp
28+ LogindServer.cpp
29+ server.cpp
30+)
31+qt5_use_modules(LightDMServer Core DBus)
32+
12### SessionBackendTest
33### SessionBackendTest
13add_executable(sessionbackendtestExec
34add_executable(sessionbackendtestExec
14 sessionbackendtest.cpp
35 sessionbackendtest.cpp
@@ -21,6 +42,13 @@ target_link_libraries(sessionbackendtestExec
21qt5_use_modules(sessionbackendtestExec Test Core Qml DBus)
42qt5_use_modules(sessionbackendtestExec Test Core Qml DBus)
22
43
23add_unity8_unittest(SessionBackend dbus-test-runner
44add_unity8_unittest(SessionBackend dbus-test-runner
45+ ENVIRONMENT XDG_SESSION_PATH=/session
24 ARG_PREFIX "--parameter"
46 ARG_PREFIX "--parameter"
47+ ARGS
48+ --task $<TARGET_FILE:LightDMServer>
49+ --task-name server
50+ --ignore-return
25− ARGS --task $<TARGET_FILE:sessionbackendtestExec>
51+ --task $<TARGET_FILE:sessionbackendtestExec>
52+ --task-name client
53+ --wait-for org.freedesktop.DisplayManager
26)
54)
tests/plugins/Unity/Session/LightDMServer.cppnew file+29
@@ -0,0 +1,29 @@
1+/*
2+ * Copyright 2016 Canonical Ltd.
3+ *
4+ * This program is free software: you can redistribute it and/or modify it
5+ * under the terms of the GNU General Public License version 3, as published
6+ * by the Free Software Foundation.
7+ *
8+ * This program is distributed in the hope that it will be useful, but
9+ * WITHOUT ANY WARRANTY; without even the implied warranties of
10+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11+ * PURPOSE. See the GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * version 3 along with this program. If not, see
15+ * <http://www.gnu.org/licenses/>
16+ */
17+
18+#include "LightDMServer.h"
19+
20+LightDMServer::LightDMServer(QObject *logind, QObject *parent)
21+ : QObject(parent)
22+ , m_logind(logind)
23+{
24+}
25+
26+void LightDMServer::Lock()
27+{
28+ QMetaObject::invokeMethod(m_logind, "Lock");
29+}
tests/plugins/Unity/Session/LightDMServer.hnew file+38
@@ -0,0 +1,38 @@
1+/*
2+ * Copyright 2016 Canonical Ltd.
3+ *
4+ * This program is free software: you can redistribute it and/or modify it
5+ * under the terms of the GNU General Public License version 3, as published
6+ * by the Free Software Foundation.
7+ *
8+ * This program is distributed in the hope that it will be useful, but
9+ * WITHOUT ANY WARRANTY; without even the implied warranties of
10+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11+ * PURPOSE. See the GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * version 3 along with this program. If not, see
15+ * <http://www.gnu.org/licenses/>
16+ */
17+
18+#ifndef UNITY_LIGHTDMSERVER_H
19+#define UNITY_LIGHTDMSERVER_H
20+
21+#include <QDBusContext>
22+#include <QObject>
23+
24+class LightDMServer: public QObject, protected QDBusContext
25+{
26+ Q_OBJECT
27+
28+public:
29+ explicit LightDMServer(QObject *logind, QObject *parent = nullptr);
30+
31+public Q_SLOTS:
32+ void Lock();
33+
34+private:
35+ QObject *m_logind;
36+};
37+
38+#endif
tests/plugins/Unity/Session/LogindServer.cppnew file+28
@@ -0,0 +1,28 @@
1+/*
2+ * Copyright 2016 Canonical Ltd.
3+ *
4+ * This program is free software: you can redistribute it and/or modify it
5+ * under the terms of the GNU General Public License version 3, as published
6+ * by the Free Software Foundation.
7+ *
8+ * This program is distributed in the hope that it will be useful, but
9+ * WITHOUT ANY WARRANTY; without even the implied warranties of
10+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11+ * PURPOSE. See the GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * version 3 along with this program. If not, see
15+ * <http://www.gnu.org/licenses/>
16+ */
17+
18+#include "LogindServer.h"
19+
20+LogindServer::LogindServer(QObject *parent)
21+ : QObject(parent)
22+{
23+}
24+
25+QDBusObjectPath LogindServer::GetSessionByPID(quint32)
26+{
27+ return QDBusObjectPath("/logindsession");
28+}
tests/plugins/Unity/Session/LogindServer.hnew file+41
@@ -0,0 +1,41 @@
1+/*
2+ * Copyright 2016 Canonical Ltd.
3+ *
4+ * This program is free software: you can redistribute it and/or modify it
5+ * under the terms of the GNU General Public License version 3, as published
6+ * by the Free Software Foundation.
7+ *
8+ * This program is distributed in the hope that it will be useful, but
9+ * WITHOUT ANY WARRANTY; without even the implied warranties of
10+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11+ * PURPOSE. See the GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * version 3 along with this program. If not, see
15+ * <http://www.gnu.org/licenses/>
16+ */
17+
18+#ifndef UNITY_LOGINDSERVER_H
19+#define UNITY_LOGINDSERVER_H
20+
21+#include <QDBusContext>
22+#include <QDBusObjectPath>
23+#include <QObject>
24+
25+class LogindServer: public QObject, protected QDBusContext
26+{
27+ Q_OBJECT
28+
29+public:
30+ explicit LogindServer(QObject *parent = nullptr);
31+
32+public Q_SLOTS:
33+ QDBusObjectPath GetSessionByPID(quint32 pid);
34+
35+Q_SIGNALS:
36+ void Lock();
37+ void Unlock();
38+ void PrepareForSleep();
39+};
40+
41+#endif
tests/plugins/Unity/Session/interfaces.xmlnew file+16
@@ -0,0 +1,16 @@
1+<node>
2+ <interface name="org.freedesktop.DisplayManager.Session">
3+ <method name="Lock" />
4+ </interface>
5+ <interface name="org.freedesktop.login1.Manager">
6+ <method name="GetSessionByPID">
7+ <arg name="pid" type="u" direction="in" />
8+ <arg name="session" type="o" direction="out" />
9+ </method>
10+ <signal name="PrepareForSleep" />
11+ </interface>
12+ <interface name="org.freedesktop.login1.Session">
13+ <signal name="Lock" />
14+ <signal name="Unlock" />
15+ </interface>
16+</node>
tests/plugins/Unity/Session/server.cppnew file+50
@@ -0,0 +1,50 @@
1+/*
2+ * Copyright 2016 Canonical Ltd.
3+ *
4+ * This program is free software: you can redistribute it and/or modify it
5+ * under the terms of the GNU General Public License version 3, as published
6+ * by the Free Software Foundation.
7+ *
8+ * This program is distributed in the hope that it will be useful, but
9+ * WITHOUT ANY WARRANTY; without even the implied warranties of
10+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11+ * PURPOSE. See the GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * version 3 along with this program. If not, see
15+ * <http://www.gnu.org/licenses/>
16+ */
17+
18+#include "LightDMServer.h"
19+#include "LightDMSessionAdaptor.h"
20+#include "LogindManagerAdaptor.h"
21+#include "LogindServer.h"
22+#include "LogindSessionAdaptor.h"
23+#include <QCoreApplication>
24+
25+int main(int argc, char *argv[])
26+{
27+ QCoreApplication a(argc, argv);
28+
29+ auto logind = new LogindServer(&a);
30+ new LogindManagerAdaptor(logind);
31+ new LogindSessionAdaptor(logind);
32+
33+ auto lightdm = new LightDMServer(logind, &a);
34+ new LightDMSessionAdaptor(lightdm);
35+
36+ // We use the session bus for testing. The real plugin uses the system bus
37+ auto connection = QDBusConnection::sessionBus();
38+ if (!connection.registerObject("/org/freedesktop/login1", logind))
39+ return 1;
40+ if (!connection.registerObject("/logindsession", logind))
41+ return 1;
42+ if (!connection.registerService("org.freedesktop.login1"))
43+ return 1;
44+ if (!connection.registerObject("/session", lightdm))
45+ return 1;
46+ if (!connection.registerService("org.freedesktop.DisplayManager"))
47+ return 1;
48+
49+ return a.exec();
50+}
tests/plugins/Unity/Session/sessionbackendtest.cpp+3−1
@@ -61,6 +61,8 @@ private Q_SLOTS:
61 QTest::newRow("Reboot") << "RequestReboot" << "RebootRequested(bool)";
61 QTest::newRow("Reboot") << "RequestReboot" << "RebootRequested(bool)";
62 QTest::newRow("Shutdown") << "RequestShutdown" << "ShutdownRequested(bool)";
62 QTest::newRow("Shutdown") << "RequestShutdown" << "ShutdownRequested(bool)";
63 QTest::newRow("PromptLock") << "PromptLock" << "LockRequested()";
63 QTest::newRow("PromptLock") << "PromptLock" << "LockRequested()";
64+ QTest::newRow("Lock") << "Lock" << "LockRequested()";
65+ QTest::newRow("LockLightDM") << "Lock" << "Locked()"; // happens when we lock LightDM, only for Lock()
64 }
66 }
65
67
66 void testUnitySessionLogoutRequested() {
68 void testUnitySessionLogoutRequested() {
@@ -76,7 +78,7 @@ private Q_SLOTS:
76 QDBusReply<void> reply = dbusUnitySession->call(method);
78 QDBusReply<void> reply = dbusUnitySession->call(method);
77 QCOMPARE(reply.isValid(), true);
79 QCOMPARE(reply.isValid(), true);
78
80
79− QCOMPARE(spy.count(), 1);
81+ QTRY_COMPARE(spy.count(), 1);
80 }
82 }
81
83
82 void testGnomeSessionWrapper_data() {
84 void testGnomeSessionWrapper_data() {