diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-04-12 11:19:24 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-04-16 15:14:50 +0200 |
commit | b6882d8f0c8c002b70fc9f5db6e11021b51739b6 (patch) | |
tree | 8fc648c4428fd321e225f2998cb1648dba749f01 /tests | |
parent | 2a5263ee76b39e2bc7f28cb41506a0b9c9eed194 (diff) |
A basic QML test case for Voice and TextToSpeech
To verify that our APIs work from QML, no function testing performed.
Uses only the mock engine.
Change-Id: Ia4c28418cc5e72f6c54bcbb06e48d1d0677e73e5
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/CMakeLists.txt | 3 | ||||
-rw-r--r-- | tests/auto/qtexttospeech_qml/CMakeLists.txt | 14 | ||||
-rw-r--r-- | tests/auto/qtexttospeech_qml/main.cpp | 7 | ||||
-rw-r--r-- | tests/auto/qtexttospeech_qml/tst_texttospeech.qml | 28 | ||||
-rw-r--r-- | tests/auto/qtexttospeech_qml/tst_voice.qml | 28 |
5 files changed, 80 insertions, 0 deletions
diff --git a/tests/auto/CMakeLists.txt b/tests/auto/CMakeLists.txt index 3bf8fec..baef21b 100644 --- a/tests/auto/CMakeLists.txt +++ b/tests/auto/CMakeLists.txt @@ -1,2 +1,5 @@ add_subdirectory(qtexttospeech) +if(TARGET Qt::Qml AND TARGET Qt::QuickTest) + add_subdirectory(qtexttospeech_qml) +endif() add_subdirectory(qvoice) diff --git a/tests/auto/qtexttospeech_qml/CMakeLists.txt b/tests/auto/qtexttospeech_qml/CMakeLists.txt new file mode 100644 index 0000000..d8335a0 --- /dev/null +++ b/tests/auto/qtexttospeech_qml/CMakeLists.txt @@ -0,0 +1,14 @@ +file(GLOB_RECURSE test_data_glob + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + *.qml) +list(APPEND test_data ${test_data_glob}) + +qt_internal_add_test(tst_qtexttospeech_qml + QMLTEST + SOURCES + main.cpp + LIBRARIES + Qt::TextToSpeech + Qt::Qml + TESTDATA ${test_data} +) diff --git a/tests/auto/qtexttospeech_qml/main.cpp b/tests/auto/qtexttospeech_qml/main.cpp new file mode 100644 index 0000000..ff1c848 --- /dev/null +++ b/tests/auto/qtexttospeech_qml/main.cpp @@ -0,0 +1,7 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#include <QtCore/QCoreApplication> +#include <QtQuickTest/quicktest.h> + +QUICK_TEST_MAIN(tst_qtexttospeech_qml) diff --git a/tests/auto/qtexttospeech_qml/tst_texttospeech.qml b/tests/auto/qtexttospeech_qml/tst_texttospeech.qml new file mode 100644 index 0000000..09338be --- /dev/null +++ b/tests/auto/qtexttospeech_qml/tst_texttospeech.qml @@ -0,0 +1,28 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +import QtTest +import QtTextToSpeech + +TestCase { + id: testCase + name: "TextToSpeech" + + TextToSpeech { + id: tts + engine: "mock" + } + + // verifies that the mock engine is synchronous + function initTestCase() { + compare(tts.state, TextToSpeech.Ready) + } + + function test_availableLocales() { + compare(tts.availableLocales().length, 3) + } + + function test_availableVoices() { + compare(tts.availableVoices().length, 2) + } +} diff --git a/tests/auto/qtexttospeech_qml/tst_voice.qml b/tests/auto/qtexttospeech_qml/tst_voice.qml new file mode 100644 index 0000000..bbd0c19 --- /dev/null +++ b/tests/auto/qtexttospeech_qml/tst_voice.qml @@ -0,0 +1,28 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +import QtTest +import QtTextToSpeech + +TestCase { + id: testCase + name: "Voice" + + TextToSpeech { + id: tts + engine: "mock" + } + + // verifies that the mock engine is synchronous + function initTestCase() { + compare(tts.state, TextToSpeech.Ready) + } + + // basic API test of the voice type and Voice namespace + function test_default_voice() { + compare(tts.voice.name, "Bob") + compare(tts.voice.age, Voice.Adult) + compare(tts.voice.gender, Voice.Male) + compare(tts.voice.locale, Qt.locale("en-UK")) + } +} |