2 * Copyright 2021 RĂ©mi Bernon for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "winstring.h"
29 #define WIDL_using_Windows_Foundation
30 #define WIDL_using_Windows_Foundation_Collections
31 #include "windows.foundation.h"
32 #define WIDL_using_Windows_Media_SpeechSynthesis
33 #include "windows.media.speechsynthesis.h"
35 #include "wine/test.h"
37 static HRESULT (WINAPI
*pRoActivateInstance
)(HSTRING
, IInspectable
**);
38 static HRESULT (WINAPI
*pRoGetActivationFactory
)(HSTRING
, REFIID
, void **);
39 static HRESULT (WINAPI
*pRoInitialize
)(RO_INIT_TYPE
);
40 static void (WINAPI
*pRoUninitialize
)(void);
41 static HRESULT (WINAPI
*pWindowsCreateString
)(LPCWSTR
, UINT32
, HSTRING
*);
42 static HRESULT (WINAPI
*pWindowsDeleteString
)(HSTRING
);
44 static void test_SpeechSynthesizer(void)
46 static const WCHAR
*speech_synthesizer_name
= L
"Windows.Media.SpeechSynthesis.SpeechSynthesizer";
48 IVectorView_VoiceInformation
*voices
= NULL
;
49 IInstalledVoicesStatic
*voices_static
= NULL
;
50 IActivationFactory
*factory
= NULL
;
51 IVoiceInformation
*voice
;
52 IInspectable
*inspectable
= NULL
, *tmp_inspectable
= NULL
;
53 IAgileObject
*agile_object
= NULL
, *tmp_agile_object
= NULL
;
58 hr
= pRoInitialize(RO_INIT_MULTITHREADED
);
59 ok(hr
== S_OK
, "RoInitialize failed, hr %#x\n", hr
);
61 hr
= pWindowsCreateString(speech_synthesizer_name
, wcslen(speech_synthesizer_name
), &str
);
62 ok(hr
== S_OK
, "WindowsCreateString failed, hr %#x\n", hr
);
64 hr
= pRoGetActivationFactory(str
, &IID_IActivationFactory
, (void **)&factory
);
65 ok(hr
== S_OK
, "RoGetActivationFactory failed, hr %#x\n", hr
);
67 hr
= IActivationFactory_QueryInterface(factory
, &IID_IInspectable
, (void **)&inspectable
);
68 ok(hr
== S_OK
, "IActivationFactory_QueryInterface IID_IInspectable failed, hr %#x\n", hr
);
70 hr
= IActivationFactory_QueryInterface(factory
, &IID_IAgileObject
, (void **)&agile_object
);
71 ok(hr
== S_OK
, "IActivationFactory_QueryInterface IID_IAgileObject failed, hr %#x\n", hr
);
73 hr
= IActivationFactory_QueryInterface(factory
, &IID_IInstalledVoicesStatic
, (void **)&voices_static
);
74 ok(hr
== S_OK
, "IActivationFactory_QueryInterface IID_IInstalledVoicesStatic failed, hr %#x\n", hr
);
76 hr
= IInstalledVoicesStatic_QueryInterface(voices_static
, &IID_IInspectable
, (void **)&tmp_inspectable
);
77 ok(hr
== S_OK
, "IInstalledVoicesStatic_QueryInterface IID_IInspectable failed, hr %#x\n", hr
);
78 ok(tmp_inspectable
== inspectable
, "IInstalledVoicesStatic_QueryInterface IID_IInspectable returned %p, expected %p\n", tmp_inspectable
, inspectable
);
79 IInspectable_Release(tmp_inspectable
);
81 hr
= IInstalledVoicesStatic_QueryInterface(voices_static
, &IID_IAgileObject
, (void **)&tmp_agile_object
);
82 ok(hr
== S_OK
, "IInstalledVoicesStatic_QueryInterface IID_IAgileObject failed, hr %#x\n", hr
);
83 ok(tmp_agile_object
== agile_object
, "IInstalledVoicesStatic_QueryInterface IID_IAgileObject returned %p, expected %p\n", tmp_agile_object
, agile_object
);
84 IAgileObject_Release(tmp_agile_object
);
86 hr
= IInstalledVoicesStatic_get_AllVoices(voices_static
, &voices
);
87 ok(hr
== S_OK
, "IInstalledVoicesStatic_get_AllVoices failed, hr %#x\n", hr
);
89 hr
= IVectorView_VoiceInformation_QueryInterface(voices
, &IID_IInspectable
, (void **)&tmp_inspectable
);
90 ok(hr
== S_OK
, "IVectorView_VoiceInformation_QueryInterface voices failed, hr %#x\n", hr
);
91 ok(tmp_inspectable
!= inspectable
, "IVectorView_VoiceInformation_QueryInterface voices returned %p, expected %p\n", tmp_inspectable
, inspectable
);
92 IInspectable_Release(tmp_inspectable
);
94 hr
= IVectorView_VoiceInformation_QueryInterface(voices
, &IID_IAgileObject
, (void **)&tmp_agile_object
);
95 ok(hr
== E_NOINTERFACE
, "IVectorView_VoiceInformation_QueryInterface voices failed, hr %#x\n", hr
);
98 hr
= IVectorView_VoiceInformation_get_Size(voices
, &size
);
99 ok(hr
== S_OK
, "IVectorView_VoiceInformation_get_Size voices failed, hr %#x\n", hr
);
100 todo_wine
ok(size
!= 0 && size
!= 0xdeadbeef, "IVectorView_VoiceInformation_get_Size returned %u\n", size
);
102 voice
= (IVoiceInformation
*)0xdeadbeef;
103 hr
= IVectorView_VoiceInformation_GetAt(voices
, size
, &voice
);
104 ok(hr
== E_BOUNDS
, "IVectorView_VoiceInformation_GetAt failed, hr %#x\n", hr
);
105 ok(voice
== NULL
, "IVectorView_VoiceInformation_GetAt returned %p\n", voice
);
107 hr
= IVectorView_VoiceInformation_GetMany(voices
, size
, 1, &voice
, &size
);
108 ok(hr
== S_OK
, "IVectorView_VoiceInformation_GetMany failed, hr %#x\n", hr
);
109 ok(size
== 0, "IVectorView_VoiceInformation_GetMany returned count %u\n", size
);
111 IVectorView_VoiceInformation_Release(voices
);
113 IInstalledVoicesStatic_Release(voices_static
);
115 IAgileObject_Release(agile_object
);
116 IInspectable_Release(inspectable
);
117 IActivationFactory_Release(factory
);
119 pWindowsDeleteString(str
);
124 static void test_VoiceInformation(void)
126 static const WCHAR
*voice_information_name
= L
"Windows.Media.SpeechSynthesis.VoiceInformation";
128 IActivationFactory
*factory
= NULL
;
132 hr
= pRoInitialize(RO_INIT_MULTITHREADED
);
133 ok(hr
== S_OK
, "RoInitialize failed, hr %#x\n", hr
);
135 hr
= pWindowsCreateString(voice_information_name
, wcslen(voice_information_name
), &str
);
136 ok(hr
== S_OK
, "WindowsCreateString failed, hr %#x\n", hr
);
138 hr
= pRoGetActivationFactory(str
, &IID_IActivationFactory
, (void **)&factory
);
139 ok(hr
== REGDB_E_CLASSNOTREG
, "RoGetActivationFactory returned unexpected hr %#x\n", hr
);
141 pWindowsDeleteString(str
);
150 if (!(combase
= LoadLibraryW(L
"combase.dll")))
152 win_skip("Failed to load combase.dll, skipping tests\n");
156 #define LOAD_FUNCPTR(x) \
157 if (!(p##x = (void*)GetProcAddress(combase, #x))) \
159 win_skip("Failed to find %s in combase.dll, skipping tests.\n", #x); \
163 LOAD_FUNCPTR(RoActivateInstance
);
164 LOAD_FUNCPTR(RoGetActivationFactory
);
165 LOAD_FUNCPTR(RoInitialize
);
166 LOAD_FUNCPTR(RoUninitialize
);
167 LOAD_FUNCPTR(WindowsCreateString
);
168 LOAD_FUNCPTR(WindowsDeleteString
);
171 test_SpeechSynthesizer();
172 test_VoiceInformation();