Module: wine Branch: master Commit: a26fb1947e8cb6d297936a9882d0bf90c683b9b4 URL: https://gitlab.winehq.org/wine/wine/-/commit/a26fb1947e8cb6d297936a9882d0bf9...
Author: Rémi Bernon rbernon@codeweavers.com Date: Thu Nov 23 12:19:34 2023 +0100
windows.globalization: Implement GeographicRegion_get_CodeTwoLetter.
---
dlls/windows.globalization/geographic_region.c | 8 ++++++-- dlls/windows.globalization/tests/globalization.c | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/dlls/windows.globalization/geographic_region.c b/dlls/windows.globalization/geographic_region.c index d8159550522..05ae7388ccc 100644 --- a/dlls/windows.globalization/geographic_region.c +++ b/dlls/windows.globalization/geographic_region.c @@ -95,8 +95,12 @@ static HRESULT WINAPI geographic_region_get_Code( IGeographicRegion *iface, HSTR
static HRESULT WINAPI geographic_region_get_CodeTwoLetter( IGeographicRegion *iface, HSTRING *value ) { - FIXME( "iface %p stub!\n", iface ); - return E_NOTIMPL; + WCHAR buffer[LOCALE_NAME_MAX_LENGTH]; + + FIXME( "iface %p semi-stub!\n", iface ); + + if (!GetLocaleInfoEx( LOCALE_NAME_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, buffer, ARRAY_SIZE(buffer) )) return E_INVALIDARG; + return WindowsCreateString( buffer, wcslen( buffer ), value ); }
static HRESULT WINAPI geographic_region_get_CodeThreeLetter( IGeographicRegion *iface, HSTRING *value ) diff --git a/dlls/windows.globalization/tests/globalization.c b/dlls/windows.globalization/tests/globalization.c index a01ed7f87f7..1abbc161cfd 100644 --- a/dlls/windows.globalization/tests/globalization.c +++ b/dlls/windows.globalization/tests/globalization.c @@ -317,8 +317,9 @@ static void test_GeographicRegion(void) IGeographicRegionFactory *geographic_region_factory; IGeographicRegion *geographic_region; IActivationFactory *factory; - HSTRING str; + HSTRING str, expect_str; HRESULT hr; + INT32 res; LONG ref;
hr = WindowsCreateString( class_name, wcslen( class_name ), &str ); @@ -344,6 +345,10 @@ static void test_GeographicRegion(void) check_interface( geographic_region, &IID_IInspectable ); check_interface( geographic_region, &IID_IAgileObject );
+ hr = IGeographicRegion_get_CodeTwoLetter( geographic_region, &str ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + WindowsDeleteString( str ); + ref = IGeographicRegion_Release( geographic_region ); ok( ref == 0, "got ref %ld.\n", ref );
@@ -358,6 +363,16 @@ static void test_GeographicRegion(void)
if (hr == S_OK) { + hr = WindowsCreateString( L"US", wcslen( L"US" ), &expect_str ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + hr = IGeographicRegion_get_CodeTwoLetter( geographic_region, &str ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + hr = WindowsCompareStringOrdinal( str, expect_str, &res ); + ok( hr == S_OK, "got hr %#lx.\n", hr ); + ok( !res, "got unexpected string %s.\n", debugstr_hstring(str) ); + WindowsDeleteString( str ); + WindowsDeleteString( expect_str ); + ref = IGeographicRegion_Release( geographic_region ); ok( ref == 0, "got ref %ld.\n", ref ); }