windows.media.speech: Fake empty IInstalledVoicesStatic::AllVoices vector.
[wine/zf.git] / dlls / windows.media.speech / tests / statics.c
blob8454729f9c32be1f78b98aee21b22e7bd99306dc
1 /*
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
18 #define COBJMACROS
19 #include <stdarg.h>
21 #include "windef.h"
22 #include "winbase.h"
23 #include "winerror.h"
24 #include "winstring.h"
26 #include "initguid.h"
27 #include "roapi.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 IInspectable *inspectable = NULL, *tmp_inspectable = NULL;
52 IAgileObject *agile_object = NULL, *tmp_agile_object = NULL;
53 HSTRING str;
54 HRESULT hr;
55 ULONG rc, size;
57 hr = pRoInitialize(RO_INIT_MULTITHREADED);
58 ok(SUCCEEDED(hr), "RoInitialize failed, hr %#x\n", hr);
60 hr = pWindowsCreateString(speech_synthesizer_name, wcslen(speech_synthesizer_name), &str);
61 ok(SUCCEEDED(hr), "WindowsCreateString failed, hr %#x\n", hr);
63 hr = pRoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory);
64 ok(SUCCEEDED(hr), "RoGetActivationFactory failed, hr %#x\n", hr);
66 rc = IActivationFactory_AddRef(factory);
67 ok(rc == 3, "IActivationFactory_AddRef returned %d\n", rc);
68 rc = IActivationFactory_Release(factory);
69 ok(rc == 2, "IActivationFactory_Release returned %d\n", rc);
71 hr = IActivationFactory_QueryInterface(factory, &IID_IInspectable, (void **)&inspectable);
72 ok(SUCCEEDED(hr), "IActivationFactory_QueryInterface IID_IInspectable failed, hr %#x\n", hr);
74 hr = IActivationFactory_QueryInterface(factory, &IID_IAgileObject, (void **)&agile_object);
75 ok(SUCCEEDED(hr), "IActivationFactory_QueryInterface IID_IAgileObject failed, hr %#x\n", hr);
77 hr = IActivationFactory_QueryInterface(factory, &IID_IInstalledVoicesStatic, (void **)&voices_static);
78 ok(SUCCEEDED(hr), "IActivationFactory_QueryInterface IID_IInstalledVoicesStatic failed, hr %#x\n", hr);
80 hr = IInstalledVoicesStatic_QueryInterface(voices_static, &IID_IInspectable, (void **)&tmp_inspectable);
81 ok(SUCCEEDED(hr), "IInstalledVoicesStatic_QueryInterface IID_IInspectable failed, hr %#x\n", hr);
82 ok(tmp_inspectable == inspectable, "IInstalledVoicesStatic_QueryInterface IID_IInspectable returned %p, expected %p\n", tmp_inspectable, inspectable);
83 IInspectable_Release(tmp_inspectable);
85 hr = IInstalledVoicesStatic_QueryInterface(voices_static, &IID_IAgileObject, (void **)&tmp_agile_object);
86 ok(SUCCEEDED(hr), "IInstalledVoicesStatic_QueryInterface IID_IAgileObject failed, hr %#x\n", hr);
87 ok(tmp_agile_object == agile_object, "IInstalledVoicesStatic_QueryInterface IID_IAgileObject returned %p, expected %p\n", tmp_agile_object, agile_object);
88 IAgileObject_Release(tmp_agile_object);
90 hr = IInstalledVoicesStatic_get_AllVoices(voices_static, &voices);
91 ok(SUCCEEDED(hr), "IInstalledVoicesStatic_get_AllVoices failed, hr %#x\n", hr);
93 hr = IVectorView_VoiceInformation_QueryInterface(voices, &IID_IInspectable, (void **)&tmp_inspectable);
94 ok(SUCCEEDED(hr), "IVectorView_VoiceInformation_QueryInterface voices failed, hr %#x\n", hr);
95 ok(tmp_inspectable != inspectable, "IVectorView_VoiceInformation_QueryInterface voices returned %p, expected %p\n", tmp_inspectable, inspectable);
96 IInspectable_Release(tmp_inspectable);
98 hr = IVectorView_VoiceInformation_QueryInterface(voices, &IID_IAgileObject, (void **)&tmp_agile_object);
99 ok(FAILED(hr), "IVectorView_VoiceInformation_QueryInterface voices failed, hr %#x\n", hr);
101 size = 0xdeadbeef;
102 hr = IVectorView_VoiceInformation_get_Size(voices, &size);
103 ok(SUCCEEDED(hr), "IVectorView_VoiceInformation_QueryInterface voices failed, hr %#x\n", hr);
104 todo_wine ok(size != 0 && size != 0xdeadbeef, "IVectorView_VoiceInformation_get_Size returned %u\n", size);
106 rc = IVectorView_VoiceInformation_Release(voices);
107 ok(rc == 0, "IVectorView_VoiceInformation_Release returned unexpected refcount %d\n", rc);
109 rc = IInstalledVoicesStatic_Release(voices_static);
110 ok(rc == 4, "IInstalledVoicesStatic_Release returned unexpected refcount %d\n", rc);
112 rc = IAgileObject_Release(agile_object);
113 ok(rc == 3, "IAgileObject_Release returned unexpected refcount %d\n", rc);
114 rc = IInspectable_Release(inspectable);
115 ok(rc == 2, "IInspectable_Release returned unexpected refcount %d\n", rc);
116 rc = IActivationFactory_Release(factory);
117 ok(rc == 1, "IActivationFactory_Release returned unexpected refcount %d\n", rc);
119 pWindowsDeleteString(str);
121 pRoUninitialize();
124 static void test_VoiceInformation(void)
126 static const WCHAR *voice_information_name = L"Windows.Media.SpeechSynthesis.VoiceInformation";
128 IActivationFactory *factory = NULL;
129 HSTRING str;
130 HRESULT hr;
132 hr = pRoInitialize(RO_INIT_MULTITHREADED);
133 ok(SUCCEEDED(hr), "RoInitialize failed, hr %#x\n", hr);
135 hr = pWindowsCreateString(voice_information_name, wcslen(voice_information_name), &str);
136 ok(SUCCEEDED(hr), "WindowsCreateString failed, hr %#x\n", hr);
138 hr = pRoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory);
139 todo_wine ok(hr == REGDB_E_CLASSNOTREG, "RoGetActivationFactory returned unexpected hr %#x\n", hr);
140 if (SUCCEEDED(hr)) IActivationFactory_Release(factory);
142 pWindowsDeleteString(str);
144 pRoUninitialize();
147 START_TEST(statics)
149 HMODULE combase;
151 if (!(combase = LoadLibraryW(L"combase.dll")))
153 win_skip("Failed to load combase.dll, skipping tests\n");
154 return;
157 #define LOAD_FUNCPTR(x) \
158 if (!(p##x = (void*)GetProcAddress(combase, #x))) \
160 win_skip("Failed to find %s in combase.dll, skipping tests.\n", #x); \
161 return; \
164 LOAD_FUNCPTR(RoActivateInstance);
165 LOAD_FUNCPTR(RoGetActivationFactory);
166 LOAD_FUNCPTR(RoInitialize);
167 LOAD_FUNCPTR(RoUninitialize);
168 LOAD_FUNCPTR(WindowsCreateString);
169 LOAD_FUNCPTR(WindowsDeleteString);
170 #undef LOAD_FUNCPTR
172 test_SpeechSynthesizer();
173 test_VoiceInformation();