summaryrefslogtreecommitdiff
path: root/utils/rbutilqt/test/stubs/stubs-talkgenerator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/rbutilqt/test/stubs/stubs-talkgenerator.cpp')
-rw-r--r--utils/rbutilqt/test/stubs/stubs-talkgenerator.cpp104
1 files changed, 104 insertions, 0 deletions
diff --git a/utils/rbutilqt/test/stubs/stubs-talkgenerator.cpp b/utils/rbutilqt/test/stubs/stubs-talkgenerator.cpp
new file mode 100644
index 0000000000..295dc81a78
--- /dev/null
+++ b/utils/rbutilqt/test/stubs/stubs-talkgenerator.cpp
@@ -0,0 +1,104 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2022 Dominik Riebeling
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20
21// Stubs for TalkGenerator unit test.
22
23#include "rbsettings.h"
24#include "ttsbase.h"
25#include "encoderbase.h"
26#include "playerbuildinfo.h"
27
28extern "C" int wavtrim(char* filename, int maxsilence, char* errstring, int errsize)
29{
30 (void)filename;
31 (void)maxsilence;
32 (void)errstring;
33 (void)errsize;
34 return 0;
35}
36
37static QMap<RbSettings::UserSettings, QVariant> stubUserSettings;
38
39QVariant RbSettings::value(UserSettings setting)
40{
41 switch (setting)
42 {
43 case RbSettings::Tts:
44 return QString("espeak");
45 default:
46 return QVariant();
47 }
48}
49
50class TTSFakeEspeak : public TTSBase
51{
52 Q_OBJECT
53public:
54 TTSFakeEspeak(QObject *parent): TTSBase(parent) {}
55 virtual bool start(QString *errStr) { (void)errStr; return true; }
56 virtual bool stop() { return true; }
57 virtual TTSStatus voice(QString text, QString wavfile, QString *errStr)
58 { (void)text; (void)wavfile; (void)errStr; return NoError; }
59 virtual QString voiceVendor() { return QString("DummyVendor"); }
60 virtual bool configOk() { return true; }
61 virtual void generateSettings() {}
62 virtual void saveSettings() {}
63 virtual Capabilities capabilities() { return None; }
64};
65
66TTSBase::TTSBase(QObject* parent) : EncTtsSettingInterface(parent)
67{
68}
69
70TTSStatus TTSBase::voice(QString /*text*/, QString /*wavfile*/, QString* /*errStr*/)
71{
72 return NoError;
73}
74
75TTSBase* TTSBase::getTTS(QObject* parent, QString /*ttsName*/)
76{
77 return new TTSFakeEspeak(parent);
78}
79
80EncoderBase* EncoderBase::getEncoder(QObject*, QString)
81{
82 return nullptr;
83}
84
85QVariant PlayerBuildInfo::value(PlayerBuildInfo::DeviceInfo /*item*/, QString /*target*/)
86{
87 return QVariant();
88}
89
90PlayerBuildInfo* PlayerBuildInfo::infoInstance = nullptr;
91
92PlayerBuildInfo::PlayerBuildInfo()
93{
94}
95
96PlayerBuildInfo* PlayerBuildInfo::instance()
97{
98 if (infoInstance == nullptr) {
99 infoInstance = new PlayerBuildInfo();
100 }
101 return infoInstance;
102}
103
104#include "stubs-talkgenerator.moc"