summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-11-04 22:23:32 +0100
committerAxel Spoerl <axel.spoerl@qt.io>2023-11-06 10:17:25 +0000
commit27e7229665cba98070a3d32cdfbf9347d3f7736c (patch)
tree9ce69df384a28304c84e7397eeca317d9d302dbc /tests
parent1f55a084efcd98b9780f8a9e22cbea76b6d649c8 (diff)
WinRT: fix hanging synthesize when RIFF header is removed
Amends 428cae98619584a51c01be135fecf6b347c117b3. If we drop the RIFF header bytes, then we have fewer bytes available as well, so decrease that value. Otherwise we never fetch more data. Improve the test, which should have caught this regression, by testing that synthesise cycles correctly through the states even if no default audio output is present. The test was completely skipped because of that, not detecting the regression. Fixes: QTBUG-118668 Pick-to: 6.6 Change-Id: I3b4276c13ce2c77ec718d1b7bbca6f3421636890 Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qtexttospeech/tst_qtexttospeech.cpp41
1 files changed, 23 insertions, 18 deletions
diff --git a/tests/auto/qtexttospeech/tst_qtexttospeech.cpp b/tests/auto/qtexttospeech/tst_qtexttospeech.cpp
index 3e63d59..b2b8fb8 100644
--- a/tests/auto/qtexttospeech/tst_qtexttospeech.cpp
+++ b/tests/auto/qtexttospeech/tst_qtexttospeech.cpp
@@ -901,11 +901,10 @@ void tst_QTextToSpeech::synthesize_data()
void tst_QTextToSpeech::synthesize()
{
QFETCH_GLOBAL(QString, engine);
- if (engine != "mock" && !hasDefaultAudioOutput())
- QSKIP("No audio device present");
-
QFETCH(QString, text);
+ const bool canCheckDuration = engine == "mock" || hasDefaultAudioOutput();
+
QTextToSpeech tts(engine);
if (!(tts.engineCapabilities() & QTextToSpeech::Capability::Synthesize))
QSKIP("This engine doesn't support synthesize()");
@@ -935,13 +934,15 @@ void tst_QTextToSpeech::synthesize()
}
});
- // first, measure how long it takes to speak the text
- tts.say(text);
- QTRY_VERIFY(running);
- QTRY_VERIFY(finished);
+ // first, measure how long it takes to speak the text. We can't do that if we
+ // can't play audio.
+ if (canCheckDuration) {
+ tts.say(text);
+ QTRY_VERIFY(running);
+ QTRY_VERIFY(finished);
+ }
running = false;
-
QAudioFormat pcmFormat;
QByteArray pcmData;
@@ -956,16 +957,20 @@ void tst_QTextToSpeech::synthesize()
QTRY_VERIFY(finished);
QVERIFY(pcmFormat.isValid());
- // bytesForDuration takes micro seconds, we measured in milliseconds.
- const qint32 bytesExpected = pcmFormat.bytesForDuration(speechTime * 1000);
-
- // We should have as much data as the format requires for the time it took
- // to play the speech, +/- 10% as we can't measure the exact audio duration.
- QCOMPARE_GE(pcmData.size(), double(bytesExpected) * 0.9);
- if (engine == "flite") // flite is very unreliable
- QCOMPARE_LT(pcmData.size(), double(bytesExpected) * 1.5);
- else
- QCOMPARE_LT(pcmData.size(), double(bytesExpected) * 1.1);
+ QVERIFY(!pcmData.isEmpty());
+
+ if (canCheckDuration) {
+ // bytesForDuration takes micro seconds, we measured in milliseconds.
+ const qint32 bytesExpected = pcmFormat.bytesForDuration(speechTime * 1000);
+
+ // We should have as much data as the format requires for the time it took
+ // to play the speech, +/- 10% as we can't measure the exact audio duration.
+ QCOMPARE_GE(pcmData.size(), double(bytesExpected) * 0.9);
+ if (engine == "flite") // flite is very unreliable
+ QCOMPARE_LT(pcmData.size(), double(bytesExpected) * 1.5);
+ else
+ QCOMPARE_LT(pcmData.size(), double(bytesExpected) * 1.1);
+ }
}
/*!