Changeset View
Changeset View
Standalone View
Standalone View
src/pimcommon/autocorrection/autotests/autocorrectiontest.cpp
Show First 20 Lines • Show All 679 Lines • ▼ Show 20 Line(s) | 678 | { | |||
---|---|---|---|---|---|
680 | QTest::newRow("empty") << QStringLiteral("empty"); | 680 | QTest::newRow("empty") << QStringLiteral("empty"); | ||
681 | QTest::newRow("custom-fr") << QStringLiteral("custom-fr"); | 681 | QTest::newRow("custom-fr") << QStringLiteral("custom-fr"); | ||
682 | } | 682 | } | ||
683 | 683 | | |||
684 | void AutoCorrectionTest::shouldLoadSaveAutocorrection() | 684 | void AutoCorrectionTest::shouldLoadSaveAutocorrection() | ||
685 | { | 685 | { | ||
686 | QFETCH(QString, filename); | 686 | QFETCH(QString, filename); | ||
687 | PimCommon::AutoCorrection autocorrection; | 687 | PimCommon::AutoCorrection autocorrection; | ||
688 | PimCommon::AutoCorrection autocorrectionReference; | ||||
688 | const QString originalFile = QLatin1String(AUTOCORRECTION_DATA_DIR) + QLatin1Char('/') + filename + QStringLiteral(".xml"); | 689 | const QString originalFile = QLatin1String(AUTOCORRECTION_DATA_DIR) + QLatin1Char('/') + filename + QStringLiteral(".xml"); | ||
689 | const QString refFile = QLatin1String(AUTOCORRECTION_DATA_DIR) + QLatin1Char('/') + filename + QStringLiteral("-ref.xml"); | 690 | const QString refFile = QLatin1String(AUTOCORRECTION_DATA_DIR) + QLatin1Char('/') + filename + QStringLiteral("-ref.xml"); | ||
690 | const QString generatedFile = QLatin1String(AUTOCORRECTION_DATA_DIR) + QLatin1Char('/') + filename + QStringLiteral("-generated.xml"); | 691 | const QString generatedFile = QLatin1String(AUTOCORRECTION_DATA_DIR) + QLatin1Char('/') + filename + QStringLiteral("-generated.xml"); | ||
691 | 692 | | |||
692 | //First | | |||
693 | autocorrection.loadGlobalFileName(originalFile, true); | 693 | autocorrection.loadGlobalFileName(originalFile, true); | ||
694 | autocorrection.writeAutoCorrectionXmlFile(generatedFile); | 694 | autocorrection.writeAutoCorrectionXmlFile(generatedFile); | ||
695 | 695 | | |||
696 | //Second | 696 | //make sure the xml is valid and we can feed ourself with our own generated file | ||
697 | autocorrection.loadGlobalFileName(generatedFile, true); | 697 | autocorrection.loadGlobalFileName(generatedFile, true); | ||
698 | autocorrection.writeAutoCorrectionXmlFile(generatedFile); | | |||
699 | 698 | | |||
700 | QStringList args = QStringList() | 699 | autocorrectionReference.loadGlobalFileName(refFile, true); | ||
701 | << QStringLiteral("-u") | 700 | | ||
702 | << refFile | 701 | QCOMPARE(autocorrection.autocorrectEntries(), autocorrectionReference.autocorrectEntries()); | ||
703 | << generatedFile; | 702 | QCOMPARE(autocorrection.upperCaseExceptions(), autocorrectionReference.upperCaseExceptions()); | ||
704 | QProcess proc; | 703 | QCOMPARE(autocorrection.twoUpperLetterExceptions(), autocorrectionReference.twoUpperLetterExceptions()); | ||
705 | proc.setProcessChannelMode(QProcess::ForwardedChannels); | | |||
706 | proc.start(QStringLiteral("diff"), args); | | |||
707 | QVERIFY(proc.waitForFinished()); | | |||
708 | QCOMPARE(proc.exitCode(), 0); | | |||
709 | } | 704 | } | ||
710 | 705 | | |||
711 | QTEST_MAIN(AutoCorrectionTest) | 706 | QTEST_MAIN(AutoCorrectionTest) |