From b6882d8f0c8c002b70fc9f5db6e11021b51739b6 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 12 Apr 2023 11:19:24 +0200 Subject: 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 --- tests/auto/CMakeLists.txt | 3 +++ tests/auto/qtexttospeech_qml/CMakeLists.txt | 14 ++++++++++++ tests/auto/qtexttospeech_qml/main.cpp | 7 ++++++ tests/auto/qtexttospeech_qml/tst_texttospeech.qml | 28 +++++++++++++++++++++++ tests/auto/qtexttospeech_qml/tst_voice.qml | 28 +++++++++++++++++++++++ 5 files changed, 80 insertions(+) create mode 100644 tests/auto/qtexttospeech_qml/CMakeLists.txt create mode 100644 tests/auto/qtexttospeech_qml/main.cpp create mode 100644 tests/auto/qtexttospeech_qml/tst_texttospeech.qml create mode 100644 tests/auto/qtexttospeech_qml/tst_voice.qml (limited to 'tests') 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 +#include + +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")) + } +} -- cgit v1.2.3