277
277
COMPARE_KEYBOARDS(stringToKeyboard(string_desc), expected_keyboard);
280
Q_SLOT void testGeneral_data()
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");
296
QTest::newRow("General test")
303
<< DictionaryValue(QString::fromUtf8("Ā“"), "|q|e|\n p a ")
304
<< DictionaryValue(";", "|q|r|\n p a ")
305
<< DictionaryValue("'", "|q|t|\n p a "))
307
<< DictionaryValue(QString::fromUtf8("Ā“"), "|Q|E|\n p a ")
308
<< DictionaryValue(";", "|Q|r|\n p a ")
309
<< DictionaryValue("'", "|Q|T|\n p a "))
311
<< DictionaryValue("q", "|y|u|\n|i|o|")
312
<< DictionaryValue("Q", "|Y|U|\n|I|O|"))
321
Q_SLOT void testGeneral()
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);
333
SharedKeyboardLoader loader(getLoader(keyboard_id));
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));
345
Q_FOREACH(const QString &dead_text, expected_dead_keyboards.keys()) {
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]));
355
Q_FOREACH(const QString &dead_text, expected_shifted_dead_keyboards.keys()) {
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]));
365
for (int iter(0); iter <= expected_symbols_keyboards.size(); ++iter) {
366
int index(iter % expected_symbols_keyboards.size());
368
qDebug() << "Symbols keyboard, page:" << iter << "(expected page:" << index << ")";
369
COMPARE_KEYBOARDS(loader->symbolsKeyboard(iter), stringToKeyboard(expected_symbols_keyboards[index]));
373
Q_SLOT void testStyle_data()
375
QTest::addColumn<QString>("keyboard_id");
376
QTest::addColumn<QString>("expected_style");
378
QTest::newRow("No style given in xml")
382
QTest::newRow("Style given in xml")
387
Q_SLOT void testStyle()
389
QFETCH(QString, keyboard_id);
390
QFETCH(QString, expected_style);
392
SharedKeyboardLoader loader(getLoader(keyboard_id));
393
QCOMPARE(loader->keyboard().style_name, expected_style);
396
Q_SLOT void testAction_data()
398
QTest::addColumn<QString>("keyboard_id");
399
QTest::addColumn<Keyboard>("expected_keyboard");
403
QTest::newRow("Implicit insert action")
406
<< createActionPair());
409
QTest::newRow("Explicit actions")
412
<< createActionPair()
413
<< createActionPair(Key::ActionShift)
414
<< createActionPair(Key::ActionBackspace)
415
<< createActionPair(Key::ActionReturn));
418
QTest::newRow("Dead action")
421
<< createActionPair(Key::ActionDead));
425
Q_SLOT void testAction()
427
QFETCH(QString, keyboard_id);
428
QFETCH(Keyboard, expected_keyboard);
430
SharedKeyboardLoader loader(getLoader(keyboard_id));
431
Keyboard gotten_keyboard(loader->keyboard());
433
QCOMPARE(gotten_keyboard.keys.size(), expected_keyboard.keys.size());
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]);
439
QCOMPARE(gotten_key.action(), expected_key.action());
443
Q_SLOT void testIcon_data()
445
QTest::addColumn<QString>("keyboard_id");
446
QTest::addColumn<Keyboard>("expected_keyboard");
449
QTest::newRow("Default icons")
452
<< createActionPair(Key::ActionBackspace, KeyDescription::BackspaceIcon)
453
<< createActionPair(Key::ActionReturn, KeyDescription::ReturnIcon)
454
<< createActionPair(Key::ActionShift, KeyDescription::ShiftIcon)
455
<< createActionPair(Key::ActionClose, KeyDescription::CloseIcon));
458
QTest::newRow("Custom or empty icons")
461
<< createActionPair()
462
<< createActionPair(Key::ActionInsert, KeyDescription::CustomIcon, "overriden_icon"));
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.
469
QTest::newRow("Overriden icons")
472
<< actionPair(Key::ActionClose, KeyDescription::CustomIcon, "overriden_icon"));
477
Q_SLOT void testIcon()
479
QFETCH(QString, keyboard_id);
480
QFETCH(Keyboard, expected_keyboard);
482
SharedKeyboardLoader loader(getLoader(keyboard_id));
483
Keyboard gotten_keyboard(loader->keyboard());
485
QCOMPARE(gotten_keyboard.keys.size(), expected_keyboard.keys.size());
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]);
493
QCOMPARE(gotten_key.action(), expected_key.action());
494
QCOMPARE(gotten_desc.icon, expected_desc.icon);
495
QCOMPARE(gotten_key.icon(), expected_key.icon());
280
// Q_SLOT void testGeneral_data()
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");
296
// QTest::newRow("General test")
297
// << "general_test1"
303
// << DictionaryValue(QString::fromUtf8("Ā“"), "|q|e|\n p a ")
304
// << DictionaryValue(";", "|q|r|\n p a ")
305
// << DictionaryValue("'", "|q|t|\n p a "))
307
// << DictionaryValue(QString::fromUtf8("Ā“"), "|Q|E|\n p a ")
308
// << DictionaryValue(";", "|Q|r|\n p a ")
309
// << DictionaryValue("'", "|Q|T|\n p a "))
311
// << DictionaryValue("q", "|y|u|\n|i|o|")
312
// << DictionaryValue("Q", "|Y|U|\n|I|O|"))
321
// Q_SLOT void testGeneral()
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);
333
// SharedKeyboardLoader loader(getLoader(keyboard_id));
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));
345
// Q_FOREACH(const QString &dead_text, expected_dead_keyboards.keys()) {
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]));
355
// Q_FOREACH(const QString &dead_text, expected_shifted_dead_keyboards.keys()) {
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]));
365
// for (int iter(0); iter <= expected_symbols_keyboards.size(); ++iter) {
366
// int index(iter % expected_symbols_keyboards.size());
368
// qDebug() << "Symbols keyboard, page:" << iter << "(expected page:" << index << ")";
369
// COMPARE_KEYBOARDS(loader->symbolsKeyboard(iter), stringToKeyboard(expected_symbols_keyboards[index]));
373
// Q_SLOT void testStyle_data()
375
// QTest::addColumn<QString>("keyboard_id");
376
// QTest::addColumn<QString>("expected_style");
378
// QTest::newRow("No style given in xml")
382
// QTest::newRow("Style given in xml")
384
// << "four_symbols";
387
// Q_SLOT void testStyle()
389
// QFETCH(QString, keyboard_id);
390
// QFETCH(QString, expected_style);
392
// SharedKeyboardLoader loader(getLoader(keyboard_id));
393
// QCOMPARE(loader->keyboard().style_name, expected_style);
396
// Q_SLOT void testAction_data()
398
// QTest::addColumn<QString>("keyboard_id");
399
// QTest::addColumn<Keyboard>("expected_keyboard");
403
// QTest::newRow("Implicit insert action")
406
// << createActionPair());
407
// clearKeyboard(kb);
409
// QTest::newRow("Explicit actions")
412
// << createActionPair()
413
// << createActionPair(Key::ActionShift)
414
// << createActionPair(Key::ActionBackspace)
415
// << createActionPair(Key::ActionReturn));
416
// clearKeyboard(kb);
418
// QTest::newRow("Dead action")
421
// << createActionPair(Key::ActionDead));
422
// clearKeyboard(kb);
425
// Q_SLOT void testAction()
427
// QFETCH(QString, keyboard_id);
428
// QFETCH(Keyboard, expected_keyboard);
430
// SharedKeyboardLoader loader(getLoader(keyboard_id));
431
// Keyboard gotten_keyboard(loader->keyboard());
433
// QCOMPARE(gotten_keyboard.keys.size(), expected_keyboard.keys.size());
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]);
439
// QCOMPARE(gotten_key.action(), expected_key.action());
443
// Q_SLOT void testIcon_data()
445
// QTest::addColumn<QString>("keyboard_id");
446
// QTest::addColumn<Keyboard>("expected_keyboard");
449
// QTest::newRow("Default icons")
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);
458
// QTest::newRow("Custom or empty icons")
461
// << createActionPair()
462
// << createActionPair(Key::ActionInsert, KeyDescription::CustomIcon, "overriden_icon"));
463
// clearKeyboard(kb);
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.
469
// QTest::newRow("Overriden icons")
472
// << actionPair(Key::ActionClose, KeyDescription::CustomIcon, "overriden_icon"));
473
// clearKeyboard(kb);
477
// Q_SLOT void testIcon()
479
// QFETCH(QString, keyboard_id);
480
// QFETCH(Keyboard, expected_keyboard);
482
// SharedKeyboardLoader loader(getLoader(keyboard_id));
483
// Keyboard gotten_keyboard(loader->keyboard());
485
// QCOMPARE(gotten_keyboard.keys.size(), expected_keyboard.keys.size());
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]);
493
// QCOMPARE(gotten_key.action(), expected_key.action());
494
// QCOMPARE(gotten_desc.icon, expected_desc.icon);
495
// QCOMPARE(gotten_key.icon(), expected_key.icon());
499
499
Q_SLOT void testExtended_data()
580
580
QCOMPARE(style.directory(Style::Sounds), test_profile_dir + "/sounds");
583
void disabled_testKeyGeometryStyling_data()
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");
592
QTest::newRow("1st row: ' a|b ', testing geometry of 'a'.")
593
<< 0 << QString("a") << 25 << 5 << 0 << 50;
595
QTest::newRow("1st row: ' a|b ', testing geometry of 'b'.")
596
<< 1 << QString("b") << 5 << 25 << 50 << 100;
599
void disabled_testKeyGeometryStyling()
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);
609
style.setProfile("test-profile");
610
StyleAttributes *attributes = style.attributes();
611
SharedKeyboardLoader loader(getLoader("styling_profile_test"));
612
Logic::KeyAreaConverter converter(attributes, loader.data());
614
const KeyArea key_area(converter.keyArea());
615
const Key key(key_area.keys().at(key_index));
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);
583
// Q_SLOT void testKeyGeometryStyling_data()
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");
592
// QTest::newRow("1st row: ' a|b ', testing geometry of 'a'.")
593
// << 0 << QString("a") << 25 << 5 << 0 << 50;
595
// QTest::newRow("1st row: ' a|b ', testing geometry of 'b'.")
596
// << 1 << QString("b") << 5 << 25 << 50 << 100;
599
// Q_SLOT void testKeyGeometryStyling()
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);
609
// style.setProfile("test-profile");
610
// StyleAttributes *attributes = style.attributes();
611
// SharedKeyboardLoader loader(getLoader("styling_profile_test"));
612
// Logic::KeyAreaConverter converter(attributes, loader.data());
614
// const KeyArea key_area(converter.keyArea());
615
// const Key key(key_area.keys().at(key_index));
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);
625
625
QTEST_MAIN(TestLanguageLayoutLoading)
626
#include "ut_language-layout-loading.moc"