Included tests for: * GetGeoInfoEx; * EnumSystemGeoNames; * GetUserGeoNames; * GetUserGeoID.
Changed test_GetGeoInfo to check new GEOTYPEs.
Didn't include SetUserGeoID() and SetUserGeoName() since normal programs aren't supposed to call those functions.
Signed-off-by: João Diogo Craveiro Ferreira devilj@outlook.pt --- dlls/kernel32/tests/locale.c | 280 +++++++++++++++++++++++++++++++++++ 1 file changed, 280 insertions(+)
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c index 81e74531ea..051045a414 100644 --- a/dlls/kernel32/tests/locale.c +++ b/dlls/kernel32/tests/locale.c @@ -97,7 +97,9 @@ static INT (WINAPI *pCompareStringEx)(LPCWSTR, DWORD, LPCWSTR, INT, LPCWSTR, INT LPNLSVERSIONINFO, LPVOID, LPARAM); static INT (WINAPI *pGetGeoInfoA)(GEOID, GEOTYPE, LPSTR, INT, LANGID); static INT (WINAPI *pGetGeoInfoW)(GEOID, GEOTYPE, LPWSTR, INT, LANGID); +static int (WINAPI *pGetGeoInfoEx)(PWSTR, GEOTYPE, PWSTR, int); static BOOL (WINAPI *pEnumSystemGeoID)(GEOCLASS, GEOID, GEO_ENUMPROC); +static BOOL (WINAPI *pEnumSystemGeoNames)(GEOCLASS, GEO_ENUMNAMEPROC, LPARAM); static BOOL (WINAPI *pGetSystemPreferredUILanguages)(DWORD, ULONG*, WCHAR*, ULONG*); static BOOL (WINAPI *pGetThreadPreferredUILanguages)(DWORD, ULONG*, WCHAR*, ULONG*); static BOOL (WINAPI *pGetUserPreferredUILanguages)(DWORD, ULONG*, WCHAR*, ULONG*); @@ -108,6 +110,8 @@ static LANGID (WINAPI *pSetThreadUILanguage)(LANGID); static LANGID (WINAPI *pGetThreadUILanguage)(VOID); static INT (WINAPI *pNormalizeString)(NORM_FORM, LPCWSTR, INT, LPWSTR, INT); static INT (WINAPI *pFindStringOrdinal)(DWORD, LPCWSTR lpStringSource, INT, LPCWSTR, INT, BOOL); +static int (WINAPI *pGetUserDefaultGeoName)(LPWSTR, int); +static BOOL (WINAPI *pSetUserGeoName)(PWSTR);
static void InitFunctionPointers(void) { @@ -135,7 +139,9 @@ static void InitFunctionPointers(void) X(CompareStringEx); X(GetGeoInfoA); X(GetGeoInfoW); + X(GetGeoInfoEx); X(EnumSystemGeoID); + X(EnumSystemGeoNames); X(GetSystemPreferredUILanguages); X(GetThreadPreferredUILanguages); X(GetUserPreferredUILanguages); @@ -145,6 +151,8 @@ static void InitFunctionPointers(void) X(GetThreadUILanguage); X(NormalizeString); X(FindStringOrdinal); + X(GetUserDefaultGeoName); + X(SetUserGeoName);
mod = GetModuleHandleA("ntdll"); X(RtlUpcaseUnicodeChar); @@ -4745,6 +4753,106 @@ static void test_CompareStringOrdinal(void) } }
+static void test_GetUserGeoID(void) +{ + GEOID id; + + if (pGetUserDefaultGeoName) + { + ok(GEOID_NOT_AVAILABLE != GetUserGeoID(GEOCLASS_NATION), + "GEOCLASS_NATION: should return GEOID_NOT_AVAILABLE when GeoName API is available.\n"); + ok(GEOID_NOT_AVAILABLE != GetUserGeoID(GEOCLASS_REGION), + "GEOCLASS_REGION: should never return GEOID_NOT_AVAILABLE when GeoName API is available.\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(12345); + 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: procedure 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 = ERROR_INVALID_PARAMETER (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 = ERROR_INVALID_PARAMETER (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 = ERROR_INSUFFICIENT_BUFFER (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 = ERROR_INVALID_PARAMETER (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 character count == %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 character count == %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: Couldn't test successful operation: GeoName string too large (%d > %lu).\n", + count, ARRAY_SIZE(name)); +} + static void test_GetGeoInfo(void) { char buffA[20]; @@ -4798,6 +4906,17 @@ static void test_GetGeoInfo(void) ok(ret == 4, "got %d\n", ret); ok(!strcmp(buffA, "203"), "got %s\n", buffA);
+ /* GEO_ID should behave like GEO_NATION */ + buffA[0] = 0; + ret = pGetGeoInfoA(203, GEO_ID, buffA, 20, 0); + if (ret) + { + ok(ret == 4, "got %d\n", ret); + ok(!strcmp(buffA, "203"), "got %s\n", buffA); + } + else + win_skip("GEO_ID not supported.\n"); + /* GEO_PARENT */ buffA[0] = 0; ret = pGetGeoInfoA(203, GEO_PARENT, buffA, 20, 0); @@ -4819,11 +4938,54 @@ static void test_GetGeoInfo(void) ok(!strcmp(buffA, "643"), "got %s\n", buffA); }
+ buffA[0] = 0; + ret = pGetGeoInfoA(193, GEO_NAME, buffA, 20, 0); /* LOCATION_NATION */ + if (ret == 0) + win_skip("GEO_NAME not supported.\n"); + else + { + ok(ret == 3, "expected ret == 3, got %d", ret); + ok(!strcmp(buffA, "PT"), "expected "PT", got %s\n", buffA); + + buffA[0] = 0; + ret = pGetGeoInfoA(39070, GEO_NAME, buffA, 20, 0); /* LOCATION_REGION */ + ok(ret == 4, "expected ret == 4, got %d", ret); + ok(!strcmp(buffA, "001"), "expected "001", got %s\n", buffA); + + buffA[0] = 0; + ret = pGetGeoInfoA(333, GEO_NAME, buffA, 20, 0); /* LOCATION_BOTH */ + ok(ret == 3, "expected ret == 3, got %d", ret); + ok(!strcmp(buffA, "AN"), "expected "AN", got %s\n", buffA); + } + /* try invalid type value */ SetLastError(0xdeadbeef); ret = pGetGeoInfoA(203, GEO_ID + 1, NULL, 0, 0); ok(ret == 0, "got %d\n", ret); ok(GetLastError() == ERROR_INVALID_FLAGS, "got %d\n", GetLastError()); + + if (pGetGeoInfoEx) + { + WCHAR buffer[10], pt[] = {'P','T',0}; + + /* Test types disallowed by GetGeoInfoEx */ + SetLastError(0xdeadbeef); + ret = pGetGeoInfoEx(pt, GEO_LCID, buffer, ARRAY_SIZE(buffer)); + ok(ret == 0, "expected ret == 0, got %d\n", ret); + ok(GetLastError() == ERROR_INVALID_FLAGS, "expected error 1004, got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pGetGeoInfoEx(pt, GEO_NATION, buffer, ARRAY_SIZE(buffer)); + ok(ret == 0, "expected ret == 0, got %d\n", ret); + ok(GetLastError() == ERROR_INVALID_FLAGS, "expected error 1004, got %d\n", GetLastError()); + + SetLastError(0xdeadbeef); + ret = pGetGeoInfoEx(pt, GEO_RFC1766, buffer, ARRAY_SIZE(buffer)); + ok(ret == 0, "expected ret == 0, got %d\n", ret); + ok(GetLastError() == ERROR_INVALID_FLAGS, "expected error 1004, got %d\n", GetLastError()); + } + else + win_skip("GetGeoInfoEx not supported.\n"); }
static int geoidenum_count; @@ -4891,6 +5053,121 @@ static void test_EnumSystemGeoID(void) ret = pEnumSystemGeoID(GEOCLASS_REGION, 0, test_geoid_enumproc2); ok(ret && geoidenum_count > 0, "got %d, count %d\n", ret, geoidenum_count); } + + geoidenum_count = 0; + ret = pEnumSystemGeoID(GEOCLASS_ALL, 39070, test_geoid_enumproc2); + if (ret == 0) + win_skip("GEOCLASS_ALL is not supported in EnumSystemGeoID.\n"); + else + { + ok(ret && geoidenum_count > 0, "got %d, count %d\n", ret, geoidenum_count); + + geoidenum_count = 0; + ret = pEnumSystemGeoID(GEOCLASS_ALL, 0, test_geoid_enumproc2); + ok(ret && geoidenum_count > 0, "got %d, count %d\n", ret, geoidenum_count); + } +} + +static BOOL CALLBACK test_geoname_enumproc_deadbeef(PWSTR name, LPARAM data) +{ + (void)name; + ok(data == 0xdeadbeef, "deadbeef: expected 0xdeadbeef, got 0x%lx", data); + return FALSE; +} + +struct test_enum_geoname_count_types { + unsigned int total, nation, region, both; +}; + +static BOOL CALLBACK test_geoname_enumproc_counts(PWSTR name, LPARAM data) +{ + struct test_enum_geoname_count_types *ptr = (void*)data; + + /* Known names */ + static const WCHAR nation[] = {'A','U',0}, + region[] = {'0','0','1',0}, + both[] = {'A','N',0}; + + if (!ptr) + { + ok((INT_PTR)ptr, "geoname_enumproc_counts: expected some pointer, got %p\n", ptr); + return FALSE; + } + + ptr->total++; + + if (!winetest_strcmpW(name, nation)) + ptr->nation++; + if (!winetest_strcmpW(name, region)) + ptr->region++; + if (!winetest_strcmpW(name, both)) + ptr->both++; + + return TRUE; +} + +static BOOL CALLBACK test_geoname_enumproc_dummy(PWSTR name, LPARAM data) +{ + (void)name; + (void)data; + return FALSE; +} + +static void test_EnumSystemGeoNames(void) +{ + struct test_enum_geoname_count_types counts; + BOOL ret; + + if (!pEnumSystemGeoNames) + { + win_skip("unsupported platorm.\n"); + return; + } + + ok(pEnumSystemGeoNames(GEOCLASS_ALL, test_geoname_enumproc_deadbeef, 0xdeadbeef), + "deadbeef: expected non-zero ret, got otherwise with error=%d.\n", GetLastError()); + + ZeroMemory(&counts, sizeof(counts)); + ret = pEnumSystemGeoNames(GEOCLASS_NATION, test_geoname_enumproc_counts, (LPARAM)&counts); + if (ret) + { + ok(counts.total > 0 && counts.nation > 0 && counts.region == 0 && counts.both == 0, + "GEOCLASS_NATION: got total=%u, nation=%u, region=%u, both=%u\n", + counts.total, counts.nation, counts.region, counts.both); + } + else + ok(ret, "GEONAME_NATION: expected non-zero, got otherwise.\n"); + + ZeroMemory(&counts, sizeof(counts)); + ret = pEnumSystemGeoNames(GEOCLASS_REGION, test_geoname_enumproc_counts, (LPARAM)&counts); + if (ret) + { + ok(counts.total > 0 && counts.nation == 0 && counts.region > 0 && counts.both > 0, + "GEOCLASS_REGION: got total=%u, nation=%u, region=%u, both=%u\n", + counts.total, counts.nation, counts.region, counts.both); + } + else + ok(ret, "GEONAME_REGION: expected ret != 0, got otherwise.\n"); + + ZeroMemory(&counts, sizeof(counts)); + ret = pEnumSystemGeoNames(GEOCLASS_ALL, test_geoname_enumproc_counts, (LPARAM)&counts); + if (ret) + { + ok(counts.total > 0 && counts.nation > 0 && counts.region > 0 && counts.both > 0, + "GEOCLASS_ALL: got total=%u, nation=%u, region=%u, both=%u\n", + counts.total, counts.nation, counts.region, counts.both); + } + else + ok(ret, "GEONAME_ALL: expected ret != 0, got otherwise.\n"); + + /* Try invalid values */ + ret = pEnumSystemGeoNames(GEOCLASS_ALL, NULL, 0xdeadbeef); + ok(!ret && GetLastError() == ERROR_INVALID_PARAMETER, + "null enumproc: expected ret=0 and error=87, got ret=%d and error=%d\n", ret, GetLastError()); + + ret = pEnumSystemGeoNames(-1, test_geoname_enumproc_dummy, 0xdeadbeef); + ok(!ret && GetLastError() == ERROR_INVALID_FLAGS, + "invalid geoclass: expected ret=0 and error=1004, got ret=%d and error=%d\n", ret, GetLastError()); }
struct invariant_entry { @@ -6049,6 +6326,7 @@ START_TEST(locale) test_CompareStringOrdinal(); test_GetGeoInfo(); test_EnumSystemGeoID(); + test_EnumSystemGeoNames(); test_invariant(); test_GetSystemPreferredUILanguages(); test_GetThreadPreferredUILanguages(); @@ -6058,6 +6336,8 @@ START_TEST(locale) test_SetThreadUILanguage(); test_NormalizeString(); test_SpecialCasing(); + test_GetUserGeoID(); + test_GetUserDefaultGeoName(); /* this requires collation table patch to make it MS compatible */ if (0) test_sorting(); }
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=58236
Your paranoid android.
=== debian10 (32 bit WoW report) ===
kernel32: comm.c:919: Test failed: OutQueue should not be empty debugger: Timeout