2 * Copyright 2016 Canonical Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18#include <QDBusInterface>
23#include "SessionBroadcast.h"
25class SessionBroadcastTest : public QObject
32 broadcastServer = new QDBusInterface("com.canonical.Unity.Greeter.Broadcast",
33 "/com/canonical/Unity/Greeter/Broadcast",
34 "com.canonical.Unity.Greeter.Broadcast",
35 QDBusConnection::sessionBus(), this);
36 serverStartUrlSpy = new QSignalSpy(broadcastServer,
37 SIGNAL(StartUrl(const QString &, const QString &)));
38 serverShowHomeSpy = new QSignalSpy(broadcastServer,
39 SIGNAL(ShowHome(const QString &)));
40 user = QString(g_get_user_name());
41 otherUser = user + "2";
46 serverStartUrlSpy->clear();
47 serverShowHomeSpy->clear();
49 broadcastPlugin = new SessionBroadcast(this);
50 pluginStartUrlSpy = new QSignalSpy(broadcastPlugin,
51 SIGNAL(startUrl(const QString &)));
52 pluginShowHomeSpy = new QSignalSpy(broadcastPlugin,
58 delete broadcastPlugin;
61 void testReceiveUrlStart() {
62 broadcastServer->call("RequestUrlStart", user, "test:");
63 QTRY_COMPARE(serverStartUrlSpy->count(), 1);
64 QCOMPARE(pluginStartUrlSpy->count(), 1);
65 QCOMPARE((*pluginStartUrlSpy)[0][0], QVariant("test:"));
68 void testReceiveUrlStartOtherUser() {
69 broadcastServer->call("RequestUrlStart", otherUser, "test:");
70 QTRY_COMPARE(serverStartUrlSpy->count(), 1);
71 QCOMPARE(pluginStartUrlSpy->count(), 0);
74 void testReceiveShowHome() {
75 broadcastServer->call("RequestHomeShown", user);
76 QTRY_COMPARE(serverShowHomeSpy->count(), 1);
77 QCOMPARE(pluginShowHomeSpy->count(), 1);
80 void testReceiveShowHomeOtherUser() {
81 broadcastServer->call("RequestHomeShown", otherUser);
82 QTRY_COMPARE(serverShowHomeSpy->count(), 1);
83 QCOMPARE(pluginShowHomeSpy->count(), 0);
86 void testSendUrlStart() {
87 broadcastPlugin->requestUrlStart(otherUser, "test:");
88 QTRY_COMPARE(serverStartUrlSpy->count(), 1);
89 QCOMPARE((*serverStartUrlSpy)[0][0], QVariant(otherUser));
90 QCOMPARE((*serverStartUrlSpy)[0][1], QVariant("test:"));
93 void testSendShowHome() {
94 broadcastPlugin->requestHomeShown(otherUser);
95 QTRY_COMPARE(serverShowHomeSpy->count(), 1);
96 QCOMPARE((*serverShowHomeSpy)[0][0], QVariant(otherUser));
100 QDBusInterface *broadcastServer;
101 SessionBroadcast *broadcastPlugin;
102 QSignalSpy *serverStartUrlSpy;
103 QSignalSpy *serverShowHomeSpy;
104 QSignalSpy *pluginStartUrlSpy;
105 QSignalSpy *pluginShowHomeSpy;
110QTEST_GUILESS_MAIN(SessionBroadcastTest)
111#include "sessionbroadcasttest.moc"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list