on xenial help sign in
Add dbus interface test.
commit5668b5e790924adb61409182a4084ee2d36d6dee authorYing-Chun Liu <paul.liu@canonical.com> dateThu 29 May 2014, 16:23 (12 years ago) parentd00cdf7
3 files changed+88
tests/plugins/Unity/CMakeLists.txt+1 tests/plugins/Unity/Session/CMakeLists.txt+23 tests/plugins/Unity/Session/sessionbackendtest.cpp+64
tests/plugins/Unity/CMakeLists.txt+1
@@ -1,2 +1,3 @@
11add_subdirectory(Indicators)
22add_subdirectory(Launcher)
3+add_subdirectory(Session)
tests/plugins/Unity/Session/CMakeLists.txtnew file+23
@@ -0,0 +1,23 @@
1+include(FindPkgConfig)
2+
3+include_directories(
4+ ${CMAKE_CURRENT_BINARY_DIR}
5+ ${CMAKE_SOURCE_DIR}/plugins/Unity/Session
6+)
7+
8+add_definitions(-DSM_BUSNAME=sessionBus)
9+add_definitions(-DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
10+add_definitions(-DSESSION_TESTING)
11+
12+### SessionBackendTest
13+set(testBackendCommand dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/sessionbackendtestExec
14+ --parameter -o --parameter ${CMAKE_BINARY_DIR}/sessionbackendtest.xml,xunitxml
15+ --parameter -o --parameter -,txt)
16+add_test(NAME sessionbackendtest COMMAND ${testBackendCommand})
17+add_custom_target(sessionbackendtest ${testBackendCommand})
18+add_executable(sessionbackendtestExec
19+ sessionbackendtest.cpp
20+ ${CMAKE_SOURCE_DIR}/plugins/Unity/Session/dbusunitysessionservice.cpp
21+)
22+target_link_libraries(sessionbackendtestExec)
23+qt5_use_modules(sessionbackendtestExec Test Core Qml DBus)
tests/plugins/Unity/Session/sessionbackendtest.cppnew file+64
@@ -0,0 +1,64 @@
1+/*
2+ * Copyright 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 Lesser 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 Lesser General Public License for more details.
12+ *
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/>.
15+ *
16+ * Authors:
17+ * Ying-Chun Liu (PaulLiu) <paul.liu@canonical.com>
18+ */
19+
20+#include <QtTest>
21+#include <QDBusConnection>
22+#include <QDBusMessage>
23+#include <QDBusInterface>
24+#include <QDBusReply>
25+#include <QDBusVariant>
26+
27+#include "dbusunitysessionservice.h"
28+
29+class SessionBackendTest : public QObject
30+{
31+ Q_OBJECT
32+
33+private Q_SLOTS:
34+
35+ void initTestCase() {
36+ }
37+
38+ void testDbusIfaceMethods_data() {
39+ QTest::addColumn<QString>("method");
40+
41+ QTest::newRow("Logout") << "RequestLogout";
42+ }
43+
44+ void testDbusIfaceMethods() {
45+ QFETCH(QString, method);
46+
47+ DBusUnitySessionService dbusUnitySessionService;
48+
49+ QDBusConnection con = QDBusConnection::sessionBus();
50+ QDBusInterface interface ("com.canonical.Unity",
51+ "/com/canonical/Unity/Session",
52+ "com.canonical.Unity.Session",
53+ con);
54+ QDBusReply<void> reply;
55+
56+ QCOMPARE(interface.isValid(), true);
57+ reply = interface.call(method);
58+ QCOMPARE(reply.isValid(), true);
59+
60+ }
61+};
62+
63+QTEST_GUILESS_MAIN(SessionBackendTest)
64+#include "sessionbackendtest.moc"