comctl32: Add a short test for the listview.
[wine/wine64.git] / dlls / comctl32 / tests / listview.c
blobc929ed554c23f008b4e303d806675a8efacc7c75
1 /*
2 * ListView tests
4 * Copyright 2006 Mike McCormack for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdio.h>
22 #include <windows.h>
23 #include <commctrl.h>
25 #include "wine/test.h"
27 START_TEST(listview)
29 HWND hwnd, hwndparent = 0;
30 INITCOMMONCONTROLSEX icc;
31 DWORD r;
32 LVITEM item;
33 HIMAGELIST himl;
34 HBITMAP hbmp;
35 RECT r1, r2;
37 icc.dwICC = 0;
38 icc.dwSize = sizeof icc;
39 InitCommonControlsEx(&icc);
41 himl = ImageList_Create(40, 40, 0, 4, 4);
42 ok(himl != NULL, "failed to create imagelist\n");
44 hbmp = CreateBitmap(40, 40, 1, 1, NULL);
45 ok(hbmp != NULL, "failed to create bitmap\n");
47 r = ImageList_Add(himl, hbmp, 0);
48 ok(r == 0, "should be zero\n");
50 hwnd = CreateWindowEx(0, "SysListView32", "foo", LVS_OWNERDRAWFIXED,
51 10, 10, 100, 200, hwndparent, NULL, NULL, NULL);
52 ok(hwnd != NULL, "failed to create listview window\n");
54 r = SendMessage(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, 0x940);
55 ok(r == 0, "should return zero\n");
57 r = SendMessage(hwnd, LVM_SETIMAGELIST, 0, (LPARAM)himl);
58 ok(r == 0, "should return zero\n");
60 r = SendMessage(hwnd, LVM_SETICONSPACING, 0, MAKELONG(100,50));
61 /* returns dimensions */
63 r = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
64 ok(r == 0, "should be zero items\n");
66 item.mask = LVIF_IMAGE | LVIF_TEXT;
67 item.iItem = 0;
68 item.iSubItem = 1;
69 item.iImage = 0;
70 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
71 ok(r == -1, "should fail\n");
73 item.iSubItem = 0;
74 item.pszText = "hello";
75 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
76 ok(r == 0, "should not fail\n");
78 memset(&r1, 0, sizeof r1);
79 r1.left = LVIR_ICON;
80 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM) &r1);
82 r = SendMessage(hwnd, LVM_DELETEALLITEMS, 0, 0);
83 ok(r == TRUE, "should not fail\n");
85 item.iSubItem = 0;
86 item.pszText = "hello";
87 r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
88 ok(r == 0, "should not fail\n");
90 memset(&r2, 0, sizeof r2);
91 r2.left = LVIR_ICON;
92 r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM) &r2);
94 ok(!memcmp(&r1, &r2, sizeof r1), "rectangle should be the same\n");
96 DestroyWindow(hwnd);