Commit 26d0105c authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

kernel32: Improved GetUserPreferredUILanguages stub.

Implementation and tests are based on GetSystemPreferredUILanguages. Signed-off-by: 's avatarJacek Caban <jacek@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 841d41bd
......@@ -1269,6 +1269,32 @@ BOOL WINAPI GetThreadPreferredUILanguages( DWORD flags, ULONG *count, WCHAR *buf
return get_dummy_preferred_ui_language( flags, count, buf, size );
}
/******************************************************************************
* GetUserPreferredUILanguages (KERNEL32.@)
*/
BOOL WINAPI GetUserPreferredUILanguages( DWORD flags, ULONG *count, WCHAR *buffer, ULONG *size )
{
TRACE( "%u %p %p %p\n", flags, count, buffer, size );
if (flags & ~(MUI_LANGUAGE_NAME | MUI_LANGUAGE_ID))
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if ((flags & MUI_LANGUAGE_NAME) && (flags & MUI_LANGUAGE_ID))
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if (*size && !buffer)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
return get_dummy_preferred_ui_language( flags, count, buffer, size );
}
/***********************************************************************
* GetUserDefaultUILanguage (KERNEL32.@)
*
......@@ -5798,15 +5824,6 @@ INT WINAPI IdnToUnicode(DWORD dwFlags, LPCWSTR lpASCIICharStr, INT cchASCIIChar,
/******************************************************************************
* GetUserPreferredUILanguages (KERNEL32.@)
*/
BOOL WINAPI GetUserPreferredUILanguages(DWORD flags, PULONG numlangs, PZZWSTR langbuffer, PULONG bufferlen)
{
FIXME( "stub: %u %p %p %p\n", flags, numlangs, langbuffer, bufferlen );
return FALSE;
}
/******************************************************************************
* GetFileMUIPath (KERNEL32.@)
*/
......
......@@ -99,6 +99,7 @@ static INT (WINAPI *pGetGeoInfoW)(GEOID, GEOTYPE, LPWSTR, INT, LANGID);
static BOOL (WINAPI *pEnumSystemGeoID)(GEOCLASS, GEOID, GEO_ENUMPROC);
static BOOL (WINAPI *pGetSystemPreferredUILanguages)(DWORD, ULONG*, WCHAR*, ULONG*);
static BOOL (WINAPI *pGetThreadPreferredUILanguages)(DWORD, ULONG*, WCHAR*, ULONG*);
static BOOL (WINAPI *pGetUserPreferredUILanguages)(DWORD, ULONG*, WCHAR*, ULONG*);
static WCHAR (WINAPI *pRtlUpcaseUnicodeChar)(WCHAR);
static INT (WINAPI *pGetNumberFormatEx)(LPCWSTR, DWORD, LPCWSTR, const NUMBERFMTW *, LPWSTR, int);
......@@ -131,6 +132,7 @@ static void InitFunctionPointers(void)
X(EnumSystemGeoID);
X(GetSystemPreferredUILanguages);
X(GetThreadPreferredUILanguages);
X(GetUserPreferredUILanguages);
X(GetNumberFormatEx);
mod = GetModuleHandleA("ntdll");
......@@ -5117,6 +5119,143 @@ static void test_GetThreadPreferredUILanguages(void)
HeapFree(GetProcessHeap(), 0, buf);
}
static void test_GetUserPreferredUILanguages(void)
{
BOOL ret;
ULONG count, size, size_id, size_name, size_buffer;
WCHAR *buffer;
if (!pGetUserPreferredUILanguages)
{
win_skip("GetUserPreferredUILanguages is not available.\n");
return;
}
count = 0xdeadbeef;
size = 0;
SetLastError(0xdeadbeef);
ret = pGetUserPreferredUILanguages(MUI_FULL_LANGUAGE, &count, NULL, &size);
ok(!ret, "Expected GetUserPreferredUILanguages to fail\n");
ok(ERROR_INVALID_PARAMETER == GetLastError(),
"Expected error ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
count = 0xdeadbeef;
size = 0;
SetLastError(0xdeadbeef);
ret = pGetUserPreferredUILanguages(MUI_LANGUAGE_ID | MUI_FULL_LANGUAGE, &count, NULL, &size);
ok(!ret, "Expected GetUserPreferredUILanguages to fail\n");
ok(ERROR_INVALID_PARAMETER == GetLastError(),
"Expected error ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
count = 0xdeadbeef;
size = 0;
SetLastError(0xdeadbeef);
ret = pGetUserPreferredUILanguages(MUI_LANGUAGE_ID | MUI_MACHINE_LANGUAGE_SETTINGS, &count, NULL, &size);
ok(!ret, "Expected GetUserPreferredUILanguages to fail\n");
ok(ERROR_INVALID_PARAMETER == GetLastError(),
"Expected error ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
count = 0xdeadbeef;
size = 1;
SetLastError(0xdeadbeef);
ret = pGetUserPreferredUILanguages(MUI_LANGUAGE_ID, &count, NULL, &size);
ok(!ret, "Expected GetUserPreferredUILanguages to fail\n");
ok(ERROR_INVALID_PARAMETER == GetLastError(),
"Expected error ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
count = 0xdeadbeef;
size_id = 0;
SetLastError(0xdeadbeef);
ret = pGetUserPreferredUILanguages(MUI_LANGUAGE_ID, &count, NULL, &size_id);
ok(ret, "Expected GetUserPreferredUILanguages to succeed\n");
ok(count, "Expected count > 0\n");
ok(size_id % 5 == 1, "Expected size (%d) %% 5 == 1\n", size_id);
count = 0xdeadbeef;
size_name = 0;
SetLastError(0xdeadbeef);
ret = pGetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &count, NULL, &size_name);
ok(ret, "Expected GetUserPreferredUILanguages to succeed\n");
ok(count, "Expected count > 0\n");
ok(size_name % 6 == 1, "Expected size (%d) %% 6 == 1\n", size_name);
size_buffer = max(size_id, size_name);
if(!size_buffer)
{
skip("No valid buffer size\n");
return;
}
buffer = HeapAlloc(GetProcessHeap(), 0, size_buffer * sizeof(WCHAR));
count = 0xdeadbeef;
size = size_buffer;
memset(buffer, 0x5a, size_buffer * sizeof(WCHAR));
SetLastError(0xdeadbeef);
ret = pGetUserPreferredUILanguages(0, &count, buffer, &size);
ok(ret, "Expected GetUserPreferredUILanguages to succeed\n");
ok(count, "Expected count > 0\n");
ok(size % 6 == 1, "Expected size (%d) %% 6 == 1\n", size);
if (ret && size % 6 == 1)
ok(!buffer[size -2] && !buffer[size -1],
"Expected last two WCHARs being empty, got 0x%x 0x%x\n",
buffer[size -2], buffer[size -1]);
count = 0xdeadbeef;
size = size_buffer;
memset(buffer, 0x5a, size_buffer * sizeof(WCHAR));
SetLastError(0xdeadbeef);
ret = pGetUserPreferredUILanguages(MUI_LANGUAGE_ID, &count, buffer, &size);
ok(ret, "Expected GetUserPreferredUILanguages to succeed\n");
ok(count, "Expected count > 0\n");
ok(size % 5 == 1, "Expected size (%d) %% 5 == 1\n", size);
if (ret && size % 5 == 1)
ok(!buffer[size -2] && !buffer[size -1],
"Expected last two WCHARs being empty, got 0x%x 0x%x\n",
buffer[size -2], buffer[size -1]);
count = 0xdeadbeef;
size = size_buffer;
SetLastError(0xdeadbeef);
ret = pGetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &count, buffer, &size);
ok(ret, "Expected GetUserPreferredUILanguages to succeed\n");
ok(count, "Expected count > 0\n");
ok(size % 6 == 1, "Expected size (%d) %% 6 == 1\n", size);
if (ret && size % 5 == 1)
ok(!buffer[size -2] && !buffer[size -1],
"Expected last two WCHARs being empty, got 0x%x 0x%x\n",
buffer[size -2], buffer[size -1]);
count = 0xdeadbeef;
size = 1;
SetLastError(0xdeadbeef);
ret = pGetUserPreferredUILanguages(MUI_LANGUAGE_ID, &count, buffer, &size);
ok(!ret, "Expected GetUserPreferredUILanguages to fail\n");
ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(),
"Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
count = 0xdeadbeef;
size = size_id -1;
memset(buffer, 0x5a, size_buffer * sizeof(WCHAR));
SetLastError(0xdeadbeef);
ret = pGetUserPreferredUILanguages(MUI_LANGUAGE_ID, &count, buffer, &size);
ok(!ret, "Expected GetUserPreferredUILanguages to fail\n");
ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(),
"Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
count = 0xdeadbeef;
size = size_id -2;
memset(buffer, 0x5a, size_buffer * sizeof(WCHAR));
SetLastError(0xdeadbeef);
ret = pGetUserPreferredUILanguages(0, &count, buffer, &size);
ok(!ret, "Expected GetUserPreferredUILanguages to fail\n");
ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(),
"Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
HeapFree(GetProcessHeap(), 0, buffer);
}
START_TEST(locale)
{
InitFunctionPointers();
......@@ -5162,6 +5301,7 @@ START_TEST(locale)
test_invariant();
test_GetSystemPreferredUILanguages();
test_GetThreadPreferredUILanguages();
test_GetUserPreferredUILanguages();
/* this requires collation table patch to make it MS compatible */
if (0) test_sorting();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment