Module: wine Branch: master Commit: 2799c95dd254f9dcd63430c98e35e7c763407f6e URL: https://gitlab.winehq.org/wine/wine/-/commit/2799c95dd254f9dcd63430c98e35e7c...
Author: Paul Gofman pgofman@codeweavers.com Date: Mon Mar 25 16:24:01 2024 -0600
wintypes: Report some API contracts as present in api_information_statics_IsApiContractPresentByMajor().
---
dlls/wintypes/main.c | 25 +++++++++++++++++++++++-- dlls/wintypes/tests/wintypes.c | 26 ++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/dlls/wintypes/main.c b/dlls/wintypes/main.c index d5bfb5ad11c..7d59ab92c41 100644 --- a/dlls/wintypes/main.c +++ b/dlls/wintypes/main.c @@ -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; }
diff --git a/dlls/wintypes/tests/wintypes.c b/dlls/wintypes/tests/wintypes.c index dd6401c212b..0703582d325 100644 --- a/dlls/wintypes/tests/wintypes.c +++ b/dlls/wintypes/tests/wintypes.c @@ -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);