Merge lp:~mterry/unity8/dbus-race-fix into lp:unity8

Proposed by Michael Terry
Status: Merged
Approved by: Michael Zanetti
Approved revision: 1344
Merged at revision: 1382
Proposed branch: lp:~mterry/unity8/dbus-race-fix
Merge into: lp:unity8
Diff against target: 935 lines (+337/-130)
28 files modified
plugins/LightDM/CMakeLists.txt (+2/-0)
plugins/LightDM/DBusGreeter.cpp (+3/-24)
plugins/LightDM/DBusGreeter.h (+3/-6)
plugins/LightDM/DBusGreeterList.cpp (+3/-24)
plugins/LightDM/DBusGreeterList.h (+3/-6)
plugins/LightDM/plugin.cpp (+2/-9)
plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.cpp (+1/-5)
plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.h (+2/-2)
plugins/Unity/Launcher/CMakeLists.txt (+5/-1)
plugins/Unity/Launcher/dbusinterface.cpp (+3/-36)
plugins/Unity/Launcher/dbusinterface.h (+2/-5)
plugins/Unity/Session/CMakeLists.txt (+5/-1)
plugins/Unity/Session/dbusunitysessionservice.cpp (+2/-8)
plugins/Unity/Session/dbusunitysessionservice.h (+2/-2)
qml/Shell.qml (+13/-0)
src/libunity8-private/CMakeLists.txt (+2/-0)
src/libunity8-private/unitydbusobject.cpp (+86/-0)
src/libunity8-private/unitydbusobject.h (+46/-0)
src/libunity8-private/unitydbusvirtualobject.cpp (+83/-0)
src/libunity8-private/unitydbusvirtualobject.h (+47/-0)
tests/mocks/LightDM/CMakeLists.txt (+2/-0)
tests/plugins/Unity/Launcher/CMakeLists.txt (+5/-1)
tests/plugins/Unity/Launcher/launchermodeltest.cpp (+1/-0)
tests/plugins/Unity/Session/CMakeLists.txt (+4/-0)
tests/plugins/Unity/Session/sessionbackendtest.cpp (+1/-0)
tests/qmltests/tst_Shell.qml (+3/-0)
tests/qmltests/tst_ShellWithPin.qml (+3/-0)
tests/qmltests/tst_TabletShell.qml (+3/-0)
To merge this branch: bzr merge lp:~mterry/unity8/dbus-race-fix
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Michael Zanetti (community) Approve
Unity Team Pending
Review via email: mp+237594@code.launchpad.net

Commit message

Fix a race between Qml loading and DBus registration that caused problems when jenkins tried to unlock the phone.

There is a small window of opportunity between when a Qml plugin registers on DBus and when the Qml is finished loading and hooking up signals. If the unlock-device script happens to hit that window, it will report success (DBus method was called), but the screen won't unlock (Qml never saw signal).

An easy fix is to just wait for the eventloop to be idle before registering on DBus. That's what I've done in this branch. In addition to fixing the proximate problem (LightDM), I've also fixed other Qml plugins that do the same thing.

Description of the change

Fix a race between Qml loading and DBus registration that caused problems when jenkins tried to unlock the phone.

There is a small window of opportunity between when a Qml plugin registers on DBus and when the Qml is finished loading and hooking up signals. If the unlock-device script happens to hit that window, it will report success (DBus method was called), but the screen won't unlock (Qml never saw signal).

An easy fix is to just wait for the eventloop to be idle before registering on DBus. That's what I've done in this branch. In addition to fixing the proximate problem (LightDM), I've also fixed other Qml plugins that do the same thing.

This unlock problem didn't appear until recently. Presumably startup timing changed. But you can test this bug before and after this branch with the following script:

adb reboot && adb wait-for-device && adb shell 'while ! gdbus call --session --dest com.canonical.UnityGreeter --object-path / --method com.canonical.UnityGreeter.HideGreeter 2>/dev/null 1>&2; do echo -n .; done' && echo -e '\nDid it work?'

== Checklist ==

 * Are there any related MPs required for this MP to build/function as expected? Please list.
 No

 * Did you perform an exploratory manual test run of your code change and any related functionality?
 Yes

 * Did you make sure that your branch does not contain spurious tags?
 Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
 NA

 * If you changed the UI, has there been a design review?
 NA

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

Nowadays we have src/libunity-private which already contains D-Bus related stuff. It has some common interface for the client side of things.

Do you think you could create some reusable server-side class in there? Something like UnityDBusService, that handles registration using this timer where all plugins exposing services would just subclass it without having to worry about such races?

review: Needs Information
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Terry (mterry) wrote :

OK, I've expanded this a bit, per your direction.

- I've added two classes UnityDBusObject and UnityDBusVirtualObject. Each with similar API to make it easier to create little DBus services in Unity.

- I actually let the dash communicator continue registering on DBus immediately, since it was noticeably slower to popuplate the dash if I did not. The other services seem fine in my quick testing.

- I closed a further race between the HideGreeter DBus call and PAM on startup. (this is the Shell.qml changes)

- I fixed a bug with the launcher's PropertiesChanged notification. It was leaving off the first 'interface' argument.

Resetting status to 'needs review'...

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

Ok. Code looks good. Tested it and it works. I think we should at least test the shell.enabled=true/false calls. Probably adding compare(shell.locked, true) at the beginning/end of existing tests would make sense to catch potential "lockup" bugs in future code modifications. What do you say?

review: Needs Information
lp:~mterry/unity8/dbus-race-fix updated
1343. By Michael Terry

Try to guard against the shell.enabled logic from biting us

1344. By Michael Terry

Merge from trunk

Revision history for this message
Michael Terry (mterry) wrote :

I've added a bit of logic to the existing Shell qmluitests to confirm that shell starts enabled and ends enabled. It's not 100% a great test since the mock PAM plugin we use returns instantly, so there's only a millisecond where the shell is disabled anyway. But can't hurt.

What did you mean about checking shell.locked?

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> I've added a bit of logic to the existing Shell qmluitests to confirm that
> shell starts enabled and ends enabled. It's not 100% a great test since the
> mock PAM plugin we use returns instantly, so there's only a millisecond where
> the shell is disabled anyway. But can't hurt.
>
> What did you mean about checking shell.locked?

sorry. I meant shell.enabled.

Ok, thanks.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/LightDM/CMakeLists.txt'
--- plugins/LightDM/CMakeLists.txt 2014-06-18 17:26:30 +0000
+++ plugins/LightDM/CMakeLists.txt 2014-10-15 17:55:21 +0000
@@ -10,6 +10,7 @@
10 ${CMAKE_SOURCE_DIR}/plugins/Utils10 ${CMAKE_SOURCE_DIR}/plugins/Utils
11 ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM11 ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM
12 #${LIBLIGHTDM_INCLUDE_DIRS}12 #${LIBLIGHTDM_INCLUDE_DIRS}
13 ${libunity8-private_SOURCE_DIR}
13 ${LIBUSERMETRICSOUTPUT_INCLUDE_DIRS}14 ${LIBUSERMETRICSOUTPUT_INCLUDE_DIRS}
14)15)
1516
@@ -28,6 +29,7 @@
2829
29target_link_libraries(LightDM-qml30target_link_libraries(LightDM-qml
30 MockLightDM-demo31 MockLightDM-demo
32 unity8-private
31# TODO: Once we split out a separate greeter process, uncomment these lines33# TODO: Once we split out a separate greeter process, uncomment these lines
32# ${LIBLIGHTDM_LDFLAGS}34# ${LIBLIGHTDM_LDFLAGS}
33 ${LIBUSERMETRICSOUTPUT_LDFLAGS}35 ${LIBUSERMETRICSOUTPUT_LDFLAGS}
3436
=== modified file 'plugins/LightDM/DBusGreeter.cpp'
--- plugins/LightDM/DBusGreeter.cpp 2014-08-27 15:11:21 +0000
+++ plugins/LightDM/DBusGreeter.cpp 2014-10-15 17:55:21 +0000
@@ -20,11 +20,9 @@
20#include <QDBusMessage>20#include <QDBusMessage>
21#include <QStringList>21#include <QStringList>
2222
23DBusGreeter::DBusGreeter(Greeter *greeter, const QDBusConnection &connection, const QString &path)23DBusGreeter::DBusGreeter(Greeter *greeter, const QString &path)
24 : QObject(greeter),24 : UnityDBusObject(path, "com.canonical.UnityGreeter", true, greeter),
25 m_greeter(greeter),25 m_greeter(greeter)
26 m_connection(connection),
27 m_path(path)
28{26{
29 connect(m_greeter, SIGNAL(isActiveChanged()), this, SLOT(isActiveChangedHandler()));27 connect(m_greeter, SIGNAL(isActiveChanged()), this, SLOT(isActiveChangedHandler()));
30}28}
@@ -49,22 +47,3 @@
49 notifyPropertyChanged("IsActive", isActive());47 notifyPropertyChanged("IsActive", isActive());
50 Q_EMIT isActiveChanged();48 Q_EMIT isActiveChanged();
51}49}
52
53// Manually emit a PropertiesChanged signal over DBus, because QtDBus
54// doesn't do it for us on Q_PROPERTIES, oddly enough.
55void DBusGreeter::notifyPropertyChanged(const QString& propertyName, const QVariant &value)
56{
57 QDBusMessage message;
58 QVariantMap changedProps;
59
60 changedProps.insert(propertyName, value);
61
62 message = QDBusMessage::createSignal(m_path,
63 "org.freedesktop.DBus.Properties",
64 "PropertiesChanged");
65 message << "com.canonical.UnityGreeter";
66 message << changedProps;
67 message << QStringList();
68
69 m_connection.send(message);
70}
7150
=== modified file 'plugins/LightDM/DBusGreeter.h'
--- plugins/LightDM/DBusGreeter.h 2014-09-05 11:57:35 +0000
+++ plugins/LightDM/DBusGreeter.h 2014-10-15 17:55:21 +0000
@@ -17,15 +17,15 @@
17#ifndef UNITY_DBUSGREETER_H17#ifndef UNITY_DBUSGREETER_H
18#define UNITY_DBUSGREETER_H18#define UNITY_DBUSGREETER_H
1919
20#include "unitydbusobject.h"
20#include <QDBusConnection>21#include <QDBusConnection>
21#include <QObject>
2222
23class Greeter;23class Greeter;
2424
25/** This is an internal class used to talk with the indicators.25/** This is an internal class used to talk with the indicators.
26 */26 */
2727
28class DBusGreeter : public QObject28class DBusGreeter : public UnityDBusObject
29{29{
30 Q_OBJECT30 Q_OBJECT
31 Q_CLASSINFO("D-Bus Interface", "com.canonical.UnityGreeter")31 Q_CLASSINFO("D-Bus Interface", "com.canonical.UnityGreeter")
@@ -33,7 +33,7 @@
33 Q_PROPERTY(bool IsActive READ isActive NOTIFY isActiveChanged) // since 14.1033 Q_PROPERTY(bool IsActive READ isActive NOTIFY isActiveChanged) // since 14.10
3434
35public:35public:
36 explicit DBusGreeter(Greeter *greeter, const QDBusConnection &connection, const QString &path);36 explicit DBusGreeter(Greeter *greeter, const QString &path);
3737
38 bool isActive() const;38 bool isActive() const;
39 Q_SCRIPTABLE void ShowGreeter(); // temporary, until we split the greeter again39 Q_SCRIPTABLE void ShowGreeter(); // temporary, until we split the greeter again
@@ -44,12 +44,9 @@
4444
45private Q_SLOTS:45private Q_SLOTS:
46 void isActiveChangedHandler();46 void isActiveChangedHandler();
47 void notifyPropertyChanged(const QString &propertyName, const QVariant &value);
4847
49private:48private:
50 Greeter *m_greeter;49 Greeter *m_greeter;
51 QDBusConnection m_connection;
52 QString m_path;
53};50};
5451
55#endif52#endif
5653
=== modified file 'plugins/LightDM/DBusGreeterList.cpp'
--- plugins/LightDM/DBusGreeterList.cpp 2013-12-03 16:55:03 +0000
+++ plugins/LightDM/DBusGreeterList.cpp 2014-10-15 17:55:21 +0000
@@ -20,11 +20,9 @@
20#include <QDBusMessage>20#include <QDBusMessage>
21#include <QStringList>21#include <QStringList>
2222
23DBusGreeterList::DBusGreeterList(Greeter *greeter, const QDBusConnection &connection, const QString &path)23DBusGreeterList::DBusGreeterList(Greeter *greeter, const QString &path)
24 : QObject(greeter),24 : UnityDBusObject(path, "com.canonical.UnityGreeter", true, greeter),
25 m_greeter(greeter),25 m_greeter(greeter)
26 m_connection(connection),
27 m_path(path)
28{26{
29 connect(m_greeter, SIGNAL(authenticationUserChanged(const QString &)), this, SLOT(authenticationUserChangedHandler(const QString &)));27 connect(m_greeter, SIGNAL(authenticationUserChanged(const QString &)), this, SLOT(authenticationUserChangedHandler(const QString &)));
30 connect(m_greeter, SIGNAL(promptlessChanged()), this, SLOT(promptlessChangedHandler()));28 connect(m_greeter, SIGNAL(promptlessChanged()), this, SLOT(promptlessChangedHandler()));
@@ -56,22 +54,3 @@
56 notifyPropertyChanged("EntryIsLocked", entryIsLocked());54 notifyPropertyChanged("EntryIsLocked", entryIsLocked());
57 Q_EMIT entryIsLockedChanged();55 Q_EMIT entryIsLockedChanged();
58}56}
59
60// Manually emit a PropertiesChanged signal over DBus, because QtDBus
61// doesn't do it for us on Q_PROPERTIES, oddly enough.
62void DBusGreeterList::notifyPropertyChanged(const QString& propertyName, const QVariant &value)
63{
64 QDBusMessage message;
65 QVariantMap changedProps;
66
67 changedProps.insert(propertyName, value);
68
69 message = QDBusMessage::createSignal(m_path,
70 "org.freedesktop.DBus.Properties",
71 "PropertiesChanged");
72 message << "com.canonical.UnityGreeter.List";
73 message << changedProps;
74 message << QStringList();
75
76 m_connection.send(message);
77}
7857
=== modified file 'plugins/LightDM/DBusGreeterList.h'
--- plugins/LightDM/DBusGreeterList.h 2014-09-05 11:57:35 +0000
+++ plugins/LightDM/DBusGreeterList.h 2014-10-15 17:55:21 +0000
@@ -17,15 +17,15 @@
17#ifndef UNITY_DBUSGREETERLIST_H17#ifndef UNITY_DBUSGREETERLIST_H
18#define UNITY_DBUSGREETERLIST_H18#define UNITY_DBUSGREETERLIST_H
1919
20#include "unitydbusobject.h"
20#include <QDBusConnection>21#include <QDBusConnection>
21#include <QObject>
2222
23class Greeter;23class Greeter;
2424
25/** This is an internal class used to talk with the indicators.25/** This is an internal class used to talk with the indicators.
26 */26 */
2727
28class DBusGreeterList : public QObject28class DBusGreeterList : public UnityDBusObject
29{29{
30 Q_OBJECT30 Q_OBJECT
31 Q_CLASSINFO("D-Bus Interface", "com.canonical.UnityGreeter.List")31 Q_CLASSINFO("D-Bus Interface", "com.canonical.UnityGreeter.List")
@@ -34,7 +34,7 @@
34 Q_PROPERTY(bool EntryIsLocked READ entryIsLocked NOTIFY entryIsLockedChanged) // since 14.0434 Q_PROPERTY(bool EntryIsLocked READ entryIsLocked NOTIFY entryIsLockedChanged) // since 14.04
3535
36public:36public:
37 explicit DBusGreeterList(Greeter *greeter, const QDBusConnection &connection, const QString &path);37 explicit DBusGreeterList(Greeter *greeter, const QString &path);
3838
39 Q_SCRIPTABLE void SetActiveEntry(const QString &entry); // since 13.0439 Q_SCRIPTABLE void SetActiveEntry(const QString &entry); // since 13.04
40 Q_SCRIPTABLE QString GetActiveEntry() const; // since 13.1040 Q_SCRIPTABLE QString GetActiveEntry() const; // since 13.10
@@ -49,12 +49,9 @@
49private Q_SLOTS:49private Q_SLOTS:
50 void authenticationUserChangedHandler(const QString &user);50 void authenticationUserChangedHandler(const QString &user);
51 void promptlessChangedHandler();51 void promptlessChangedHandler();
52 void notifyPropertyChanged(const QString &propertyName, const QVariant &value);
5352
54private:53private:
55 Greeter *m_greeter;54 Greeter *m_greeter;
56 QDBusConnection m_connection;
57 QString m_path;
58};55};
5956
60#endif57#endif
6158
=== modified file 'plugins/LightDM/plugin.cpp'
--- plugins/LightDM/plugin.cpp 2014-07-01 20:23:44 +0000
+++ plugins/LightDM/plugin.cpp 2014-10-15 17:55:21 +0000
@@ -30,21 +30,14 @@
30#include <QDBusConnection>30#include <QDBusConnection>
31#include <QtQml/qqml.h>31#include <QtQml/qqml.h>
3232
33static const char* GREETER_LIST_DBUS_PATH = "/list";
34static const char* GREETER_DBUS_SERVICE = "com.canonical.UnityGreeter";
35
36static QObject *greeter_provider(QQmlEngine *engine, QJSEngine *scriptEngine)33static QObject *greeter_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
37{34{
38 Q_UNUSED(engine)35 Q_UNUSED(engine)
39 Q_UNUSED(scriptEngine)36 Q_UNUSED(scriptEngine)
4037
41 Greeter *greeter = new Greeter();38 Greeter *greeter = new Greeter();
42 QDBusConnection connection = QDBusConnection::sessionBus();39 new DBusGreeter(greeter, "/");
43 DBusGreeter *root = new DBusGreeter(greeter, connection, "/");40 new DBusGreeterList(greeter, "/list");
44 connection.registerObject("/", root, QDBusConnection::ExportScriptableContents);
45 DBusGreeterList *list = new DBusGreeterList(greeter, connection, GREETER_LIST_DBUS_PATH);
46 connection.registerObject(GREETER_LIST_DBUS_PATH, list, QDBusConnection::ExportScriptableContents);
47 connection.registerService(GREETER_DBUS_SERVICE);
4841
49 return greeter;42 return greeter;
50}43}
5144
=== modified file 'plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.cpp'
--- plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.cpp 2014-09-02 10:14:23 +0000
+++ plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.cpp 2014-10-15 17:55:21 +0000
@@ -21,12 +21,8 @@
21#include <QDebug>21#include <QDebug>
2222
23DBusDashCommunicatorService::DBusDashCommunicatorService(QObject *parent):23DBusDashCommunicatorService::DBusDashCommunicatorService(QObject *parent):
24 QObject(parent)24 UnityDBusObject("/com/canonical/UnityDash", "com.canonical.UnityDash", false, parent)
25{25{
26 QDBusConnection connection = QDBusConnection::sessionBus();
27
28 connection.registerService("com.canonical.UnityDash");
29 connection.registerObject("/com/canonical/UnityDash", this, QDBusConnection::ExportScriptableSlots);
30}26}
3127
32DBusDashCommunicatorService::~DBusDashCommunicatorService()28DBusDashCommunicatorService::~DBusDashCommunicatorService()
3329
=== modified file 'plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.h'
--- plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.h 2014-09-02 10:14:23 +0000
+++ plugins/Unity/DashCommunicator/dbusdashcommunicatorservice.h 2014-10-15 17:55:21 +0000
@@ -17,9 +17,9 @@
17#ifndef DBUSDASHCOMMUNICATORSERVICE_H17#ifndef DBUSDASHCOMMUNICATORSERVICE_H
18#define DBUSDASHCOMMUNICATORSERVICE_H18#define DBUSDASHCOMMUNICATORSERVICE_H
1919
20#include <QObject>20#include "unitydbusobject.h"
2121
22class DBusDashCommunicatorService: public QObject22class DBusDashCommunicatorService: public UnityDBusObject
23{23{
24 Q_OBJECT24 Q_OBJECT
25 Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.DashCommunicator")25 Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.DashCommunicator")
2626
=== modified file 'plugins/Unity/Launcher/CMakeLists.txt'
--- plugins/Unity/Launcher/CMakeLists.txt 2014-09-29 09:43:18 +0000
+++ plugins/Unity/Launcher/CMakeLists.txt 2014-10-15 17:55:21 +0000
@@ -9,6 +9,7 @@
9 ${CMAKE_CURRENT_SOURCE_DIR}9 ${CMAKE_CURRENT_SOURCE_DIR}
10 ${CMAKE_SOURCE_DIR}/plugins/AccountsService10 ${CMAKE_SOURCE_DIR}/plugins/AccountsService
11 ${GSETTINGS_QT_INCLUDE_DIRS}11 ${GSETTINGS_QT_INCLUDE_DIRS}
12 ${libunity8-private_SOURCE_DIR}
12)13)
1314
14set(QMLLAUNCHERPLUGIN_SRC15set(QMLLAUNCHERPLUGIN_SRC
@@ -30,7 +31,10 @@
30 ${QMLLAUNCHERPLUGIN_SRC}31 ${QMLLAUNCHERPLUGIN_SRC}
31 )32 )
3233
33target_link_libraries(UnityLauncher-qml ${GSETTINGS_QT_LDFLAGS})34target_link_libraries(UnityLauncher-qml
35 unity8-private
36 ${GSETTINGS_QT_LDFLAGS}
37 )
3438
35qt5_use_modules(UnityLauncher-qml DBus Qml Gui)39qt5_use_modules(UnityLauncher-qml DBus Qml Gui)
3640
3741
=== modified file 'plugins/Unity/Launcher/dbusinterface.cpp'
--- plugins/Unity/Launcher/dbusinterface.cpp 2014-08-29 14:24:45 +0000
+++ plugins/Unity/Launcher/dbusinterface.cpp 2014-10-15 17:55:21 +0000
@@ -27,25 +27,13 @@
27#include <QDebug>27#include <QDebug>
2828
29DBusInterface::DBusInterface(LauncherModel *parent):29DBusInterface::DBusInterface(LauncherModel *parent):
30 QDBusVirtualObject(parent),30 UnityDBusVirtualObject("/com/canonical/Unity/Launcher", "com.canonical.Unity.Launcher", true, parent),
31 m_launcherModel(parent)31 m_launcherModel(parent)
32{32{
33 /* Set up ourselves on DBus */
34 QDBusConnection con = QDBusConnection::sessionBus();
35 if (!con.registerService("com.canonical.Unity.Launcher")) {
36 qWarning() << "Unable to register launcher name";
37 }
38 if (!con.registerVirtualObject("/com/canonical/Unity/Launcher", this, QDBusConnection::VirtualObjectRegisterOption::SubPath)) {
39 qWarning() << "Unable to register launcher object";
40 }
41}33}
4234
43DBusInterface::~DBusInterface()35DBusInterface::~DBusInterface()
44{36{
45 /* Remove oursevles from DBus */
46 QDBusConnection con = QDBusConnection::sessionBus();
47 con.unregisterService("com.canonical.Unity.Launcher");
48 con.unregisterObject("/com/canonical/Unity/Launcher");
49}37}
5038
51QString DBusInterface::introspect(const QString &path) const39QString DBusInterface::introspect(const QString &path) const
@@ -186,13 +174,13 @@
186 int newCount = message.arguments()[2].toInt();174 int newCount = message.arguments()[2].toInt();
187 if (!item || newCount != item->count()) {175 if (!item || newCount != item->count()) {
188 Q_EMIT countChanged(appid, newCount);176 Q_EMIT countChanged(appid, newCount);
189 emitPropChangedDbus(appid, "count", QVariant(newCount));177 notifyPropertyChanged("com.canonical.Unity.Launcher.Item", encodeAppId(appid), "count", QVariant(newCount));
190 }178 }
191 } else if (message.arguments()[1].toString() == "countVisible") {179 } else if (message.arguments()[1].toString() == "countVisible") {
192 bool newVisible = message.arguments()[2].toBool();180 bool newVisible = message.arguments()[2].toBool();
193 if (!item || newVisible != item->countVisible()) {181 if (!item || newVisible != item->countVisible()) {
194 Q_EMIT countVisibleChanged(appid, newVisible);182 Q_EMIT countVisibleChanged(appid, newVisible);
195 emitPropChangedDbus(appid, "countVisible", newVisible);183 notifyPropertyChanged("com.canonical.Unity.Launcher.Item", encodeAppId(appid), "countVisible", newVisible);
196 }184 }
197 }185 }
198 } else if (message.member() == "GetAll") {186 } else if (message.member() == "GetAll") {
@@ -209,24 +197,3 @@
209 QDBusMessage reply = message.createReply(retval);197 QDBusMessage reply = message.createReply(retval);
210 return connection.send(reply);198 return connection.send(reply);
211}199}
212
213void DBusInterface::emitPropChangedDbus(const QString& appId, const QString& property, const QVariant &value)
214{
215 QString path("/com/canonical/Unity/Launcher/");
216 path.append(encodeAppId(appId));
217
218 QDBusMessage message = QDBusMessage::createSignal(path, "org.freedesktop.DBus.Properties", "PropertiesChanged");
219
220 QList<QVariant> arguments;
221 QVariantHash changedprops;
222 changedprops[property] = QVariant::fromValue(QDBusVariant(value));
223 QVariantList deletedprops;
224
225 arguments.append(changedprops);
226 arguments.append(deletedprops);
227
228 message.setArguments(arguments);
229
230 QDBusConnection con = QDBusConnection::sessionBus();
231 con.send(message);
232}
233200
=== modified file 'plugins/Unity/Launcher/dbusinterface.h'
--- plugins/Unity/Launcher/dbusinterface.h 2014-08-29 12:59:15 +0000
+++ plugins/Unity/Launcher/dbusinterface.h 2014-10-15 17:55:21 +0000
@@ -18,12 +18,11 @@
18 */18 */
1919
20#include "launcheritem.h"20#include "launcheritem.h"
2121#include "unitydbusvirtualobject.h"
22#include <QDBusVirtualObject>
2322
24class LauncherModel;23class LauncherModel;
2524
26class DBusInterface: public QDBusVirtualObject25class DBusInterface: public UnityDBusVirtualObject
27{26{
28 Q_OBJECT27 Q_OBJECT
29public:28public:
@@ -43,8 +42,6 @@
43 static QString decodeAppId(const QString& path);42 static QString decodeAppId(const QString& path);
44 static QString encodeAppId(const QString& appId);43 static QString encodeAppId(const QString& appId);
4544
46 void emitPropChangedDbus(const QString& appId, const QString& property, const QVariant &value);
47
48 LauncherModel *m_launcherModel;45 LauncherModel *m_launcherModel;
4946
50};47};
5148
=== modified file 'plugins/Unity/Session/CMakeLists.txt'
--- plugins/Unity/Session/CMakeLists.txt 2014-08-26 23:33:17 +0000
+++ plugins/Unity/Session/CMakeLists.txt 2014-10-15 17:55:21 +0000
@@ -5,6 +5,7 @@
5include_directories(5include_directories(
6 ${CMAKE_CURRENT_SOURCE_DIR}6 ${CMAKE_CURRENT_SOURCE_DIR}
7 ${GIO_INCLUDE_DIRS}7 ${GIO_INCLUDE_DIRS}
8 ${libunity8-private_SOURCE_DIR}
8)9)
910
10set(QMLSESSIONPLUGIN_SRC11set(QMLSESSIONPLUGIN_SRC
@@ -18,7 +19,10 @@
18 )19 )
1920
20qt5_use_modules(UnitySession-qml DBus Qml)21qt5_use_modules(UnitySession-qml DBus Qml)
21target_link_libraries(UnitySession-qml ${GIO_LDFLAGS})22target_link_libraries(UnitySession-qml
23 unity8-private
24 ${GIO_LDFLAGS}
25 )
2226
23# export the qmldir and qmltypes files27# export the qmldir and qmltypes files
24add_unity8_plugin(Unity.Session 0.1 Unity/Session TARGETS UnitySession-qml)28add_unity8_plugin(Unity.Session 0.1 Unity/Session TARGETS UnitySession-qml)
2529
=== modified file 'plugins/Unity/Session/dbusunitysessionservice.cpp'
--- plugins/Unity/Session/dbusunitysessionservice.cpp 2014-07-09 12:22:19 +0000
+++ plugins/Unity/Session/dbusunitysessionservice.cpp 2014-10-15 17:55:21 +0000
@@ -21,15 +21,9 @@
21#include <QDBusConnection>21#include <QDBusConnection>
22#include <QDBusInterface>22#include <QDBusInterface>
2323
24DBusUnitySessionService::DBusUnitySessionService() : QObject()24DBusUnitySessionService::DBusUnitySessionService()
25 : UnityDBusObject("/com/canonical/Unity/Session", "com.canonical.Unity")
25{26{
26 QDBusConnection connection = QDBusConnection::sessionBus();
27
28 connection.registerService("com.canonical.Unity");
29 connection.registerObject("/com/canonical/Unity/Session", this,
30 QDBusConnection::ExportScriptableSignals
31 | QDBusConnection::ExportScriptableSlots
32 | QDBusConnection::ExportScriptableInvokables);
33}27}
3428
35DBusUnitySessionService::~DBusUnitySessionService()29DBusUnitySessionService::~DBusUnitySessionService()
3630
=== modified file 'plugins/Unity/Session/dbusunitysessionservice.h'
--- plugins/Unity/Session/dbusunitysessionservice.h 2014-05-27 15:43:52 +0000
+++ plugins/Unity/Session/dbusunitysessionservice.h 2014-10-15 17:55:21 +0000
@@ -17,7 +17,7 @@
17#ifndef DBUSUNITYSESSIONSERVICE_H17#ifndef DBUSUNITYSESSIONSERVICE_H
18#define DBUSUNITYSESSIONSERVICE_H18#define DBUSUNITYSESSIONSERVICE_H
1919
20#include <QObject>20#include "unitydbusobject.h"
2121
22/**22/**
23 * DBusUnitySessionService provides com.canonical.Unity.Session dbus23 * DBusUnitySessionService provides com.canonical.Unity.Session dbus
@@ -26,7 +26,7 @@
26 * com.canonical.Unity.Session interface provides public methods26 * com.canonical.Unity.Session interface provides public methods
27 * and signals to handle Logout/Reboot/Shutdown.27 * and signals to handle Logout/Reboot/Shutdown.
28 */28 */
29class DBusUnitySessionService : public QObject29class DBusUnitySessionService : public UnityDBusObject
30{30{
31 Q_OBJECT31 Q_OBJECT
32 Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.Session")32 Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.Session")
3333
=== modified file 'qml/Shell.qml'
--- qml/Shell.qml 2014-10-13 15:41:29 +0000
+++ qml/Shell.qml 2014-10-15 17:55:21 +0000
@@ -370,6 +370,10 @@
370 onHideGreeter: greeter.login()370 onHideGreeter: greeter.login()
371371
372 onShowPrompt: {372 onShowPrompt: {
373 shell.enabled = true;
374 if (!LightDM.Greeter.active) {
375 return; // could happen if hideGreeter() comes in before we prompt
376 }
373 if (greeter.narrowMode) {377 if (greeter.narrowMode) {
374 if (isDefaultPrompt) {378 if (isDefaultPrompt) {
375 if (lockscreen.alphaNumeric) {379 if (lockscreen.alphaNumeric) {
@@ -390,6 +394,9 @@
390 }394 }
391395
392 onPromptlessChanged: {396 onPromptlessChanged: {
397 if (!LightDM.Greeter.active) {
398 return; // could happen if hideGreeter() comes in before we prompt
399 }
393 if (greeter.narrowMode) {400 if (greeter.narrowMode) {
394 if (LightDM.Greeter.promptless && LightDM.Greeter.authenticated) {401 if (LightDM.Greeter.promptless && LightDM.Greeter.authenticated) {
395 lockscreen.hide()402 lockscreen.hide()
@@ -401,6 +408,7 @@
401 }408 }
402409
403 onAuthenticationComplete: {410 onAuthenticationComplete: {
411 shell.enabled = true;
404 if (LightDM.Greeter.authenticated) {412 if (LightDM.Greeter.authenticated) {
405 AccountsService.failedLogins = 0413 AccountsService.failedLogins = 0
406 }414 }
@@ -537,6 +545,11 @@
537545
538 onShownChanged: {546 onShownChanged: {
539 if (shown) {547 if (shown) {
548 // Disable everything so that user can't swipe greeter or
549 // launcher until we get first prompt/authenticate, which
550 // will re-enable the shell.
551 shell.enabled = false;
552
540 if (greeter.narrowMode) {553 if (greeter.narrowMode) {
541 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));554 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
542 } else {555 } else {
543556
=== modified file 'src/libunity8-private/CMakeLists.txt'
--- src/libunity8-private/CMakeLists.txt 2014-09-05 11:57:01 +0000
+++ src/libunity8-private/CMakeLists.txt 2014-10-15 17:55:21 +0000
@@ -6,6 +6,8 @@
66
7set(lib${LIB_NAME}_SRCS7set(lib${LIB_NAME}_SRCS
8 abstractdbusservicemonitor.cpp8 abstractdbusservicemonitor.cpp
9 unitydbusobject.cpp
10 unitydbusvirtualobject.cpp
9 )11 )
1012
11add_library(${LIB_NAME} SHARED13add_library(${LIB_NAME} SHARED
1214
=== added file 'src/libunity8-private/unitydbusobject.cpp'
--- src/libunity8-private/unitydbusobject.cpp 1970-01-01 00:00:00 +0000
+++ src/libunity8-private/unitydbusobject.cpp 2014-10-15 17:55:21 +0000
@@ -0,0 +1,86 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 */
16
17#include "unitydbusobject.h"
18
19#include <QDebug>
20#include <QDBusMessage>
21#include <QMetaClassInfo>
22#include <QTimer>
23
24UnityDBusObject::UnityDBusObject(const QString &path, const QString &service, bool async, QObject *parent)
25 : QObject(parent)
26 , m_connection(QDBusConnection::sessionBus())
27 , m_path(path)
28 , m_service(service)
29{
30 if (async) {
31 // Use a zero-timer to let Qml finish loading before we announce on DBus
32 QTimer::singleShot(0, this, SLOT(registerObject()));
33 } else {
34 registerObject();
35 }
36}
37
38UnityDBusObject::~UnityDBusObject()
39{
40 // Leave service in place because multiple objects may be registered with
41 // the same service. But we know we own the object path and can unregister it.
42 m_connection.unregisterObject(path());
43}
44
45QDBusConnection UnityDBusObject::connection() const
46{
47 return m_connection;
48}
49
50QString UnityDBusObject::path() const
51{
52 return m_path;
53}
54
55// Manually emit a PropertiesChanged signal over DBus, because QtDBus
56// doesn't do it for us on Q_PROPERTIES, oddly enough.
57void UnityDBusObject::notifyPropertyChanged(const QString& propertyName, const QVariant &value)
58{
59 QDBusMessage message;
60 QString interface;
61 QVariantMap changedProps;
62
63 interface = metaObject()->classInfo(metaObject()->indexOfClassInfo("D-Bus Interface")).value();
64 changedProps.insert(propertyName, value);
65
66 message = QDBusMessage::createSignal(path(),
67 "org.freedesktop.DBus.Properties",
68 "PropertiesChanged");
69 message << interface;
70 message << changedProps;
71 message << QStringList();
72
73 connection().send(message);
74}
75
76void UnityDBusObject::registerObject()
77{
78 if (!m_connection.registerObject(m_path, this, QDBusConnection::ExportScriptableContents)) {
79 qWarning() << "Unable to register DBus object" << m_path;
80 }
81 if (!m_service.isEmpty()) {
82 if (!m_connection.registerService(m_service)) {
83 qWarning() << "Unable to register DBus service" << m_service;
84 }
85 }
86}
087
=== added file 'src/libunity8-private/unitydbusobject.h'
--- src/libunity8-private/unitydbusobject.h 1970-01-01 00:00:00 +0000
+++ src/libunity8-private/unitydbusobject.h 2014-10-15 17:55:21 +0000
@@ -0,0 +1,46 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 */
16
17#ifndef UNITYDBUSOBJECT_H
18#define UNITYDBUSOBJECT_H
19
20#include <QDBusConnection>
21#include <QObject>
22
23class Q_DECL_EXPORT UnityDBusObject : public QObject
24{
25 Q_OBJECT
26
27public:
28 explicit UnityDBusObject(const QString &path, const QString &service = QString(), bool async = true, QObject *parent = 0);
29 ~UnityDBusObject();
30
31 QDBusConnection connection() const;
32 QString path() const;
33
34protected:
35 void notifyPropertyChanged(const QString& propertyName, const QVariant &value);
36
37private Q_SLOTS:
38 void registerObject();
39
40private:
41 QDBusConnection m_connection;
42 QString m_path;
43 QString m_service;
44};
45
46#endif // UNITYDBUSOBJECT_H
047
=== added file 'src/libunity8-private/unitydbusvirtualobject.cpp'
--- src/libunity8-private/unitydbusvirtualobject.cpp 1970-01-01 00:00:00 +0000
+++ src/libunity8-private/unitydbusvirtualobject.cpp 2014-10-15 17:55:21 +0000
@@ -0,0 +1,83 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 */
16
17#include "unitydbusvirtualobject.h"
18
19#include <QDebug>
20#include <QDBusMessage>
21#include <QTimer>
22
23UnityDBusVirtualObject::UnityDBusVirtualObject(const QString &path, const QString &service, bool async, QObject *parent)
24 : QDBusVirtualObject(parent)
25 , m_connection(QDBusConnection::sessionBus())
26 , m_path(path)
27 , m_service(service)
28{
29 if (async) {
30 // Use a zero-timer to let Qml finish loading before we announce on DBus
31 QTimer::singleShot(0, this, SLOT(registerObject()));
32 } else {
33 registerObject();
34 }
35}
36
37UnityDBusVirtualObject::~UnityDBusVirtualObject()
38{
39 // Leave service in place because multiple objects may be registered with
40 // the same service. But we know we own the object path and can unregister it.
41 m_connection.unregisterObject(path());
42}
43
44QDBusConnection UnityDBusVirtualObject::connection() const
45{
46 return m_connection;
47}
48
49QString UnityDBusVirtualObject::path() const
50{
51 return m_path;
52}
53
54// Manually emit a PropertiesChanged signal over DBus, because QtDBus
55// doesn't do it for us on Q_PROPERTIES, oddly enough.
56void UnityDBusVirtualObject::notifyPropertyChanged(const QString& interface, const QString& node, const QString& propertyName, const QVariant &value)
57{
58 QDBusMessage message;
59 QVariantMap changedProps;
60
61 changedProps.insert(propertyName, value);
62
63 message = QDBusMessage::createSignal(path() + "/" + node,
64 "org.freedesktop.DBus.Properties",
65 "PropertiesChanged");
66 message << interface;
67 message << changedProps;
68 message << QStringList();
69
70 connection().send(message);
71}
72
73void UnityDBusVirtualObject::registerObject()
74{
75 if (!m_connection.registerVirtualObject(m_path, this, QDBusConnection::VirtualObjectRegisterOption::SubPath)) {
76 qWarning() << "Unable to register DBus object" << m_path;
77 }
78 if (!m_service.isEmpty()) {
79 if (!m_connection.registerService(m_service)) {
80 qWarning() << "Unable to register DBus service" << m_service;
81 }
82 }
83}
084
=== added file 'src/libunity8-private/unitydbusvirtualobject.h'
--- src/libunity8-private/unitydbusvirtualobject.h 1970-01-01 00:00:00 +0000
+++ src/libunity8-private/unitydbusvirtualobject.h 2014-10-15 17:55:21 +0000
@@ -0,0 +1,47 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 */
16
17#ifndef UNITYDBUSVIRTUALOBJECT_H
18#define UNITYDBUSVIRTUALOBJECT_H
19
20#include <QDBusConnection>
21#include <QDBusVirtualObject>
22#include <QObject>
23
24class Q_DECL_EXPORT UnityDBusVirtualObject : public QDBusVirtualObject
25{
26 Q_OBJECT
27
28public:
29 explicit UnityDBusVirtualObject(const QString &path, const QString &service = QString(), bool async = true, QObject *parent = 0);
30 ~UnityDBusVirtualObject();
31
32 QDBusConnection connection() const;
33 QString path() const;
34
35protected:
36 void notifyPropertyChanged(const QString& interface, const QString& node, const QString& propertyName, const QVariant &value);
37
38private Q_SLOTS:
39 void registerObject();
40
41private:
42 QDBusConnection m_connection;
43 QString m_path;
44 QString m_service;
45};
46
47#endif // UNITYDBUSVIRTUALOBJECT_H
048
=== modified file 'tests/mocks/LightDM/CMakeLists.txt'
--- tests/mocks/LightDM/CMakeLists.txt 2014-06-18 17:26:30 +0000
+++ tests/mocks/LightDM/CMakeLists.txt 2014-10-15 17:55:21 +0000
@@ -15,6 +15,7 @@
15 ${CMAKE_CURRENT_BINARY_DIR}15 ${CMAKE_CURRENT_BINARY_DIR}
16 ${CMAKE_SOURCE_DIR}/plugins/Utils16 ${CMAKE_SOURCE_DIR}/plugins/Utils
17 ${CMAKE_SOURCE_DIR}/tests/mocks/libusermetrics17 ${CMAKE_SOURCE_DIR}/tests/mocks/libusermetrics
18 ${libunity8-private_SOURCE_DIR}
18)19)
1920
20set(QMLPLUGIN_SRC21set(QMLPLUGIN_SRC
@@ -40,6 +41,7 @@
40 -llightdm-qt5-241 -llightdm-qt5-2
41 -L${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics42 -L${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics
42 -lusermetricsoutput43 -lusermetricsoutput
44 unity8-private
43 )45 )
4446
45qt5_use_modules(MockLightDM-qml DBus Gui Qml)47qt5_use_modules(MockLightDM-qml DBus Gui Qml)
4648
=== modified file 'tests/plugins/Unity/Launcher/CMakeLists.txt'
--- tests/plugins/Unity/Launcher/CMakeLists.txt 2014-09-29 09:43:18 +0000
+++ tests/plugins/Unity/Launcher/CMakeLists.txt 2014-10-15 17:55:21 +0000
@@ -7,6 +7,7 @@
7 ${CMAKE_SOURCE_DIR}/plugins/AccountsService7 ${CMAKE_SOURCE_DIR}/plugins/AccountsService
8 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher8 ${CMAKE_SOURCE_DIR}/plugins/Unity/Launcher
9 ${GSETTINGS_QT_INCLUDE_DIRS}9 ${GSETTINGS_QT_INCLUDE_DIRS}
10 ${libunity8-private_SOURCE_DIR}
10 )11 )
1112
12add_definitions(-DSM_BUSNAME=sessionBus)13add_definitions(-DSM_BUSNAME=sessionBus)
@@ -34,7 +35,10 @@
34 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h35 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
35 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h36 ${LAUNCHER_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
36 )37 )
37target_link_libraries(launchermodeltestExec ${GSETTINGS_QT_LDFLAGS})38target_link_libraries(launchermodeltestExec
39 unity8-private
40 ${GSETTINGS_QT_LDFLAGS}
41 )
38qt5_use_modules(launchermodeltestExec Test Core DBus Xml Gui)42qt5_use_modules(launchermodeltestExec Test Core DBus Xml Gui)
3943
40# copy .desktop files into build directory for shadow builds44# copy .desktop files into build directory for shadow builds
4145
=== modified file 'tests/plugins/Unity/Launcher/launchermodeltest.cpp'
--- tests/plugins/Unity/Launcher/launchermodeltest.cpp 2014-09-29 14:26:56 +0000
+++ tests/plugins/Unity/Launcher/launchermodeltest.cpp 2014-10-15 17:55:21 +0000
@@ -124,6 +124,7 @@
124124
125 void initTestCase() {125 void initTestCase() {
126 launcherModel = new LauncherModel(this);126 launcherModel = new LauncherModel(this);
127 QCoreApplication::processEvents(); // to let the model register on DBus
127 QCOMPARE(launcherModel->rowCount(QModelIndex()), 0);128 QCOMPARE(launcherModel->rowCount(QModelIndex()), 0);
128129
129 appManager = new MockAppManager(this);130 appManager = new MockAppManager(this);
130131
=== modified file 'tests/plugins/Unity/Session/CMakeLists.txt'
--- tests/plugins/Unity/Session/CMakeLists.txt 2014-06-13 12:45:12 +0000
+++ tests/plugins/Unity/Session/CMakeLists.txt 2014-10-15 17:55:21 +0000
@@ -1,6 +1,7 @@
1include_directories(1include_directories(
2 ${CMAKE_CURRENT_BINARY_DIR}2 ${CMAKE_CURRENT_BINARY_DIR}
3 ${CMAKE_SOURCE_DIR}/plugins/Unity/Session3 ${CMAKE_SOURCE_DIR}/plugins/Unity/Session
4 ${libunity8-private_SOURCE_DIR}
4)5)
56
6add_definitions(-DSM_BUSNAME=sessionBus)7add_definitions(-DSM_BUSNAME=sessionBus)
@@ -17,4 +18,7 @@
17 sessionbackendtest.cpp18 sessionbackendtest.cpp
18 ${CMAKE_SOURCE_DIR}/plugins/Unity/Session/dbusunitysessionservice.cpp19 ${CMAKE_SOURCE_DIR}/plugins/Unity/Session/dbusunitysessionservice.cpp
19)20)
21target_link_libraries(sessionbackendtestExec
22 unity8-private
23 )
20qt5_use_modules(sessionbackendtestExec Test Core Qml DBus)24qt5_use_modules(sessionbackendtestExec Test Core Qml DBus)
2125
=== modified file 'tests/plugins/Unity/Session/sessionbackendtest.cpp'
--- tests/plugins/Unity/Session/sessionbackendtest.cpp 2014-05-29 08:23:37 +0000
+++ tests/plugins/Unity/Session/sessionbackendtest.cpp 2014-10-15 17:55:21 +0000
@@ -45,6 +45,7 @@
45 QFETCH(QString, method);45 QFETCH(QString, method);
4646
47 DBusUnitySessionService dbusUnitySessionService;47 DBusUnitySessionService dbusUnitySessionService;
48 QCoreApplication::processEvents(); // to let the service register on DBus
4849
49 QDBusConnection con = QDBusConnection::sessionBus();50 QDBusConnection con = QDBusConnection::sessionBus();
50 QDBusInterface interface ("com.canonical.Unity",51 QDBusInterface interface ("com.canonical.Unity",
5152
=== modified file 'tests/qmltests/tst_Shell.qml'
--- tests/qmltests/tst_Shell.qml 2014-10-13 15:42:40 +0000
+++ tests/qmltests/tst_Shell.qml 2014-10-15 17:55:21 +0000
@@ -132,6 +132,8 @@
132 property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null132 property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
133133
134 function init() {134 function init() {
135 tryCompare(shell, "enabled", true); // enabled by greeter when ready
136
135 swipeAwayGreeter();137 swipeAwayGreeter();
136138
137 sessionSpy.target = findChild(shell, "greeter")139 sessionSpy.target = findChild(shell, "greeter")
@@ -142,6 +144,7 @@
142 }144 }
143145
144 function cleanup() {146 function cleanup() {
147 tryCompare(shell, "enabled", true); // make sure greeter didn't leave us in disabled state
145 launcherShowDashHomeSpy.target = null;148 launcherShowDashHomeSpy.target = null;
146149
147 shellLoader.itemDestroyed = false;150 shellLoader.itemDestroyed = false;
148151
=== modified file 'tests/qmltests/tst_ShellWithPin.qml'
--- tests/qmltests/tst_ShellWithPin.qml 2014-10-13 15:42:15 +0000
+++ tests/qmltests/tst_ShellWithPin.qml 2014-10-15 17:55:21 +0000
@@ -127,6 +127,7 @@
127 property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null127 property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
128128
129 function init() {129 function init() {
130 tryCompare(shell, "enabled", true); // will be enabled when greeter is all ready
130 sessionSpy.target = findChild(shell, "greeter")131 sessionSpy.target = findChild(shell, "greeter")
131 swipeAwayGreeter()132 swipeAwayGreeter()
132 waitForLockscreen()133 waitForLockscreen()
@@ -135,6 +136,8 @@
135 }136 }
136137
137 function cleanup() {138 function cleanup() {
139 tryCompare(shell, "enabled", true); // make sure greeter didn't leave us in disabled state
140
138 shellLoader.itemDestroyed = false141 shellLoader.itemDestroyed = false
139142
140 shellLoader.active = false143 shellLoader.active = false
141144
=== modified file 'tests/qmltests/tst_TabletShell.qml'
--- tests/qmltests/tst_TabletShell.qml 2014-10-09 13:05:21 +0000
+++ tests/qmltests/tst_TabletShell.qml 2014-10-15 17:55:21 +0000
@@ -119,12 +119,15 @@
119 property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null119 property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
120120
121 function init() {121 function init() {
122 tryCompare(shell, "enabled", true); // will be enabled when greeter is all ready
122 sessionSpy.clear()123 sessionSpy.clear()
123 sessionSpy.target = findChild(shell, "greeter")124 sessionSpy.target = findChild(shell, "greeter")
124 dashCommunicatorSpy.target = findInvisibleChild(shell, "dashCommunicator")125 dashCommunicatorSpy.target = findInvisibleChild(shell, "dashCommunicator")
125 }126 }
126127
127 function cleanup() {128 function cleanup() {
129 tryCompare(shell, "enabled", true); // make sure greeter didn't leave us in disabled state
130
128 shellLoader.itemDestroyed = false131 shellLoader.itemDestroyed = false
129132
130 shellLoader.active = false133 shellLoader.active = false

Subscribers

People subscribed via source and target branches