not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / khotkeys / test / kdedmodule_daemon_test.cpp
blob32ff1120b9a4bd30ab21be52ebaaf1225f496d36
1 /*
2 Copyright (c) 2006 Volker Krause <volker.krause@rwth-aachen.de>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #include "kdedmodule_daemon_test.h"
22 #include "daemon/daemon.h"
23 #include "daemon/kded_module.h"
25 #include <qtest_kde.h>
27 #include <QtDBus/QtDBus>
30 void Test::initTestCase()
32 daemonActive = KHotKeys::Daemon::isRunning();
33 if (daemonActive)
35 qWarning() << "Shutting down a running daemon";
36 KHotKeys::Daemon::stop();
41 void Test::cleanupTestCase()
43 if (daemonActive)
45 qWarning() << "Restarting the stopped daemon";
46 KHotKeys::Daemon::start();
51 void Test::testLoading()
53 // Check loading/unloading. We have to do it more than once. When
54 // something is amiss kded will crash after reloading it.
55 QVERIFY(!KHotKeys::KdedModuleDaemon::isRunning());
56 // 1st round
57 QVERIFY(KHotKeys::KdedModuleDaemon::start());
58 QVERIFY(KHotKeys::KdedModuleDaemon::isRunning());
59 QVERIFY(KHotKeys::KdedModuleDaemon::stop());
60 QVERIFY(!KHotKeys::KdedModuleDaemon::isRunning());
61 // 2nd round
62 QVERIFY(KHotKeys::KdedModuleDaemon::start());
63 QVERIFY(KHotKeys::KdedModuleDaemon::isRunning());
64 QVERIFY(KHotKeys::KdedModuleDaemon::stop());
65 QVERIFY(!KHotKeys::KdedModuleDaemon::isRunning());
66 // 3nd round
67 QVERIFY(KHotKeys::KdedModuleDaemon::start());
68 QVERIFY(KHotKeys::KdedModuleDaemon::isRunning());
69 // Ensure kded is still there
70 QVERIFY(QDBusInterface( "org.kde.kded", "/kded","org.kde.kded" ).isValid());
71 QVERIFY(KHotKeys::KdedModuleDaemon::stop());
74 QTEST_MAIN(Test)
75 #include "moc_kdedmodule_daemon_test.cpp"