diff options
Diffstat (limited to 'tests/auto/texttospeech/tst_qtexttospeech.cpp')
-rw-r--r-- | tests/auto/texttospeech/tst_qtexttospeech.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/tests/auto/texttospeech/tst_qtexttospeech.cpp b/tests/auto/texttospeech/tst_qtexttospeech.cpp index 9996659..dce6d81 100644 --- a/tests/auto/texttospeech/tst_qtexttospeech.cpp +++ b/tests/auto/texttospeech/tst_qtexttospeech.cpp @@ -47,11 +47,14 @@ #endif #endif +enum : int { SpeechDuration = 20000 }; + class tst_QTextToSpeech : public QObject { Q_OBJECT private slots: + void initTestCase(); void say_hello(); void speech_rate(); void pitch(); @@ -59,6 +62,12 @@ private slots: void volume(); }; +void tst_QTextToSpeech::initTestCase() +{ +#if QT_CONFIG(speechd) && defined(LIBSPEECHD_MAJOR_VERSION) && defined(LIBSPEECHD_MINOR_VERSION) + qInfo("Using libspeechd v%d.%d", LIBSPEECHD_MAJOR_VERSION, LIBSPEECHD_MINOR_VERSION); +#endif +} void tst_QTextToSpeech::say_hello() { @@ -70,9 +79,9 @@ void tst_QTextToSpeech::say_hello() 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); + QSignalSpy spy(&tts, &QTextToSpeech::stateChanged); + QVERIFY(spy.wait(SpeechDuration)); + QCOMPARE(int(tts.state()), int(QTextToSpeech::Ready)); QVERIFY(timer.elapsed() > 100); } @@ -94,9 +103,9 @@ void tst_QTextToSpeech::speech_rate() 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); + QSignalSpy spy(&tts, &QTextToSpeech::stateChanged); + QVERIFY(spy.wait(SpeechDuration)); + QCOMPARE(int(tts.state()), int(QTextToSpeech::Ready)); qint64 time = timer.elapsed(); QVERIFY(time > lastTime); lastTime = time; @@ -134,9 +143,9 @@ void tst_QTextToSpeech::set_voice() 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); + QSignalSpy spy(&tts, &QTextToSpeech::stateChanged); + QVERIFY(spy.wait(SpeechDuration)); + QCOMPARE(int(tts.state()), int(QTextToSpeech::Ready)); QVERIFY(timer.elapsed() > 100); } |