Commit 20f990a3 authored by Bernhard Kölbl's avatar Bernhard Kölbl Committed by Alexandre Julliard

windows.media.speech/tests: Add basic tests for ssml/text to stream functions.

parent 22aa88a1
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#define AsyncStatus_Closed 4 #define AsyncStatus_Closed 4
#define SPERR_WINRT_INTERNAL_ERROR 0x800455a0 #define SPERR_WINRT_INTERNAL_ERROR 0x800455a0
#define SPERR_WINRT_INCORRECT_FORMAT 0x80131537
#define IHandler_RecognitionResult ITypedEventHandler_SpeechContinuousRecognitionSession_SpeechContinuousRecognitionResultGeneratedEventArgs #define IHandler_RecognitionResult ITypedEventHandler_SpeechContinuousRecognitionSession_SpeechContinuousRecognitionResultGeneratedEventArgs
#define IHandler_RecognitionResultVtbl ITypedEventHandler_SpeechContinuousRecognitionSession_SpeechContinuousRecognitionResultGeneratedEventArgsVtbl #define IHandler_RecognitionResultVtbl ITypedEventHandler_SpeechContinuousRecognitionSession_SpeechContinuousRecognitionResultGeneratedEventArgsVtbl
...@@ -779,18 +780,27 @@ static void test_ActivationFactory(void) ...@@ -779,18 +780,27 @@ static void test_ActivationFactory(void)
static void test_SpeechSynthesizer(void) static void test_SpeechSynthesizer(void)
{ {
static const WCHAR *simple_ssml =
L"<speak version='1.0' xmlns='http://www.w3.org/2001/10/synthesis' xml:lang='en-US'>"
"Hello, how are you doing today?"
"</speak>";
static const WCHAR *simple_synth_text = L"Hello, how are you doing today?";
static const WCHAR *speech_synthesizer_name = L"Windows.Media.SpeechSynthesis.SpeechSynthesizer"; static const WCHAR *speech_synthesizer_name = L"Windows.Media.SpeechSynthesis.SpeechSynthesizer";
static const WCHAR *speech_synthesizer_name2 = L"windows.media.speechsynthesis.speechsynthesizer"; static const WCHAR *speech_synthesizer_name2 = L"windows.media.speechsynthesis.speechsynthesizer";
static const WCHAR *unknown_class_name = L"Unknown.Class"; static const WCHAR *unknown_class_name = L"Unknown.Class";
IActivationFactory *factory = NULL, *factory2 = NULL; IActivationFactory *factory = NULL, *factory2 = NULL;
IAsyncOperation_SpeechSynthesisStream *operation_ss_stream = NULL;
IVectorView_IMediaMarker *media_markers = NULL;
IVectorView_VoiceInformation *voices = NULL; IVectorView_VoiceInformation *voices = NULL;
IInstalledVoicesStatic *voices_static = NULL; IInstalledVoicesStatic *voices_static = NULL;
ISpeechSynthesisStream *ss_stream = NULL;
IVoiceInformation *voice; IVoiceInformation *voice;
IInspectable *inspectable = NULL, *tmp_inspectable = NULL; IInspectable *inspectable = NULL, *tmp_inspectable = NULL;
IAgileObject *agile_object = NULL, *tmp_agile_object = NULL; IAgileObject *agile_object = NULL, *tmp_agile_object = NULL;
ISpeechSynthesizer *synthesizer; ISpeechSynthesizer *synthesizer;
ISpeechSynthesizer2 *synthesizer2; ISpeechSynthesizer2 *synthesizer2;
IClosable *closable; IClosable *closable;
struct async_inspectable_handler async_inspectable_handler;
HMODULE hdll; HMODULE hdll;
HSTRING str, str2; HSTRING str, str2;
HRESULT hr; HRESULT hr;
...@@ -843,6 +853,7 @@ static void test_SpeechSynthesizer(void) ...@@ -843,6 +853,7 @@ static void test_SpeechSynthesizer(void)
FreeLibrary(hdll); FreeLibrary(hdll);
} }
/* Test static Synth ifaces: IActivationFactory, IInstalledVoicesStatic, etc. */
hr = IActivationFactory_QueryInterface(factory, &IID_IInspectable, (void **)&inspectable); hr = IActivationFactory_QueryInterface(factory, &IID_IInspectable, (void **)&inspectable);
ok(hr == S_OK, "IActivationFactory_QueryInterface IID_IInspectable failed, hr %#lx\n", hr); ok(hr == S_OK, "IActivationFactory_QueryInterface IID_IInspectable failed, hr %#lx\n", hr);
...@@ -889,27 +900,135 @@ static void test_SpeechSynthesizer(void) ...@@ -889,27 +900,135 @@ static void test_SpeechSynthesizer(void)
IVectorView_VoiceInformation_Release(voices); IVectorView_VoiceInformation_Release(voices);
IInstalledVoicesStatic_Release(voices_static); hr = IInstalledVoicesStatic_get_DefaultVoice(voices_static, &voice);
todo_wine ok(hr == S_OK, "IInstalledVoicesStatic_get_DefaultVoice failed, hr %#lx\n", hr);
if (hr == S_OK)
{
IVoiceInformation_get_Description(voice, &str2);
trace("SpeechSynthesizer default voice %s.\n", debugstr_hstring(str2));
WindowsDeleteString(str2);
ref = IVoiceInformation_Release(voice);
ok(ref == 0, "Got unexpected ref %lu.\n", ref);
}
IInstalledVoicesStatic_Release(voices_static);
IAgileObject_Release(agile_object); IAgileObject_Release(agile_object);
IInspectable_Release(inspectable); IInspectable_Release(inspectable);
/* Test Synthesizer */
hr = IActivationFactory_QueryInterface(factory, &IID_ISpeechSynthesizer, (void **)&synthesizer); hr = IActivationFactory_QueryInterface(factory, &IID_ISpeechSynthesizer, (void **)&synthesizer);
ok(hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr); ok(hr == E_NOINTERFACE, "Got unexpected hr %#lx.\n", hr);
hr = RoActivateInstance(str, &inspectable); hr = RoActivateInstance(str, &inspectable);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
WindowsDeleteString(str);
hr = IInspectable_QueryInterface(inspectable, &IID_ISpeechSynthesizer, (void **)&synthesizer); hr = IInspectable_QueryInterface(inspectable, &IID_ISpeechSynthesizer, (void **)&synthesizer);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
/* Test SynthesizeTextToStreamAsync */
hr = WindowsCreateString(simple_synth_text, wcslen(simple_synth_text), &str);
ok(hr == S_OK, "WindowsCreateString failed, hr %#lx\n", hr);
hr = ISpeechSynthesizer_SynthesizeTextToStreamAsync(synthesizer, NULL, &operation_ss_stream);
todo_wine ok(hr == S_OK, "ISpeechSynthesizer_SynthesizeTextToStreamAsync failed, hr %#lx\n", hr);
if(FAILED(hr)) goto skip_ss_stream;
IAsyncOperation_SpeechSynthesisStream_Release(operation_ss_stream);
hr = ISpeechSynthesizer_SynthesizeTextToStreamAsync(synthesizer, str, &operation_ss_stream);
todo_wine ok(hr == S_OK, "ISpeechSynthesizer_SynthesizeTextToStreamAsync failed, hr %#lx\n", hr);
await_async_inspectable((IAsyncOperation_IInspectable *)operation_ss_stream,
&async_inspectable_handler,
&IID_IAsyncOperationCompletedHandler_SpeechSynthesisStream);
check_async_info((IInspectable *)operation_ss_stream, 2, Completed, S_OK);
check_interface(operation_ss_stream, &IID_IAsyncOperation_SpeechSynthesisStream, TRUE);
check_interface(operation_ss_stream, &IID_IAgileObject, TRUE);
hr = IAsyncOperation_SpeechSynthesisStream_GetResults(operation_ss_stream, &ss_stream);
todo_wine ok(hr == S_OK, "IAsyncOperation_SpeechSynthesisStream_GetResults failed, hr %#lx\n", hr);
if (hr == S_OK)
{
hr = ISpeechSynthesisStream_get_Markers(ss_stream, &media_markers);
todo_wine ok(hr == S_OK, "ISpeechSynthesisStream_get_Markers failed, hr %#lx\n", hr);
check_interface(media_markers, &IID_IVectorView_IMediaMarker, TRUE);
check_interface(media_markers, &IID_IIterable_IMediaMarker, TRUE);
check_interface(media_markers, &IID_IAgileObject, TRUE);
ref = IVectorView_IMediaMarker_Release(media_markers);
todo_wine ok(ref == 0, "Got unexpected ref %lu.\n", ref);
ref = ISpeechSynthesisStream_Release(ss_stream);
todo_wine ok(ref == 0, "Got unexpected ref %lu.\n", ref);
}
IAsyncOperation_SpeechSynthesisStream_Release(operation_ss_stream);
/* Test SynthesizeSsmlToStreamAsync */
hr = WindowsCreateString(simple_ssml, wcslen(simple_ssml), &str2);
ok(hr == S_OK, "WindowsCreateString failed, hr %#lx\n", hr);
hr = ISpeechSynthesizer_SynthesizeSsmlToStreamAsync(synthesizer, str2, &operation_ss_stream);
todo_wine ok(hr == S_OK, "ISpeechSynthesizer_SynthesizeSsmlToStreamAsync failed, hr %#lx\n", hr);
await_async_inspectable((IAsyncOperation_IInspectable *)operation_ss_stream,
&async_inspectable_handler,
&IID_IAsyncOperationCompletedHandler_SpeechSynthesisStream);
check_async_info((IInspectable *)operation_ss_stream, 3, Completed, S_OK);
check_interface(operation_ss_stream, &IID_IAsyncOperation_SpeechSynthesisStream, TRUE);
check_interface(operation_ss_stream, &IID_IAgileObject, TRUE);
hr = IAsyncOperation_SpeechSynthesisStream_GetResults(operation_ss_stream, &ss_stream);
todo_wine ok(hr == S_OK, "IAsyncOperation_SpeechSynthesisStream_GetResults failed, hr %#lx\n", hr);
if (hr == S_OK)
{
check_interface(ss_stream, &IID_ISpeechSynthesisStream, TRUE);
check_interface(ss_stream, &IID_IAgileObject, TRUE);
ref = ISpeechSynthesisStream_Release(ss_stream);
ok(ref == 0, "Got unexpected ref %lu.\n", ref);
}
IAsyncOperation_SpeechSynthesisStream_Release(operation_ss_stream);
operation_ss_stream = (void *)0xdeadbeef;
hr = ISpeechSynthesizer_SynthesizeSsmlToStreamAsync(synthesizer, NULL, &operation_ss_stream);
/* Broken on Win 8 + 8.1 */
todo_wine ok(hr == S_OK || broken(hr == E_INVALIDARG), "ISpeechSynthesizer_SynthesizeSsmlToStreamAsync failed, hr %#lx\n", hr);
if (hr == S_OK)
{
todo_wine ok(!!operation_ss_stream, "operation_ss_stream had value %p.\n", operation_ss_stream);
IAsyncOperation_SpeechSynthesisStream_Release(operation_ss_stream);
}
else todo_wine ok(operation_ss_stream == NULL, "operation_ss_stream had value %p.\n", operation_ss_stream);
operation_ss_stream = (void *)0xdeadbeef;
hr = ISpeechSynthesizer_SynthesizeSsmlToStreamAsync(synthesizer, str, &operation_ss_stream);
/* Broken on Win 8 + 8.1 */
todo_wine ok(hr == S_OK || broken(hr == SPERR_WINRT_INCORRECT_FORMAT), "ISpeechSynthesizer_SynthesizeSsmlToStreamAsync failed, hr %#lx\n", hr);
if (hr == S_OK)
{
todo_wine ok(!!operation_ss_stream, "operation_ss_stream had value %p.\n", operation_ss_stream);
IAsyncOperation_SpeechSynthesisStream_Release(operation_ss_stream);
}
else todo_wine ok(operation_ss_stream == NULL, "operation_ss_stream had value %p.\n", operation_ss_stream);
WindowsDeleteString(str2);
skip_ss_stream:
WindowsDeleteString(str);
hr = IInspectable_QueryInterface(inspectable, &IID_IClosable, (void **)&closable); hr = IInspectable_QueryInterface(inspectable, &IID_IClosable, (void **)&closable);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
hr = IInspectable_QueryInterface(inspectable, &IID_ISpeechSynthesizer2, (void **)&synthesizer2); hr = IInspectable_QueryInterface(inspectable, &IID_ISpeechSynthesizer2, (void **)&synthesizer2);
ok(hr == S_OK || ok(hr == S_OK || broken(hr == E_NOINTERFACE), "Got unexpected hr %#lx.\n", hr); /* Requires Win10 >= 1703 */
broken(hr == E_NOINTERFACE), /* requires newer Windows */
"Got unexpected hr %#lx.\n", hr);
if (hr == S_OK) if (hr == S_OK)
{ {
...@@ -927,8 +1046,6 @@ static void test_SpeechSynthesizer(void) ...@@ -927,8 +1046,6 @@ static void test_SpeechSynthesizer(void)
ok(!ref, "Got unexpected ref %lu.\n", ref); ok(!ref, "Got unexpected ref %lu.\n", ref);
IActivationFactory_Release(factory); IActivationFactory_Release(factory);
WindowsDeleteString(str);
RoUninitialize(); RoUninitialize();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment