[1/5] comctl32/tests: more tests for icon spacing calculation
Daniel Jelinski
djelinski1 at gmail.com
Sat Jan 19 17:15:59 CST 2013
-------------- next part --------------
From 5fbaf05867315c77adf0bfff25e555d14c833a52 Mon Sep 17 00:00:00 2001
From: Daniel Jelinski <djelinski1 at gmail.com>
Date: Sun, 13 Jan 2013 13:25:17 +0100
Subject: comctl32/tests: more tests for icon spacing calculation
Based on a patch by Nikolay Sivov from bug 17380.
Tested okay on Windows (testbot), both 32 and 64bit listview.
---
dlls/comctl32/tests/listview.c | 103 +++++++++++++++++++++++++++++++++------
1 files changed, 87 insertions(+), 16 deletions(-)
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index 2fb7cb5..45e403a 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -4597,10 +4597,11 @@ static void test_getitemspacing(void)
{
HWND hwnd;
DWORD ret;
+#ifdef _WIN64
+ LPARAM ret2;
+#endif
INT cx, cy;
- HIMAGELIST himl;
- HBITMAP hbmp;
- LVITEMA itema;
+ HIMAGELIST himl40, himl80;
cx = GetSystemMetrics(SM_CXICONSPACING) - GetSystemMetrics(SM_CXICON);
cy = GetSystemMetrics(SM_CYICONSPACING) - GetSystemMetrics(SM_CYICON);
@@ -4613,27 +4614,85 @@ todo_wine {
expect(cy, HIWORD(ret));
}
/* now try with icons */
- himl = ImageList_Create(40, 40, 0, 4, 4);
- ok(himl != NULL, "failed to create imagelist\n");
- hbmp = CreateBitmap(40, 40, 1, 1, NULL);
- ok(hbmp != NULL, "failed to create bitmap\n");
- ret = ImageList_Add(himl, hbmp, 0);
- expect(0, ret);
- ret = SendMessage(hwnd, LVM_SETIMAGELIST, 0, (LPARAM)himl);
+ himl40 = ImageList_Create(40, 40, 0, 4, 4);
+ ok(himl40 != NULL, "failed to create imagelist\n");
+ himl80 = ImageList_Create(80, 80, 0, 4, 4);
+ ok(himl80 != NULL, "failed to create imagelist\n");
+ ret = SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_NORMAL, (LPARAM)himl40);
expect(0, ret);
- itema.mask = LVIF_IMAGE;
- itema.iImage = 0;
- itema.iItem = 0;
- itema.iSubItem = 0;
- ret = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM)&itema);
- expect(0, ret);
ret = SendMessage(hwnd, LVM_GETITEMSPACING, FALSE, 0);
todo_wine {
/* spacing + icon size returned */
expect(cx + 40, LOWORD(ret));
expect(cy + 40, HIWORD(ret));
+ /* try changing icon size */
+ SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_NORMAL, (LPARAM)himl80);
+
+ ret = SendMessage(hwnd, LVM_GETITEMSPACING, FALSE, 0);
+ /* spacing + icon size returned */
+ expect(cx + 80, LOWORD(ret));
+ expect(cy + 80, HIWORD(ret));
+
+ /* set own icon spacing */
+ ret = SendMessage(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(100, 100));
+ expect(cx + 80, LOWORD(ret));
+ expect(cy + 80, HIWORD(ret));
}
+ ret = SendMessage(hwnd, LVM_GETITEMSPACING, FALSE, 0);
+ /* set size returned */
+ expect(100, LOWORD(ret));
+ expect(100, HIWORD(ret));
+
+ /* now change image list - icon spacing should be unaffected */
+ SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_NORMAL, (LPARAM)himl40);
+
+ ret = SendMessage(hwnd, LVM_GETITEMSPACING, FALSE, 0);
+ /* set size returned */
+todo_wine {
+ expect(100, LOWORD(ret));
+ expect(100, HIWORD(ret));
+
+ /* spacing = 0 - keep previous value */
+ ret = SendMessage(hwnd, LVM_SETICONSPACING, 0, MAKELPARAM(0, -1));
+ expect(100, LOWORD(ret));
+ expect(100, HIWORD(ret));
+
+ ret = SendMessage(hwnd, LVM_GETITEMSPACING, FALSE, 0);
+ expect(100, LOWORD(ret));
+ expect(0xFFFF, HIWORD(ret));
+}
+#ifdef _WIN64
+ /* NOTE: -1 is not treated the same as (DWORD)-1 by 64bit listview */
+ ret = SendMessage(hwnd, LVM_SETICONSPACING, 0, (DWORD)-1);
+todo_wine {
+ expect(100, LOWORD(ret));
+ expect(0xFFFF, HIWORD(ret));
+}
+ ret = SendMessage(hwnd, LVM_SETICONSPACING, 0, 0xBAADF00DDEADBEEFLL);
+todo_wine {
+ expect(0xFFFF, LOWORD(ret));
+ expect(0xFFFF, HIWORD(ret));
+}
+ ret2 = SendMessage(hwnd, LVM_GETITEMSPACING, FALSE, 0);
+ ok((LONG)0xDEADBEEF == ret2, "Expected FFFFFFFFDEADBEEF, got %p\n", (void*)ret2);
+ ret2 = SendMessage(hwnd, LVM_SETICONSPACING, 0, -1);
+ ok(0xDEADBEEF == ret2, "Expected 00000000DEADBEEF, got %p\n", (void*)ret2);
+#else
+ ret = SendMessage(hwnd, LVM_SETICONSPACING, 0, -1);
+todo_wine {
+ expect(100, LOWORD(ret));
+ expect(0xFFFF, HIWORD(ret));
+}
+#endif
+ ret = SendMessage(hwnd, LVM_GETITEMSPACING, FALSE, 0);
+ /* spacing + icon size returned */
+todo_wine {
+ expect(cx + 40, LOWORD(ret));
+ expect(cy + 40, HIWORD(ret));
+}
+ SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_NORMAL, 0);
+ ImageList_Destroy(himl80);
DestroyWindow(hwnd);
/* LVS_SMALLICON */
hwnd = create_listview_control(LVS_SMALLICON);
@@ -4642,6 +4701,18 @@ todo_wine {
expect(cx, LOWORD(ret));
expect(cy, HIWORD(ret));
}
+ /* spacing does not depend on selected view type */
+ ret = SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_NORMAL, (LPARAM)himl40);
+ expect(0, ret);
+
+ ret = SendMessage(hwnd, LVM_GETITEMSPACING, FALSE, 0);
+ /* spacing + icon size returned */
+todo_wine {
+ expect(cx + 40, LOWORD(ret));
+ expect(cy + 40, HIWORD(ret));
+}
+ SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_NORMAL, 0);
+ ImageList_Destroy(himl40);
DestroyWindow(hwnd);
/* LVS_REPORT */
hwnd = create_listview_control(LVS_REPORT);
--
1.7.5.4
More information about the wine-patches
mailing list