wined3d: Implement more GLSL instructions and a little cleanup.
[wine] / dlls / comctl32 / tests / listview.c
1 /*
2  * ListView tests
3  *
4  * Copyright 2006 Mike McCormack for CodeWeavers
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include <stdio.h>
22 #include <windows.h>
23 #include <commctrl.h>
24
25 #include "wine/test.h"
26
27 START_TEST(listview)
28 {
29     HWND hwnd, hwndparent = 0;
30     INITCOMMONCONTROLSEX icc;
31     DWORD r;
32     LVITEM item;
33     HIMAGELIST himl;
34     HBITMAP hbmp;
35     RECT r1, r2;
36
37     icc.dwICC = 0;
38     icc.dwSize = sizeof icc;
39     InitCommonControlsEx(&icc);
40
41     himl = ImageList_Create(40, 40, 0, 4, 4);
42     ok(himl != NULL, "failed to create imagelist\n");
43
44     hbmp = CreateBitmap(40, 40, 1, 1, NULL);
45     ok(hbmp != NULL, "failed to create bitmap\n");
46
47     r = ImageList_Add(himl, hbmp, 0);
48     ok(r == 0, "should be zero\n");
49
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");
53
54     r = SendMessage(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, 0x940);
55     ok(r == 0, "should return zero\n");
56
57     r = SendMessage(hwnd, LVM_SETIMAGELIST, 0, (LPARAM)himl);
58     ok(r == 0, "should return zero\n");
59
60     r = SendMessage(hwnd, LVM_SETICONSPACING, 0, MAKELONG(100,50));
61     /* returns dimensions */
62
63     r = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
64     ok(r == 0, "should be zero items\n");
65
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");
72
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");
77
78     memset(&r1, 0, sizeof r1);
79     r1.left = LVIR_ICON;
80     r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM) &r1);
81
82     r = SendMessage(hwnd, LVM_DELETEALLITEMS, 0, 0);
83     ok(r == TRUE, "should not fail\n");
84
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");
89
90     memset(&r2, 0, sizeof r2);
91     r2.left = LVIR_ICON;
92     r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM) &r2);
93
94     ok(!memcmp(&r1, &r2, sizeof r1), "rectangle should be the same\n");
95
96     DestroyWindow(hwnd);
97 }