Commit 25bb9815 authored by Andreas Cord-Landwehr's avatar Andreas Cord-Landwehr
Browse files

Move test method to language stub

parent bbe9b8d2
......@@ -22,6 +22,7 @@
#define LANGUAGESTUB_H
#include "src/core/ilanguage.h"
#include "core/phonemegroup.h"
#include <QObject>
#include <QVector>
......@@ -56,16 +57,31 @@ public:
}
QVector<std::shared_ptr<Phoneme>> phonemes() const override
{
return QVector<std::shared_ptr<Phoneme>>();
QVector<std::shared_ptr<Phoneme>> phonemes;
for (auto group : m_phonemeGroups) {
phonemes.append(group->phonemes());
}
return phonemes;
}
QVector<std::shared_ptr<PhonemeGroup>> phonemeGroups() const override
{
return QVector<std::shared_ptr<PhonemeGroup>>();
return m_phonemeGroups;
}
std::shared_ptr<PhonemeGroup> addPhonemeGroup(const QString &identifier, const QString &title)
{
std::shared_ptr<PhonemeGroup> phonemeGroup(new PhonemeGroup);
phonemeGroup->setId(identifier);
phonemeGroup->setTitle(title);
m_phonemeGroups.append(phonemeGroup);
return phonemeGroup;
}
private:
QString m_id{ "UNKNOWN_ID" };
QString m_title{ "title" };
QVector<std::shared_ptr<PhonemeGroup>> m_phonemeGroups;
};
......
......@@ -51,7 +51,7 @@ void TestCourseResource::cleanup()
void TestCourseResource::loadCourseResource()
{
std::shared_ptr<ILanguage> language(new LanguageStub("de"));
auto group = std::static_pointer_cast<Language>(language)->addPhonemeGroup("id", "title");
auto group = std::static_pointer_cast<LanguageStub>(language)->addPhonemeGroup("id", "title");
group->addPhoneme("g", "G");
group->addPhoneme("u", "U");
std::vector<std::shared_ptr<ILanguage>> languages;
......
......@@ -157,23 +157,3 @@ QVector<std::shared_ptr<PhonemeGroup>> Language::phonemeGroups() const
{
return m_phonemeGroups;
}
std::shared_ptr<PhonemeGroup> Language::addPhonemeGroup(const QString &identifier, const QString &title)
{
for (auto group : m_phonemeGroups) {
if (QString::compare(group->id(), identifier) == 0) {
qCWarning(ARTIKULATE_LOG) << "Pronunciation Group identifier already registered, aborting";
return std::shared_ptr<PhonemeGroup>();
}
}
std::shared_ptr<PhonemeGroup> phonemeGroup(new PhonemeGroup);
phonemeGroup->setId(identifier);
phonemeGroup->setTitle(title);
m_phonemeGroups.append(phonemeGroup);
connect(phonemeGroup.get(), &PhonemeGroup::phonemeAdded, this, &Language::phonemesChanged);
emit phonemeGroupsChanged();
return phonemeGroup;
}
......@@ -55,14 +55,12 @@ public:
void setFile(const QUrl &file);
QVector<std::shared_ptr<Phoneme>> phonemes() const override;
QVector<std::shared_ptr<PhonemeGroup>> phonemeGroups() const override;
std::shared_ptr<PhonemeGroup> addPhonemeGroup(const QString &identifier, const QString &title);
Q_SIGNALS:
void idChanged();
void titleChanged();
void i18nTitleChanged();
void phonemesChanged();
void phonemeGroupsChanged();
protected:
explicit Language();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment