1
0
mirror of https://github.com/wine-mirror/wine synced 2024-06-29 06:14:34 +00:00

wintypes: Report some API contracts as present in api_information_statics_IsApiContractPresentByMajor().

This commit is contained in:
Paul Gofman 2024-03-25 16:24:01 -06:00 committed by Alexandre Julliard
parent ce2ae79f9d
commit 2799c95dd2
2 changed files with 49 additions and 2 deletions

View File

@ -34,6 +34,27 @@
WINE_DEFAULT_DEBUG_CHANNEL(wintypes);
static const struct
{
const WCHAR *name;
unsigned int max_major;
}
present_contracts[] =
{
{ L"Windows.Foundation.UniversalApiContract", 10, },
};
static BOOLEAN is_api_contract_present( const HSTRING hname, unsigned int version )
{
const WCHAR *name = WindowsGetStringRawBuffer( hname, NULL );
unsigned int i;
for (i = 0; i < ARRAY_SIZE(present_contracts); ++i)
if (!wcsicmp( name, present_contracts[i].name )) return version <= present_contracts[i].max_major;
return FALSE;
}
struct wintypes
{
IActivationFactory IActivationFactory_iface;
@ -280,13 +301,13 @@ static HRESULT STDMETHODCALLTYPE api_information_statics_IsEnumNamedValuePresent
static HRESULT STDMETHODCALLTYPE api_information_statics_IsApiContractPresentByMajor(
IApiInformationStatics *iface, HSTRING contract_name, UINT16 major_version, BOOLEAN *value)
{
FIXME("iface %p, contract_name %s, major_version %u, value %p stub!\n", iface,
FIXME("iface %p, contract_name %s, major_version %u, value %p semi-stub.\n", iface,
debugstr_hstring(contract_name), major_version, value);
if (!contract_name)
return E_INVALIDARG;
*value = FALSE;
*value = is_api_contract_present( contract_name, major_version );
return S_OK;
}

View File

@ -33,12 +33,23 @@
static void test_IApiInformationStatics(void)
{
static const struct
{
const WCHAR *name;
unsigned int max_major;
}
present_contracts[] =
{
{ L"Windows.Foundation.UniversalApiContract", 10, },
};
static const WCHAR *class_name = L"Windows.Foundation.Metadata.ApiInformation";
IAgileObject *agile_object = NULL, *tmp_agile_object = NULL;
IInspectable *inspectable = NULL, *tmp_inspectable = NULL;
IApiInformationStatics *statics = NULL;
IActivationFactory *factory = NULL;
HSTRING str, str2;
unsigned int i, j;
BOOLEAN ret;
HRESULT hr;
@ -424,6 +435,21 @@ static void test_IApiInformationStatics(void)
WindowsDeleteString(str);
/* Test API contracts presence. */
for (i = 0; i < ARRAY_SIZE(present_contracts); ++i)
{
hr = WindowsCreateString(present_contracts[i].name, wcslen(present_contracts[i].name), &str);
ok(hr == S_OK, "WindowsCreateString failed, hr %#lx.\n", hr);
for (j = 0; j <= present_contracts[i].max_major; ++j)
{
ret = FALSE;
hr = IApiInformationStatics_IsApiContractPresentByMajor(statics, str, i, &ret);
ok(hr == S_OK, "IsApiContractPresentByMajor failed, hr %#lx, i %u, major %u.\n", hr, i, j);
ok(ret == TRUE, "IsApiContractPresentByMajor returned FALSE, i %u, major %u.\n", i, j);
}
WindowsDeleteString(str);
}
IApiInformationStatics_Release(statics);
IAgileObject_Release(agile_object);
IInspectable_Release(inspectable);