summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPeter Bouda <pbouda@cidles.eu>2015-05-04 09:20:56 +0100
committerJeremy Whiting <jpwhiting@kde.org>2015-05-07 21:20:49 +0000
commite7c610bca417b0ba50c892762616ffea34bfc670 (patch)
tree6ce3e6d856f9e7a6725981323748b79036994832 /tests
parent168898499bfa1df13faa0bc43da18cb4a510cdd4 (diff)
Added test for set_voice()
Added a test for the set_voice() function. The test first chooses a voice from the list of availableVoices(). If there is more than one voice available it will choose the second voice in the list. Change-Id: Ibc458beda0a939f4512e41927e0ff8210b98e0f8 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/texttospeech/tst_qtexttospeech.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/texttospeech/tst_qtexttospeech.cpp b/tests/auto/texttospeech/tst_qtexttospeech.cpp
index 71de089..edafa16 100644
--- a/tests/auto/texttospeech/tst_qtexttospeech.cpp
+++ b/tests/auto/texttospeech/tst_qtexttospeech.cpp
@@ -43,6 +43,7 @@ private slots:
void say_hello();
void speech_rate();
void pitch();
+ void set_voice();
};
@@ -96,5 +97,30 @@ void tst_QTextToSpeech::pitch()
}
}
+void tst_QTextToSpeech::set_voice()
+{
+ QString text = QStringLiteral("this is an example text");
+ QTextToSpeech tts;
+ QCOMPARE(tts.state(), QTextToSpeech::Ready);
+
+ // Choose a voice
+ QVector<QVoice> voices = tts.availableVoices();
+ int vId = 0;
+ if (voices.length() > 1) {
+ vId = 1;
+ }
+ tts.setVoice(voices[vId]);
+ QCOMPARE(tts.state(), QTextToSpeech::Ready);
+
+ QElapsedTimer timer;
+ timer.start();
+ tts.say(text);
+ QTRY_COMPARE(tts.state(), QTextToSpeech::Speaking);
+ QSignalSpy spy(&tts, SIGNAL(stateChanged(QTextToSpeech::State)));
+ spy.wait(10000);
+ QCOMPARE(tts.state(), QTextToSpeech::Ready);
+ QVERIFY(timer.elapsed() > 100);
+}
+
QTEST_MAIN(tst_QTextToSpeech)
#include "tst_qtexttospeech.moc"