On 13.11.2017 8:13, Alex Henrie wrote:
Fixes test failures on Arabic and Hebrew Windows. For some reason, on these locales Windows uses a different formula for allocating the template buffer, allocating a little more than 2 times the resource size on Hebrew and a little less on Arabic. Because we don't know how exactly the buffer size is determined on these locales, just accept a size near 2 times the resource size.
Signed-off-by: Alex Henrie alexhenrie24@gmail.com
dlls/comctl32/tests/propsheet.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/dlls/comctl32/tests/propsheet.c b/dlls/comctl32/tests/propsheet.c index a3f910d2d5..68dce519bb 100644 --- a/dlls/comctl32/tests/propsheet.c +++ b/dlls/comctl32/tests/propsheet.c @@ -58,16 +58,21 @@ static int CALLBACK sheet_callback(HWND hwnd, UINT msg, LPARAM lparam) case PSCB_PRECREATE: { HMODULE module = GetModuleHandleA("comctl32.dll");
HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
LANGID (WINAPI *pGetThreadUILanguage)(void) = (void *)GetProcAddress(kernel32, "GetThreadUILanguage"); DWORD size, buffer_size; HRSRC hrsrc;
int reading_layout; hrsrc = FindResourceA(module, MAKEINTRESOURCEA(1006 /* IDD_PROPSHEET */), (LPSTR)RT_DIALOG); size = SizeofResource(module, hrsrc); ok(size != 0, "Failed to get size of propsheet dialog resource\n"); buffer_size = HeapSize(GetProcessHeap(), 0, (void *)lparam);
ok(buffer_size == 2 * size, "Unexpected template buffer size %u, resource size %u\n",
buffer_size, size);
GetLocaleInfoA(pGetThreadUILanguage ? pGetThreadUILanguage() : GetUserDefaultUILanguage(),
LOCALE_IREADINGLAYOUT | LOCALE_RETURN_NUMBER, (void *)&reading_layout, sizeof(reading_layout));
ok(reading_layout == 2 /* RTL */ ? abs(buffer_size - 2 * size) <= 32 : buffer_size == 2 * size,
case PSCB_INITIALIZED:"Unexpected template buffer size %u, resource size %u\n", buffer_size, size); break; }
Is it possible we're picking wrong resource with FindResource() here? Maybe we should be using explicit language instead of a neutral one, so
--- propsheet.c:69: Test failed: Unexpected template buffer size 508, resource size 270 ---
could mean we were supposed to pick up a different resource of size 254.
P.S. GetLocaleInfo() takes LCID not LANGID, and you can use special constants like LOCALE_USER_DEFAULT too.