Fixes from last version: - Removed testing for SetUserGeoID and SetUserGeoName; - Inverted if blocks to avoid long nesting blocks.
Good riddance to those two testing units, as they were a pain to write and still failed on older Windows versions. If someone thinks they're necessary, please contact me.
Signed-off-by: João Diogo Craveiro Ferreira devilj@outlook.pt --- dlls/kernel32/tests/locale.c | 86 ++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+)
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c index 81e74531ea..7527c36bb9 100644 --- a/dlls/kernel32/tests/locale.c +++ b/dlls/kernel32/tests/locale.c @@ -108,6 +108,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) { @@ -145,6 +147,8 @@ static void InitFunctionPointers(void) X(GetThreadUILanguage); X(NormalizeString); X(FindStringOrdinal); + X(GetUserDefaultGeoName); + X(SetUserGeoName);
mod = GetModuleHandleA("ntdll"); X(RtlUpcaseUnicodeChar); @@ -4745,6 +4749,86 @@ static void test_CompareStringOrdinal(void) } }
+static void test_GetUserGeoID(void) +{ + GEOID id; + +todo_wine { + if (pGetUserDefaultGeoName && pSetUserGeoName) + { + ok(GEOID_NOT_AVAILABLE != GetUserGeoID(GEOCLASS_NATION), + "GEOCLASS_NATION: should never 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 GEOID_NOT_AVAILABLE to be returned.\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; + +todo_wine +{ + if (!(pGetUserDefaultGeoName && pSetUserGeoName)) + { + todo_wine win_skip("GetUserDefaultGeoName: procedure not implemented on this platform.\n"); + return; + } + SetLastError(ERROR_SUCCESS); + count = result = pGetUserDefaultGeoName(NULL, 0); + ok(result > 0, "Expected character count > 0, got %d; last error was %d.\n", result, GetLastError()); + + result = pGetUserDefaultGeoName(NULL, 10); + ok(result == 0 && (GetLastError() == ERROR_INVALID_PARAMETER), + "Expected ret=0, got %d; and expected last error = ERROR_INVALID_PARAMETER (87), got %d\n", + result, GetLastError()); + + result = pGetUserDefaultGeoName(NULL, -1); + ok(result == 0 && (GetLastError() == ERROR_INVALID_PARAMETER), + "Expected ret=0, got %d; and expected last error = ERROR_INVALID_PARAMETER (87), got %d\n", + result, GetLastError()); + + SetLastError(ERROR_SUCCESS); + result = pGetUserDefaultGeoName(name, 0); + ok(result > 0, "Expected character count > 0, got %d; last error was %d.\n", result, GetLastError()); + + result = pGetUserDefaultGeoName(name, 1); + ok(result == 0 && (GetLastError() == ERROR_INSUFFICIENT_BUFFER), + "Expected ret == 0, got %d; and expected last error = ERROR_INSUFFICIENT_BUFFER (122), got %d\n", + result, GetLastError()); + + result = pGetUserDefaultGeoName(name, -1); + ok(result == 0 && (GetLastError() == ERROR_INVALID_PARAMETER), + "Expected ret=0, got %d; and expected last error = ERROR_INVALID_PARAMETER (87), got %d\n", + result, GetLastError()); + + SetLastError(ERROR_SUCCESS); + + ok(count <= 4, "Character count should never be higher than 4 (3 + null), got %d!\n", count); + if (count <= ARRAY_SIZE(name)) + { + const int result = pGetUserDefaultGeoName(name, count); + ok(result, + "Expected character count == %d, got %d; last error was %d.\n", + count, result, GetLastError()); + } + else + trace("Couldn't test successful operation since string is exceedingly large (%d > %lu).\n", + count, ARRAY_SIZE(name)); +} +} + static void test_GetGeoInfo(void) { char buffA[20]; @@ -6058,6 +6142,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(); }