on xenial help sign in
Fix some tests; add a mock SessionManager plugin to avoid actually switching sessions during a test
5a1e855Michael Terry
CMakeLists.txt+1−3
@@ -187,10 +187,8 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${SHELL_APP}.desktop
187install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${GREETER_APP}.desktop
187install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${GREETER_APP}.desktop
188 DESTINATION ${CMAKE_INSTALL_DATADIR}/lightdm/greeters
188 DESTINATION ${CMAKE_INSTALL_DATADIR}/lightdm/greeters
189 )
189 )
190−# This next rule should use ${CMAKE_INSTALL_SYSCONFDIR}, but until Debian bug
191−# 719148 is fixed, we need to manually specify /etc
192install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/51-${GREETER_APP}.conf
190install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/51-${GREETER_APP}.conf
193− DESTINATION /etc/lightdm/lightdm.conf.d
191+ DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/lightdm/lightdm.conf.d
194 )
192 )
195
193
196#
194#
debian/rules+2−1
@@ -19,7 +19,8 @@ override_dh_auto_clean:
19override_dh_auto_configure:
19override_dh_auto_configure:
20 # Debian defines CMAKE_INSTALL_LOCALSTATEDIR as /usr/var, which is wrong.
20 # Debian defines CMAKE_INSTALL_LOCALSTATEDIR as /usr/var, which is wrong.
21 # So until Debian bug 719148 is fixed, do it ourselves.
21 # So until Debian bug 719148 is fixed, do it ourselves.
22− dh_auto_configure -- -DCMAKE_INSTALL_LOCALSTATEDIR="/var"
22+ dh_auto_configure -- -DCMAKE_INSTALL_LOCALSTATEDIR="/var" \
23+ -DCMAKE_INSTALL_SYSCONFDIR="/etc"
23
24
24override_dh_install:
25override_dh_install:
25 # install autopilot tests
26 # install autopilot tests
tests/autopilot/unity8/shell/tests/test_notifications.py−20
@@ -119,8 +119,6 @@ class InteractiveNotificationBase(NotificationsBase):
119 def test_interactive(self):
119 def test_interactive(self):
120 """Interactive notification must react upon click on itself."""
120 """Interactive notification must react upon click on itself."""
121 self.launch_unity()
121 self.launch_unity()
122− greeter = self.main_window.get_greeter()
123− greeter.swipe()
124
122
125 notify_list = self._get_notifications_list()
123 notify_list = self._get_notifications_list()
126
124
@@ -158,8 +156,6 @@ class InteractiveNotificationBase(NotificationsBase):
158 def test_sd_incoming_call(self):
156 def test_sd_incoming_call(self):
159 """Rejecting a call should make notification expand and offer more options."""
157 """Rejecting a call should make notification expand and offer more options."""
160 self.launch_unity()
158 self.launch_unity()
161− greeter = self.main_window.get_greeter()
162− greeter.swipe()
163
159
164 notify_list = self._get_notifications_list()
160 notify_list = self._get_notifications_list()
165
161
@@ -334,8 +330,6 @@ class EphemeralNotificationsTests(NotificationsBase):
334 def test_icon_summary_body(self):
330 def test_icon_summary_body(self):
335 """Notification must display the expected summary and body text."""
331 """Notification must display the expected summary and body text."""
336 self.launch_unity()
332 self.launch_unity()
337− greeter = self.main_window.get_greeter()
338− greeter.swipe()
339
333
340 notify_list = self._get_notifications_list()
334 notify_list = self._get_notifications_list()
341
335
@@ -368,8 +362,6 @@ class EphemeralNotificationsTests(NotificationsBase):
368 def test_icon_summary(self):
362 def test_icon_summary(self):
369 """Notification must display the expected summary and secondary icon."""
363 """Notification must display the expected summary and secondary icon."""
370 self.launch_unity()
364 self.launch_unity()
371− greeter = self.main_window.get_greeter()
372− greeter.swipe()
373
365
374 notify_list = self._get_notifications_list()
366 notify_list = self._get_notifications_list()
375
367
@@ -406,8 +398,6 @@ class EphemeralNotificationsTests(NotificationsBase):
406 def test_urgency_order(self):
398 def test_urgency_order(self):
407 """Notifications must be displayed in order according to their urgency."""
399 """Notifications must be displayed in order according to their urgency."""
408 self.launch_unity()
400 self.launch_unity()
409− greeter = self.main_window.get_greeter()
410− greeter.swipe()
411
401
412 notify_list = self._get_notifications_list()
402 notify_list = self._get_notifications_list()
413
403
@@ -497,8 +487,6 @@ class EphemeralNotificationsTests(NotificationsBase):
497 def test_summary_and_body(self):
487 def test_summary_and_body(self):
498 """Notification must display the expected summary- and body-text."""
488 """Notification must display the expected summary- and body-text."""
499 self.launch_unity()
489 self.launch_unity()
500− greeter = self.main_window.get_greeter()
501− greeter.swipe()
502
490
503 notify_list = self._get_notifications_list()
491 notify_list = self._get_notifications_list()
504
492
@@ -523,8 +511,6 @@ class EphemeralNotificationsTests(NotificationsBase):
523 def test_summary_only(self):
511 def test_summary_only(self):
524 """Notification must display only the expected summary-text."""
512 """Notification must display only the expected summary-text."""
525 self.launch_unity()
513 self.launch_unity()
526− greeter = self.main_window.get_greeter()
527− greeter.swipe()
528
514
529 notify_list = self._get_notifications_list()
515 notify_list = self._get_notifications_list()
530
516
@@ -542,8 +528,6 @@ class EphemeralNotificationsTests(NotificationsBase):
542 def test_update_notification_same_layout(self):
528 def test_update_notification_same_layout(self):
543 """Notification must allow updating its contents while being displayed."""
529 """Notification must allow updating its contents while being displayed."""
544 self.launch_unity()
530 self.launch_unity()
545− greeter = self.main_window.get_greeter()
546− greeter.swipe()
547
531
548 notify_list = self._get_notifications_list()
532 notify_list = self._get_notifications_list()
549
533
@@ -581,8 +565,6 @@ class EphemeralNotificationsTests(NotificationsBase):
581 def test_update_notification_layout_change(self):
565 def test_update_notification_layout_change(self):
582 """Notification must allow updating its contents and layout while being displayed."""
566 """Notification must allow updating its contents and layout while being displayed."""
583 self.launch_unity()
567 self.launch_unity()
584− greeter = self.main_window.get_greeter()
585− greeter.swipe()
586
568
587 notify_list = self._get_notifications_list()
569 notify_list = self._get_notifications_list()
588
570
@@ -627,8 +609,6 @@ class EphemeralNotificationsTests(NotificationsBase):
627 def test_append_hint(self):
609 def test_append_hint(self):
628 """Notification has to accumulate body-text using append-hint."""
610 """Notification has to accumulate body-text using append-hint."""
629 self.launch_unity()
611 self.launch_unity()
630− greeter = self.main_window.get_greeter()
631− greeter.swipe()
632
612
633 notify_list = self._get_notifications_list()
613 notify_list = self._get_notifications_list()
634
614
tests/mocks/CMakeLists.txt+1
@@ -5,5 +5,6 @@ add_subdirectory(liblightdm)
5add_subdirectory(libusermetrics)
5add_subdirectory(libusermetrics)
6add_subdirectory(Powerd)
6add_subdirectory(Powerd)
7add_subdirectory(QMenuModel)
7add_subdirectory(QMenuModel)
8+add_subdirectory(SessionManager)
8add_subdirectory(Ubuntu)
9add_subdirectory(Ubuntu)
9add_subdirectory(Unity)
10add_subdirectory(Unity)
tests/mocks/SessionManager/CMakeLists.txtnew file+19
@@ -0,0 +1,19 @@
1+add_library(MockSessionManager-qml MODULE
2+ plugin.cpp
3+ SessionManager.cpp
4+ )
5+
6+qt5_use_modules(MockSessionManager-qml Qml)
7+
8+# copy qmldir file into build directory for shadow builds
9+file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/qmldir"
10+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
11+ )
12+
13+install(TARGETS MockSessionManager-qml
14+ DESTINATION ${SHELL_PRIVATE_LIBDIR}/qml/mocks/SessionManager
15+ )
16+
17+install(FILES qmldir
18+ DESTINATION ${SHELL_PRIVATE_LIBDIR}/qml/mocks/SessionManager
19+ )
tests/mocks/SessionManager/SessionManager.cppnew file+33
@@ -0,0 +1,33 @@
1+/*
2+ * Copyright (C) 2013 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+ * Author: Michael Terry <michael.terry@canonical.com>
17+ */
18+
19+#include "SessionManager.h"
20+
21+SessionManager::SessionManager(QObject* parent)
22+ : QObject(parent)
23+{
24+}
25+
26+bool SessionManager::active() const
27+{
28+ return true;
29+}
30+
31+void SessionManager::lock()
32+{
33+}
tests/mocks/SessionManager/SessionManager.hnew file+41
@@ -0,0 +1,41 @@
1+/*
2+ * Copyright (C) 2013 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+ * Authors: Michael Terry <michael.terry@canonical.com>
17+ */
18+
19+#ifndef UNITY_MOCK_SESSIONMANAGER_H
20+#define UNITY_MOCK_SESSIONMANAGER_H
21+
22+#include <QObject>
23+
24+class SessionManager: public QObject
25+{
26+ Q_OBJECT
27+ Q_PROPERTY(bool active READ active NOTIFY activeChanged FINAL)
28+
29+public:
30+ explicit SessionManager(QObject *parent = 0);
31+
32+ bool active() const;
33+
34+public Q_SLOTS:
35+ void lock();
36+
37+Q_SIGNALS:
38+ void activeChanged();
39+};
40+
41+#endif
tests/mocks/SessionManager/plugin.cppnew file+35
@@ -0,0 +1,35 @@
1+/*
2+ * Copyright (C) 2013 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+ * Authors: Michael Terry <michael.terry@canonical.com>
17+ */
18+
19+#include "plugin.h"
20+#include "SessionManager.h"
21+
22+#include <QtQml>
23+
24+static QObject *sessionmanager_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
25+{
26+ Q_UNUSED(engine)
27+ Q_UNUSED(scriptEngine)
28+ return new SessionManager();
29+}
30+
31+void SessionManagerPlugin::registerTypes(const char *uri)
32+{
33+ Q_ASSERT(uri == QLatin1String("SessionManager"));
34+ qmlRegisterSingletonType<SessionManager>(uri, 0, 1, "SessionManager", sessionmanager_provider);
35+}
tests/mocks/SessionManager/plugin.hnew file+34
@@ -0,0 +1,34 @@
1+/*
2+ * Copyright (C) 2013 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+ * Authors: Michael Terry <michael.terry@canonical.com>
17+ */
18+
19+#ifndef MOCK_SESSIONMANAGER_PLUGIN_H
20+#define MOCK_SESSIONMANAGER_PLUGIN_H
21+
22+#include <QQmlEngine>
23+#include <QQmlExtensionPlugin>
24+
25+class SessionManagerPlugin : public QQmlExtensionPlugin
26+{
27+ Q_OBJECT
28+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
29+
30+public:
31+ void registerTypes(const char *uri);
32+};
33+
34+#endif
tests/mocks/SessionManager/qmldirnew file+2
@@ -0,0 +1,2 @@
1+module SessionManager
2+plugin MockSessionManager-qml
tests/plugins/SessionBroadcast/CMakeLists.txt+3−3
@@ -13,12 +13,12 @@ include_directories(
13
13
14add_definitions(-DSM_BUSNAME=sessionBus)
14add_definitions(-DSM_BUSNAME=sessionBus)
15
15
16−add_executable(mock-server
16+add_executable(sessionbroadcastmock
17 ${CMAKE_CURRENT_BINARY_DIR}/BroadcastAdaptor.cpp
17 ${CMAKE_CURRENT_BINARY_DIR}/BroadcastAdaptor.cpp
18 server.cpp
18 server.cpp
19 BroadcastServer.cpp
19 BroadcastServer.cpp
20 )
20 )
21−qt5_use_modules(mock-server Core DBus)
21+qt5_use_modules(sessionbroadcastmock Core DBus)
22
22
23add_executable(sessionbroadcasttest
23add_executable(sessionbroadcasttest
24 ${CMAKE_SOURCE_DIR}/plugins/SessionBroadcast/SessionBroadcast.cpp
24 ${CMAKE_SOURCE_DIR}/plugins/SessionBroadcast/SessionBroadcast.cpp
@@ -28,7 +28,7 @@ qt5_use_modules(sessionbroadcasttest Core DBus Test)
28
28
29add_test(NAME sessionbroadcasttest
29add_test(NAME sessionbroadcasttest
30 COMMAND dbus-test-runner
30 COMMAND dbus-test-runner
31− --task ${CMAKE_CURRENT_BINARY_DIR}/mock-server
31+ --task ${CMAKE_CURRENT_BINARY_DIR}/sessionbroadcastmock
32 --task-name server
32 --task-name server
33 --ignore-return
33 --ignore-return
34 --task ${CMAKE_CURRENT_BINARY_DIR}/sessionbroadcasttest
34 --task ${CMAKE_CURRENT_BINARY_DIR}/sessionbroadcasttest
tests/plugins/SessionManager/CMakeLists.txt+7−7
@@ -16,7 +16,7 @@ include_directories(
16
16
17add_definitions(-DSM_BUSNAME=sessionBus)
17add_definitions(-DSM_BUSNAME=sessionBus)
18
18
19−add_executable(mock-server
19+add_executable(sessionmanagermock
20 ${CMAKE_CURRENT_BINARY_DIR}/LightDMSessionAdaptor.cpp
20 ${CMAKE_CURRENT_BINARY_DIR}/LightDMSessionAdaptor.cpp
21 ${CMAKE_CURRENT_BINARY_DIR}/LoginManagerAdaptor.cpp
21 ${CMAKE_CURRENT_BINARY_DIR}/LoginManagerAdaptor.cpp
22 ${CMAKE_CURRENT_BINARY_DIR}/LoginPropertiesAdaptor.cpp
22 ${CMAKE_CURRENT_BINARY_DIR}/LoginPropertiesAdaptor.cpp
@@ -26,23 +26,23 @@ add_executable(mock-server
26 LoginManagerServer.cpp
26 LoginManagerServer.cpp
27 LoginSessionServer.cpp
27 LoginSessionServer.cpp
28 )
28 )
29−qt5_use_modules(mock-server Core DBus)
29+qt5_use_modules(sessionmanagermock Core DBus)
30
30
31−add_executable(test-sessionmanager
31+add_executable(sessionmanagertest
32 ${CMAKE_SOURCE_DIR}/plugins/SessionManager/SessionManager.cpp
32 ${CMAKE_SOURCE_DIR}/plugins/SessionManager/SessionManager.cpp
33 client.cpp
33 client.cpp
34 )
34 )
35−qt5_use_modules(test-sessionmanager Core DBus Test)
35+qt5_use_modules(sessionmanagertest Core DBus Test)
36
36
37−add_test(NAME test-sessionmanager
37+add_test(NAME sessionmanagertest
38 COMMAND env
38 COMMAND env
39 XDG_SESSION_ID=sessionid
39 XDG_SESSION_ID=sessionid
40 XDG_SESSION_PATH=/mocksession/lightdm
40 XDG_SESSION_PATH=/mocksession/lightdm
41 dbus-test-runner
41 dbus-test-runner
42− --task ${CMAKE_CURRENT_BINARY_DIR}/mock-server
42+ --task ${CMAKE_CURRENT_BINARY_DIR}/sessionmanagermock
43 --task-name server
43 --task-name server
44 --ignore-return
44 --ignore-return
45− --task ${CMAKE_CURRENT_BINARY_DIR}/test-sessionmanager
45+ --task ${CMAKE_CURRENT_BINARY_DIR}/sessionmanagertest
46 --task-name client
46 --task-name client
47 --wait-for org.freedesktop.login1
47 --wait-for org.freedesktop.login1
48 )
48 )
tests/qmltests/tst_Shell.qml+3−29
@@ -54,17 +54,7 @@ Item {
54 name: "Shell"
54 name: "Shell"
55 when: windowShown
55 when: windowShown
56
56
57− function initTestCase() {
58− swipeAwayGreeter();
59− }
60−
61 function cleanup() {
57 function cleanup() {
62− // If a test invoked the greeter, make sure we swipe it away again
63− var greeter = findChild(shell, "greeter");
64− if (greeter.shown) {
65− swipeAwayGreeter();
66− }
67−
68 // kill all (fake) running apps
58 // kill all (fake) running apps
69 killApps(ApplicationManager.mainStageApplications);
59 killApps(ApplicationManager.mainStageApplications);
70 killApps(ApplicationManager.sideStageApplications);
60 killApps(ApplicationManager.sideStageApplications);
@@ -115,8 +105,6 @@ Item {
115 }
105 }
116
106
117 function test_suspend() {
107 function test_suspend() {
118− var greeter = findChild(shell, "greeter");
119−
120 // Launch an app from the launcher
108 // Launch an app from the launcher
121 dragLauncherIntoView();
109 dragLauncherIntoView();
122 tapOnAppIconInLauncher();
110 tapOnAppIconInLauncher();
@@ -127,29 +115,15 @@ Item {
127
115
128 // Try to suspend while proximity is engaged...
116 // Try to suspend while proximity is engaged...
129 Powerd.displayPowerStateChange(Powerd.Off, Powerd.UseProximity);
117 Powerd.displayPowerStateChange(Powerd.Off, Powerd.UseProximity);
130− tryCompare(greeter, "showProgress", 0);
118+ tryCompare(ApplicationManager, "mainStageFocusedApplication", mainApp);
131
119
132 // Now really suspend
120 // Now really suspend
133 Powerd.displayPowerStateChange(Powerd.Off, 0);
121 Powerd.displayPowerStateChange(Powerd.Off, 0);
134− tryCompare(greeter, "showProgress", 1);
135 tryCompare(ApplicationManager, "mainStageFocusedApplication", null);
122 tryCompare(ApplicationManager, "mainStageFocusedApplication", null);
136
123
137 // And wake up
124 // And wake up
138 Powerd.displayPowerStateChange(Powerd.On, 0);
125 Powerd.displayPowerStateChange(Powerd.On, 0);
139 tryCompare(ApplicationManager, "mainStageFocusedApplication", mainApp);
126 tryCompare(ApplicationManager, "mainStageFocusedApplication", mainApp);
140− tryCompare(greeter, "showProgress", 1);
141− }
142−
143− function swipeAwayGreeter() {
144− var greeter = findChild(shell, "greeter");
145− tryCompare(greeter, "showProgress", 1);
146−
147− var touchX = shell.width - (shell.edgeSize / 2);
148− var touchY = shell.height / 2;
149− touchFlick(shell, touchX, touchY, shell.width * 0.1, touchY);
150−
151− // wait until the animation has finished
152− tryCompare(greeter, "showProgress", 0);
153 }
127 }
154
128
155 /*
129 /*
@@ -323,8 +297,8 @@ Item {
323
297
324 function test_wallpaper_data() {
298 function test_wallpaper_data() {
325 return [
299 return [
326− {tag: "red", url: "tests/data/unity/backgrounds/red.png", expectedUrl: "tests/data/unity/backgrounds/red.png"},
300+ {tag: "red", url: "../tests/data/unity/backgrounds/red.png", expectedUrl: "tests/data/unity/backgrounds/red.png"},
327− {tag: "blue", url: "tests/data/unity/backgrounds/blue.png", expectedUrl: "tests/data/unity/backgrounds/blue.png"},
301+ {tag: "blue", url: "../tests/data/unity/backgrounds/blue.png", expectedUrl: "tests/data/unity/backgrounds/blue.png"},
328 {tag: "invalid", url: "invalid", expectedUrl: shell.defaultBackground},
302 {tag: "invalid", url: "invalid", expectedUrl: shell.defaultBackground},
329 {tag: "empty", url: "", expectedUrl: shell.defaultBackground}
303 {tag: "empty", url: "", expectedUrl: shell.defaultBackground}
330 ]
304 ]