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

« back to all changes in this revision

Viewing changes to kcontrol/keyboard/tests/keyboard_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) 2011 Andriy Rysin (rysin@kde.org)
 
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; either version 2 of the License, or
 
7
 *  (at your option) any later version.
 
8
 *
 
9
 *  This program 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
 
12
 *  GNU General Public License for more details.
 
13
 *
 
14
 *  You should have received a copy of the GNU General Public License
 
15
 *  along with this program; if not, write to the Free Software
 
16
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
17
 */
 
18
 
 
19
#include <kdebug.h>
 
20
//#include <kapplication.h>
 
21
 
 
22
#include <qtest_kde.h>
 
23
#include <QtGui/QIcon>
 
24
 
 
25
#include "../flags.h"
 
26
#include "../xkb_rules.h"
 
27
#include "../keyboard_config.h"
 
28
#include "../keyboard_daemon.h"
 
29
 
 
30
 
 
31
class KeyboardDaemonTest : public QObject
 
32
{
 
33
    Q_OBJECT
 
34
 
 
35
    KeyboardDaemon* keyboardDaemon;
 
36
//    KApplication* kapplication;
 
37
 
 
38
private Q_SLOTS:
 
39
    void initTestCase() {
 
40
//      kapplication = new KApplication();
 
41
//      const KAboutData* kAboutData = new KAboutData(i18n("a").toAscii(), i18n("a").toAscii(), KLocalizedString(), i18n("a").toAscii());
 
42
//      KCmdLineArgs::init(kAboutData);
 
43
        keyboardDaemon = new KeyboardDaemon(this, QList<QVariant>());
 
44
    }
 
45
 
 
46
    void cleanupTestCase() {
 
47
        delete keyboardDaemon;
 
48
//      delete kapplication;
 
49
    }
 
50
 
 
51
    void testDaemon() {
 
52
        QVERIFY( keyboardDaemon != NULL );
 
53
 
 
54
//        QVERIFY( ! flags->getTransparentPixmap().isNull() );
 
55
//
 
56
//        const QIcon iconUs(flags->getIcon("us"));
 
57
//        QVERIFY( ! iconUs.isNull() );
 
58
//        QVERIFY( flags->getIcon("--").isNull() );
 
59
//
 
60
//      KeyboardConfig keyboardConfig;
 
61
//        LayoutUnit layoutUnit("us");
 
62
//        LayoutUnit layoutUnit1("us", "intl");
 
63
//        layoutUnit1.setDisplayName("usi");
 
64
//        LayoutUnit layoutUnit2("us", "other");
 
65
//
 
66
//        keyboardConfig.showFlag = true;
 
67
//        const QIcon iconUsFlag = flags->getIconWithText(layoutUnit, keyboardConfig);
 
68
//        QVERIFY( ! iconUsFlag.isNull() );
 
69
//        QCOMPARE( image(iconUsFlag), image(iconUs) );
 
70
//
 
71
//        keyboardConfig.showFlag = false;
 
72
//        const QIcon iconUsText = flags->getIconWithText(layoutUnit, keyboardConfig);
 
73
//        QVERIFY( ! iconUsText.isNull() );
 
74
//        QVERIFY( image(iconUsText) != image(iconUs) );
 
75
//
 
76
//        keyboardConfig.layouts.append(layoutUnit1);
 
77
//        QCOMPARE( flags->getShortText(layoutUnit, keyboardConfig), QString("us") );
 
78
//        QCOMPARE( flags->getShortText(layoutUnit1, keyboardConfig), QString("usi") );
 
79
//        QCOMPARE( flags->getShortText(layoutUnit2, keyboardConfig), QString("us") );
 
80
//
 
81
//        const Rules* rules = Rules::readRules();
 
82
//        QCOMPARE( flags->getLongText(layoutUnit, rules), QString("USA") );
 
83
//        QVERIFY( flags->getLongText(layoutUnit1, rules).startsWith("USA - International") );
 
84
//        QCOMPARE( flags->getLongText(layoutUnit2, rules), QString("USA - other") );
 
85
//
 
86
//        flags->clearCache();
 
87
    }
 
88
 
 
89
//    void loadRulesBenchmark() {
 
90
//      QBENCHMARK {
 
91
//              Flags* flags = new Flags();
 
92
//              delete flags;
 
93
//      }
 
94
//    }
 
95
 
 
96
};
 
97
 
 
98
// need GUI for xkb protocol in xkb_rules.cpp
 
99
QTEST_KDEMAIN( KeyboardDaemonTest, GUI )
 
100
 
 
101
#include "keyboard_daemon_test.moc"