Module: wine Branch: master Commit: fe467cf452196de64adee04da8775a6456e8cfb8 URL: https://gitlab.winehq.org/wine/wine/-/commit/fe467cf452196de64adee04da8775a6...
Author: Rémi Bernon rbernon@codeweavers.com Date: Mon Feb 27 22:35:47 2023 +0100
windows.globalization: Stub Windows.Globalization.GeographicRegion runtimeclass.
---
dlls/windows.globalization/geographic_region.c | 139 ++++++++++++++++++++++- dlls/windows.globalization/tests/globalization.c | 31 ++++- 2 files changed, 167 insertions(+), 3 deletions(-)
diff --git a/dlls/windows.globalization/geographic_region.c b/dlls/windows.globalization/geographic_region.c index 350d85c67a6..d8159550522 100644 --- a/dlls/windows.globalization/geographic_region.c +++ b/dlls/windows.globalization/geographic_region.c @@ -21,6 +21,133 @@
WINE_DEFAULT_DEBUG_CHANNEL(locale);
+struct geographic_region +{ + IGeographicRegion IGeographicRegion_iface; + LONG ref; +}; + +static inline struct geographic_region *impl_from_IGeographicRegion( IGeographicRegion *iface ) +{ + return CONTAINING_RECORD( iface, struct geographic_region, IGeographicRegion_iface ); +} + +static HRESULT WINAPI geographic_region_QueryInterface( IGeographicRegion *iface, REFIID iid, void **out ) +{ + struct geographic_region *impl = impl_from_IGeographicRegion( iface ); + + TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out ); + + if (IsEqualGUID( iid, &IID_IUnknown ) || + IsEqualGUID( iid, &IID_IInspectable ) || + IsEqualGUID( iid, &IID_IAgileObject ) || + IsEqualGUID( iid, &IID_IGeographicRegion )) + { + IInspectable_AddRef( (*out = &impl->IGeographicRegion_iface) ); + return S_OK; + } + + FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) ); + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG WINAPI geographic_region_AddRef( IGeographicRegion *iface ) +{ + struct geographic_region *impl = impl_from_IGeographicRegion( iface ); + ULONG ref = InterlockedIncrement( &impl->ref ); + TRACE( "iface %p, ref %lu.\n", iface, ref ); + return ref; +} + +static ULONG WINAPI geographic_region_Release( IGeographicRegion *iface ) +{ + struct geographic_region *impl = impl_from_IGeographicRegion( iface ); + ULONG ref = InterlockedDecrement( &impl->ref ); + TRACE( "iface %p, ref %lu.\n", iface, ref ); + if (!ref) free( impl ); + return ref; +} + +static HRESULT WINAPI geographic_region_GetIids( IGeographicRegion *iface, ULONG *iid_count, IID **iids ) +{ + FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids ); + return E_NOTIMPL; +} + +static HRESULT WINAPI geographic_region_GetRuntimeClassName( IGeographicRegion *iface, HSTRING *class_name ) +{ + FIXME( "iface %p, class_name %p stub!\n", iface, class_name ); + return E_NOTIMPL; +} + +static HRESULT WINAPI geographic_region_GetTrustLevel( IGeographicRegion *iface, TrustLevel *trust_level ) +{ + FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level ); + return E_NOTIMPL; +} + +static HRESULT WINAPI geographic_region_get_Code( IGeographicRegion *iface, HSTRING *value ) +{ + FIXME( "iface %p stub!\n", iface ); + return E_NOTIMPL; +} + +static HRESULT WINAPI geographic_region_get_CodeTwoLetter( IGeographicRegion *iface, HSTRING *value ) +{ + FIXME( "iface %p stub!\n", iface ); + return E_NOTIMPL; +} + +static HRESULT WINAPI geographic_region_get_CodeThreeLetter( IGeographicRegion *iface, HSTRING *value ) +{ + FIXME( "iface %p stub!\n", iface ); + return E_NOTIMPL; +} + +static HRESULT WINAPI geographic_region_get_CodeThreeDigit( IGeographicRegion *iface, HSTRING *value ) +{ + FIXME( "iface %p stub!\n", iface ); + return E_NOTIMPL; +} + +static HRESULT WINAPI geographic_region_get_DisplayName( IGeographicRegion *iface, HSTRING *value ) +{ + FIXME( "iface %p stub!\n", iface ); + return E_NOTIMPL; +} + +static HRESULT WINAPI geographic_region_get_NativeName( IGeographicRegion *iface, HSTRING *value ) +{ + FIXME( "iface %p stub!\n", iface ); + return E_NOTIMPL; +} + +static HRESULT WINAPI geographic_region_get_CurrenciesInUse( IGeographicRegion *iface, IVectorView_HSTRING **value ) +{ + FIXME( "iface %p stub!\n", iface ); + return E_NOTIMPL; +} + +static const struct IGeographicRegionVtbl geographic_region_vtbl = +{ + geographic_region_QueryInterface, + geographic_region_AddRef, + geographic_region_Release, + /* IInspectable methods */ + geographic_region_GetIids, + geographic_region_GetRuntimeClassName, + geographic_region_GetTrustLevel, + /* IGeographicRegion methods */ + geographic_region_get_Code, + geographic_region_get_CodeTwoLetter, + geographic_region_get_CodeThreeLetter, + geographic_region_get_CodeThreeDigit, + geographic_region_get_DisplayName, + geographic_region_get_NativeName, + geographic_region_get_CurrenciesInUse, +}; + struct geographic_region_factory { IActivationFactory IActivationFactory_iface; @@ -95,8 +222,16 @@ static HRESULT WINAPI activation_factory_GetTrustLevel( IActivationFactory *ifac
static HRESULT WINAPI activation_factory_ActivateInstance( IActivationFactory *iface, IInspectable **out ) { - FIXME( "iface %p, out %p stub!\n", iface, out ); - return E_NOTIMPL; + struct geographic_region *region; + + TRACE( "iface %p, out %p.\n", iface, out ); + + if (!(region = calloc( 1, sizeof(*region) ))) return E_OUTOFMEMORY; + region->IGeographicRegion_iface.lpVtbl = &geographic_region_vtbl; + region->ref = 1; + + *out = (IInspectable *)®ion->IGeographicRegion_iface; + return S_OK; }
static const struct IActivationFactoryVtbl activation_factory_vtbl = diff --git a/dlls/windows.globalization/tests/globalization.c b/dlls/windows.globalization/tests/globalization.c index c391bea5804..a01ed7f87f7 100644 --- a/dlls/windows.globalization/tests/globalization.c +++ b/dlls/windows.globalization/tests/globalization.c @@ -314,6 +314,8 @@ static void test_Language(void) static void test_GeographicRegion(void) { static const WCHAR *class_name = RuntimeClass_Windows_Globalization_GeographicRegion; + IGeographicRegionFactory *geographic_region_factory; + IGeographicRegion *geographic_region; IActivationFactory *factory; HSTRING str; HRESULT hr; @@ -334,7 +336,34 @@ static void test_GeographicRegion(void) check_interface( factory, &IID_IUnknown ); check_interface( factory, &IID_IInspectable ); check_interface( factory, &IID_IAgileObject ); - check_interface( factory, &IID_IGeographicRegionFactory ); + + hr = IActivationFactory_ActivateInstance( factory, (IInspectable **)&geographic_region ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + check_interface( geographic_region, &IID_IUnknown ); + check_interface( geographic_region, &IID_IInspectable ); + check_interface( geographic_region, &IID_IAgileObject ); + + ref = IGeographicRegion_Release( geographic_region ); + ok( ref == 0, "got ref %ld.\n", ref ); + + hr = IActivationFactory_QueryInterface( factory, &IID_IGeographicRegionFactory, (void **)&geographic_region_factory ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + + hr = WindowsCreateString( L"US", wcslen( L"US" ), &str ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + hr = IGeographicRegionFactory_CreateGeographicRegion( geographic_region_factory, str, &geographic_region ); + todo_wine ok( hr == S_OK, "got hr %#lx.\n", hr ); + WindowsDeleteString( str ); + + if (hr == S_OK) + { + ref = IGeographicRegion_Release( geographic_region ); + ok( ref == 0, "got ref %ld.\n", ref ); + } + + ref = IGeographicRegionFactory_Release( geographic_region_factory ); + ok( ref == 2, "got ref %ld.\n", ref );
ref = IActivationFactory_Release( factory ); ok( ref == 1, "got ref %ld.\n", ref );