ole32: Remove unnecessary assert(This) calls.
[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     static CHAR hello[] = "hello";
37
38     icc.dwICC = 0;
39     icc.dwSize = sizeof icc;
40     InitCommonControlsEx(&icc);
41
42     himl = ImageList_Create(40, 40, 0, 4, 4);
43     ok(himl != NULL, "failed to create imagelist\n");
44
45     hbmp = CreateBitmap(40, 40, 1, 1, NULL);
46     ok(hbmp != NULL, "failed to create bitmap\n");
47
48     r = ImageList_Add(himl, hbmp, 0);
49     ok(r == 0, "should be zero\n");
50
51     hwnd = CreateWindowEx(0, "SysListView32", "foo", LVS_OWNERDRAWFIXED, 
52                 10, 10, 100, 200, hwndparent, NULL, NULL, NULL);
53     ok(hwnd != NULL, "failed to create listview window\n");
54
55     r = SendMessage(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, 0x940);
56     ok(r == 0, "should return zero\n");
57
58     r = SendMessage(hwnd, LVM_SETIMAGELIST, 0, (LPARAM)himl);
59     ok(r == 0, "should return zero\n");
60
61     r = SendMessage(hwnd, LVM_SETICONSPACING, 0, MAKELONG(100,50));
62     /* returns dimensions */
63
64     r = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, 0);
65     ok(r == 0, "should be zero items\n");
66
67     item.mask = LVIF_IMAGE | LVIF_TEXT;
68     item.iItem = 0;
69     item.iSubItem = 1;
70     item.iImage = 0;
71     r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
72     ok(r == -1, "should fail\n");
73
74     item.iSubItem = 0;
75     item.pszText = hello;
76     r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
77     ok(r == 0, "should not fail\n");
78
79     memset(&r1, 0, sizeof r1);
80     r1.left = LVIR_ICON;
81     r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM) &r1);
82
83     r = SendMessage(hwnd, LVM_DELETEALLITEMS, 0, 0);
84     ok(r == TRUE, "should not fail\n");
85
86     item.iSubItem = 0;
87     item.pszText = hello;
88     r = SendMessage(hwnd, LVM_INSERTITEM, 0, (LPARAM) &item);
89     ok(r == 0, "should not fail\n");
90
91     memset(&r2, 0, sizeof r2);
92     r2.left = LVIR_ICON;
93     r = SendMessage(hwnd, LVM_GETITEMRECT, 0, (LPARAM) &r2);
94
95     ok(!memcmp(&r1, &r2, sizeof r1), "rectangle should be the same\n");
96
97     DestroyWindow(hwnd);
98 }