diff options
author | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2014-10-24 13:40:41 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@theqtcompany.com> | 2014-10-28 13:52:47 +0100 |
commit | bfac1c827e2b3e88df29bf36e806c13f215bce1d (patch) | |
tree | 95e5ece62e010f14df491eccb3e89116013aeab7 /tests | |
parent | 5d47ff2bc8c753f4105d588cba4a825fe59d7494 (diff) |
Add basic tests
Change-Id: I2c671f04fe19f74f7b781a12bd23ad10a15fc2bb
Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/auto.pro | 4 | ||||
-rw-r--r-- | tests/auto/texttospeech/texttospeech.pro | 4 | ||||
-rw-r--r-- | tests/auto/texttospeech/tst_qtexttospeech.cpp | 90 |
3 files changed, 97 insertions, 1 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index cd69d33..61e0135 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -1,3 +1,5 @@ TEMPLATE = subdirs -SUBDIRS += cmake +SUBDIRS += \ + cmake \ + texttospeech diff --git a/tests/auto/texttospeech/texttospeech.pro b/tests/auto/texttospeech/texttospeech.pro new file mode 100644 index 0000000..c83eaa4 --- /dev/null +++ b/tests/auto/texttospeech/texttospeech.pro @@ -0,0 +1,4 @@ +CONFIG += testcase +TARGET = tst_qtexttospeech +QT += testlib core texttospeech +SOURCES += tst_qtexttospeech.cpp diff --git a/tests/auto/texttospeech/tst_qtexttospeech.cpp b/tests/auto/texttospeech/tst_qtexttospeech.cpp new file mode 100644 index 0000000..f534312 --- /dev/null +++ b/tests/auto/texttospeech/tst_qtexttospeech.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QTest> +#include <QTextToSpeech> +#include <QSignalSpy> + +class tst_QTextToSpeech : public QObject +{ + Q_OBJECT + +private slots: + void say_hello(); + void speech_rate(); +}; + + +void tst_QTextToSpeech::say_hello() +{ + QString text = QStringLiteral("this is an example text"); + QTextToSpeech tts; + QCOMPARE(tts.state(), QTextToSpeech::Ready); + + QElapsedTimer timer; + timer.start(); + tts.say(text); + QCOMPARE(tts.state(), QTextToSpeech::Speaking); + QSignalSpy spy(&tts, SIGNAL(stateChanged(QTextToSpeech::State))); + spy.wait(10000); + QCOMPARE(tts.state(), QTextToSpeech::Ready); + QVERIFY(timer.elapsed() > 100); +} + +void tst_QTextToSpeech::speech_rate() +{ + QString text = QStringLiteral("this is an example text"); + QTextToSpeech tts; + tts.setRate(0.5); + QCOMPARE(tts.state(), QTextToSpeech::Ready); +// QCOMPARE(tts.rate(), 0.0); FIXME not implemented yet + + qint64 lastTime = 0; + // check that speaking at slower rate takes more time (for 0.5, 0.0, -0.5) + for (int i = 1; i >= -1; --i) { + tts.setRate(i * 0.5); + QElapsedTimer timer; + timer.start(); + tts.say(text); + QCOMPARE(tts.state(), QTextToSpeech::Speaking); + QSignalSpy spy(&tts, SIGNAL(stateChanged(QTextToSpeech::State))); + spy.wait(10000); + QCOMPARE(tts.state(), QTextToSpeech::Ready); + qint64 time = timer.elapsed(); + QVERIFY(time > lastTime); + lastTime = time; + } +} + +QTEST_MAIN(tst_QTextToSpeech) +#include "tst_qtexttospeech.moc" |