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 #include "managermodelvoskspeechtotexttest.h" 0007 #include "managermodelvoskspeechtotext.h" 0008 #include <QStandardPaths> 0009 #include <QTest> 0010 QTEST_MAIN(ManagerModelVoskSpeechToTextTest) 0011 ManagerModelVoskSpeechToTextTest::ManagerModelVoskSpeechToTextTest(QObject *parent) 0012 : QObject{parent} 0013 { 0014 QStandardPaths::setTestModeEnabled(true); 0015 } 0016 0017 void ManagerModelVoskSpeechToTextTest::shouldHaveDefaultValues() 0018 { 0019 ManagerModelVoskSpeechToText w; 0020 QVERIFY(w.speechToTextInfos().isEmpty()); 0021 QVERIFY(w.needDownloadModelList()); 0022 } 0023 0024 void ManagerModelVoskSpeechToTextTest::shouldLoadModelList_data() 0025 { 0026 QTest::addColumn<QString>("fileName"); 0027 QTest::addColumn<int>("numberOfTranslator"); 0028 QTest::newRow("empty") << QStringLiteral("empty") << 0; 0029 QTest::newRow("fullmodels") << QStringLiteral("model-list") << 106; 0030 // 1 correct 1 invalid 0031 QTest::newRow("invalid") << QStringLiteral("invalid") << 1; 0032 } 0033 0034 void ManagerModelVoskSpeechToTextTest::shouldLoadModelList() 0035 { 0036 QFETCH(QString, fileName); 0037 QFETCH(int, numberOfTranslator); 0038 const QString originalJsonFile = QLatin1String(VOSK_DATA_DIR) + QStringLiteral("/modellanguages/") + fileName + QStringLiteral(".json"); 0039 ManagerModelVoskSpeechToText w; 0040 w.loadModelList(originalJsonFile); 0041 QCOMPARE(w.speechToTextInfos().count(), numberOfTranslator); 0042 } 0043 0044 #include "moc_managermodelvoskspeechtotexttest.cpp"