~sil/ubuntu-keyboard/numbers-on-top-row

« back to all changes in this revision

Viewing changes to tests/unittests/ut_language-layout-loading/ut_language-layout-loading.cpp

  • Committer: Guenter Schwann
  • Date: 2013-11-13 15:36:39 UTC
  • mfrom: (101.4.5 keyboard-cleanups)
  • Revision ID: guenter.schwann@canonical.com-20131113153639-9i9irt1mle00vy1t
Remove some dead code

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * This file is part of Maliit Plugins
3
 
 *
4
 
 * Copyright (C) 2012 Openismus GmbH. All rights reserved.
5
 
 *
6
 
 * Contact: maliit-discuss@lists.maliit.org
7
 
 *
8
 
 * Redistribution and use in source and binary forms, with or without modification,
9
 
 * are permitted provided that the following conditions are met:
10
 
 *
11
 
 * Redistributions of source code must retain the above copyright notice, this list
12
 
 * of conditions and the following disclaimer.
13
 
 * Redistributions in binary form must reproduce the above copyright notice, this list
14
 
 * of conditions and the following disclaimer in the documentation and/or other materials
15
 
 * provided with the distribution.
16
 
 * Neither the name of Nokia Corporation nor the names of its contributors may be
17
 
 * used to endorse or promote products derived from this software without specific
18
 
 * prior written permission.
19
 
 *
20
 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
21
 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22
 
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23
 
 * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24
 
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
 
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26
 
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
 
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
 
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
 
 *
30
 
 */
31
 
 
32
 
#include "utils.h"
33
 
#include "coreutils.h"
34
 
 
35
 
#include "models/key.h"
36
 
#include "models/keydescription.h"
37
 
#include "models/keyboard.h"
38
 
#include "models/styleattributes.h"
39
 
#include "logic/keyboardloader.h"
40
 
#include "logic/keyareaconverter.h"
41
 
#include "logic/style.h"
42
 
#include "logic/layouthelper.h"
43
 
 
44
 
#include <QtCore>
45
 
#include <QtTest>
46
 
#include <QDebug>
47
 
 
48
 
using namespace MaliitKeyboard;
49
 
 
50
 
typedef QSharedPointer<KeyboardLoader> SharedKeyboardLoader;
51
 
 
52
 
typedef QPair<QString, QString> DictionaryValue;
53
 
typedef QMap<QString, QString> Dictionary;
54
 
 
55
 
typedef QPair<Key, KeyDescription> KeyDescriptionPair;
56
 
 
57
 
Q_DECLARE_METATYPE(Dictionary)
58
 
Q_DECLARE_METATYPE(Keyboard)
59
 
 
60
 
namespace {
61
 
 
62
 
SharedKeyboardLoader getLoader(const QString &id)
63
 
{
64
 
    SharedKeyboardLoader loader(new KeyboardLoader);
65
 
 
66
 
    loader->setActiveId(id);
67
 
    return loader;
68
 
}
69
 
 
70
 
Keyboard stringToKeyboard(const QString &str)
71
 
{
72
 
    enum
73
 
    {
74
 
        ExpectFirstSeparator,
75
 
        ExpectKey,
76
 
        ExpectSeparator
77
 
    } expected_char = ExpectFirstSeparator;
78
 
 
79
 
    Keyboard kb;
80
 
    int row(0);
81
 
    bool left_spacer(false);
82
 
 
83
 
    Q_FOREACH(const QChar &c, str) {
84
 
        switch (expected_char) {
85
 
        case ExpectKey:
86
 
            expected_char = ExpectSeparator;
87
 
 
88
 
            if (c == '\n') {
89
 
                ++row;
90
 
            } else {
91
 
                Label label;
92
 
                Key key;
93
 
                KeyDescription key_desc;
94
 
 
95
 
                label.setText(c);
96
 
                key.setLabel(label);
97
 
                key_desc.row = row;
98
 
                key_desc.left_spacer = left_spacer;
99
 
                key_desc.right_spacer = false;
100
 
                kb.keys.append(key);
101
 
                kb.key_descriptions.append(key_desc);
102
 
            }
103
 
            left_spacer = false;
104
 
            break;
105
 
 
106
 
        case ExpectFirstSeparator:
107
 
        case ExpectSeparator:
108
 
            expected_char = ExpectKey;
109
 
 
110
 
            switch (c.toLatin1()) {
111
 
            case '|':
112
 
                break;
113
 
 
114
 
            case ' ':
115
 
                if (not kb.key_descriptions.isEmpty()) {
116
 
                    KeyDescription& last(kb.key_descriptions.last());
117
 
 
118
 
                    if (last.row == row) {
119
 
                        last.right_spacer = true;
120
 
                    }
121
 
                }
122
 
                left_spacer = true;
123
 
                break;
124
 
 
125
 
            default:
126
 
                qFatal("A bug in test - wrong separator (expected either | or space)");
127
 
                break;
128
 
            }
129
 
            break;
130
 
 
131
 
        default:
132
 
            qFatal("A bug in test - wrong expected char type.");
133
 
            break;
134
 
        }
135
 
    }
136
 
 
137
 
    if (expected_char == ExpectSeparator) {
138
 
        qFatal("A bug in test - last char should be a separator");
139
 
    }
140
 
 
141
 
    return kb;
142
 
}
143
 
 
144
 
 
145
 
Dictionary &operator<<(Dictionary &dict, const DictionaryValue &value)
146
 
{
147
 
    dict.insert(value.first, value.second);
148
 
    return dict;
149
 
}
150
 
 
151
 
Keyboard &operator<<(Keyboard &keyboard, const KeyDescriptionPair &value)
152
 
{
153
 
    keyboard.keys.append(value.first);
154
 
    keyboard.key_descriptions.append(value.second);
155
 
    return keyboard;
156
 
}
157
 
 
158
 
KeyDescriptionPair createActionPair(Key::Action action = Key::ActionInsert,
159
 
                                    KeyDescription::Icon icon_type = KeyDescription::NoIcon,
160
 
                                    const QByteArray &icon = "")
161
 
{
162
 
    Key key;
163
 
    KeyDescription desc;
164
 
 
165
 
    key.setAction(action);
166
 
    key.setIcon(icon);
167
 
    desc.icon = icon_type;
168
 
    return KeyDescriptionPair(key, desc);
169
 
}
170
 
 
171
 
KeyDescriptionPair createPair(const QString &text,
172
 
                              int row,
173
 
                              bool left_spacer,
174
 
                              bool right_spacer)
175
 
{
176
 
    Label label;
177
 
    Key key;
178
 
    KeyDescription desc;
179
 
 
180
 
    label.setText(text);
181
 
    key.setLabel(label);
182
 
    desc.row = row;
183
 
    desc.left_spacer = left_spacer;
184
 
    desc.right_spacer = right_spacer;
185
 
 
186
 
    return KeyDescriptionPair(key, desc);
187
 
}
188
 
 
189
 
void clearKeyboard(Keyboard &kb)
190
 
{
191
 
    kb.keys.clear();
192
 
    kb.key_descriptions.clear();
193
 
    kb.style_name.clear();
194
 
}
195
 
 
196
 
Key getKey(const QString &text,
197
 
           Key::Action action = Key::ActionInsert)
198
 
{
199
 
    Label label;
200
 
    Key key;
201
 
 
202
 
    label.setText(text);
203
 
    key.setLabel(label);
204
 
    key.setAction(action);
205
 
 
206
 
    return key;
207
 
}
208
 
 
209
 
} // unnamed namespace
210
 
 
211
 
class TestLanguageLayoutLoading
212
 
    : public QObject
213
 
{
214
 
    Q_OBJECT
215
 
 
216
 
private:
217
 
    void compareKeyboards(const Keyboard &kb1, const Keyboard &kb2)
218
 
    {
219
 
        QCOMPARE(kb1.keys.size(), kb2.keys.size());
220
 
        QCOMPARE(kb1.key_descriptions.size(), kb2.key_descriptions.size());
221
 
        QCOMPARE(kb1.keys.size(), kb1.key_descriptions.size());
222
 
 
223
 
        for (int iter(0); iter < kb1.keys.size(); ++iter) {
224
 
            QCOMPARE(kb1.keys[iter].label().text(), kb2.keys[iter].label().text());
225
 
 
226
 
            const KeyDescription& kd1(kb1.key_descriptions[iter]);
227
 
            const KeyDescription& kd2(kb2.key_descriptions[iter]);
228
 
 
229
 
            QCOMPARE(kd1.row, kd2.row);
230
 
            QCOMPARE(kd1.left_spacer, kd2.left_spacer);
231
 
            QCOMPARE(kd1.right_spacer, kd2.right_spacer);
232
 
        }
233
 
    }
234
 
 
235
 
    // QCOMPARE is a macro with "return;" statement in it. So it does not quit
236
 
    // the test immediately on failure when it is used in a function called by
237
 
    // our test routine. So we are adding another ugly macro. Wheee...
238
 
#define COMPARE_KEYBOARDS(gotten_keyboard, expected_keyboard) \
239
 
    compareKeyboards(gotten_keyboard, expected_keyboard); \
240
 
    if (QTest::currentTestFailed()) { \
241
 
        return; \
242
 
    }
243
 
 
244
 
    Q_SLOT void initTestCase()
245
 
    {
246
 
        QVERIFY(qputenv("MALIIT_PLUGINS_DATADIR", TEST_DATADIR));
247
 
        QVERIFY(qputenv("MALIIT_KEYBOARD_DATADIR", TEST_MALIIT_KEYBOARD_DATADIR));
248
 
        QVERIFY(qputenv("UBUNTU_KEYBOARD_DATA_DIR", TEST_MALIIT_KEYBOARD_DATADIR));
249
 
    }
250
 
 
251
 
    Q_SLOT void testSanity_data()
252
 
    {
253
 
        QTest::addColumn<QString>("string_desc");
254
 
        QTest::addColumn<Keyboard>("expected_keyboard");
255
 
 
256
 
        Keyboard kb;
257
 
        QTest::newRow("Empty string - empty keyboard")
258
 
            << ""
259
 
            << kb;
260
 
        clearKeyboard(kb);
261
 
 
262
 
        QTest::newRow("Complicated string")
263
 
            << " a b \n c|d|"
264
 
            << (kb
265
 
                << createPair("a", 0, true, true)
266
 
                << createPair("b", 0, true, true)
267
 
                << createPair("c", 1, true, false)
268
 
                << createPair("d", 1, false, false));
269
 
        clearKeyboard(kb);
270
 
    }
271
 
 
272
 
    Q_SLOT void testSanity()
273
 
    {
274
 
        QFETCH(QString, string_desc);
275
 
        QFETCH(Keyboard, expected_keyboard);
276
 
 
277
 
        COMPARE_KEYBOARDS(stringToKeyboard(string_desc), expected_keyboard);
278
 
    }
279
 
 
280
 
//    Q_SLOT void testGeneral_data()
281
 
//    {
282
 
//        QTest::addColumn<QString>("keyboard_id");
283
 
//        QTest::addColumn<QString>("expected_keyboard");
284
 
//        QTest::addColumn<QString>("expected_shifted_keyboard");
285
 
//        QTest::addColumn<QString>("expected_number_keyboard");
286
 
//        QTest::addColumn<QString>("expected_phone_number_keyboard");
287
 
//        QTest::addColumn<Dictionary>("expected_dead_keyboards");
288
 
//        QTest::addColumn<Dictionary>("expected_shifted_dead_keyboards");
289
 
//        QTest::addColumn<Dictionary>("expected_extended_keyboards");
290
 
//        QTest::addColumn<QStringList>("expected_symbols_keyboards");
291
 
 
292
 
//        Dictionary dead;
293
 
//        Dictionary sdead;
294
 
//        Dictionary ext;
295
 
 
296
 
//        QTest::newRow("General test")
297
 
//            << "general_test1"
298
 
//            << "|q|w|\n p a "
299
 
//            << "|Q|W|\n p a "
300
 
//            << "|0|1|\n 2 3 "
301
 
//            << " 9 8 \n 7|6 "
302
 
//            << (dead
303
 
//                << DictionaryValue(QString::fromUtf8("´"), "|q|e|\n p a ")
304
 
//                << DictionaryValue(";", "|q|r|\n p a ")
305
 
//                << DictionaryValue("'", "|q|t|\n p a "))
306
 
//            << (sdead
307
 
//                << DictionaryValue(QString::fromUtf8("´"), "|Q|E|\n p a ")
308
 
//                << DictionaryValue(";", "|Q|r|\n p a ")
309
 
//                << DictionaryValue("'", "|Q|T|\n p a "))
310
 
//            << (ext
311
 
//                << DictionaryValue("q", "|y|u|\n|i|o|")
312
 
//                << DictionaryValue("Q", "|Y|U|\n|I|O|"))
313
 
//            << (QStringList()
314
 
//                << "|1|\n|2|"
315
 
//                << "|3|\n|4|");
316
 
//        dead.clear();
317
 
//        sdead.clear();
318
 
//        ext.clear();
319
 
//    }
320
 
 
321
 
//    Q_SLOT void testGeneral()
322
 
//    {
323
 
//        QFETCH(QString, keyboard_id);
324
 
//        QFETCH(QString, expected_keyboard);
325
 
//        QFETCH(QString, expected_shifted_keyboard);
326
 
//        QFETCH(QString, expected_number_keyboard);
327
 
//        QFETCH(QString, expected_phone_number_keyboard);
328
 
//        QFETCH(Dictionary, expected_dead_keyboards);
329
 
//        QFETCH(Dictionary, expected_shifted_dead_keyboards);
330
 
//        QFETCH(Dictionary, expected_extended_keyboards);
331
 
//        QFETCH(QStringList, expected_symbols_keyboards);
332
 
 
333
 
//        SharedKeyboardLoader loader(getLoader(keyboard_id));
334
 
 
335
 
//        QVERIFY(loader->ids().indexOf(keyboard_id) != -1);
336
 
//        qDebug() << "Keyboard";
337
 
//        COMPARE_KEYBOARDS(loader->keyboard(), stringToKeyboard(expected_keyboard));
338
 
//        qDebug() << "Shifted eyboard";
339
 
//        COMPARE_KEYBOARDS(loader->shiftedKeyboard(), stringToKeyboard(expected_shifted_keyboard));
340
 
//        qDebug() << "Number keyboard";
341
 
//        COMPARE_KEYBOARDS(loader->numberKeyboard(), stringToKeyboard(expected_number_keyboard));
342
 
//        qDebug() << "Phonenumber keyboard";
343
 
//        COMPARE_KEYBOARDS(loader->phoneNumberKeyboard(), stringToKeyboard(expected_phone_number_keyboard));
344
 
 
345
 
//        Q_FOREACH(const QString &dead_text, expected_dead_keyboards.keys()) {
346
 
//            Key dead_key;
347
 
//            Label dead_label;
348
 
 
349
 
//            dead_label.setText(dead_text);
350
 
//            dead_key.setLabel(dead_label);
351
 
//            qDebug() << "Dead keyboard for:" << dead_text;
352
 
//            COMPARE_KEYBOARDS(loader->deadKeyboard(dead_key), stringToKeyboard(expected_dead_keyboards[dead_text]));
353
 
//        }
354
 
 
355
 
//        Q_FOREACH(const QString &dead_text, expected_shifted_dead_keyboards.keys()) {
356
 
//            Key dead_key;
357
 
//            Label dead_label;
358
 
 
359
 
//            dead_label.setText(dead_text);
360
 
//            dead_key.setLabel(dead_label);
361
 
//            qDebug() << "Shifted dead keyboard for:" << dead_text;
362
 
//            COMPARE_KEYBOARDS(loader->shiftedDeadKeyboard(dead_key), stringToKeyboard(expected_shifted_dead_keyboards[dead_text]));
363
 
//        }
364
 
 
365
 
//        for (int iter(0); iter <= expected_symbols_keyboards.size(); ++iter) {
366
 
//            int index(iter % expected_symbols_keyboards.size());
367
 
 
368
 
//            qDebug() << "Symbols keyboard, page:" << iter << "(expected page:" << index << ")";
369
 
//            COMPARE_KEYBOARDS(loader->symbolsKeyboard(iter), stringToKeyboard(expected_symbols_keyboards[index]));
370
 
//        }
371
 
//    }
372
 
 
373
 
//    Q_SLOT void testStyle_data()
374
 
//    {
375
 
//        QTest::addColumn<QString>("keyboard_id");
376
 
//        QTest::addColumn<QString>("expected_style");
377
 
 
378
 
//        QTest::newRow("No style given in xml")
379
 
//            << "style_test1"
380
 
//            << "keys4";
381
 
 
382
 
//        QTest::newRow("Style given in xml")
383
 
//            << "style_test2"
384
 
//            << "four_symbols";
385
 
//    }
386
 
 
387
 
//    Q_SLOT void testStyle()
388
 
//    {
389
 
//        QFETCH(QString, keyboard_id);
390
 
//        QFETCH(QString, expected_style);
391
 
 
392
 
//        SharedKeyboardLoader loader(getLoader(keyboard_id));
393
 
//        QCOMPARE(loader->keyboard().style_name, expected_style);
394
 
//    }
395
 
 
396
 
//    Q_SLOT void testAction_data()
397
 
//    {
398
 
//        QTest::addColumn<QString>("keyboard_id");
399
 
//        QTest::addColumn<Keyboard>("expected_keyboard");
400
 
 
401
 
//        Keyboard kb;
402
 
 
403
 
//        QTest::newRow("Implicit insert action")
404
 
//            << "action_test1"
405
 
//            << (kb
406
 
//                << createActionPair());
407
 
//        clearKeyboard(kb);
408
 
 
409
 
//        QTest::newRow("Explicit actions")
410
 
//            << "action_test2"
411
 
//            << (kb
412
 
//                << createActionPair()
413
 
//                << createActionPair(Key::ActionShift)
414
 
//                << createActionPair(Key::ActionBackspace)
415
 
//                << createActionPair(Key::ActionReturn));
416
 
//        clearKeyboard(kb);
417
 
 
418
 
//        QTest::newRow("Dead action")
419
 
//            << "action_test3"
420
 
//            << (kb
421
 
//                << createActionPair(Key::ActionDead));
422
 
//        clearKeyboard(kb);
423
 
//    }
424
 
 
425
 
//    Q_SLOT void testAction()
426
 
//    {
427
 
//        QFETCH(QString, keyboard_id);
428
 
//        QFETCH(Keyboard, expected_keyboard);
429
 
 
430
 
//        SharedKeyboardLoader loader(getLoader(keyboard_id));
431
 
//        Keyboard gotten_keyboard(loader->keyboard());
432
 
 
433
 
//        QCOMPARE(gotten_keyboard.keys.size(), expected_keyboard.keys.size());
434
 
 
435
 
//        for (int iter(0); iter < expected_keyboard.keys.size(); ++iter) {
436
 
//            const Key &gotten_key(gotten_keyboard.keys[iter]);
437
 
//            const Key &expected_key(expected_keyboard.keys[iter]);
438
 
 
439
 
//            QCOMPARE(gotten_key.action(), expected_key.action());
440
 
//        }
441
 
//    }
442
 
 
443
 
//    Q_SLOT void testIcon_data()
444
 
//    {
445
 
//        QTest::addColumn<QString>("keyboard_id");
446
 
//        QTest::addColumn<Keyboard>("expected_keyboard");
447
 
 
448
 
//        Keyboard kb;
449
 
//        QTest::newRow("Default icons")
450
 
//            << "icon_test1"
451
 
//            << (kb
452
 
//                << createActionPair(Key::ActionBackspace, KeyDescription::BackspaceIcon)
453
 
//                << createActionPair(Key::ActionReturn, KeyDescription::ReturnIcon)
454
 
//                << createActionPair(Key::ActionShift, KeyDescription::ShiftIcon)
455
 
//                << createActionPair(Key::ActionClose, KeyDescription::CloseIcon));
456
 
//        clearKeyboard(kb);
457
 
 
458
 
//        QTest::newRow("Custom or empty icons")
459
 
//            << "icon_test2"
460
 
//            << (kb
461
 
//                << createActionPair()
462
 
//                << createActionPair(Key::ActionInsert, KeyDescription::CustomIcon, "overriden_icon"));
463
 
//        clearKeyboard(kb);
464
 
 
465
 
//        /* TODO: Commented out for now, as it is not not possible to override
466
 
//           icons for some action keys and I don't know if we want to allow
467
 
//           this. I would say that we indeed do want.
468
 
 
469
 
//        QTest::newRow("Overriden icons")
470
 
//            << "icon_test3"
471
 
//            << (kb
472
 
//                << actionPair(Key::ActionClose, KeyDescription::CustomIcon, "overriden_icon"));
473
 
//        clearKeyboard(kb);
474
 
//        */
475
 
//    }
476
 
 
477
 
//    Q_SLOT void testIcon()
478
 
//    {
479
 
//        QFETCH(QString, keyboard_id);
480
 
//        QFETCH(Keyboard, expected_keyboard);
481
 
 
482
 
//        SharedKeyboardLoader loader(getLoader(keyboard_id));
483
 
//        Keyboard gotten_keyboard(loader->keyboard());
484
 
 
485
 
//        QCOMPARE(gotten_keyboard.keys.size(), expected_keyboard.keys.size());
486
 
 
487
 
//        for (int iter(0); iter < expected_keyboard.keys.size(); ++iter) {
488
 
//            const Key& gotten_key(gotten_keyboard.keys[iter]);
489
 
//            const Key& expected_key(expected_keyboard.keys[iter]);
490
 
//            const KeyDescription& gotten_desc(gotten_keyboard.key_descriptions[iter]);
491
 
//            const KeyDescription& expected_desc(expected_keyboard.key_descriptions[iter]);
492
 
 
493
 
//            QCOMPARE(gotten_key.action(), expected_key.action());
494
 
//            QCOMPARE(gotten_desc.icon, expected_desc.icon);
495
 
//            QCOMPARE(gotten_key.icon(), expected_key.icon());
496
 
//        }
497
 
//    }
498
 
 
499
 
    Q_SLOT void testExtended_data()
500
 
    {
501
 
        QTest::addColumn<QString>("keyboard_id");
502
 
        QTest::addColumn<Key>("pressed_key");
503
 
        QTest::addColumn<QString>("expected_keyboard");
504
 
 
505
 
        // TODO: we should get rid of this prepending stuff and fix the language
506
 
        // layouts.
507
 
        /*
508
 
        QTest::newRow("Extended keyboard for unshifted key (also notice prepending)")
509
 
            << "extended_test"
510
 
            << getKey("a")
511
 
            << "|a|b|c|";
512
 
        */
513
 
 
514
 
//        QTest::newRow("Extended keyboard for shifted key (also notice prepending)")
515
 
//            << "extended_test"
516
 
//            << getKey("A")
517
 
//            << "|A|B|C|";
518
 
 
519
 
//        QTest::newRow("Ignore spacers in extended keyboard")
520
 
//            << "extended_test"
521
 
//            << getKey("d")
522
 
//            << "|d|e|f|";
523
 
 
524
 
//        QTest::newRow("Extended keyboard with multiple rows (also notice lack of prepending)")
525
 
//            << "extended_test"
526
 
//            << getKey("g")
527
 
//            << "|h|i|\n|j|k|";
528
 
 
529
 
//        QTest::newRow("Extended keyboard for empty label (also notice lack of prepending the key with empty label)")
530
 
//            << "extended_test"
531
 
//            << getKey("")
532
 
//            << "|x|";
533
 
 
534
 
        QTest::newRow("No extended keyboard for spacebars.")
535
 
            << "extended_test"
536
 
            << getKey("", Key::ActionSpace)
537
 
            << "";
538
 
 
539
 
//        QTest::newRow("No non-action-insert prepending")
540
 
//            << "extended_test"
541
 
//            << getKey("close", Key::ActionClose)
542
 
//            << "|X|";
543
 
    }
544
 
 
545
 
    Q_SLOT void testExtended()
546
 
    {
547
 
        QFETCH(QString, keyboard_id);
548
 
        QFETCH(Key, pressed_key);
549
 
        QFETCH(QString, expected_keyboard);
550
 
 
551
 
        SharedKeyboardLoader loader(getLoader(keyboard_id));
552
 
 
553
 
        COMPARE_KEYBOARDS(loader->extendedKeyboard(pressed_key), stringToKeyboard(expected_keyboard));
554
 
    }
555
 
 
556
 
    Q_SLOT void testStylingProfile()
557
 
    {
558
 
        const Logic::LayoutHelper::Orientation orientation(Logic::LayoutHelper::Landscape);
559
 
        Style style;
560
 
        QCOMPARE(style.availableProfiles().size(), 1);
561
 
        QCOMPARE(style.availableProfiles().first(), QString("test-profile"));
562
 
        QCOMPARE(style.profile(), QString());
563
 
        QCOMPARE(style.attributes()->fontSize(orientation), 0.0);
564
 
        QCOMPARE(style.extendedKeysAttributes()->fontSize(orientation), 0.0);
565
 
        QCOMPARE(style.directory(Style::Images), QString());
566
 
        QCOMPARE(style.directory(Style::Fonts), QString());
567
 
        QCOMPARE(style.directory(Style::Sounds), QString());
568
 
 
569
 
        QSignalSpy profile_changed_spy(&style, SIGNAL(profileChanged()));
570
 
        style.setProfile("test-profile");
571
 
        QCOMPARE(profile_changed_spy.count(), 1);
572
 
        QCOMPARE(style.profile(), QString("test-profile"));
573
 
        QCOMPARE(style.attributes()->fontSize(orientation), 10.0);
574
 
        QCOMPARE(style.extendedKeysAttributes()->fontSize(orientation), 0.0);
575
 
 
576
 
        const QString test_profile_dir(QString::fromLatin1(TEST_MALIIT_KEYBOARD_DATADIR)
577
 
                                       + "/styles/test-profile");
578
 
        QCOMPARE(style.directory(Style::Images), test_profile_dir + "/images");
579
 
        QCOMPARE(style.directory(Style::Fonts), test_profile_dir + "/fonts");
580
 
        QCOMPARE(style.directory(Style::Sounds), test_profile_dir + "/sounds");
581
 
    }
582
 
 
583
 
//    Q_SLOT void testKeyGeometryStyling_data()
584
 
//    {
585
 
//        QTest::addColumn<int>("key_index");
586
 
//        QTest::addColumn<QString>("expected_label");
587
 
//        QTest::addColumn<int>("expected_left_distance");
588
 
//        QTest::addColumn<int>("expected_right_distance");
589
 
//        QTest::addColumn<int>("expected_left_edge");
590
 
//        QTest::addColumn<int>("expected_right_edge");
591
 
 
592
 
//        QTest::newRow("1st row: ' a|b ', testing geometry of 'a'.")
593
 
//            << 0 << QString("a") << 25 << 5 << 0 << 50;
594
 
 
595
 
//        QTest::newRow("1st row: ' a|b ', testing geometry of 'b'.")
596
 
//            << 1 << QString("b") << 5 << 25 << 50 << 100;
597
 
//    }
598
 
 
599
 
//    Q_SLOT void testKeyGeometryStyling()
600
 
//    {
601
 
//        QFETCH(int, key_index);
602
 
//        QFETCH(QString, expected_label);
603
 
//        QFETCH(int, expected_left_distance);
604
 
//        QFETCH(int, expected_right_distance);
605
 
//        QFETCH(int, expected_left_edge);
606
 
//        QFETCH(int, expected_right_edge);
607
 
 
608
 
//        Style style;
609
 
//        style.setProfile("test-profile");
610
 
//        StyleAttributes *attributes = style.attributes();
611
 
//        SharedKeyboardLoader loader(getLoader("styling_profile_test"));
612
 
//        Logic::KeyAreaConverter converter(attributes, loader.data());
613
 
 
614
 
//        const KeyArea key_area(converter.keyArea());
615
 
//        const Key key(key_area.keys().at(key_index));
616
 
 
617
 
//        QCOMPARE(key.label().text(), expected_label);
618
 
//        QCOMPARE(key.margins().left(), expected_left_distance);
619
 
//        QCOMPARE(key.margins().right(), expected_right_distance);
620
 
//        QCOMPARE(key.rect().x(), expected_left_edge);
621
 
//        QCOMPARE(key.rect().x() + key.rect().width(), expected_right_edge);
622
 
//    }
623
 
};
624
 
 
625
 
QTEST_MAIN(TestLanguageLayoutLoading)
626
 
#include "ut_language-layout-loading.moc"