summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2023-04-22 09:42:10 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-04-23 23:24:12 +0200
commit3543b7c3b69d69280122958f5949ac7827c543b0 (patch)
treeaf32261066bf722028f13682aa3410356b7c5e5a /tests
parent37ed92157d19ca2f1c7f95e72811fc54438d7a9b (diff)
Provide a VoiceSelector attached property
This makes it possible to select a voice declaratively, by specifying the selection criteria in a grouped property. If the VoiceSelector is specified as part of the element declaration, then the voice is selected only once the component is completed and all selection criteria set. Since this adds a bunch of QML-specific code to the module, move the existing QML binding code and module build files into a subdirectory. Move the findVoices invokable from QTextToSpeech to the new QML-specific subclass (it's not needed as a C++ API and was documented as internal in QTextToSpeech). Change-Id: I6f8907f53b513d1108f8446d57bef5975035163b Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qtexttospeech_qml/tst_texttospeech.qml62
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/auto/qtexttospeech_qml/tst_texttospeech.qml b/tests/auto/qtexttospeech_qml/tst_texttospeech.qml
index d01c86d..8caed32 100644
--- a/tests/auto/qtexttospeech_qml/tst_texttospeech.qml
+++ b/tests/auto/qtexttospeech_qml/tst_texttospeech.qml
@@ -1,6 +1,8 @@
// 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 QtQuick
+
import QtTest
import QtTextToSpeech
@@ -48,4 +50,64 @@ TestCase {
});
compare(englishWomen.length, 1)
}
+
+ Component {
+ id: name_selector
+ TextToSpeech {
+ engine: "mock"
+ VoiceSelector.name: "Ingvild"
+ }
+ }
+
+ Component {
+ id: genderLanguage_selector
+ TextToSpeech {
+ engine: "mock"
+ VoiceSelector.gender: Voice.Female
+ VoiceSelector.language: Qt.locale("en")
+ }
+ }
+
+ function test_voiceSelector() {
+ var selector = createTemporaryObject(name_selector, testCase)
+ compare(selector.voice.name, "Ingvild")
+
+ // there is no way to get to QLocale::English from QML
+ let EnglishID = 75
+
+ selector = createTemporaryObject(genderLanguage_selector, testCase)
+ verify(["Anne", "Mary"].includes(selector.voice.name))
+ let oldName = selector.voice.name
+ compare(selector.voice.gender, Voice.Female)
+ compare(selector.voice.language, EnglishID)
+
+ // overwrite after initialization
+ selector.VoiceSelector.gender = Voice.Male
+ // no change until select is called
+ compare(selector.voice.name, oldName)
+ selector.VoiceSelector.select()
+
+ compare(selector.voice.name, "Bob")
+ compare(selector.voice.gender, Voice.Male)
+ compare(selector.voice.language, EnglishID)
+ }
+
+ function test_delayedSelection() {
+ var selector = createTemporaryObject(name_selector, testCase)
+
+ selector.VoiceSelector.gender = Voice.Female
+ selector.VoiceSelector.name = "Kjersti"
+ selector.VoiceSelector.select()
+
+ compare(selector.voice.name, "Kjersti")
+ }
+
+ function test_regularExpressionName() {
+ var selector = createTemporaryObject(name_selector, testCase)
+
+ selector.VoiceSelector.name = /K.*/
+ selector.VoiceSelector.select()
+
+ verify(["Kjersti", "Kari"].includes(selector.voice.name))
+ }
}