comctl32/tests: Add a test for combo resizing from smaller item height.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
John Alway 2019-11-28 09:06:37 +03:00 committed by Alexandre Julliard
parent 8dfd51b487
commit ec8c949901
1 changed files with 27 additions and 10 deletions

View File

@ -614,7 +614,7 @@ static HWND create_combobox(DWORD style)
return CreateWindowA(WC_COMBOBOXA, "Combo", WS_VISIBLE|WS_CHILD|style, 5, 5, 100, 100, hMainWnd, (HMENU)COMBO_ID, NULL, 0);
}
static int font_height(HFONT hFont)
static int get_font_height(HFONT hFont)
{
TEXTMETRICA tm;
HFONT hFontOld;
@ -632,11 +632,12 @@ static int font_height(HFONT hFont)
static void test_combo_setitemheight(DWORD style)
{
HWND hCombo = create_combobox(style);
int i, font_height, height;
HFONT hFont;
RECT r;
int i;
GetClientRect(hCombo, &r);
expect_rect(r, 0, 0, 100, font_height(GetStockObject(SYSTEM_FONT)) + 8);
expect_rect(r, 0, 0, 100, get_font_height(GetStockObject(SYSTEM_FONT)) + 8);
SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r);
MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2);
todo_wine expect_rect(r, 5, 5, 105, 105);
@ -649,6 +650,22 @@ static void test_combo_setitemheight(DWORD style)
}
DestroyWindow(hCombo);
/* Set item height below text height, force resize. */
hCombo = create_combobox(style);
hFont = (HFONT)SendMessageA(hCombo, WM_GETFONT, 0, 0);
font_height = get_font_height(hFont);
SendMessageA(hCombo, CB_SETITEMHEIGHT, -1, font_height / 2);
height = SendMessageA(hCombo, CB_GETITEMHEIGHT, -1, 0);
todo_wine
ok(height == font_height / 2, "Unexpected item height %d, expected %d.\n", height, font_height / 2);
SetWindowPos(hCombo, NULL, 10, 10, 150, 5 * font_height, SWP_SHOWWINDOW);
height = SendMessageA(hCombo, CB_GETITEMHEIGHT, -1, 0);
ok(height > font_height, "Unexpected item height %d, font height %d.\n", height, font_height);
DestroyWindow(hCombo);
}
static void test_combo_setfont(DWORD style)
@ -663,7 +680,7 @@ static void test_combo_setfont(DWORD style)
hFont2 = CreateFontA(8, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, SYMBOL_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Marlett");
GetClientRect(hCombo, &r);
expect_rect(r, 0, 0, 100, font_height(GetStockObject(SYSTEM_FONT)) + 8);
expect_rect(r, 0, 0, 100, get_font_height(GetStockObject(SYSTEM_FONT)) + 8);
SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r);
MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2);
todo_wine expect_rect(r, 5, 5, 105, 105);
@ -672,39 +689,39 @@ static void test_combo_setfont(DWORD style)
of the window when it was created. The size of the calculated
dropped area changes only by how much the selection area
changes, not by how much the list area changes. */
if (font_height(hFont1) == 10 && font_height(hFont2) == 8)
if (get_font_height(hFont1) == 10 && get_font_height(hFont2) == 8)
{
SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont1, FALSE);
GetClientRect(hCombo, &r);
expect_rect(r, 0, 0, 100, 18);
SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r);
MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2);
todo_wine expect_rect(r, 5, 5, 105, 105 - (font_height(GetStockObject(SYSTEM_FONT)) - font_height(hFont1)));
todo_wine expect_rect(r, 5, 5, 105, 105 - (get_font_height(GetStockObject(SYSTEM_FONT)) - get_font_height(hFont1)));
SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont2, FALSE);
GetClientRect(hCombo, &r);
expect_rect(r, 0, 0, 100, 16);
SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r);
MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2);
todo_wine expect_rect(r, 5, 5, 105, 105 - (font_height(GetStockObject(SYSTEM_FONT)) - font_height(hFont2)));
todo_wine expect_rect(r, 5, 5, 105, 105 - (get_font_height(GetStockObject(SYSTEM_FONT)) - get_font_height(hFont2)));
SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont1, FALSE);
GetClientRect(hCombo, &r);
expect_rect(r, 0, 0, 100, 18);
SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r);
MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2);
todo_wine expect_rect(r, 5, 5, 105, 105 - (font_height(GetStockObject(SYSTEM_FONT)) - font_height(hFont1)));
todo_wine expect_rect(r, 5, 5, 105, 105 - (get_font_height(GetStockObject(SYSTEM_FONT)) - get_font_height(hFont1)));
}
else
{
ok(0, "Expected Marlett font heights 10/8, got %d/%d\n",
font_height(hFont1), font_height(hFont2));
get_font_height(hFont1), get_font_height(hFont2));
}
for (i = 1; i < 30; i++)
{
HFONT hFont = CreateFontA(i, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, SYMBOL_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Marlett");
int height = font_height(hFont);
int height = get_font_height(hFont);
SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont, FALSE);
GetClientRect(hCombo, &r);