Francois Gouget : windows.globalization/tests: Load GetUserDefaultGeoName() dynamically.

Alexandre Julliard julliard at winehq.org
Wed Apr 21 15:57:55 CDT 2021


Module: wine
Branch: master
Commit: 0e0f3ef87281b7f26ca0de88a9934f5a68587c4e
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=0e0f3ef87281b7f26ca0de88a9934f5a68587c4e

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Wed Apr 21 20:24:48 2021 +0200

windows.globalization/tests: Load GetUserDefaultGeoName() dynamically.

Many windows versions before Windows 10 1709 have
windows.globalization.dll but not GetUserDefaultGeoName().

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/windows.globalization/tests/globalization.c | 25 ++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/dlls/windows.globalization/tests/globalization.c b/dlls/windows.globalization/tests/globalization.c
index aa51b8b83f9..7746e93dc1a 100644
--- a/dlls/windows.globalization/tests/globalization.c
+++ b/dlls/windows.globalization/tests/globalization.c
@@ -34,6 +34,11 @@
 
 #include "wine/test.h"
 
+
+/* kernel32.dll */
+static INT (WINAPI *pGetUserDefaultGeoName)(LPWSTR, int);
+
+/* combase.dll */
 static HRESULT (WINAPI *pRoGetActivationFactory)(HSTRING, REFIID, void **);
 static HRESULT (WINAPI *pRoInitialize)(RO_INIT_TYPE);
 static void    (WINAPI *pRoUninitialize)(void);
@@ -41,6 +46,7 @@ static HRESULT (WINAPI *pWindowsCreateString)(LPCWSTR, UINT32, HSTRING *);
 static HRESULT (WINAPI *pWindowsDeleteString)(HSTRING);
 static WCHAR  *(WINAPI *pWindowsGetStringRawBuffer)(HSTRING, UINT32 *);
 
+
 static void test_GlobalizationPreferences(void)
 {
     static const WCHAR *class_name = L"Windows.System.UserProfile.GlobalizationPreferences";
@@ -54,11 +60,10 @@ static void test_GlobalizationPreferences(void)
     BOOLEAN found;
     HRESULT hr;
     UINT32 len;
-    WCHAR *buf, locale[LOCALE_NAME_MAX_LENGTH], country[16];
+    WCHAR *buf, locale[LOCALE_NAME_MAX_LENGTH];
     UINT32 i, size;
 
     GetUserDefaultLocaleName(locale, LOCALE_NAME_MAX_LENGTH);
-    GetUserDefaultGeoName(country, 16);
 
     hr = pRoInitialize(RO_INIT_MULTITHREADED);
     ok(hr == S_OK, "RoInitialize failed, hr %#x\n", hr);
@@ -100,9 +105,14 @@ static void test_GlobalizationPreferences(void)
 
     buf = pWindowsGetStringRawBuffer(tmp_str, &len);
     ok(buf != NULL && len > 0, "WindowsGetStringRawBuffer returned buf %p, len %u\n", buf, len);
-    ok(wcslen(country) == len && !memcmp(buf, country, len),
-       "IGlobalizationPreferencesStatics_get_HomeGeographicRegion returned len %u, str %s, expected %s\n",
-       len, wine_dbgstr_w(buf), wine_dbgstr_w(country));
+    if (pGetUserDefaultGeoName)
+    {
+        WCHAR country[16];
+        pGetUserDefaultGeoName(country, ARRAY_SIZE(country));
+        ok(wcslen(country) == len && !memcmp(buf, country, len),
+           "IGlobalizationPreferencesStatics_get_HomeGeographicRegion returned len %u, str %s, expected %s\n",
+           len, wine_dbgstr_w(buf), wine_dbgstr_w(country));
+    }
 
     pWindowsDeleteString(tmp_str);
 
@@ -224,7 +234,7 @@ static void test_GlobalizationPreferences(void)
 
 START_TEST(globalization)
 {
-    HMODULE combase;
+    HMODULE combase, kernel32;
 
     if (!(combase = LoadLibraryW(L"combase.dll")))
     {
@@ -247,5 +257,8 @@ START_TEST(globalization)
     LOAD_FUNCPTR(WindowsGetStringRawBuffer);
 #undef LOAD_FUNCPTR
 
+    kernel32 = GetModuleHandleA("kernel32");
+    pGetUserDefaultGeoName = (void*)GetProcAddress(kernel32, "GetUserDefaultGeoName");
+
     test_GlobalizationPreferences();
 }




More information about the wine-cvs mailing list