Tests for SetUserGeoID() and SetUserGeoName() are not included, since normal programs shouldn't call those anyway.
Signed-off-by: João Diogo Craveiro Ferreira devilj@outlook.pt --- Supersedes: 172516 V5: (no changes.) --- dlls/kernel32/tests/locale.c | 109 +++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+)
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c index 81e74531ea..b40df611ca 100644 --- a/dlls/kernel32/tests/locale.c +++ b/dlls/kernel32/tests/locale.c @@ -98,6 +98,8 @@ static INT (WINAPI *pCompareStringEx)(LPCWSTR, DWORD, LPCWSTR, INT, LPCWSTR, INT static INT (WINAPI *pGetGeoInfoA)(GEOID, GEOTYPE, LPSTR, INT, LANGID); static INT (WINAPI *pGetGeoInfoW)(GEOID, GEOTYPE, LPWSTR, INT, LANGID); static BOOL (WINAPI *pEnumSystemGeoID)(GEOCLASS, GEOID, GEO_ENUMPROC); +static GEOID (WINAPI *pGetUserGeoID)(GEOCLASS); +static int (WINAPI *pGetUserDefaultGeoName)(WCHAR*, int); static BOOL (WINAPI *pGetSystemPreferredUILanguages)(DWORD, ULONG*, WCHAR*, ULONG*); static BOOL (WINAPI *pGetThreadPreferredUILanguages)(DWORD, ULONG*, WCHAR*, ULONG*); static BOOL (WINAPI *pGetUserPreferredUILanguages)(DWORD, ULONG*, WCHAR*, ULONG*); @@ -136,6 +138,8 @@ static void InitFunctionPointers(void) X(GetGeoInfoA); X(GetGeoInfoW); X(EnumSystemGeoID); + X(GetUserGeoID); + X(GetUserDefaultGeoName); X(GetSystemPreferredUILanguages); X(GetThreadPreferredUILanguages); X(GetUserPreferredUILanguages); @@ -4893,6 +4897,109 @@ static void test_EnumSystemGeoID(void) } }
+static void test_GetUserGeoID(void) +{ + GEOID id; + + if (pGetUserDefaultGeoName) + { + ok(GEOID_NOT_AVAILABLE != GetUserGeoID(GEOCLASS_NATION), + "GEOCLASS_NATION: should never return GEOID_NOT_AVAILABLE in this platform.\n"); + ok(GEOID_NOT_AVAILABLE != GetUserGeoID(GEOCLASS_REGION), + "GEOCLASS_REGION: should never return GEOID_NOT_AVAILABLE in this platform.\n"); + } + else + win_skip("This platform allows returning GEOID_NOT_AVAILABLE on success.\n"); + + id = GetUserGeoID(GEOCLASS_ALL); + ok(id == GEOID_NOT_AVAILABLE, + "GEOCLASS_ALL: expected GEOID_NOT_AVAILABLE, got %d.\n", id); + + id = GetUserGeoID(0xdeadbeef); + ok(id == GEOID_NOT_AVAILABLE, + "Gibberish argument: expected GEOID_NOT_AVAILABLE, got %d.\n", id); +} + +static void test_GetUserDefaultGeoName(void) +{ + WCHAR name[10] = {0}; + int result, count; + + if (!pGetUserDefaultGeoName) + { + win_skip("GetUserDefaultGeoName: not implemented on this platform.\n"); + return; + } + + SetLastError(ERROR_SUCCESS); + count = result = pGetUserDefaultGeoName(NULL, 0); + ok(result > 0, + "(NULL, 0): Expected ret > 0, got %d; last error was %d.\n", + result, GetLastError()); + + SetLastError(ERROR_SUCCESS); + result = pGetUserDefaultGeoName(name, 0); + ok(result == count, + "(buffer, 0): Expected ret to match previous result (%d), got %d; last error was %d.\n", + result, count, GetLastError()); + + SetLastError(ERROR_SUCCESS); + result = pGetUserDefaultGeoName(NULL, 10); + ok(result == 0 && (GetLastError() == ERROR_INVALID_PARAMETER), + "(NULL, 10): Expected ret=0, got %d; and expected last error = 87, got %d\n", + result, GetLastError()); + + SetLastError(ERROR_SUCCESS); + result = pGetUserDefaultGeoName(NULL, -1); + ok(result == 0 && (GetLastError() == ERROR_INVALID_PARAMETER), + "(NULL, -1): Expected ret=0, got %d; and expected last error = 87, got %d.\n", + result, GetLastError()); + + SetLastError(ERROR_SUCCESS); + result = pGetUserDefaultGeoName(name, 1); + ok(result == 0 && (GetLastError() == ERROR_INSUFFICIENT_BUFFER), + "(buffer, 1): Expected ret == 0, got %d; and expected last error = 122, got %d.\n", + result, GetLastError()); + + SetLastError(ERROR_SUCCESS); + result = pGetUserDefaultGeoName(name, -1); + ok(result == 0 && (GetLastError() == ERROR_INVALID_PARAMETER), + "(buffer, -1): Expected ret=0, got %d; and expected last error = 87, got %d.\n", + result, GetLastError()); + + if (count <= ARRAY_SIZE(name)) + { + SetLastError(ERROR_SUCCESS); + result = pGetUserDefaultGeoName(name, count); + ok(result, + "(buffer, reported length): Expected non-zero ret, got otherwise with error = %d.\n", + GetLastError()); + ok(result == count, + "(buffer, reported length): Expected charcount == %d, got %d; last error was %d.\n", + count, result, GetLastError()); + ok(result == strlenW(name) + 1, + "(buffer, reported length): Expected string length to match ret (%d), got %d.\n", + result, strlenW(name) + 1); + + if (count < ARRAY_SIZE(name)) + { + SetLastError(ERROR_SUCCESS); + result = pGetUserDefaultGeoName(name, ARRAY_SIZE(name)); + ok(result, + "(buffer, larger length): Expected non-zero ret, got otherwise with error = %d.\n", + GetLastError()); + ok(result == count, + "(buffer, larger length): Expected charcount == %d, got %d; last error was %d.\n", + count, result, GetLastError()); + ok(result == strlenW(name) + 1, + "(buffer, larger length): Expected string length to match ret (%d), got %d.\n", + result, strlenW(name) + 1); + } + } + else + skip("GetUserDefaultGeoName: string length (%d) too large to test.\n", count); +} + struct invariant_entry { const char *name; int id; @@ -6048,6 +6155,8 @@ START_TEST(locale) test_IsValidLocaleName(); test_CompareStringOrdinal(); test_GetGeoInfo(); + test_GetUserGeoID(); + test_GetUserDefaultGeoName(); test_EnumSystemGeoID(); test_invariant(); test_GetSystemPreferredUILanguages();
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=59518
Your paranoid android.
=== debian10 (32 bit Chinese:China report) ===
kernel32: debugger: Timeout
=== debian10 (32 bit WoW report) ===
kernel32: comm.c:919: Test failed: OutQueue should not be empty