276
276
COMPARE_KEYBOARDS(stringToKeyboard(string_desc), expected_keyboard);
279
Q_SLOT void testGeneral_data()
281
QTest::addColumn<QString>("keyboard_id");
282
QTest::addColumn<QString>("expected_keyboard");
283
QTest::addColumn<QString>("expected_shifted_keyboard");
284
QTest::addColumn<QString>("expected_number_keyboard");
285
QTest::addColumn<QString>("expected_phone_number_keyboard");
286
QTest::addColumn<Dictionary>("expected_dead_keyboards");
287
QTest::addColumn<Dictionary>("expected_shifted_dead_keyboards");
288
QTest::addColumn<Dictionary>("expected_extended_keyboards");
289
QTest::addColumn<QStringList>("expected_symbols_keyboards");
295
QTest::newRow("General test")
302
<< DictionaryValue(QString::fromUtf8("´"), "|q|e|\n p a ")
303
<< DictionaryValue(";", "|q|r|\n p a ")
304
<< DictionaryValue("'", "|q|t|\n p a "))
306
<< DictionaryValue(QString::fromUtf8("´"), "|Q|E|\n p a ")
307
<< DictionaryValue(";", "|Q|r|\n p a ")
308
<< DictionaryValue("'", "|Q|T|\n p a "))
310
<< DictionaryValue("q", "|y|u|\n|i|o|")
311
<< DictionaryValue("Q", "|Y|U|\n|I|O|"))
320
Q_SLOT void testGeneral()
322
QFETCH(QString, keyboard_id);
323
QFETCH(QString, expected_keyboard);
324
QFETCH(QString, expected_shifted_keyboard);
325
QFETCH(QString, expected_number_keyboard);
326
QFETCH(QString, expected_phone_number_keyboard);
327
QFETCH(Dictionary, expected_dead_keyboards);
328
QFETCH(Dictionary, expected_shifted_dead_keyboards);
329
QFETCH(Dictionary, expected_extended_keyboards);
330
QFETCH(QStringList, expected_symbols_keyboards);
332
SharedKeyboardLoader loader(getLoader(keyboard_id));
334
QVERIFY(loader->ids().indexOf(keyboard_id) != -1);
335
qDebug() << "Keyboard";
336
COMPARE_KEYBOARDS(loader->keyboard(), stringToKeyboard(expected_keyboard));
337
qDebug() << "Shifted eyboard";
338
COMPARE_KEYBOARDS(loader->shiftedKeyboard(), stringToKeyboard(expected_shifted_keyboard));
339
qDebug() << "Number keyboard";
340
COMPARE_KEYBOARDS(loader->numberKeyboard(), stringToKeyboard(expected_number_keyboard));
341
qDebug() << "Phonenumber keyboard";
342
COMPARE_KEYBOARDS(loader->phoneNumberKeyboard(), stringToKeyboard(expected_phone_number_keyboard));
344
Q_FOREACH(const QString &dead_text, expected_dead_keyboards.keys()) {
348
dead_label.setText(dead_text);
349
dead_key.setLabel(dead_label);
350
qDebug() << "Dead keyboard for:" << dead_text;
351
COMPARE_KEYBOARDS(loader->deadKeyboard(dead_key), stringToKeyboard(expected_dead_keyboards[dead_text]));
354
Q_FOREACH(const QString &dead_text, expected_shifted_dead_keyboards.keys()) {
358
dead_label.setText(dead_text);
359
dead_key.setLabel(dead_label);
360
qDebug() << "Shifted dead keyboard for:" << dead_text;
361
COMPARE_KEYBOARDS(loader->shiftedDeadKeyboard(dead_key), stringToKeyboard(expected_shifted_dead_keyboards[dead_text]));
364
for (int iter(0); iter <= expected_symbols_keyboards.size(); ++iter) {
365
int index(iter % expected_symbols_keyboards.size());
367
qDebug() << "Symbols keyboard, page:" << iter << "(expected page:" << index << ")";
368
COMPARE_KEYBOARDS(loader->symbolsKeyboard(iter), stringToKeyboard(expected_symbols_keyboards[index]));
372
Q_SLOT void testStyle_data()
374
QTest::addColumn<QString>("keyboard_id");
375
QTest::addColumn<QString>("expected_style");
377
QTest::newRow("No style given in xml")
381
QTest::newRow("Style given in xml")
386
Q_SLOT void testStyle()
388
QFETCH(QString, keyboard_id);
389
QFETCH(QString, expected_style);
391
SharedKeyboardLoader loader(getLoader(keyboard_id));
392
QCOMPARE(loader->keyboard().style_name, expected_style);
395
Q_SLOT void testAction_data()
397
QTest::addColumn<QString>("keyboard_id");
398
QTest::addColumn<Keyboard>("expected_keyboard");
402
QTest::newRow("Implicit insert action")
405
<< createActionPair());
408
QTest::newRow("Explicit actions")
411
<< createActionPair()
412
<< createActionPair(Key::ActionShift)
413
<< createActionPair(Key::ActionBackspace)
414
<< createActionPair(Key::ActionReturn));
417
QTest::newRow("Dead action")
420
<< createActionPair(Key::ActionDead));
424
Q_SLOT void testAction()
426
QFETCH(QString, keyboard_id);
427
QFETCH(Keyboard, expected_keyboard);
429
SharedKeyboardLoader loader(getLoader(keyboard_id));
430
Keyboard gotten_keyboard(loader->keyboard());
432
QCOMPARE(gotten_keyboard.keys.size(), expected_keyboard.keys.size());
434
for (int iter(0); iter < expected_keyboard.keys.size(); ++iter) {
435
const Key &gotten_key(gotten_keyboard.keys[iter]);
436
const Key &expected_key(expected_keyboard.keys[iter]);
438
QCOMPARE(gotten_key.action(), expected_key.action());
442
Q_SLOT void testIcon_data()
444
QTest::addColumn<QString>("keyboard_id");
445
QTest::addColumn<Keyboard>("expected_keyboard");
448
QTest::newRow("Default icons")
451
<< createActionPair(Key::ActionBackspace, KeyDescription::BackspaceIcon)
452
<< createActionPair(Key::ActionReturn, KeyDescription::ReturnIcon)
453
<< createActionPair(Key::ActionShift, KeyDescription::ShiftIcon)
454
<< createActionPair(Key::ActionClose, KeyDescription::CloseIcon));
457
QTest::newRow("Custom or empty icons")
460
<< createActionPair()
461
<< createActionPair(Key::ActionInsert, KeyDescription::CustomIcon, "overriden_icon"));
464
/* TODO: Commented out for now, as it is not not possible to override
465
icons for some action keys and I don't know if we want to allow
466
this. I would say that we indeed do want.
468
QTest::newRow("Overriden icons")
471
<< actionPair(Key::ActionClose, KeyDescription::CustomIcon, "overriden_icon"));
476
Q_SLOT void testIcon()
478
QFETCH(QString, keyboard_id);
479
QFETCH(Keyboard, expected_keyboard);
481
SharedKeyboardLoader loader(getLoader(keyboard_id));
482
Keyboard gotten_keyboard(loader->keyboard());
484
QCOMPARE(gotten_keyboard.keys.size(), expected_keyboard.keys.size());
486
for (int iter(0); iter < expected_keyboard.keys.size(); ++iter) {
487
const Key& gotten_key(gotten_keyboard.keys[iter]);
488
const Key& expected_key(expected_keyboard.keys[iter]);
489
const KeyDescription& gotten_desc(gotten_keyboard.key_descriptions[iter]);
490
const KeyDescription& expected_desc(expected_keyboard.key_descriptions[iter]);
492
QCOMPARE(gotten_key.action(), expected_key.action());
493
QCOMPARE(gotten_desc.icon, expected_desc.icon);
494
QCOMPARE(gotten_key.icon(), expected_key.icon());
279
// Q_SLOT void testGeneral_data()
281
// QTest::addColumn<QString>("keyboard_id");
282
// QTest::addColumn<QString>("expected_keyboard");
283
// QTest::addColumn<QString>("expected_shifted_keyboard");
284
// QTest::addColumn<QString>("expected_number_keyboard");
285
// QTest::addColumn<QString>("expected_phone_number_keyboard");
286
// QTest::addColumn<Dictionary>("expected_dead_keyboards");
287
// QTest::addColumn<Dictionary>("expected_shifted_dead_keyboards");
288
// QTest::addColumn<Dictionary>("expected_extended_keyboards");
289
// QTest::addColumn<QStringList>("expected_symbols_keyboards");
295
// QTest::newRow("General test")
296
// << "general_test1"
302
// << DictionaryValue(QString::fromUtf8("´"), "|q|e|\n p a ")
303
// << DictionaryValue(";", "|q|r|\n p a ")
304
// << DictionaryValue("'", "|q|t|\n p a "))
306
// << DictionaryValue(QString::fromUtf8("´"), "|Q|E|\n p a ")
307
// << DictionaryValue(";", "|Q|r|\n p a ")
308
// << DictionaryValue("'", "|Q|T|\n p a "))
310
// << DictionaryValue("q", "|y|u|\n|i|o|")
311
// << DictionaryValue("Q", "|Y|U|\n|I|O|"))
320
// Q_SLOT void testGeneral()
322
// QFETCH(QString, keyboard_id);
323
// QFETCH(QString, expected_keyboard);
324
// QFETCH(QString, expected_shifted_keyboard);
325
// QFETCH(QString, expected_number_keyboard);
326
// QFETCH(QString, expected_phone_number_keyboard);
327
// QFETCH(Dictionary, expected_dead_keyboards);
328
// QFETCH(Dictionary, expected_shifted_dead_keyboards);
329
// QFETCH(Dictionary, expected_extended_keyboards);
330
// QFETCH(QStringList, expected_symbols_keyboards);
332
// SharedKeyboardLoader loader(getLoader(keyboard_id));
334
// QVERIFY(loader->ids().indexOf(keyboard_id) != -1);
335
// qDebug() << "Keyboard";
336
// COMPARE_KEYBOARDS(loader->keyboard(), stringToKeyboard(expected_keyboard));
337
// qDebug() << "Shifted eyboard";
338
// COMPARE_KEYBOARDS(loader->shiftedKeyboard(), stringToKeyboard(expected_shifted_keyboard));
339
// qDebug() << "Number keyboard";
340
// COMPARE_KEYBOARDS(loader->numberKeyboard(), stringToKeyboard(expected_number_keyboard));
341
// qDebug() << "Phonenumber keyboard";
342
// COMPARE_KEYBOARDS(loader->phoneNumberKeyboard(), stringToKeyboard(expected_phone_number_keyboard));
344
// Q_FOREACH(const QString &dead_text, expected_dead_keyboards.keys()) {
348
// dead_label.setText(dead_text);
349
// dead_key.setLabel(dead_label);
350
// qDebug() << "Dead keyboard for:" << dead_text;
351
// COMPARE_KEYBOARDS(loader->deadKeyboard(dead_key), stringToKeyboard(expected_dead_keyboards[dead_text]));
354
// Q_FOREACH(const QString &dead_text, expected_shifted_dead_keyboards.keys()) {
358
// dead_label.setText(dead_text);
359
// dead_key.setLabel(dead_label);
360
// qDebug() << "Shifted dead keyboard for:" << dead_text;
361
// COMPARE_KEYBOARDS(loader->shiftedDeadKeyboard(dead_key), stringToKeyboard(expected_shifted_dead_keyboards[dead_text]));
364
// for (int iter(0); iter <= expected_symbols_keyboards.size(); ++iter) {
365
// int index(iter % expected_symbols_keyboards.size());
367
// qDebug() << "Symbols keyboard, page:" << iter << "(expected page:" << index << ")";
368
// COMPARE_KEYBOARDS(loader->symbolsKeyboard(iter), stringToKeyboard(expected_symbols_keyboards[index]));
372
// Q_SLOT void testStyle_data()
374
// QTest::addColumn<QString>("keyboard_id");
375
// QTest::addColumn<QString>("expected_style");
377
// QTest::newRow("No style given in xml")
381
// QTest::newRow("Style given in xml")
383
// << "four_symbols";
386
// Q_SLOT void testStyle()
388
// QFETCH(QString, keyboard_id);
389
// QFETCH(QString, expected_style);
391
// SharedKeyboardLoader loader(getLoader(keyboard_id));
392
// QCOMPARE(loader->keyboard().style_name, expected_style);
395
// Q_SLOT void testAction_data()
397
// QTest::addColumn<QString>("keyboard_id");
398
// QTest::addColumn<Keyboard>("expected_keyboard");
402
// QTest::newRow("Implicit insert action")
405
// << createActionPair());
406
// clearKeyboard(kb);
408
// QTest::newRow("Explicit actions")
411
// << createActionPair()
412
// << createActionPair(Key::ActionShift)
413
// << createActionPair(Key::ActionBackspace)
414
// << createActionPair(Key::ActionReturn));
415
// clearKeyboard(kb);
417
// QTest::newRow("Dead action")
420
// << createActionPair(Key::ActionDead));
421
// clearKeyboard(kb);
424
// Q_SLOT void testAction()
426
// QFETCH(QString, keyboard_id);
427
// QFETCH(Keyboard, expected_keyboard);
429
// SharedKeyboardLoader loader(getLoader(keyboard_id));
430
// Keyboard gotten_keyboard(loader->keyboard());
432
// QCOMPARE(gotten_keyboard.keys.size(), expected_keyboard.keys.size());
434
// for (int iter(0); iter < expected_keyboard.keys.size(); ++iter) {
435
// const Key &gotten_key(gotten_keyboard.keys[iter]);
436
// const Key &expected_key(expected_keyboard.keys[iter]);
438
// QCOMPARE(gotten_key.action(), expected_key.action());
442
// Q_SLOT void testIcon_data()
444
// QTest::addColumn<QString>("keyboard_id");
445
// QTest::addColumn<Keyboard>("expected_keyboard");
448
// QTest::newRow("Default icons")
451
// << createActionPair(Key::ActionBackspace, KeyDescription::BackspaceIcon)
452
// << createActionPair(Key::ActionReturn, KeyDescription::ReturnIcon)
453
// << createActionPair(Key::ActionShift, KeyDescription::ShiftIcon)
454
// << createActionPair(Key::ActionClose, KeyDescription::CloseIcon));
455
// clearKeyboard(kb);
457
// QTest::newRow("Custom or empty icons")
460
// << createActionPair()
461
// << createActionPair(Key::ActionInsert, KeyDescription::CustomIcon, "overriden_icon"));
462
// clearKeyboard(kb);
464
// /* TODO: Commented out for now, as it is not not possible to override
465
// icons for some action keys and I don't know if we want to allow
466
// this. I would say that we indeed do want.
468
// QTest::newRow("Overriden icons")
471
// << actionPair(Key::ActionClose, KeyDescription::CustomIcon, "overriden_icon"));
472
// clearKeyboard(kb);
476
// Q_SLOT void testIcon()
478
// QFETCH(QString, keyboard_id);
479
// QFETCH(Keyboard, expected_keyboard);
481
// SharedKeyboardLoader loader(getLoader(keyboard_id));
482
// Keyboard gotten_keyboard(loader->keyboard());
484
// QCOMPARE(gotten_keyboard.keys.size(), expected_keyboard.keys.size());
486
// for (int iter(0); iter < expected_keyboard.keys.size(); ++iter) {
487
// const Key& gotten_key(gotten_keyboard.keys[iter]);
488
// const Key& expected_key(expected_keyboard.keys[iter]);
489
// const KeyDescription& gotten_desc(gotten_keyboard.key_descriptions[iter]);
490
// const KeyDescription& expected_desc(expected_keyboard.key_descriptions[iter]);
492
// QCOMPARE(gotten_key.action(), expected_key.action());
493
// QCOMPARE(gotten_desc.icon, expected_desc.icon);
494
// QCOMPARE(gotten_key.icon(), expected_key.icon());
498
498
Q_SLOT void testExtended_data()
579
579
QCOMPARE(style.directory(Style::Sounds), test_profile_dir + "/sounds");
582
Q_SLOT void testKeyGeometryStyling_data()
584
QTest::addColumn<int>("key_index");
585
QTest::addColumn<QString>("expected_label");
586
QTest::addColumn<int>("expected_left_distance");
587
QTest::addColumn<int>("expected_right_distance");
588
QTest::addColumn<int>("expected_left_edge");
589
QTest::addColumn<int>("expected_right_edge");
591
QTest::newRow("1st row: ' a|b ', testing geometry of 'a'.")
592
<< 0 << QString("a") << 25 << 5 << 0 << 50;
594
QTest::newRow("1st row: ' a|b ', testing geometry of 'b'.")
595
<< 1 << QString("b") << 5 << 25 << 50 << 100;
598
Q_SLOT void testKeyGeometryStyling()
600
QFETCH(int, key_index);
601
QFETCH(QString, expected_label);
602
QFETCH(int, expected_left_distance);
603
QFETCH(int, expected_right_distance);
604
QFETCH(int, expected_left_edge);
605
QFETCH(int, expected_right_edge);
608
style.setProfile("test-profile");
609
StyleAttributes *attributes = style.attributes();
610
SharedKeyboardLoader loader(getLoader("styling_profile_test"));
611
Logic::KeyAreaConverter converter(attributes, loader.data());
613
const KeyArea key_area(converter.keyArea());
614
const Key key(key_area.keys().at(key_index));
616
QCOMPARE(key.label().text(), expected_label);
617
QCOMPARE(key.margins().left(), expected_left_distance);
618
QCOMPARE(key.margins().right(), expected_right_distance);
619
QCOMPARE(key.rect().x(), expected_left_edge);
620
QCOMPARE(key.rect().x() + key.rect().width(), expected_right_edge);
582
// Q_SLOT void testKeyGeometryStyling_data()
584
// QTest::addColumn<int>("key_index");
585
// QTest::addColumn<QString>("expected_label");
586
// QTest::addColumn<int>("expected_left_distance");
587
// QTest::addColumn<int>("expected_right_distance");
588
// QTest::addColumn<int>("expected_left_edge");
589
// QTest::addColumn<int>("expected_right_edge");
591
// QTest::newRow("1st row: ' a|b ', testing geometry of 'a'.")
592
// << 0 << QString("a") << 25 << 5 << 0 << 50;
594
// QTest::newRow("1st row: ' a|b ', testing geometry of 'b'.")
595
// << 1 << QString("b") << 5 << 25 << 50 << 100;
598
// Q_SLOT void testKeyGeometryStyling()
600
// QFETCH(int, key_index);
601
// QFETCH(QString, expected_label);
602
// QFETCH(int, expected_left_distance);
603
// QFETCH(int, expected_right_distance);
604
// QFETCH(int, expected_left_edge);
605
// QFETCH(int, expected_right_edge);
608
// style.setProfile("test-profile");
609
// StyleAttributes *attributes = style.attributes();
610
// SharedKeyboardLoader loader(getLoader("styling_profile_test"));
611
// Logic::KeyAreaConverter converter(attributes, loader.data());
613
// const KeyArea key_area(converter.keyArea());
614
// const Key key(key_area.keys().at(key_index));
616
// QCOMPARE(key.label().text(), expected_label);
617
// QCOMPARE(key.margins().left(), expected_left_distance);
618
// QCOMPARE(key.margins().right(), expected_right_distance);
619
// QCOMPARE(key.rect().x(), expected_left_edge);
620
// QCOMPARE(key.rect().x() + key.rect().width(), expected_right_edge);
624
624
QTEST_MAIN(TestLanguageLayoutLoading)
625
#include "ut_language-layout-loading.moc"