~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to khotkeys/test/kdedmodule_daemon_test.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright (c) 2006 Volker Krause <volker.krause@rwth-aachen.de>
 
3
 
 
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.
 
8
 
 
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.
 
13
 
 
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.
 
18
*/
 
19
 
 
20
#include "kdedmodule_daemon_test.h"
 
21
 
 
22
#include "daemon/daemon.h"
 
23
#include "daemon/kded_module.h"
 
24
 
 
25
#include <qtest_kde.h>
 
26
 
 
27
#include <QtDBus/QtDBus>
 
28
 
 
29
 
 
30
void Test::initTestCase()
 
31
    {
 
32
    daemonActive = KHotKeys::Daemon::isRunning();
 
33
    if (daemonActive)
 
34
        {
 
35
        qWarning() << "Shutting down a running daemon";
 
36
        KHotKeys::Daemon::stop();
 
37
        }
 
38
    }
 
39
 
 
40
 
 
41
void Test::cleanupTestCase()
 
42
    {
 
43
    if (daemonActive)
 
44
        {
 
45
        qWarning() << "Restarting the stopped daemon";
 
46
        KHotKeys::Daemon::start();
 
47
        }
 
48
    }
 
49
 
 
50
 
 
51
void Test::testLoading()
 
52
    {
 
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());
 
72
    }
 
73
 
 
74
QTEST_MAIN(Test)
 
75
#include "moc_kdedmodule_daemon_test.cpp"