Commit cac04651 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

kernel32/tests: Add more tests for Get[*]PreferredUILanguages APIs.

parent 9870f932
...@@ -5461,12 +5461,24 @@ static void test_GetSystemPreferredUILanguages(void) ...@@ -5461,12 +5461,24 @@ static void test_GetSystemPreferredUILanguages(void)
"Expected last two WCHARs being empty, got 0x%x 0x%x\n", "Expected last two WCHARs being empty, got 0x%x 0x%x\n",
buffer[size -2], buffer[size -1]); buffer[size -2], buffer[size -1]);
size = 0;
SetLastError(0xdeadbeef);
ret = pGetSystemPreferredUILanguages(MUI_LANGUAGE_ID, &count, buffer, &size);
todo_wine
ok(!ret, "Expected GetSystemPreferredUILanguages to fail\n");
todo_wine
ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(),
"Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
ok(size == size_id, "expected %u, got %u\n", size_id, size);
size = 1; size = 1;
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pGetSystemPreferredUILanguages(MUI_LANGUAGE_ID, &count, buffer, &size); ret = pGetSystemPreferredUILanguages(MUI_LANGUAGE_ID, &count, buffer, &size);
ok(!ret, "Expected GetSystemPreferredUILanguages to fail\n"); ok(!ret, "Expected GetSystemPreferredUILanguages to fail\n");
ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(), ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(),
"Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); "Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
todo_wine
ok(size == size_id, "expected %u, got %u\n", size_id, size);
size = size_id -1; size = size_id -1;
memset(buffer, 0x5a, size_buffer * sizeof(WCHAR)); memset(buffer, 0x5a, size_buffer * sizeof(WCHAR));
...@@ -5475,6 +5487,8 @@ static void test_GetSystemPreferredUILanguages(void) ...@@ -5475,6 +5487,8 @@ static void test_GetSystemPreferredUILanguages(void)
ok(!ret, "Expected GetSystemPreferredUILanguages to fail\n"); ok(!ret, "Expected GetSystemPreferredUILanguages to fail\n");
ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(), ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(),
"Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); "Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
todo_wine
ok(size == size_id, "expected %u, got %u\n", size_id, size);
size = size_id -2; size = size_id -2;
memset(buffer, 0x5a, size_buffer * sizeof(WCHAR)); memset(buffer, 0x5a, size_buffer * sizeof(WCHAR));
...@@ -5483,6 +5497,8 @@ static void test_GetSystemPreferredUILanguages(void) ...@@ -5483,6 +5497,8 @@ static void test_GetSystemPreferredUILanguages(void)
ok(!ret, "Expected GetSystemPreferredUILanguages to fail\n"); ok(!ret, "Expected GetSystemPreferredUILanguages to fail\n");
ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(), ok(ERROR_INSUFFICIENT_BUFFER == GetLastError(),
"Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError()); "Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
todo_wine
ok(size == size_id + 2 || size == size_id + 1 /* before win10 1809 */, "expected %u, got %u\n", size_id + 2, size);
HeapFree(GetProcessHeap(), 0, buffer); HeapFree(GetProcessHeap(), 0, buffer);
} }
...@@ -5490,7 +5506,7 @@ static void test_GetSystemPreferredUILanguages(void) ...@@ -5490,7 +5506,7 @@ static void test_GetSystemPreferredUILanguages(void)
static void test_GetThreadPreferredUILanguages(void) static void test_GetThreadPreferredUILanguages(void)
{ {
BOOL ret; BOOL ret;
ULONG count, size; ULONG count, size, size_id;
WCHAR *buf; WCHAR *buf;
if (!pGetThreadPreferredUILanguages) if (!pGetThreadPreferredUILanguages)
...@@ -5510,6 +5526,51 @@ static void test_GetThreadPreferredUILanguages(void) ...@@ -5510,6 +5526,51 @@ static void test_GetThreadPreferredUILanguages(void)
ret = pGetThreadPreferredUILanguages(MUI_LANGUAGE_ID|MUI_UI_FALLBACK, &count, buf, &size); ret = pGetThreadPreferredUILanguages(MUI_LANGUAGE_ID|MUI_UI_FALLBACK, &count, buf, &size);
ok(ret, "got %u\n", GetLastError()); ok(ret, "got %u\n", GetLastError());
ok(count, "expected count > 0\n"); ok(count, "expected count > 0\n");
size_id = count = 0;
ret = pGetThreadPreferredUILanguages(MUI_LANGUAGE_ID, &count, NULL, &size_id);
ok(ret, "got %u\n", GetLastError());
ok(count, "expected count > 0\n");
ok(size_id, "expected size > 0\n");
ok(size_id <= size, "expected size > 0\n");
size = 0;
SetLastError(0xdeadbeef);
ret = pGetThreadPreferredUILanguages(MUI_LANGUAGE_ID, &count, buf, &size);
todo_wine
ok(!ret, "Expected GetThreadPreferredUILanguages to fail\n");
todo_wine
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
ok(size == size_id, "expected %u, got %u\n", size_id, size);
size = 1;
SetLastError(0xdeadbeef);
ret = pGetThreadPreferredUILanguages(MUI_LANGUAGE_ID, &count, buf, &size);
ok(!ret, "Expected GetThreadPreferredUILanguages to fail\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
todo_wine
ok(size == size_id, "expected %u, got %u\n", size_id, size);
size = size_id - 1;
SetLastError(0xdeadbeef);
ret = pGetThreadPreferredUILanguages(MUI_LANGUAGE_ID, &count, buf, &size);
ok(!ret, "Expected GetThreadPreferredUILanguages to fail\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
todo_wine
ok(size == size_id, "expected %u, got %u\n", size_id, size);
size = size_id - 2;
SetLastError(0xdeadbeef);
ret = pGetThreadPreferredUILanguages(0, &count, buf, &size);
ok(!ret, "Expected GetThreadPreferredUILanguages to fail\n");
ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER,
"Expected error ERROR_INSUFFICIENT_BUFFER, got %d\n", GetLastError());
todo_wine
ok(size == size_id || size == size_id - 1 /* before win10 1809 */, "expected %u, got %u\n", size_id, size);
HeapFree(GetProcessHeap(), 0, buf); HeapFree(GetProcessHeap(), 0, buf);
} }
......
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