Merge lp:~lukas-kde/unity8/fixLogin1Tests into lp:unity8

Proposed by Lukáš Tinkl on 2015-09-25
Status: Work in progress
Proposed branch: lp:~lukas-kde/unity8/fixLogin1Tests
Merge into: lp:unity8
Diff against target: 319 lines (+131/-30)
5 files modified
debian/control (+2/-1)
plugins/Unity/Session/CMakeLists.txt (+2/-0)
plugins/Unity/Session/dbusunitysessionservice.cpp (+12/-12)
tests/plugins/Unity/Session/CMakeLists.txt (+1/-1)
tests/plugins/Unity/Session/sessionbackendtest.cpp (+114/-16)
To merge this branch: bzr merge lp:~lukas-kde/unity8/fixLogin1Tests
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Needs Information on 2016-01-12
Josh Arenson 2015-09-25 Needs Information on 2015-10-27
PS Jenkins bot continuous-integration Needs Fixing on 2015-10-26
Michał Sawicz Abstain on 2015-09-29
Review via email: mp+272493@code.launchpad.net

Commit Message

Extend the sessionBackendTest with methods testing also the mock dbus interfaces

Description of the Change

Extend the sessionBackendTest with methods testing also the mock dbus interfaces (org.freedesktop.login1 and org.gnome.ScreenSaver) created by python-dbusmock helpers.

Fix the testLogin1Capabilities to use data-driven testing.

* 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?

Yes

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

N/A

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:1976
http://jenkins.qa.ubuntu.com/job/unity8-ci/6356/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/4371
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-wily-touch/731
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1068
    FAILURE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-wily/386/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/963
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/964
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-wily-amd64-ci/595
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-wily-i386-ci/596
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-mako/3561
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4368
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4368/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/23688
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-wily-mako/441
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-wily-armhf/731
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-wily-armhf/731/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/23689

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/6356/rebuild

review: Needs Fixing (continuous-integration)
Michał Sawicz (saviq) wrote :

Text conflict in plugins/Unity/Session/dbusunitysessionservice.cpp
1 conflicts encountered.

review: Needs Fixing
lp:~lukas-kde/unity8/fixLogin1Tests updated on 2015-09-29
1977. By Lukáš Tinkl on 2015-09-29

merge trunk and fix conflicts

Lukáš Tinkl (lukas-kde) wrote :

> Text conflict in plugins/Unity/Session/dbusunitysessionservice.cpp
> 1 conflicts encountered.

Fixed

Michał Sawicz (saviq) :
review: Abstain
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:1977
http://jenkins.qa.ubuntu.com/job/unity8-ci/6372/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/4401
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-wily-touch/749
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1084
    FAILURE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-wily/402/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/979
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/980
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-wily-amd64-ci/611
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-wily-i386-ci/612
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-mako/3581
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4398
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4398/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/23745
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-wily-mako/450
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-wily-armhf/749
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-wily-armhf/749/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/23746

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/6372/rebuild

review: Needs Fixing (continuous-integration)
Josh Arenson (josharenson) wrote :

1 small change (inline). Else, looks good for now. The qmltest failure seems CI related, but another run would be nice to see.

review: Needs Fixing
Lukáš Tinkl (lukas-kde) wrote :

Saviq advised me to make it a build dep; I will put it in place alphabetically

lp:~lukas-kde/unity8/fixLogin1Tests updated on 2015-09-29
1978. By Lukáš Tinkl on 2015-09-29

put the python-dbusmock dep in place alphabetically

Michał Sawicz (saviq) wrote :

W dniu 29.09.2015 o 17:51, Lukáš Tinkl pisze:
> Not technically a build dep but it's neither a runtime dep :)

It is a build dep because it's needed for tests that run during package
building.

PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:1977
http://jenkins.qa.ubuntu.com/job/unity8-ci/6383/
Executed test runs:
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/4416/console
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-wily-touch/760
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1095
    FAILURE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-wily/413/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/990
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/991
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-wily-amd64-ci/622
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-wily-i386-ci/623
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-mako/3593/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4413
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4413/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/23769
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-wily-mako/457
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-wily-armhf/760
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-wily-armhf/760/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/23770

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/6383/rebuild

review: Needs Fixing (continuous-integration)
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:1978
http://jenkins.qa.ubuntu.com/job/unity8-ci/6386/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/4428
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-wily-touch/763
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1098
    FAILURE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-wily/416/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/993
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/994
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-wily-amd64-ci/625
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-wily-i386-ci/626
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-mako/3602
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4425
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4425/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/23784
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-wily-mako/459
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-wily-armhf/763
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-wily-armhf/763/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/23785

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/6386/rebuild

review: Needs Fixing (continuous-integration)
Francis Ginther (fginther) wrote :

I took a look at the QML test issue. The build is failing because there are processes still active when the build tries to exit the pbuilder chroot. On a rerun of this I found:

ubuntu@ps-wily-server-amd64-1:/var/cache/pbuilder/build$ sudo lsof 5058
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
      Output information may be incomplete.
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
dbus-laun 19410 root cwd DIR 253,1 4096 393622 5058
dbus-laun 19410 root rtd DIR 253,1 4096 393622 5058
dbus-daem 19411 root cwd DIR 253,1 4096 393622 5058
dbus-daem 19411 root rtd DIR 253,1 4096 393622 5058
ubuntu@ps-wily-server-amd64-1:/var/cache/pbuilder/build$ ps -ef|grep dbus
message+ 693 1 0 20:04 ? 00:00:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
root 855 1 0 20:04 ? 00:00:00 /usr/bin/dbus-launch --autolaunch 024226a659a4bd8ca13eea115550c33b --binary-syntax --close-stderr
root 863 1 0 20:04 ? 00:00:00 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
root 870 865 0 20:04 ? 00:00:00 /usr/bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.conf --nofork --print-address 3
ubuntu 4238 4201 0 20:11 ? 00:00:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session /usr/bin/im-launch /home/ubuntu/.xsession
ubuntu 4241 1 0 20:11 ? 00:00:00 /usr/bin/dbus-launch --exit-with-session /usr/bin/im-launch /home/ubuntu/.xsession
ubuntu 4242 1 0 20:11 ? 00:00:00 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
ubuntu 4293 4289 0 20:11 ? 00:00:00 /usr/bin/dbus-daemon --config-file=/etc/at-spi2/accessibility.conf --nofork --print-address 3
ubuntu 4322 1 0 20:11 ? 00:00:00 dbus-launch --autolaunch 024226a659a4bd8ca13eea115550c33b --binary-syntax --close-stderr
ubuntu 4323 1 0 20:11 ? 00:00:00 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
root 19410 1 0 20:54 ? 00:00:00 dbus-launch --autolaunch=b3438f151772a1f0748771fb467c882c --binary-syntax --close-stderr
root 19411 1 0 20:54 ? 00:00:00 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session
ubuntu 21343 21278 0 21:09 pts/0 00:00:00 grep --color=auto dbus

lp:~lukas-kde/unity8/fixLogin1Tests updated on 2015-10-14
1979. By Lukáš Tinkl on 2015-10-14

kill the DBUS processes in ordeer not to hog up the test runner

PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:1979
http://jenkins.qa.ubuntu.com/job/unity8-ci/6472/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/4643
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-wily-touch/854
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1184
    FAILURE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-wily/503/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/1079
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/1080
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-wily-amd64-ci/711
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-wily-i386-ci/712
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-mako/3745
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4640
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4640/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/24199
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-wily-mako/505
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-wily-armhf/854
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-wily-armhf/854/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/24195

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/6472/rebuild

review: Needs Fixing (continuous-integration)
lp:~lukas-kde/unity8/fixLogin1Tests updated on 2015-10-19
1980. By Lukáš Tinkl on 2015-10-19

merge trunk

PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:1980
http://jenkins.qa.ubuntu.com/job/unity8-ci/6493/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/4713
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-wily-touch/875
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/1205
    FAILURE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-wily/521/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/1100
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/1101
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-wily-amd64-ci/732
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-wily-i386-ci/733
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-mako/3806
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4710
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/4710/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/24368
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-wily-mako/519
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-wily-armhf/875
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-wily-armhf/875/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/24369

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/6493/rebuild

review: Needs Fixing (continuous-integration)
lp:~lukas-kde/unity8/fixLogin1Tests updated on 2015-10-26
1981. By Lukáš Tinkl on 2015-10-26

merge trunk

Josh Arenson (josharenson) wrote :

1 comment inline

review: Needs Information
Albert Astals Cid (aacid) wrote :

Text conflict in plugins/Unity/Session/dbusunitysessionservice.cpp
1 conflicts encountered.

review: Needs Fixing
Albert Astals Cid (aacid) wrote :

> add_definitions(-DSM_BUSNAME=systemBus)

What's the use of this? It doesn't get defined to anything else elsewhere, no?

review: Needs Information

Unmerged revisions

1981. By Lukáš Tinkl on 2015-10-26

merge trunk

1980. By Lukáš Tinkl on 2015-10-19

merge trunk

1979. By Lukáš Tinkl on 2015-10-14

kill the DBUS processes in ordeer not to hog up the test runner

1978. By Lukáš Tinkl on 2015-09-29

put the python-dbusmock dep in place alphabetically

1977. By Lukáš Tinkl on 2015-09-29

merge trunk and fix conflicts

1976. By Lukáš Tinkl on 2015-09-25

add a build dep on python3-dbusmock

1975. By Lukáš Tinkl on 2015-09-25

test the gnome screensaver mock

1974. By Lukáš Tinkl on 2015-09-25

test logind mock

1973. By Lukáš Tinkl on 2015-09-24

use metaObject and invokeMethod instead of if/else branches

1972. By Lukáš Tinkl on 2015-09-24

create the DUSS service on either session/system bus depending on the testing status;

test login1 DBUS iface using a mock on session bus

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2015-10-21 11:51:11 +0000
3+++ debian/control 2015-10-26 12:59:07 +0000
4@@ -34,6 +34,7 @@
5 libxcb1-dev,
6 pkg-config,
7 python3-all:any,
8+ python3-dbusmock,
9 python3-setuptools,
10 qml-module-qt-labs-folderlistmodel,
11 qml-module-qtquick-layouts,
12@@ -54,7 +55,7 @@
13 qtdeclarative5-ubuntu-web-plugin,
14 ttf-ubuntu-font-family,
15 Standards-Version: 3.9.4
16-Homepage: http://launchpad.net/unity
17+Homepage: http://launchpad.net/unity8
18 # If you aren't a member of ~unity-team but need to upload
19 # packaging changes, just go ahead. ~unity-team will notice
20 # and sync up the code again.
21
22=== modified file 'plugins/Unity/Session/CMakeLists.txt'
23--- plugins/Unity/Session/CMakeLists.txt 2015-06-18 16:06:44 +0000
24+++ plugins/Unity/Session/CMakeLists.txt 2015-10-26 12:59:07 +0000
25@@ -7,6 +7,8 @@
26 ${libunity8-private_SOURCE_DIR}
27 )
28
29+add_definitions(-DSM_BUSNAME=systemBus)
30+
31 set(QMLSESSIONPLUGIN_SRC
32 plugin.cpp
33 dbusunitysessionservice.cpp
34
35=== modified file 'plugins/Unity/Session/dbusunitysessionservice.cpp'
36--- plugins/Unity/Session/dbusunitysessionservice.cpp 2015-09-29 12:45:19 +0000
37+++ plugins/Unity/Session/dbusunitysessionservice.cpp 2015-10-26 12:59:07 +0000
38@@ -61,18 +61,18 @@
39 QStringLiteral("GetSessionByPID"));
40 msg << (quint32) getpid();
41
42- QDBusReply<QDBusObjectPath> reply = QDBusConnection::systemBus().asyncCall(msg);
43+ QDBusReply<QDBusObjectPath> reply = QDBusConnection::SM_BUSNAME().asyncCall(msg);
44 if (reply.isValid()) {
45 logindSessionPath = reply.value().path();
46
47 // start watching the Active property
48- QDBusConnection::systemBus().connect(LOGIN1_SERVICE, logindSessionPath, QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("PropertiesChanged"),
49+ QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, logindSessionPath, QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("PropertiesChanged"),
50 this, SLOT(onPropertiesChanged(QString,QVariantMap,QStringList)));
51
52 setupSystemdInhibition();
53
54 // re-enable the inhibition upon resume from sleep
55- QDBusConnection::systemBus().connect(LOGIN1_SERVICE, LOGIN1_PATH, LOGIN1_IFACE, QStringLiteral("PrepareForSleep"),
56+ QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, LOGIN1_PATH, LOGIN1_IFACE, QStringLiteral("PrepareForSleep"),
57 this, SLOT(onResuming(bool)));
58 } else {
59 qWarning() << "Failed to get logind session path" << reply.error().message();
60@@ -92,7 +92,7 @@
61 msg << "Unity"; // who
62 msg << "Unity8 handles power events"; // why
63 msg << "block"; // mode
64- QDBusReply<QDBusUnixFileDescriptor> desc = QDBusConnection::systemBus().asyncCall(msg);
65+ QDBusReply<QDBusUnixFileDescriptor> desc = QDBusConnection::SM_BUSNAME().asyncCall(msg);
66
67 if (desc.isValid()) {
68 m_systemdInhibitFd = desc.value();
69@@ -105,7 +105,7 @@
70 bool checkLogin1Call(const QString &method) const
71 {
72 QDBusMessage msg = QDBusMessage::createMethodCall(LOGIN1_SERVICE, LOGIN1_PATH, LOGIN1_IFACE, method);
73- QDBusReply<QString> reply = QDBusConnection::systemBus().asyncCall(msg);
74+ QDBusReply<QString> reply = QDBusConnection::SM_BUSNAME().asyncCall(msg);
75 return reply.isValid() && (reply == QStringLiteral("yes") || reply == QStringLiteral("challenge"));
76 }
77
78@@ -116,7 +116,7 @@
79 LOGIN1_IFACE,
80 method);
81 msg.setArguments(args);
82- QDBusConnection::systemBus().asyncCall(msg);
83+ QDBusConnection::SM_BUSNAME().asyncCall(msg);
84 }
85
86 void checkActive()
87@@ -133,7 +133,7 @@
88 msg << LOGIN1_SESSION_IFACE;
89 msg << ACTIVE_KEY;
90
91- QDBusReply<QVariant> reply = QDBusConnection::systemBus().asyncCall(msg);
92+ QDBusReply<QVariant> reply = QDBusConnection::SM_BUSNAME().asyncCall(msg);
93 if (reply.isValid()) {
94 isSessionActive = reply.value().toBool();
95 } else {
96@@ -159,7 +159,7 @@
97 msg << LOGIN1_SESSION_IFACE;
98 msg << IDLE_SINCE_KEY;
99
100- QDBusReply<QVariant> reply = QDBusConnection::systemBus().asyncCall(msg);
101+ QDBusReply<QVariant> reply = QDBusConnection::SM_BUSNAME().asyncCall(msg);
102 if (reply.isValid()) {
103 return reply.value().value<quint64>();
104 } else {
105@@ -176,7 +176,7 @@
106 LOGIN1_SESSION_IFACE,
107 QStringLiteral("SetIdleHint"));
108 msg << idle;
109- QDBusConnection::systemBus().asyncCall(msg);
110+ QDBusConnection::SM_BUSNAME().asyncCall(msg);
111 }
112
113 private Q_SLOTS:
114@@ -221,10 +221,10 @@
115 {
116 if (!d->logindSessionPath.isEmpty()) {
117 // connect our Lock() slot to the logind's session Lock() signal
118- QDBusConnection::systemBus().connect(LOGIN1_SERVICE, d->logindSessionPath, LOGIN1_SESSION_IFACE, QStringLiteral("Lock"), this, SLOT(Lock()));
119+ QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, d->logindSessionPath, LOGIN1_SESSION_IFACE, QStringLiteral("Lock"), this, SLOT(Lock()));
120 // ... and our Unlocked() signal to the logind's session Unlock() signal
121 // (lightdm handles the unlocking by calling logind's Unlock method which in turn emits this signal we connect to)
122- QDBusConnection::systemBus().connect(LOGIN1_SERVICE, d->logindSessionPath, LOGIN1_SESSION_IFACE, QStringLiteral("Unlock"), this, SIGNAL(Unlocked()));
123+ QDBusConnection::SM_BUSNAME().connect(LOGIN1_SERVICE, d->logindSessionPath, LOGIN1_SESSION_IFACE, QStringLiteral("Unlock"), this, SIGNAL(Unlocked()));
124 } else {
125 qWarning() << "Failed to connect to logind's session Lock/Unlock signals";
126 }
127@@ -325,7 +325,7 @@
128 sessionPath,
129 QStringLiteral("org.freedesktop.DisplayManager.Session"),
130 QStringLiteral("Lock"));
131- QDBusReply<void> reply = QDBusConnection::systemBus().asyncCall(msg);
132+ QDBusReply<void> reply = QDBusConnection::SM_BUSNAME().asyncCall(msg);
133 if (!reply.isValid()) {
134 qWarning() << "Lock call failed" << reply.error().message();
135 } else {
136
137=== modified file 'tests/plugins/Unity/Session/CMakeLists.txt'
138--- tests/plugins/Unity/Session/CMakeLists.txt 2015-06-29 14:53:02 +0000
139+++ tests/plugins/Unity/Session/CMakeLists.txt 2015-10-26 12:59:07 +0000
140@@ -16,7 +16,7 @@
141 target_link_libraries(sessionbackendtestExec
142 unity8-private
143 )
144-qt5_use_modules(sessionbackendtestExec Test Core Qml DBus)
145+qt5_use_modules(sessionbackendtestExec Test Core DBus)
146
147 add_unity8_unittest(SessionBackend dbus-test-runner
148 ARG_PREFIX "--parameter"
149
150=== modified file 'tests/plugins/Unity/Session/sessionbackendtest.cpp'
151--- tests/plugins/Unity/Session/sessionbackendtest.cpp 2015-06-30 03:45:36 +0000
152+++ tests/plugins/Unity/Session/sessionbackendtest.cpp 2015-10-26 12:59:07 +0000
153@@ -12,10 +12,6 @@
154 *
155 * You should have received a copy of the GNU Lesser General Public License
156 * along with this program. If not, see <http://www.gnu.org/licenses/>.
157- *
158- * Authors:
159- * Ying-Chun Liu (PaulLiu) <paul.liu@canonical.com>
160- * Lukáš Tinkl <lukas.tinkl@canonical.com>
161 */
162
163 #include <QtTest>
164@@ -50,10 +46,55 @@
165 dbusUnitySession = new QDBusInterface ("com.canonical.Unity",
166 "/com/canonical/Unity/Session",
167 "com.canonical.Unity.Session",
168- QDBusConnection::sessionBus());
169- }
170-
171- void testUnitySessionLogoutRequested_data() {
172+ QDBusConnection::sessionBus(), this);
173+
174+ // logind mock
175+ m_fakeLogindServer = new QProcess;
176+ m_fakeLogindServer->start("python3 -m dbusmock org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager");
177+ m_fakeLogindServer->waitForStarted();
178+ qDebug() << "Logind DBUS mock started with pid:" << m_fakeLogindServer->processId();
179+
180+ m_logindMockIface = new QDBusInterface("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.DBus.Mock",
181+ QDBusConnection::sessionBus(), this);
182+ QTRY_VERIFY(m_logindMockIface->isValid());
183+
184+ m_logindMockIface->call("AddTemplate", "logind", QVariant::fromValue(QVariantMap())); // load the logind template, no params
185+
186+ // add a fake session to make DBusUnitySessionService happy
187+ QDBusReply<QString> fakeSession = m_logindMockIface->call("AddSession", "fakesession", "fakeseat", (quint32) getuid(),
188+ "fakeuser", true);
189+
190+ qDebug() << "Using a fake login1 session:" << fakeSession;
191+
192+ if (!fakeSession.isValid()) {
193+ qWarning() << "Fake session error:" << fakeSession.error().name() << ":" << fakeSession.error().message();
194+ QFAIL("Fake session could not be found");
195+ }
196+ m_logindMockIface->call("AddMethod", "org.freedesktop.login1.Manager", "GetSessionByPID", "u", "o",
197+ QStringLiteral("ret='%1'").arg(fakeSession)); // let DBUSS find the fake session to operate on
198+
199+ // gnome screensaver mock
200+ m_fakeGnomeScreensaverServer = new QProcess;
201+ m_fakeGnomeScreensaverServer->start("python3 -m dbusmock org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver");
202+ m_fakeGnomeScreensaverServer->waitForStarted();
203+ qDebug() << "Gnome screensaver DBUS mock started with pid:" << m_fakeGnomeScreensaverServer->processId();
204+
205+ m_gnomeScreensaverMockIface = new QDBusInterface("org.gnome.ScreenSaver", "/org/gnome/ScreenSaver", "org.freedesktop.DBus.Mock",
206+ QDBusConnection::sessionBus(), this);
207+ QTRY_VERIFY(m_gnomeScreensaverMockIface->isValid());
208+
209+ m_gnomeScreensaverMockIface->call("AddTemplate", "gnome_screensaver", QVariant::fromValue(QVariantMap())); // load the gnome ss template, no params
210+ }
211+
212+ void cleanupTestCase() {
213+ m_fakeLogindServer->kill();
214+ delete m_fakeLogindServer;
215+
216+ m_fakeGnomeScreensaverServer->kill();
217+ delete m_fakeGnomeScreensaverServer;
218+ }
219+
220+ void testUnitySessionService_data() {
221 QTest::addColumn<QString>("method");
222 QTest::addColumn<QString>("signal");
223
224@@ -63,7 +104,7 @@
225 QTest::newRow("PromptLock") << "PromptLock" << "LockRequested()";
226 }
227
228- void testUnitySessionLogoutRequested() {
229+ void testUnitySessionService() {
230 QFETCH(QString, method);
231 QFETCH(QString, signal);
232
233@@ -148,22 +189,79 @@
234 }
235 }
236
237+ void testLogin1Capabilities_data() {
238+ QTest::addColumn<QString>("dbusMethod"); // dbus method on the login1 iface
239+ QTest::addColumn<QString>("method"); // our method
240+
241+ QTest::newRow("CanHibernate") << "CanHibernate" << "CanHibernate";
242+ QTest::newRow("CanSuspend") << "CanSuspend" << "CanSuspend";
243+ QTest::newRow("CanReboot") << "CanReboot" << "CanReboot";
244+ QTest::newRow("CanPowerOff") << "CanPowerOff" << "CanShutdown";
245+ QTest::newRow("CanHybridSleep") << "CanHybridSleep" << "CanHybridSleep";
246+ }
247+
248 void testLogin1Capabilities() {
249+ QFETCH(QString, dbusMethod);
250+ QFETCH(QString, method);
251+
252 DBusUnitySessionService dbusUnitySessionService;
253- QDBusInterface login1face("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", QDBusConnection::systemBus());
254+ QDBusInterface login1face("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", QDBusConnection::SM_BUSNAME());
255 QCoreApplication::processEvents(); // to let the services register on DBus
256
257- if (login1face.isValid()) {
258- QCOMPARE(dbusUnitySessionService.CanHibernate(), (login1face.call("CanHibernate").arguments().first().toString() != "no"));
259- QCOMPARE(dbusUnitySessionService.CanSuspend(), (login1face.call("CanSuspend").arguments().first().toString() != "no"));
260- QCOMPARE(dbusUnitySessionService.CanReboot(), (login1face.call("CanReboot").arguments().first().toString() != "no"));
261- QCOMPARE(dbusUnitySessionService.CanShutdown(), (login1face.call("CanPowerOff").arguments().first().toString() != "no"));
262- QCOMPARE(dbusUnitySessionService.CanHybridSleep(), (login1face.call("CanHybridSleep").arguments().first().toString() != "no"));
263+ QDBusReply<QString> dbusReply = login1face.call(dbusMethod);
264+ bool reply;
265+ dbusUnitySessionService.metaObject()->invokeMethod(&dbusUnitySessionService, qPrintable(method), Q_RETURN_ARG(bool, reply));
266+ QCOMPARE(reply, (dbusReply == "yes" || dbusReply == "challenge"));
267+ }
268+
269+ void testLogindMock_data() {
270+ QTest::addColumn<QString>("method"); // dbus method on the login1 iface
271+
272+ QTest::newRow("CanHibernate") << "CanHibernate";
273+ QTest::newRow("CanSuspend") << "CanSuspend";
274+ QTest::newRow("CanReboot") << "CanReboot";
275+ QTest::newRow("CanPowerOff") << "CanPowerOff";
276+ QTest::newRow("CanHybridSleep") << "CanHybridSleep";
277+ }
278+
279+ void testLogindMock() {
280+ QFETCH(QString, method);
281+
282+ const QStringList replies = {"yes", "no", "na", "challenge"};
283+
284+ Q_FOREACH(const QString &reply, replies) {
285+ m_logindMockIface->call("AddMethod", "org.freedesktop.login1.Manager", method, "", "s",
286+ QStringLiteral("ret='%1'").arg(reply));
287+
288+ QDBusInterface login1face("org.freedesktop.login1", "/org/freedesktop/login1", "org.freedesktop.login1.Manager", QDBusConnection::SM_BUSNAME());
289+ QCoreApplication::processEvents(); // to let the services register on DBus
290+
291+ QDBusReply<QString> dbusReply = login1face.call(method);
292+
293+ QCOMPARE(dbusReply.value(), reply);
294 }
295 }
296
297+ void testGnomeScreenSaverMock() {
298+ QDBusInterface gnomeSaverIface("org.gnome.ScreenSaver", "/org/gnome/ScreenSaver", "org.gnome.ScreenSaver",
299+ QDBusConnection::sessionBus(), this);
300+ QCoreApplication::processEvents(); // to let the service register on DBus
301+
302+ gnomeSaverIface.call("Lock");
303+
304+ QDBusReply<bool> isActive = gnomeSaverIface.call("GetActive");
305+
306+ QTRY_VERIFY(isActive.value()); // verify it's active (locked)
307+ }
308+
309 private:
310 QDBusInterface *dbusUnitySession;
311+
312+ QProcess *m_fakeLogindServer = nullptr;
313+ QDBusInterface *m_logindMockIface = nullptr;
314+
315+ QProcess *m_fakeGnomeScreensaverServer = nullptr;
316+ QDBusInterface *m_gnomeScreensaverMockIface = nullptr;
317 };
318
319 QTEST_GUILESS_MAIN(SessionBackendTest)

Subscribers

People subscribed via source and target branches