janitorial: Remove remaining NULL checks before free() (found by Smatch).
[wine] / dlls / comctl32 / tests / imagelist.c
1 /* Unit test suite for imagelist control.
2  *
3  * Copyright 2004 Michael Stefaniuc
4  * Copyright 2002 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 <assert.h>
22 #include <windows.h>
23 #include <commctrl.h>
24 #include <stdio.h>
25
26 #include "wine/test.h"
27
28 #undef VISIBLE
29
30 #ifdef VISIBLE
31 #define WAIT Sleep (1000)
32 #define REDRAW(hwnd) RedrawWindow (hwnd, NULL, 0, RDW_UPDATENOW)
33 #else
34 #define WAIT
35 #define REDRAW(hwnd)
36 #endif
37
38
39 static BOOL (WINAPI *pImageList_DrawIndirect)(IMAGELISTDRAWPARAMS*) = NULL;
40
41 static HDC desktopDC;
42 static HINSTANCE hinst;
43
44 /* These macros build cursor/bitmap data in 4x4 pixel blocks */
45 #define B(x,y) ((x?0xf0:0)|(y?0xf:0))
46 #define ROW1(a,b,c,d,e,f,g,h) B(a,b),B(c,d),B(e,f),B(g,h)
47 #define ROW32(a,b,c,d,e,f,g,h) ROW1(a,b,c,d,e,f,g,h), ROW1(a,b,c,d,e,f,g,h), \
48   ROW1(a,b,c,d,e,f,g,h), ROW1(a,b,c,d,e,f,g,h)
49 #define ROW2(a,b,c,d,e,f,g,h,i,j,k,l) ROW1(a,b,c,d,e,f,g,h),B(i,j),B(k,l)
50 #define ROW48(a,b,c,d,e,f,g,h,i,j,k,l) ROW2(a,b,c,d,e,f,g,h,i,j,k,l), \
51   ROW2(a,b,c,d,e,f,g,h,i,j,k,l), ROW2(a,b,c,d,e,f,g,h,i,j,k,l), \
52   ROW2(a,b,c,d,e,f,g,h,i,j,k,l)
53
54 static const BYTE empty_bits[48*48/8];
55
56 static const BYTE icon_bits[32*32/8] =
57 {
58   ROW32(0,0,0,0,0,0,0,0),
59   ROW32(0,0,1,1,1,1,0,0),
60   ROW32(0,1,1,1,1,1,1,0),
61   ROW32(0,1,1,0,0,1,1,0),
62   ROW32(0,1,1,0,0,1,1,0),
63   ROW32(0,1,1,1,1,1,1,0),
64   ROW32(0,0,1,1,1,1,0,0),
65   ROW32(0,0,0,0,0,0,0,0)
66 };
67
68 static const BYTE bitmap_bits[48*48/8] =
69 {
70   ROW48(0,0,0,0,0,0,0,0,0,0,0,0),
71   ROW48(0,1,1,1,1,1,1,1,1,1,1,0),
72   ROW48(0,1,1,0,0,0,0,0,0,1,1,0),
73   ROW48(0,1,0,0,0,0,0,0,1,0,1,0),
74   ROW48(0,1,0,0,0,0,0,1,0,0,1,0),
75   ROW48(0,1,0,0,0,0,1,0,0,0,1,0),
76   ROW48(0,1,0,0,0,1,0,0,0,0,1,0),
77   ROW48(0,1,0,0,1,0,0,0,0,0,1,0),
78   ROW48(0,1,0,1,0,0,0,0,0,0,1,0),
79   ROW48(0,1,1,0,0,0,0,0,0,1,1,0),
80   ROW48(0,1,1,1,1,1,1,1,1,1,1,0),
81   ROW48(0,0,0,0,0,0,0,0,0,0,0,0)
82 };
83
84 static HIMAGELIST createImageList(int cx, int cy)
85 {
86     /* Create an ImageList and put an image into it */
87     HIMAGELIST himl = ImageList_Create(cx, cy, ILC_COLOR, 1, 1);
88     HBITMAP hbm = CreateBitmap(48, 48, 1, 1, bitmap_bits);
89     ImageList_Add(himl, hbm, NULL);
90     return himl;
91 }
92
93 static HWND create_a_window(void)
94 {
95     char className[] = "bmwnd";
96     char winName[]   = "Test Bitmap";
97     HWND hWnd;
98     static int registered = 0;
99
100     if (!registered)
101     {
102         WNDCLASSA cls;
103
104         cls.style         = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
105         cls.lpfnWndProc   = DefWindowProcA;
106         cls.cbClsExtra    = 0;
107         cls.cbWndExtra    = 0;
108         cls.hInstance     = 0;
109         cls.hIcon         = LoadIconA (0, (LPSTR)IDI_APPLICATION);
110         cls.hCursor       = LoadCursorA (0, (LPSTR)IDC_ARROW);
111         cls.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
112         cls.lpszMenuName  = 0;
113         cls.lpszClassName = className;
114
115         RegisterClassA (&cls);
116         registered = 1;
117     }
118
119     /* Setup window */
120     hWnd = CreateWindowA (className, winName,
121        WS_OVERLAPPEDWINDOW ,
122        CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
123        0, hinst, 0);
124
125 #ifdef VISIBLE
126     ShowWindow (hWnd, SW_SHOW);
127 #endif
128     REDRAW(hWnd);
129     WAIT;
130
131     return hWnd;
132 }
133
134 static HDC show_image(HWND hwnd, HIMAGELIST himl, int idx, int size,
135                       LPCSTR loc, BOOL clear)
136 {
137     HDC hdc = NULL;
138 #ifdef VISIBLE
139     if (!himl) return NULL;
140
141     SetWindowText(hwnd, loc);
142     hdc = GetDC(hwnd);
143     ImageList_Draw(himl, idx, hdc, 0, 0, ILD_TRANSPARENT);
144
145     REDRAW(hwnd);
146     WAIT;
147
148     if (clear)
149     {
150         BitBlt(hdc, 0, 0, size, size, hdc, size+1, size+1, SRCCOPY);
151         ReleaseDC(hwnd, hdc);
152         hdc = NULL;
153     }
154 #endif /* VISIBLE */
155     return hdc;
156 }
157
158 /* Useful for checking differences */
159 #if 0
160 static void dump_bits(const BYTE *p, const BYTE *q, int size)
161 {
162   int i, j;
163
164   size /= 8;
165
166   for (i = 0; i < size * 2; i++)
167   {
168       printf("|");
169       for (j = 0; j < size; j++)
170           printf("%c%c", p[j] & 0xf0 ? 'X' : ' ', p[j] & 0xf ? 'X' : ' ');
171       printf(" -- ");
172       for (j = 0; j < size; j++)
173           printf("%c%c", q[j] & 0xf0 ? 'X' : ' ', q[j] & 0xf ? 'X' : ' ');
174       printf("|\n");
175       p += size * 4;
176       q += size * 4;
177   }
178   printf("\n");
179 }
180 #endif
181
182 static void check_bits(HWND hwnd, HIMAGELIST himl, int idx, int size,
183                        const BYTE *checkbits, LPCSTR loc)
184 {
185 #ifdef VISIBLE
186     BYTE bits[100*100/8];
187     COLORREF c;
188     HDC hdc;
189     int x, y, i = -1;
190
191     if (!himl) return;
192
193     memset(bits, 0, sizeof(bits));
194     hdc = show_image(hwnd, himl, idx, size, loc, FALSE);
195
196     c = GetPixel(hdc, 0, 0);
197
198     for (y = 0; y < size; y ++)
199     {
200         for (x = 0; x < size; x++)
201         {
202             if (!(x & 0x7)) i++;
203             if (GetPixel(hdc, x, y) != c) bits[i] |= (0x80 >> (x & 0x7));
204         }
205     }
206
207     BitBlt(hdc, 0, 0, size, size, hdc, size+1, size+1, SRCCOPY);
208     ReleaseDC(hwnd, hdc);
209
210     ok (memcmp(bits, checkbits, (size * size)/8) == 0,
211         "%s: bits different\n", loc);
212     if (memcmp(bits, checkbits, (size * size)/8))
213         dump_bits(bits, checkbits, size);
214 #endif /* VISIBLE */
215 }
216
217 static void testHotspot (void)
218 {
219     struct hotspot {
220         int dx;
221         int dy;
222     };
223
224 #define SIZEX1 47
225 #define SIZEY1 31
226 #define SIZEX2 11
227 #define SIZEY2 17
228 #define HOTSPOTS_MAX 4       /* Number of entries in hotspots */
229     static const struct hotspot hotspots[HOTSPOTS_MAX] = {
230         { 10, 7 },
231         { SIZEX1, SIZEY1 },
232         { -9, -8 },
233         { -7, 35 }
234     };
235     int i, j, ret;
236     HIMAGELIST himl1 = createImageList(SIZEX1, SIZEY1);
237     HIMAGELIST himl2 = createImageList(SIZEX2, SIZEY2);
238     HWND hwnd = create_a_window();
239
240
241     for (i = 0; i < HOTSPOTS_MAX; i++) {
242         for (j = 0; j < HOTSPOTS_MAX; j++) {
243             int dx1 = hotspots[i].dx;
244             int dy1 = hotspots[i].dy;
245             int dx2 = hotspots[j].dx;
246             int dy2 = hotspots[j].dy;
247             int correctx, correcty, newx, newy;
248             char loc[256];
249             HIMAGELIST himlNew;
250             POINT ppt;
251
252             ret = ImageList_BeginDrag(himl1, 0, dx1, dy1);
253             ok(ret != 0, "BeginDrag failed for { %d, %d }\n", dx1, dy1);
254             sprintf(loc, "BeginDrag (%d,%d)\n", i, j);
255             show_image(hwnd, himl1, 0, max(SIZEX1, SIZEY1), loc, TRUE);
256
257             /* check merging the dragged image with a second image */
258             ret = ImageList_SetDragCursorImage(himl2, 0, dx2, dy2);
259             ok(ret != 0, "SetDragCursorImage failed for {%d, %d}{%d, %d}\n",
260                     dx1, dy1, dx2, dy2);
261             sprintf(loc, "SetDragCursorImage (%d,%d)\n", i, j);
262             show_image(hwnd, himl2, 0, max(SIZEX2, SIZEY2), loc, TRUE);
263
264             /* check new hotspot, it should be the same like the old one */
265             himlNew = ImageList_GetDragImage(NULL, &ppt);
266             ok(ppt.x == dx1 && ppt.y == dy1,
267                     "Expected drag hotspot [%d,%d] got [%ld,%ld]\n",
268                     dx1, dy1, ppt.x, ppt.y);
269             /* check size of new dragged image */
270             ImageList_GetIconSize(himlNew, &newx, &newy);
271             correctx = max(SIZEX1, max(SIZEX2 + dx2, SIZEX1 - dx2));
272             correcty = max(SIZEY1, max(SIZEY2 + dy2, SIZEY1 - dy2));
273             ok(newx == correctx && newy == correcty,
274                     "Expected drag image size [%d,%d] got [%d,%d]\n",
275                     correctx, correcty, newx, newy);
276             sprintf(loc, "GetDragImage (%d,%d)\n", i, j);
277             show_image(hwnd, himlNew, 0, max(correctx, correcty), loc, TRUE);
278             ImageList_EndDrag();
279         }
280     }
281 #undef SIZEX1
282 #undef SIZEY1
283 #undef SIZEX2
284 #undef SIZEY2
285 #undef HOTSPOTS_MAX
286     DestroyWindow(hwnd);
287 }
288
289 static BOOL DoTest1(void)
290 {
291     HIMAGELIST himl ;
292
293     HICON hicon1 ;
294     HICON hicon2 ;
295     HICON hicon3 ;
296
297     /* create an imagelist to play with */
298     himl = ImageList_Create(84,84,0x10,0,3);
299     ok(himl!=0,"failed to create imagelist\n");
300
301     /* load the icons to add to the image list */
302     hicon1 = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
303     ok(hicon1 != 0, "no hicon1\n");
304     hicon2 = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
305     ok(hicon2 != 0, "no hicon2\n");
306     hicon3 = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
307     ok(hicon3 != 0, "no hicon3\n");
308
309     /* remove when nothing exists */
310     ok(!ImageList_Remove(himl,0),"removed nonexistent icon\n");
311     /* removing everything from an empty imagelist should succeed */
312     ok(ImageList_RemoveAll(himl),"removed nonexistent icon\n");
313
314     /* add three */
315     ok(0==ImageList_AddIcon(himl, hicon1),"failed to add icon1\n");
316     ok(1==ImageList_AddIcon(himl, hicon2),"failed to add icon2\n");
317     ok(2==ImageList_AddIcon(himl, hicon3),"failed to add icon3\n");
318
319     /* remove an index out of range */
320     ok(!ImageList_Remove(himl,4711),"removed nonexistent icon\n");
321
322     /* remove three */
323     ok(ImageList_Remove(himl,0),"can't remove 0\n");
324     ok(ImageList_Remove(himl,0),"can't remove 0\n");
325     ok(ImageList_Remove(himl,0),"can't remove 0\n");
326
327     /* remove one extra */
328     ok(!ImageList_Remove(himl,0),"removed nonexistent icon\n");
329
330     /* check SetImageCount/GetImageCount */
331     ok(ImageList_SetImageCount(himl, 3), "couldn't increase image count\n");
332     ok(ImageList_GetImageCount(himl) == 3, "invalid image count after increase\n");
333     ok(ImageList_SetImageCount(himl, 1), "couldn't decrease image count\n");
334     ok(ImageList_GetImageCount(himl) == 1, "invalid image count after decrease to 1\n");
335     ok(ImageList_SetImageCount(himl, 0), "couldn't decrease image count\n");
336     ok(ImageList_GetImageCount(himl) == 0, "invalid image count after decrease to 0\n");
337
338     /* destroy it */
339     ok(ImageList_Destroy(himl),"destroy imagelist failed\n");
340
341     /* icons should be deleted by the imagelist */
342     ok(!DeleteObject(hicon1),"icon 1 wasn't deleted\n");
343     ok(!DeleteObject(hicon2),"icon 2 wasn't deleted\n");
344     ok(!DeleteObject(hicon3),"icon 3 wasn't deleted\n");
345
346     return TRUE;
347 }
348
349 static BOOL DoTest2(void)
350 {
351     HIMAGELIST himl ;
352
353     HICON hicon1 ;
354     HICON hicon2 ;
355     HICON hicon3 ;
356
357     /* create an imagelist to play with */
358     himl = ImageList_Create(84,84,0x10,0,3);
359     ok(himl!=0,"failed to create imagelist\n");
360
361     /* load the icons to add to the image list */
362     hicon1 = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
363     ok(hicon1 != 0, "no hicon1\n");
364     hicon2 = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
365     ok(hicon2 != 0, "no hicon2\n");
366     hicon3 = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
367     ok(hicon3 != 0, "no hicon3\n");
368
369     /* add three */
370     ok(0==ImageList_AddIcon(himl, hicon1),"failed to add icon1\n");
371     ok(1==ImageList_AddIcon(himl, hicon2),"failed to add icon2\n");
372     ok(2==ImageList_AddIcon(himl, hicon3),"failed to add icon3\n");
373
374     /* destroy it */
375     ok(ImageList_Destroy(himl),"destroy imagelist failed\n");
376
377     /* icons should be deleted by the imagelist */
378     ok(!DeleteObject(hicon1),"icon 1 wasn't deleted\n");
379     ok(!DeleteObject(hicon2),"icon 2 wasn't deleted\n");
380     ok(!DeleteObject(hicon3),"icon 3 wasn't deleted\n");
381
382     return TRUE;
383 }
384
385 static BOOL DoTest3(void)
386 {
387     HIMAGELIST himl;
388
389     HBITMAP hbm1;
390     HBITMAP hbm2;
391     HBITMAP hbm3;
392
393     IMAGELISTDRAWPARAMS imldp;
394     HDC hdc;
395     HWND hwndfortest;
396
397     if (!pImageList_DrawIndirect)
398     {
399         HMODULE hComCtl32 = LoadLibraryA("comctl32.dll");
400         pImageList_DrawIndirect = (void*)GetProcAddress(hComCtl32, "ImageList_DrawIndirect");
401         if (!pImageList_DrawIndirect)
402         {
403             trace("ImageList_DrawIndirect not available, skipping test\n");
404             return TRUE;
405         }
406     }
407
408     hwndfortest = create_a_window();
409     hdc = GetDC(hwndfortest);
410     ok(hdc!=NULL, "couldn't get DC\n");
411
412     /* create an imagelist to play with */
413     himl = ImageList_Create(48,48,0x10,0,3);
414     ok(himl!=0,"failed to create imagelist\n");
415
416     /* load the icons to add to the image list */
417     hbm1 = CreateBitmap(48, 48, 1, 1, bitmap_bits);
418     ok(hbm1 != 0, "no bitmap 1\n");
419     hbm2 = CreateBitmap(48, 48, 1, 1, bitmap_bits);
420     ok(hbm2 != 0, "no bitmap 2\n");
421     hbm3 = CreateBitmap(48, 48, 1, 1, bitmap_bits);
422     ok(hbm3 != 0, "no bitmap 3\n");
423
424     /* add three */
425     ok(0==ImageList_Add(himl, hbm1, 0),"failed to add bitmap 1\n");
426     ok(1==ImageList_Add(himl, hbm2, 0),"failed to add bitmap 2\n");
427
428     ok(ImageList_SetImageCount(himl,3),"Setimage count failed\n");
429     /*ok(2==ImageList_Add(himl, hbm3, NULL),"failed to add bitmap 3\n"); */
430     ok(ImageList_Replace(himl, 2, hbm3, 0),"failed to replace bitmap 3\n");
431
432     memset(&imldp, 0, sizeof (imldp));
433     ok(!pImageList_DrawIndirect(&imldp), "zero data succeeded!\n");
434     imldp.cbSize = sizeof (imldp);
435     ok(!pImageList_DrawIndirect(&imldp), "zero hdc succeeded!\n");
436     imldp.hdcDst = hdc;
437     ok(!pImageList_DrawIndirect(&imldp),"zero himl succeeded!\n");
438     imldp.himl = himl;
439     if (!pImageList_DrawIndirect(&imldp))
440     {
441       /* Earlier versions of native comctl32 use a smaller structure */
442       imldp.cbSize -= 3 * sizeof(DWORD);
443       ok(pImageList_DrawIndirect(&imldp),"DrawIndirect should succeed\n");
444     }
445     REDRAW(hwndfortest);
446     WAIT;
447
448     imldp.fStyle = SRCCOPY;
449     imldp.rgbBk = CLR_DEFAULT;
450     imldp.rgbFg = CLR_DEFAULT;
451     imldp.y = 100;
452     imldp.x = 100;
453     ok(pImageList_DrawIndirect(&imldp),"should succeed\n");
454     imldp.i ++;
455     ok(pImageList_DrawIndirect(&imldp),"should succeed\n");
456     imldp.i ++;
457     ok(pImageList_DrawIndirect(&imldp),"should succeed\n");
458     imldp.i ++;
459     ok(!pImageList_DrawIndirect(&imldp),"should fail\n");
460
461     /* remove three */
462     ok(ImageList_Remove(himl, 0), "removing 1st bitmap\n");
463     ok(ImageList_Remove(himl, 0), "removing 2nd bitmap\n");
464     ok(ImageList_Remove(himl, 0), "removing 3rd bitmap\n");
465
466     /* destroy it */
467     ok(ImageList_Destroy(himl),"destroy imagelist failed\n");
468
469     /* bitmaps should not be deleted by the imagelist */
470     ok(DeleteObject(hbm1),"bitmap 1 can't be deleted\n");
471     ok(DeleteObject(hbm2),"bitmap 2 can't be deleted\n");
472     ok(DeleteObject(hbm3),"bitmap 3 can't be deleted\n");
473
474     ReleaseDC(hwndfortest, hdc);
475     DestroyWindow(hwndfortest);
476
477     return TRUE;
478 }
479
480 static void testMerge(void)
481 {
482     HIMAGELIST himl1, himl2, hmerge;
483     HICON hicon1;
484     HWND hwnd = create_a_window();
485
486     himl1 = ImageList_Create(32,32,0,0,3);
487     ok(himl1 != NULL,"failed to create himl1\n");
488
489     himl2 = ImageList_Create(32,32,0,0,3);
490     ok(himl2 != NULL,"failed to create himl2\n");
491
492     hicon1 = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
493     ok(hicon1 != NULL, "failed to create hicon1\n");
494
495     if (!himl1 || !himl2 || !hicon1)
496         return;
497
498     ok(0==ImageList_AddIcon(himl2, hicon1),"add icon1 to himl2 failed\n");
499     check_bits(hwnd, himl2, 0, 32, icon_bits, "add icon1 to himl2");
500
501     /* If himl1 has no images, merge still succeeds */
502     hmerge = ImageList_Merge(himl1, -1, himl2, 0, 0, 0);
503     ok(hmerge != NULL, "merge himl1,-1 failed\n");
504     check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl1,-1");
505     if (hmerge) ImageList_Destroy(hmerge);
506
507     hmerge = ImageList_Merge(himl1, 0, himl2, 0, 0, 0);
508     ok(hmerge != NULL,"merge himl1,0 failed\n");
509     check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl1,0");
510     if (hmerge) ImageList_Destroy(hmerge);
511
512     /* Same happens if himl2 is empty */
513     ImageList_Destroy(himl2);
514     himl2 = ImageList_Create(32,32,0,0,3);
515     ok(himl2 != NULL,"failed to recreate himl2\n");
516     if (!himl2)
517         return;
518
519     hmerge = ImageList_Merge(himl1, -1, himl2, -1, 0, 0);
520     ok(hmerge != NULL, "merge himl2,-1 failed\n");
521     check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl2,-1");
522     if (hmerge) ImageList_Destroy(hmerge);
523
524     hmerge = ImageList_Merge(himl1, -1, himl2, 0, 0, 0);
525     ok(hmerge != NULL, "merge himl2,0 failed\n");
526     check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl2,0");
527     if (hmerge) ImageList_Destroy(hmerge);
528
529     /* Now try merging an image with itself */
530     ok(0==ImageList_AddIcon(himl2, hicon1),"re-add icon1 to himl2 failed\n");
531
532     hmerge = ImageList_Merge(himl2, 0, himl2, 0, 0, 0);
533     ok(hmerge != NULL, "merge himl2 with itself failed\n");
534     check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl2 with itself");
535     if (hmerge) ImageList_Destroy(hmerge);
536
537     /* Try merging 2 different image lists */
538     ok(0==ImageList_AddIcon(himl1, hicon1),"add icon1 to himl1 failed\n");
539
540     hmerge = ImageList_Merge(himl1, 0, himl2, 0, 0, 0);
541     ok(hmerge != NULL, "merge himl1 with himl2 failed\n");
542     check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl1 with himl2");
543     if (hmerge) ImageList_Destroy(hmerge);
544
545     hmerge = ImageList_Merge(himl1, 0, himl2, 0, 8, 16);
546     ok(hmerge != NULL, "merge himl1 with himl2 8,16 failed\n");
547     check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl1 with himl2, 8,16");
548     if (hmerge) ImageList_Destroy(hmerge);
549
550     ImageList_Destroy(himl1);
551     ImageList_Destroy(himl2);
552     DeleteObject(hicon1);
553     DestroyWindow(hwnd);
554 }
555
556 START_TEST(imagelist)
557 {
558     desktopDC=GetDC(NULL);
559     hinst = GetModuleHandleA(NULL);
560
561     InitCommonControls();
562
563     testHotspot();
564     DoTest1();
565     DoTest2();
566     DoTest3();
567     testMerge();
568 }