diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-05-22 20:15:23 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-05-24 15:23:28 +0200 |
commit | b76115a843707e9cce0dd8d14d72f943b345cf54 (patch) | |
tree | fc99d2705eea709ff02f8db99529ad2963678dff /tests | |
parent | 456a59547b6ae36ec975d5353669ff1b49b57ec0 (diff) |
API review: add word string to sayingWord signal parameters
For UIs that just want to display the currently spoken word, this is
easier to connect to existing APIs. Also add the ID of the utterance,
as returned by enqueue().
The index and length into the overall string stay as the final
parameters.
Change-Id: I70bf35eeadd24540670cad2edd42126331796f4b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qtexttospeech/tst_qtexttospeech.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/tests/auto/qtexttospeech/tst_qtexttospeech.cpp b/tests/auto/qtexttospeech/tst_qtexttospeech.cpp index 9c9dac4..1ab869c 100644 --- a/tests/auto/qtexttospeech/tst_qtexttospeech.cpp +++ b/tests/auto/qtexttospeech/tst_qtexttospeech.cpp @@ -730,13 +730,17 @@ void tst_QTextToSpeech::pauseAtUtterance() } }); QStringList wordsSpoken; - connect(&tts, &QTextToSpeech::sayingWord, [&](int at, int length){ - wordsSpoken += textList.at(atIndex).mid(at, length); + connect(&tts, &QTextToSpeech::sayingWord, + [&](const QString &word, qsizetype id, qsizetype at, qsizetype length){ + const QString text = textList.at(atIndex).mid(at, length); + QCOMPARE(id, atIndex); + QCOMPARE(text, word); + wordsSpoken += text; }); for (qsizetype i = 0; i < textList.count(); ++i) { const QString &text = textList.at(i); - tts.enqueue(text); + QCOMPARE(tts.enqueue(text), i); if (!i) QTRY_COMPARE(tts.state(), QTextToSpeech::Speaking); } @@ -784,7 +788,11 @@ void tst_QTextToSpeech::sayingWord() QElapsedTimer timer; QStringList words; QList<qint64> times; - connect(&tts, &QTextToSpeech::sayingWord, [&words, ×, &timer, text](qsizetype start, qsizetype length) { + connect(&tts, &QTextToSpeech::sayingWord, + [&words, ×, &timer, text](const QString &word, qsizetype id, qsizetype start, qsizetype length) { + const QString &slice = text.sliced(start, length); + QCOMPARE(word, slice); + QCOMPARE(id, 0); words << text.sliced(start, length); times << timer.elapsed(); }); @@ -843,7 +851,10 @@ void tst_QTextToSpeech::sayingWordWithPause() selectWorkingVoice(&tts); QStringList spokenWords; - connect(&tts, &QTextToSpeech::sayingWord, [&](qsizetype start, qsizetype length) { + connect(&tts, &QTextToSpeech::sayingWord, + [&](const QString &word, qsizetype id, qsizetype start, qsizetype length) { + QCOMPARE(word, text.sliced(start, length)); + QCOMPARE(id, 0); spokenWords << text.sliced(start, length); if (spokenWords.size() == pauseAt) tts.pause(QTextToSpeech::BoundaryHint::Word); |