File indexing completed on 2024-12-22 04:28:22
0001 /* 0002 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "voskengineutilstest.h" 0008 #include "voskengineutils.h" 0009 #include <QStandardPaths> 0010 #include <QTest> 0011 0012 QTEST_GUILESS_MAIN(VoskEngineUtilsTest) 0013 VoskEngineUtilsTest::VoskEngineUtilsTest(QObject *parent) 0014 : QObject{parent} 0015 { 0016 QStandardPaths::setTestModeEnabled(true); 0017 } 0018 0019 void VoskEngineUtilsTest::shouldDefineStoragePath() 0020 { 0021 QCOMPARE(VoskEngineUtils::storageLanguagePath(), 0022 QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/vosk-texttospeech")); 0023 } 0024 0025 void VoskEngineUtilsTest::shouldDefineRepositoryPath() 0026 { 0027 QCOMPARE(VoskEngineUtils::defaultVoskRepository(), QStringLiteral("https://alphacephei.com/vosk/models/model-list.json")); 0028 } 0029 0030 void VoskEngineUtilsTest::shouldVerifyLanguageInstalledStruct() 0031 { 0032 VoskEngineUtils::LanguageInstalled info; 0033 QVERIFY(!info.isValid()); 0034 QVERIFY(info.absoluteLanguageModelPath.isEmpty()); 0035 QVERIFY(info.name.isEmpty()); 0036 QVERIFY(info.url.isEmpty()); 0037 QVERIFY(info.versionStr.isEmpty()); 0038 } 0039 0040 void VoskEngineUtilsTest::shouldSaveLoadLanguageInstalled() 0041 { 0042 VoskEngineUtils::LanguageInstalled info; 0043 info.absoluteLanguageModelPath = QStringLiteral("absolute path"); 0044 info.name = QStringLiteral("Name1"); 0045 info.url = QStringLiteral("https://foo.bla.com"); 0046 info.versionStr = QStringLiteral("version"); 0047 const QString pathTest = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); 0048 QVERIFY(VoskEngineUtils::createInstalledLanguageInfo(pathTest, info)); 0049 0050 const VoskEngineUtils::LanguageInstalled loadInfo = VoskEngineUtils::loadInstalledLanguageInfo(pathTest); 0051 QCOMPARE(loadInfo, info); 0052 } 0053 0054 #include "moc_voskengineutilstest.cpp"