Commit af30ffaa authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/tests: Fix couple of metrics tests that fail on some systems.

parent e1b160b0
...@@ -3915,7 +3915,6 @@ static void test_getitemrect(void) ...@@ -3915,7 +3915,6 @@ static void test_getitemrect(void)
LVCOLUMNA col; LVCOLUMNA col;
INT order[2]; INT order[2];
POINT pt; POINT pt;
HDC hdc;
/* rectangle isn't empty for empty text items */ /* rectangle isn't empty for empty text items */
hwnd = create_listview_control(LVS_LIST); hwnd = create_listview_control(LVS_LIST);
...@@ -3929,9 +3928,9 @@ static void test_getitemrect(void) ...@@ -3929,9 +3928,9 @@ static void test_getitemrect(void)
expect(TRUE, r); expect(TRUE, r);
expect(0, rect.left); expect(0, rect.left);
expect(0, rect.top); expect(0, rect.top);
hdc = GetDC(hwnd); /* estimate it as width / height ratio */
todo_wine expect(((GetDeviceCaps(hdc, LOGPIXELSX) + 15) / 16) * 16, rect.right); todo_wine
ReleaseDC(hwnd, hdc); ok((rect.right / rect.bottom) >= 5, "got right %d, bottom %d\n", rect.right, rect.bottom);
DestroyWindow(hwnd); DestroyWindow(hwnd);
hwnd = create_listview_control(LVS_REPORT); hwnd = create_listview_control(LVS_REPORT);
...@@ -4833,6 +4832,36 @@ static void test_getitemspacing(void) ...@@ -4833,6 +4832,36 @@ static void test_getitemspacing(void)
DestroyWindow(hwnd); DestroyWindow(hwnd);
} }
static INT get_current_font_height(HWND listview)
{
TEXTMETRICA tm;
HFONT hfont;
HWND hwnd;
HDC hdc;
hwnd = (HWND)SendMessageA(listview, LVM_GETHEADER, 0, 0);
if (!hwnd)
hwnd = listview;
hfont = (HFONT)SendMessageA(hwnd, WM_GETFONT, 0, 0);
if (!hfont) {
hdc = GetDC(hwnd);
GetTextMetricsA(hdc, &tm);
ReleaseDC(hwnd, hdc);
}
else {
HFONT oldfont;
hdc = GetDC(0);
oldfont = SelectObject(hdc, hfont);
GetTextMetricsA(hdc, &tm);
SelectObject(hdc, oldfont);
ReleaseDC(0, hdc);
}
return tm.tmHeight;
}
static void test_getcolumnwidth(void) static void test_getcolumnwidth(void)
{ {
HWND hwnd; HWND hwnd;
...@@ -4840,7 +4869,7 @@ static void test_getcolumnwidth(void) ...@@ -4840,7 +4869,7 @@ static void test_getcolumnwidth(void)
DWORD_PTR style; DWORD_PTR style;
LVCOLUMNA col; LVCOLUMNA col;
LVITEMA itema; LVITEMA itema;
HDC hdc; INT height;
/* default column width */ /* default column width */
hwnd = create_listview_control(LVS_ICON); hwnd = create_listview_control(LVS_ICON);
...@@ -4864,9 +4893,8 @@ static void test_getcolumnwidth(void) ...@@ -4864,9 +4893,8 @@ static void test_getcolumnwidth(void)
memset(&itema, 0, sizeof(itema)); memset(&itema, 0, sizeof(itema));
SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&itema); SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&itema);
ret = SendMessageA(hwnd, LVM_GETCOLUMNWIDTH, 0, 0); ret = SendMessageA(hwnd, LVM_GETCOLUMNWIDTH, 0, 0);
hdc = GetDC(hwnd); height = get_current_font_height(hwnd);
todo_wine expect(((GetDeviceCaps(hdc, LOGPIXELSX) + 15) / 16) * 16, ret); ok((ret / height) >= 6, "got width %d, height %d\n", ret, height);
ReleaseDC(hwnd, hdc);
DestroyWindow(hwnd); DestroyWindow(hwnd);
} }
......
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