windows.media.speech/tests: Add interface query tests.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2021-03-12 12:31:09 +01:00 committed by Alexandre Julliard
parent 3c502f40c4
commit f333672a97
4 changed files with 183 additions and 0 deletions

1
configure vendored
View File

@ -21124,6 +21124,7 @@ wine_fn_config_makefile dlls/win87em.dll16 enable_win16
wine_fn_config_makefile dlls/winaspi.dll16 enable_win16
wine_fn_config_makefile dlls/windebug.dll16 enable_win16
wine_fn_config_makefile dlls/windows.media.speech enable_windows_media_speech
wine_fn_config_makefile dlls/windows.media.speech/tests enable_tests
wine_fn_config_makefile dlls/windowscodecs enable_windowscodecs
wine_fn_config_makefile dlls/windowscodecs/tests enable_tests
wine_fn_config_makefile dlls/windowscodecsext enable_windowscodecsext

View File

@ -3802,6 +3802,7 @@ WINE_CONFIG_MAKEFILE(dlls/win87em.dll16,enable_win16)
WINE_CONFIG_MAKEFILE(dlls/winaspi.dll16,enable_win16)
WINE_CONFIG_MAKEFILE(dlls/windebug.dll16,enable_win16)
WINE_CONFIG_MAKEFILE(dlls/windows.media.speech)
WINE_CONFIG_MAKEFILE(dlls/windows.media.speech/tests)
WINE_CONFIG_MAKEFILE(dlls/windowscodecs)
WINE_CONFIG_MAKEFILE(dlls/windowscodecs/tests)
WINE_CONFIG_MAKEFILE(dlls/windowscodecsext)

View File

@ -0,0 +1,5 @@
TESTDLL = windows.media.speech.dll
IMPORTS = uuid
C_SRCS = \
statics.c

View File

@ -0,0 +1,176 @@
/*
* Copyright 2021 Rémi Bernon for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#define COBJMACROS
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "winstring.h"
#include "initguid.h"
#include "roapi.h"
#define WIDL_using_Windows_Foundation
#define WIDL_using_Windows_Foundation_Collections
#include "windows.foundation.h"
#define WIDL_using_Windows_Media_SpeechSynthesis
#include "windows.media.speechsynthesis.h"
#include "wine/test.h"
static HRESULT (WINAPI *pRoActivateInstance)(HSTRING, IInspectable **);
static HRESULT (WINAPI *pRoGetActivationFactory)(HSTRING, REFIID, void **);
static HRESULT (WINAPI *pRoInitialize)(RO_INIT_TYPE);
static void (WINAPI *pRoUninitialize)(void);
static HRESULT (WINAPI *pWindowsCreateString)(LPCWSTR, UINT32, HSTRING *);
static HRESULT (WINAPI *pWindowsDeleteString)(HSTRING);
static void test_SpeechSynthesizer(void)
{
static const WCHAR *speech_synthesizer_name = L"Windows.Media.SpeechSynthesis.SpeechSynthesizer";
IVectorView_VoiceInformation *voices = NULL;
IInstalledVoicesStatic *voices_static = NULL;
IActivationFactory *factory = NULL;
IInspectable *inspectable = NULL, *tmp_inspectable = NULL;
IAgileObject *agile_object = NULL, *tmp_agile_object = NULL;
HSTRING str;
HRESULT hr;
ULONG rc, size;
hr = pRoInitialize(RO_INIT_MULTITHREADED);
ok(SUCCEEDED(hr), "RoInitialize failed, hr %#x\n", hr);
hr = pWindowsCreateString(speech_synthesizer_name, wcslen(speech_synthesizer_name), &str);
ok(SUCCEEDED(hr), "WindowsCreateString failed, hr %#x\n", hr);
hr = pRoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory);
ok(SUCCEEDED(hr), "RoGetActivationFactory failed, hr %#x\n", hr);
rc = IActivationFactory_AddRef(factory);
ok(rc == 3, "IActivationFactory_AddRef returned %d\n", rc);
rc = IActivationFactory_Release(factory);
ok(rc == 2, "IActivationFactory_Release returned %d\n", rc);
hr = IActivationFactory_QueryInterface(factory, &IID_IInspectable, (void **)&inspectable);
ok(SUCCEEDED(hr), "IActivationFactory_QueryInterface IID_IInspectable failed, hr %#x\n", hr);
hr = IActivationFactory_QueryInterface(factory, &IID_IAgileObject, (void **)&agile_object);
ok(SUCCEEDED(hr), "IActivationFactory_QueryInterface IID_IAgileObject failed, hr %#x\n", hr);
hr = IActivationFactory_QueryInterface(factory, &IID_IInstalledVoicesStatic, (void **)&voices_static);
todo_wine ok(SUCCEEDED(hr), "IActivationFactory_QueryInterface IID_IInstalledVoicesStatic failed, hr %#x\n", hr);
if (FAILED(hr)) goto done;
hr = IInstalledVoicesStatic_QueryInterface(voices_static, &IID_IInspectable, (void **)&tmp_inspectable);
ok(SUCCEEDED(hr), "IInstalledVoicesStatic_QueryInterface IID_IInspectable failed, hr %#x\n", hr);
ok(tmp_inspectable == inspectable, "IInstalledVoicesStatic_QueryInterface IID_IInspectable returned %p, expected %p\n", tmp_inspectable, inspectable);
IInspectable_Release(tmp_inspectable);
hr = IInstalledVoicesStatic_QueryInterface(voices_static, &IID_IAgileObject, (void **)&tmp_agile_object);
ok(SUCCEEDED(hr), "IInstalledVoicesStatic_QueryInterface IID_IAgileObject failed, hr %#x\n", hr);
ok(tmp_agile_object == agile_object, "IInstalledVoicesStatic_QueryInterface IID_IAgileObject returned %p, expected %p\n", tmp_agile_object, agile_object);
IAgileObject_Release(tmp_agile_object);
hr = IInstalledVoicesStatic_get_AllVoices(voices_static, &voices);
ok(SUCCEEDED(hr), "IInstalledVoicesStatic_get_AllVoices failed, hr %#x\n", hr);
hr = IVectorView_VoiceInformation_QueryInterface(voices, &IID_IInspectable, (void **)&tmp_inspectable);
ok(SUCCEEDED(hr), "IVectorView_VoiceInformation_QueryInterface voices failed, hr %#x\n", hr);
ok(tmp_inspectable != inspectable, "IVectorView_VoiceInformation_QueryInterface voices returned %p, expected %p\n", tmp_inspectable, inspectable);
IInspectable_Release(tmp_inspectable);
hr = IVectorView_VoiceInformation_QueryInterface(voices, &IID_IAgileObject, (void **)&tmp_agile_object);
ok(FAILED(hr), "IVectorView_VoiceInformation_QueryInterface voices failed, hr %#x\n", hr);
size = 0xdeadbeef;
hr = IVectorView_VoiceInformation_get_Size(voices, &size);
ok(SUCCEEDED(hr), "IVectorView_VoiceInformation_QueryInterface voices failed, hr %#x\n", hr);
ok(size != 0 && size != 0xdeadbeef, "IVectorView_VoiceInformation_get_Size returned %u\n", size);
rc = IVectorView_VoiceInformation_Release(voices);
ok(rc == 0, "IVectorView_VoiceInformation_Release returned unexpected refcount %d\n", rc);
rc = IInstalledVoicesStatic_Release(voices_static);
ok(rc == 4, "IInstalledVoicesStatic_Release returned unexpected refcount %d\n", rc);
done:
rc = IAgileObject_Release(agile_object);
ok(rc == 3, "IAgileObject_Release returned unexpected refcount %d\n", rc);
rc = IInspectable_Release(inspectable);
ok(rc == 2, "IInspectable_Release returned unexpected refcount %d\n", rc);
rc = IActivationFactory_Release(factory);
ok(rc == 1, "IActivationFactory_Release returned unexpected refcount %d\n", rc);
pWindowsDeleteString(str);
pRoUninitialize();
}
static void test_VoiceInformation(void)
{
static const WCHAR *voice_information_name = L"Windows.Media.SpeechSynthesis.VoiceInformation";
IActivationFactory *factory = NULL;
HSTRING str;
HRESULT hr;
hr = pRoInitialize(RO_INIT_MULTITHREADED);
ok(SUCCEEDED(hr), "RoInitialize failed, hr %#x\n", hr);
hr = pWindowsCreateString(voice_information_name, wcslen(voice_information_name), &str);
ok(SUCCEEDED(hr), "WindowsCreateString failed, hr %#x\n", hr);
hr = pRoGetActivationFactory(str, &IID_IActivationFactory, (void **)&factory);
todo_wine ok(hr == REGDB_E_CLASSNOTREG, "RoGetActivationFactory returned unexpected hr %#x\n", hr);
if (SUCCEEDED(hr)) IActivationFactory_Release(factory);
pWindowsDeleteString(str);
pRoUninitialize();
}
START_TEST(statics)
{
HMODULE combase;
if (!(combase = LoadLibraryW(L"combase.dll")))
{
win_skip("Failed to load combase.dll, skipping tests\n");
return;
}
#define LOAD_FUNCPTR(x) \
if (!(p##x = (void*)GetProcAddress(combase, #x))) \
{ \
win_skip("Failed to find %s in combase.dll, skipping tests.\n", #x); \
return; \
}
LOAD_FUNCPTR(RoActivateInstance);
LOAD_FUNCPTR(RoGetActivationFactory);
LOAD_FUNCPTR(RoInitialize);
LOAD_FUNCPTR(RoUninitialize);
LOAD_FUNCPTR(WindowsCreateString);
LOAD_FUNCPTR(WindowsDeleteString);
#undef LOAD_FUNCPTR
test_SpeechSynthesizer();
test_VoiceInformation();
}