2007-04-23 13:39:18 +02:00
|
|
|
/*
|
|
|
|
* Unit test suite for imagelist control.
|
2004-08-22 03:59:55 +02:00
|
|
|
*
|
|
|
|
* Copyright 2004 Michael Stefaniuc
|
2004-08-24 20:41:52 +02:00
|
|
|
* Copyright 2002 Mike McCormack for CodeWeavers
|
2007-04-23 13:39:18 +02:00
|
|
|
* Copyright 2007 Dmitry Timoshkov
|
2009-08-12 22:51:28 +02:00
|
|
|
* Copyright 2009 Owen Rudge for CodeWeavers
|
2004-08-22 03:59:55 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-08-22 03:59:55 +02:00
|
|
|
*/
|
|
|
|
|
2007-04-23 13:39:18 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
#define CONST_VTABLE
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2004-10-07 19:34:56 +02:00
|
|
|
#include <stdio.h>
|
2007-04-23 13:39:18 +02:00
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "objbase.h"
|
|
|
|
#include "commctrl.h" /* must be included after objbase.h to get ImageList_Write */
|
2009-08-12 22:51:28 +02:00
|
|
|
#include "initguid.h"
|
|
|
|
#include "commoncontrols.h"
|
|
|
|
#include "shellapi.h"
|
2004-08-22 03:59:55 +02:00
|
|
|
|
|
|
|
#include "wine/test.h"
|
2009-08-12 22:51:28 +02:00
|
|
|
#include "v6util.h"
|
2017-11-20 14:26:16 +01:00
|
|
|
#include "resources.h"
|
2004-08-22 03:59:55 +02:00
|
|
|
|
2007-04-23 13:39:18 +02:00
|
|
|
#define IMAGELIST_MAGIC (('L' << 8) | 'I')
|
|
|
|
|
|
|
|
#include "pshpack2.h"
|
|
|
|
/* Header used by ImageList_Read() and ImageList_Write() */
|
|
|
|
typedef struct _ILHEAD
|
|
|
|
{
|
|
|
|
USHORT usMagic;
|
|
|
|
USHORT usVersion;
|
|
|
|
WORD cCurImage;
|
|
|
|
WORD cMaxImage;
|
|
|
|
WORD cGrow;
|
|
|
|
WORD cx;
|
|
|
|
WORD cy;
|
|
|
|
COLORREF bkcolor;
|
|
|
|
WORD flags;
|
|
|
|
SHORT ovls[4];
|
|
|
|
} ILHEAD;
|
|
|
|
#include "poppack.h"
|
2004-10-07 19:34:56 +02:00
|
|
|
|
2009-10-09 00:28:49 +02:00
|
|
|
static HIMAGELIST (WINAPI *pImageList_Create)(int, int, UINT, int, int);
|
2017-12-22 13:30:47 +01:00
|
|
|
static BOOL (WINAPI *pImageList_Destroy)(HIMAGELIST);
|
2009-10-09 00:28:49 +02:00
|
|
|
static int (WINAPI *pImageList_Add)(HIMAGELIST, HBITMAP, HBITMAP);
|
2020-03-02 03:30:44 +01:00
|
|
|
static int (WINAPI *pImageList_AddMasked)(HIMAGELIST, HBITMAP, COLORREF);
|
2007-12-10 01:25:15 +01:00
|
|
|
static BOOL (WINAPI *pImageList_DrawIndirect)(IMAGELISTDRAWPARAMS*);
|
|
|
|
static BOOL (WINAPI *pImageList_SetImageCount)(HIMAGELIST,UINT);
|
2009-11-12 17:27:44 +01:00
|
|
|
static HRESULT (WINAPI *pImageList_CoCreateInstance)(REFCLSID,const IUnknown *,
|
|
|
|
REFIID,void **);
|
|
|
|
static HRESULT (WINAPI *pHIMAGELIST_QueryInterface)(HIMAGELIST,REFIID,void **);
|
2017-01-30 19:54:07 +01:00
|
|
|
static int (WINAPI *pImageList_SetColorTable)(HIMAGELIST,int,int,RGBQUAD*);
|
2017-11-20 14:26:16 +01:00
|
|
|
static DWORD (WINAPI *pImageList_GetFlags)(HIMAGELIST);
|
2017-12-22 13:30:47 +01:00
|
|
|
static BOOL (WINAPI *pImageList_BeginDrag)(HIMAGELIST, int, int, int);
|
|
|
|
static HIMAGELIST (WINAPI *pImageList_GetDragImage)(POINT *, POINT *);
|
|
|
|
static void (WINAPI *pImageList_EndDrag)(void);
|
|
|
|
static INT (WINAPI *pImageList_GetImageCount)(HIMAGELIST);
|
|
|
|
static BOOL (WINAPI *pImageList_SetDragCursorImage)(HIMAGELIST, int, int, int);
|
|
|
|
static BOOL (WINAPI *pImageList_GetIconSize)(HIMAGELIST, int *, int *);
|
2020-03-06 10:57:43 +01:00
|
|
|
static BOOL (WINAPI *pImageList_SetIconSize)(HIMAGELIST, INT, INT);
|
2017-12-22 13:30:47 +01:00
|
|
|
static BOOL (WINAPI *pImageList_Remove)(HIMAGELIST, int);
|
|
|
|
static INT (WINAPI *pImageList_ReplaceIcon)(HIMAGELIST, int, HICON);
|
|
|
|
static BOOL (WINAPI *pImageList_Replace)(HIMAGELIST, int, HBITMAP, HBITMAP);
|
|
|
|
static HIMAGELIST (WINAPI *pImageList_Merge)(HIMAGELIST, int, HIMAGELIST, int, int, int);
|
|
|
|
static BOOL (WINAPI *pImageList_GetImageInfo)(HIMAGELIST, int, IMAGEINFO *);
|
|
|
|
static BOOL (WINAPI *pImageList_Write)(HIMAGELIST, IStream *);
|
|
|
|
static HIMAGELIST (WINAPI *pImageList_Read)(IStream *);
|
|
|
|
static BOOL (WINAPI *pImageList_Copy)(HIMAGELIST, int, HIMAGELIST, int, UINT);
|
|
|
|
static HIMAGELIST (WINAPI *pImageList_LoadImageW)(HINSTANCE, LPCWSTR, int, int, COLORREF, UINT, UINT);
|
2018-01-24 13:47:09 +01:00
|
|
|
static BOOL (WINAPI *pImageList_Draw)(HIMAGELIST,INT,HDC,INT,INT,UINT);
|
2004-08-26 20:22:31 +02:00
|
|
|
|
2004-10-07 19:34:56 +02:00
|
|
|
static HINSTANCE hinst;
|
|
|
|
|
2015-11-15 13:54:01 +01:00
|
|
|
/* only used in interactive mode */
|
|
|
|
static void force_redraw(HWND hwnd)
|
|
|
|
{
|
|
|
|
if (!winetest_interactive)
|
|
|
|
return;
|
|
|
|
|
|
|
|
RedrawWindow(hwnd, NULL, 0, RDW_UPDATENOW);
|
|
|
|
Sleep(1000);
|
|
|
|
}
|
|
|
|
|
2017-12-27 11:51:38 +01:00
|
|
|
static BOOL is_v6_test(void)
|
|
|
|
{
|
|
|
|
return pHIMAGELIST_QueryInterface != NULL;
|
|
|
|
}
|
|
|
|
|
2004-10-07 19:34:56 +02:00
|
|
|
/* These macros build cursor/bitmap data in 4x4 pixel blocks */
|
|
|
|
#define B(x,y) ((x?0xf0:0)|(y?0xf:0))
|
|
|
|
#define ROW1(a,b,c,d,e,f,g,h) B(a,b),B(c,d),B(e,f),B(g,h)
|
|
|
|
#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), \
|
|
|
|
ROW1(a,b,c,d,e,f,g,h), ROW1(a,b,c,d,e,f,g,h)
|
|
|
|
#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)
|
|
|
|
#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), \
|
|
|
|
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), \
|
|
|
|
ROW2(a,b,c,d,e,f,g,h,i,j,k,l)
|
|
|
|
|
|
|
|
static const BYTE empty_bits[48*48/8];
|
|
|
|
|
|
|
|
static const BYTE icon_bits[32*32/8] =
|
|
|
|
{
|
|
|
|
ROW32(0,0,0,0,0,0,0,0),
|
|
|
|
ROW32(0,0,1,1,1,1,0,0),
|
|
|
|
ROW32(0,1,1,1,1,1,1,0),
|
|
|
|
ROW32(0,1,1,0,0,1,1,0),
|
|
|
|
ROW32(0,1,1,0,0,1,1,0),
|
|
|
|
ROW32(0,1,1,1,1,1,1,0),
|
|
|
|
ROW32(0,0,1,1,1,1,0,0),
|
|
|
|
ROW32(0,0,0,0,0,0,0,0)
|
|
|
|
};
|
|
|
|
|
|
|
|
static const BYTE bitmap_bits[48*48/8] =
|
|
|
|
{
|
|
|
|
ROW48(0,0,0,0,0,0,0,0,0,0,0,0),
|
|
|
|
ROW48(0,1,1,1,1,1,1,1,1,1,1,0),
|
|
|
|
ROW48(0,1,1,0,0,0,0,0,0,1,1,0),
|
|
|
|
ROW48(0,1,0,0,0,0,0,0,1,0,1,0),
|
|
|
|
ROW48(0,1,0,0,0,0,0,1,0,0,1,0),
|
|
|
|
ROW48(0,1,0,0,0,0,1,0,0,0,1,0),
|
|
|
|
ROW48(0,1,0,0,0,1,0,0,0,0,1,0),
|
|
|
|
ROW48(0,1,0,0,1,0,0,0,0,0,1,0),
|
|
|
|
ROW48(0,1,0,1,0,0,0,0,0,0,1,0),
|
|
|
|
ROW48(0,1,1,0,0,0,0,0,0,1,1,0),
|
|
|
|
ROW48(0,1,1,1,1,1,1,1,1,1,1,0),
|
|
|
|
ROW48(0,0,0,0,0,0,0,0,0,0,0,0)
|
|
|
|
};
|
2004-08-22 03:59:55 +02:00
|
|
|
|
2004-12-13 22:19:01 +01:00
|
|
|
static HIMAGELIST createImageList(int cx, int cy)
|
2004-08-22 03:59:55 +02:00
|
|
|
{
|
|
|
|
/* Create an ImageList and put an image into it */
|
2017-12-22 13:30:47 +01:00
|
|
|
HIMAGELIST himl = pImageList_Create(cx, cy, ILC_COLOR, 1, 1);
|
2004-10-07 19:34:56 +02:00
|
|
|
HBITMAP hbm = CreateBitmap(48, 48, 1, 1, bitmap_bits);
|
2017-12-22 13:30:47 +01:00
|
|
|
|
|
|
|
ok(himl != NULL, "Failed to create image list, %d x %d.\n", cx, cy);
|
|
|
|
pImageList_Add(himl, hbm, NULL);
|
2010-06-23 10:57:39 +02:00
|
|
|
DeleteObject(hbm);
|
2004-08-22 03:59:55 +02:00
|
|
|
return himl;
|
|
|
|
}
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
static HWND create_window(void)
|
2004-10-07 19:34:56 +02:00
|
|
|
{
|
|
|
|
char className[] = "bmwnd";
|
|
|
|
char winName[] = "Test Bitmap";
|
|
|
|
HWND hWnd;
|
2013-11-14 10:44:27 +01:00
|
|
|
static BOOL registered = FALSE;
|
2004-10-07 19:34:56 +02:00
|
|
|
|
|
|
|
if (!registered)
|
|
|
|
{
|
|
|
|
WNDCLASSA cls;
|
|
|
|
|
|
|
|
cls.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
|
|
|
|
cls.lpfnWndProc = DefWindowProcA;
|
|
|
|
cls.cbClsExtra = 0;
|
|
|
|
cls.cbWndExtra = 0;
|
|
|
|
cls.hInstance = 0;
|
2013-12-04 00:49:00 +01:00
|
|
|
cls.hIcon = LoadIconA(0, (LPCSTR)IDI_APPLICATION);
|
|
|
|
cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
|
2008-10-25 23:38:37 +02:00
|
|
|
cls.hbrBackground = GetStockObject (WHITE_BRUSH);
|
2004-10-07 19:34:56 +02:00
|
|
|
cls.lpszMenuName = 0;
|
|
|
|
cls.lpszClassName = className;
|
|
|
|
|
|
|
|
RegisterClassA (&cls);
|
2013-11-14 10:44:27 +01:00
|
|
|
registered = TRUE;
|
2004-10-07 19:34:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Setup window */
|
|
|
|
hWnd = CreateWindowA (className, winName,
|
|
|
|
WS_OVERLAPPEDWINDOW ,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
|
|
|
|
0, hinst, 0);
|
|
|
|
|
2015-11-15 13:54:01 +01:00
|
|
|
if (winetest_interactive)
|
|
|
|
{
|
|
|
|
ShowWindow (hWnd, SW_SHOW);
|
|
|
|
force_redraw (hWnd);
|
|
|
|
}
|
2004-10-07 19:34:56 +02:00
|
|
|
|
|
|
|
return hWnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HDC show_image(HWND hwnd, HIMAGELIST himl, int idx, int size,
|
|
|
|
LPCSTR loc, BOOL clear)
|
|
|
|
{
|
2015-11-15 13:54:01 +01:00
|
|
|
HDC hdc;
|
|
|
|
|
|
|
|
if (!winetest_interactive || !himl) return NULL;
|
2004-10-07 19:34:56 +02:00
|
|
|
|
2015-11-15 13:54:01 +01:00
|
|
|
SetWindowTextA(hwnd, loc);
|
2004-10-07 19:34:56 +02:00
|
|
|
hdc = GetDC(hwnd);
|
2018-01-24 13:47:09 +01:00
|
|
|
pImageList_Draw(himl, idx, hdc, 0, 0, ILD_TRANSPARENT);
|
2004-10-07 19:34:56 +02:00
|
|
|
|
2015-11-15 13:54:01 +01:00
|
|
|
force_redraw(hwnd);
|
2004-10-07 19:34:56 +02:00
|
|
|
|
|
|
|
if (clear)
|
|
|
|
{
|
|
|
|
BitBlt(hdc, 0, 0, size, size, hdc, size+1, size+1, SRCCOPY);
|
|
|
|
ReleaseDC(hwnd, hdc);
|
|
|
|
hdc = NULL;
|
|
|
|
}
|
2015-11-15 13:54:01 +01:00
|
|
|
|
2004-10-07 19:34:56 +02:00
|
|
|
return hdc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Useful for checking differences */
|
|
|
|
static void dump_bits(const BYTE *p, const BYTE *q, int size)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
size /= 8;
|
|
|
|
|
|
|
|
for (i = 0; i < size * 2; i++)
|
|
|
|
{
|
|
|
|
printf("|");
|
|
|
|
for (j = 0; j < size; j++)
|
|
|
|
printf("%c%c", p[j] & 0xf0 ? 'X' : ' ', p[j] & 0xf ? 'X' : ' ');
|
|
|
|
printf(" -- ");
|
|
|
|
for (j = 0; j < size; j++)
|
|
|
|
printf("%c%c", q[j] & 0xf0 ? 'X' : ' ', q[j] & 0xf ? 'X' : ' ');
|
|
|
|
printf("|\n");
|
|
|
|
p += size * 4;
|
|
|
|
q += size * 4;
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void check_bits(HWND hwnd, HIMAGELIST himl, int idx, int size,
|
|
|
|
const BYTE *checkbits, LPCSTR loc)
|
|
|
|
{
|
|
|
|
BYTE bits[100*100/8];
|
|
|
|
COLORREF c;
|
|
|
|
HDC hdc;
|
|
|
|
int x, y, i = -1;
|
|
|
|
|
2015-11-15 13:54:01 +01:00
|
|
|
if (!winetest_interactive || !himl) return;
|
2004-10-07 19:34:56 +02:00
|
|
|
|
|
|
|
memset(bits, 0, sizeof(bits));
|
|
|
|
hdc = show_image(hwnd, himl, idx, size, loc, FALSE);
|
|
|
|
|
|
|
|
c = GetPixel(hdc, 0, 0);
|
|
|
|
|
|
|
|
for (y = 0; y < size; y ++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < size; x++)
|
|
|
|
{
|
|
|
|
if (!(x & 0x7)) i++;
|
|
|
|
if (GetPixel(hdc, x, y) != c) bits[i] |= (0x80 >> (x & 0x7));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BitBlt(hdc, 0, 0, size, size, hdc, size+1, size+1, SRCCOPY);
|
|
|
|
ReleaseDC(hwnd, hdc);
|
|
|
|
|
|
|
|
ok (memcmp(bits, checkbits, (size * size)/8) == 0,
|
|
|
|
"%s: bits different\n", loc);
|
|
|
|
if (memcmp(bits, checkbits, (size * size)/8))
|
|
|
|
dump_bits(bits, checkbits, size);
|
|
|
|
}
|
|
|
|
|
2014-10-07 01:01:56 +02:00
|
|
|
static void test_begindrag(void)
|
|
|
|
{
|
|
|
|
HIMAGELIST himl = createImageList(7,13);
|
|
|
|
HIMAGELIST drag;
|
|
|
|
BOOL ret;
|
|
|
|
int count;
|
|
|
|
POINT hotspot;
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
count = pImageList_GetImageCount(himl);
|
2014-10-07 01:01:56 +02:00
|
|
|
ok(count > 2, "Tests need an ImageList with more than 2 images\n");
|
|
|
|
|
|
|
|
/* Two BeginDrag() without EndDrag() in between */
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_BeginDrag(himl, 1, 0, 0);
|
|
|
|
drag = pImageList_GetDragImage(NULL, NULL);
|
2014-10-07 01:01:56 +02:00
|
|
|
ok(ret && drag, "ImageList_BeginDrag() failed\n");
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_BeginDrag(himl, 0, 3, 5);
|
2014-10-07 01:01:56 +02:00
|
|
|
ok(!ret, "ImageList_BeginDrag() returned TRUE\n");
|
2017-12-22 13:30:47 +01:00
|
|
|
drag = pImageList_GetDragImage(NULL, &hotspot);
|
2014-10-07 01:01:56 +02:00
|
|
|
ok(!!drag, "No active ImageList drag left\n");
|
|
|
|
ok(hotspot.x == 0 && hotspot.y == 0, "New ImageList drag was created\n");
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_EndDrag();
|
|
|
|
drag = pImageList_GetDragImage(NULL, NULL);
|
2014-10-07 01:01:56 +02:00
|
|
|
ok(!drag, "ImageList drag was not destroyed\n");
|
|
|
|
|
|
|
|
/* Invalid image index */
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_BeginDrag(himl, 0, 0, 0);
|
|
|
|
ret = pImageList_BeginDrag(himl, count, 3, 5);
|
2014-10-07 01:01:56 +02:00
|
|
|
ok(!ret, "ImageList_BeginDrag() returned TRUE\n");
|
2017-12-22 13:30:47 +01:00
|
|
|
drag = pImageList_GetDragImage(NULL, &hotspot);
|
2014-10-07 01:01:56 +02:00
|
|
|
ok(drag && hotspot.x == 0 && hotspot.y == 0, "Active drag should not have been canceled\n");
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_EndDrag();
|
|
|
|
drag = pImageList_GetDragImage(NULL, NULL);
|
2014-10-07 01:01:56 +02:00
|
|
|
ok(!drag, "ImageList drag was not destroyed\n");
|
|
|
|
/* Invalid negative image indexes succeed */
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_BeginDrag(himl, -17, 0, 0);
|
|
|
|
drag = pImageList_GetDragImage(NULL, NULL);
|
2014-10-07 01:01:56 +02:00
|
|
|
ok(ret && drag, "ImageList drag was created\n");
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_EndDrag();
|
|
|
|
ret = pImageList_BeginDrag(himl, -1, 0, 0);
|
|
|
|
drag = pImageList_GetDragImage(NULL, NULL);
|
2014-10-07 01:01:56 +02:00
|
|
|
ok(ret && drag, "ImageList drag was created\n");
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_EndDrag();
|
|
|
|
pImageList_Destroy(himl);
|
2014-10-07 01:01:56 +02:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:32:09 +02:00
|
|
|
static void test_hotspot(void)
|
2004-08-22 03:59:55 +02:00
|
|
|
{
|
|
|
|
struct hotspot {
|
|
|
|
int dx;
|
|
|
|
int dy;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SIZEX1 47
|
|
|
|
#define SIZEY1 31
|
|
|
|
#define SIZEX2 11
|
|
|
|
#define SIZEY2 17
|
|
|
|
#define HOTSPOTS_MAX 4 /* Number of entries in hotspots */
|
|
|
|
static const struct hotspot hotspots[HOTSPOTS_MAX] = {
|
|
|
|
{ 10, 7 },
|
|
|
|
{ SIZEX1, SIZEY1 },
|
|
|
|
{ -9, -8 },
|
|
|
|
{ -7, 35 }
|
|
|
|
};
|
|
|
|
int i, j, ret;
|
|
|
|
HIMAGELIST himl1 = createImageList(SIZEX1, SIZEY1);
|
|
|
|
HIMAGELIST himl2 = createImageList(SIZEX2, SIZEY2);
|
2017-12-22 13:30:47 +01:00
|
|
|
HWND hwnd = create_window();
|
2004-10-07 19:34:56 +02:00
|
|
|
|
2004-08-22 03:59:55 +02:00
|
|
|
|
|
|
|
for (i = 0; i < HOTSPOTS_MAX; i++) {
|
|
|
|
for (j = 0; j < HOTSPOTS_MAX; j++) {
|
|
|
|
int dx1 = hotspots[i].dx;
|
|
|
|
int dy1 = hotspots[i].dy;
|
|
|
|
int dx2 = hotspots[j].dx;
|
|
|
|
int dy2 = hotspots[j].dy;
|
|
|
|
int correctx, correcty, newx, newy;
|
2004-10-07 19:34:56 +02:00
|
|
|
char loc[256];
|
2004-08-22 03:59:55 +02:00
|
|
|
HIMAGELIST himlNew;
|
|
|
|
POINT ppt;
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_BeginDrag(himl1, 0, dx1, dy1);
|
2004-08-22 03:59:55 +02:00
|
|
|
ok(ret != 0, "BeginDrag failed for { %d, %d }\n", dx1, dy1);
|
2004-10-07 19:34:56 +02:00
|
|
|
sprintf(loc, "BeginDrag (%d,%d)\n", i, j);
|
|
|
|
show_image(hwnd, himl1, 0, max(SIZEX1, SIZEY1), loc, TRUE);
|
|
|
|
|
2004-08-22 03:59:55 +02:00
|
|
|
/* check merging the dragged image with a second image */
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_SetDragCursorImage(himl2, 0, dx2, dy2);
|
2004-08-22 03:59:55 +02:00
|
|
|
ok(ret != 0, "SetDragCursorImage failed for {%d, %d}{%d, %d}\n",
|
|
|
|
dx1, dy1, dx2, dy2);
|
2004-10-07 19:34:56 +02:00
|
|
|
sprintf(loc, "SetDragCursorImage (%d,%d)\n", i, j);
|
|
|
|
show_image(hwnd, himl2, 0, max(SIZEX2, SIZEY2), loc, TRUE);
|
|
|
|
|
2004-08-22 03:59:55 +02:00
|
|
|
/* check new hotspot, it should be the same like the old one */
|
2017-12-22 13:30:47 +01:00
|
|
|
himlNew = pImageList_GetDragImage(NULL, &ppt);
|
2004-08-22 03:59:55 +02:00
|
|
|
ok(ppt.x == dx1 && ppt.y == dy1,
|
2006-10-13 15:17:40 +02:00
|
|
|
"Expected drag hotspot [%d,%d] got [%d,%d]\n",
|
2004-08-22 03:59:55 +02:00
|
|
|
dx1, dy1, ppt.x, ppt.y);
|
|
|
|
/* check size of new dragged image */
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_GetIconSize(himlNew, &newx, &newy);
|
2004-08-22 03:59:55 +02:00
|
|
|
correctx = max(SIZEX1, max(SIZEX2 + dx2, SIZEX1 - dx2));
|
|
|
|
correcty = max(SIZEY1, max(SIZEY2 + dy2, SIZEY1 - dy2));
|
|
|
|
ok(newx == correctx && newy == correcty,
|
|
|
|
"Expected drag image size [%d,%d] got [%d,%d]\n",
|
|
|
|
correctx, correcty, newx, newy);
|
2004-10-07 19:34:56 +02:00
|
|
|
sprintf(loc, "GetDragImage (%d,%d)\n", i, j);
|
|
|
|
show_image(hwnd, himlNew, 0, max(correctx, correcty), loc, TRUE);
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_EndDrag();
|
2004-08-22 03:59:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#undef SIZEX1
|
|
|
|
#undef SIZEY1
|
|
|
|
#undef SIZEX2
|
|
|
|
#undef SIZEY2
|
|
|
|
#undef HOTSPOTS_MAX
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(himl2);
|
|
|
|
pImageList_Destroy(himl1);
|
2004-10-07 19:34:56 +02:00
|
|
|
DestroyWindow(hwnd);
|
2004-08-22 03:59:55 +02:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:32:09 +02:00
|
|
|
static void test_add_remove(void)
|
2004-08-24 20:41:52 +02:00
|
|
|
{
|
|
|
|
HIMAGELIST himl ;
|
|
|
|
|
|
|
|
HICON hicon1 ;
|
|
|
|
HICON hicon2 ;
|
|
|
|
HICON hicon3 ;
|
|
|
|
|
|
|
|
/* create an imagelist to play with */
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(84, 84, ILC_COLOR16, 0, 3);
|
2004-09-02 22:08:15 +02:00
|
|
|
ok(himl!=0,"failed to create imagelist\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
|
|
|
|
/* load the icons to add to the image list */
|
|
|
|
hicon1 = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
|
2004-09-02 22:08:15 +02:00
|
|
|
ok(hicon1 != 0, "no hicon1\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
hicon2 = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
|
2004-09-02 22:08:15 +02:00
|
|
|
ok(hicon2 != 0, "no hicon2\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
hicon3 = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
|
2004-09-02 22:08:15 +02:00
|
|
|
ok(hicon3 != 0, "no hicon3\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
|
|
|
|
/* remove when nothing exists */
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(!pImageList_Remove(himl, 0), "Removed nonexistent icon.\n");
|
2004-09-28 21:17:43 +02:00
|
|
|
/* removing everything from an empty imagelist should succeed */
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(pImageList_Remove(himl, -1), "Removed nonexistent icon\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
|
|
|
|
/* add three */
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(0 == pImageList_ReplaceIcon(himl, -1, hicon1), "Failed to add icon1.\n");
|
|
|
|
ok(1 == pImageList_ReplaceIcon(himl, -1, hicon2), "Failed to add icon2.\n");
|
|
|
|
ok(2 == pImageList_ReplaceIcon(himl, -1, hicon3), "Failed to add icon3.\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
|
2004-09-28 21:17:43 +02:00
|
|
|
/* remove an index out of range */
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(!pImageList_Remove(himl, 4711), "removed nonexistent icon\n");
|
2004-09-28 21:17:43 +02:00
|
|
|
|
2004-08-24 20:41:52 +02:00
|
|
|
/* remove three */
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(pImageList_Remove(himl, 0), "Can't remove 0\n");
|
|
|
|
ok(pImageList_Remove(himl, 0), "Can't remove 0\n");
|
|
|
|
ok(pImageList_Remove(himl, 0), "Can't remove 0\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
|
|
|
|
/* remove one extra */
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(!pImageList_Remove(himl, 0), "Removed nonexistent icon.\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
|
|
|
|
/* destroy it */
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(pImageList_Destroy(himl), "Failed to destroy imagelist.\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(-1 == pImageList_ReplaceIcon((HIMAGELIST)0xdeadbeef, -1, hicon1), "Don't crash on bad handle\n");
|
2011-09-19 15:32:16 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(DestroyIcon(hicon1), "Failed to destroy icon 1.\n");
|
|
|
|
ok(DestroyIcon(hicon2), "Failed to destroy icon 2.\n");
|
|
|
|
ok(DestroyIcon(hicon3), "Failed to destroy icon 3.\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:32:09 +02:00
|
|
|
static void test_imagecount(void)
|
2004-08-24 20:41:52 +02:00
|
|
|
{
|
2010-08-19 07:32:09 +02:00
|
|
|
HIMAGELIST himl;
|
2004-08-24 20:41:52 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(0 == pImageList_GetImageCount((HIMAGELIST)0xdeadbeef), "don't crash on bad handle\n");
|
2011-09-19 15:32:16 +02:00
|
|
|
|
2010-08-19 07:32:09 +02:00
|
|
|
if (!pImageList_SetImageCount)
|
|
|
|
{
|
|
|
|
win_skip("ImageList_SetImageCount not available\n");
|
|
|
|
return;
|
|
|
|
}
|
2004-08-24 20:41:52 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(84, 84, ILC_COLOR16, 0, 3);
|
|
|
|
ok(himl != 0, "Failed to create imagelist.\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
|
2010-08-19 07:32:09 +02:00
|
|
|
ok(pImageList_SetImageCount(himl, 3), "couldn't increase image count\n");
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(pImageList_GetImageCount(himl) == 3, "invalid image count after increase\n");
|
2010-08-19 07:32:09 +02:00
|
|
|
ok(pImageList_SetImageCount(himl, 1), "couldn't decrease image count\n");
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(pImageList_GetImageCount(himl) == 1, "invalid image count after decrease to 1\n");
|
2010-08-19 07:32:09 +02:00
|
|
|
ok(pImageList_SetImageCount(himl, 0), "couldn't decrease image count\n");
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(pImageList_GetImageCount(himl) == 0, "invalid image count after decrease to 0\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(pImageList_Destroy(himl), "Failed to destroy imagelist.\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:32:09 +02:00
|
|
|
static void test_DrawIndirect(void)
|
2004-08-24 20:41:52 +02:00
|
|
|
{
|
2004-10-07 19:34:56 +02:00
|
|
|
HIMAGELIST himl;
|
2004-08-24 20:41:52 +02:00
|
|
|
|
2004-10-07 19:34:56 +02:00
|
|
|
HBITMAP hbm1;
|
|
|
|
HBITMAP hbm2;
|
|
|
|
HBITMAP hbm3;
|
2004-08-24 20:41:52 +02:00
|
|
|
|
|
|
|
IMAGELISTDRAWPARAMS imldp;
|
|
|
|
HDC hdc;
|
|
|
|
HWND hwndfortest;
|
|
|
|
|
2004-08-26 20:22:31 +02:00
|
|
|
if (!pImageList_DrawIndirect)
|
|
|
|
{
|
2008-10-20 22:13:32 +02:00
|
|
|
win_skip("ImageList_DrawIndirect not available, skipping test\n");
|
2010-08-19 07:32:09 +02:00
|
|
|
return;
|
2004-08-26 20:22:31 +02:00
|
|
|
}
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
hwndfortest = create_window();
|
2004-08-24 20:41:52 +02:00
|
|
|
hdc = GetDC(hwndfortest);
|
|
|
|
ok(hdc!=NULL, "couldn't get DC\n");
|
|
|
|
|
|
|
|
/* create an imagelist to play with */
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(48, 48, ILC_COLOR16, 0, 3);
|
|
|
|
ok(himl != 0, "Failed to create imagelist.\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
|
|
|
|
/* load the icons to add to the image list */
|
|
|
|
hbm1 = CreateBitmap(48, 48, 1, 1, bitmap_bits);
|
2004-09-02 22:08:15 +02:00
|
|
|
ok(hbm1 != 0, "no bitmap 1\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
hbm2 = CreateBitmap(48, 48, 1, 1, bitmap_bits);
|
2004-09-02 22:08:15 +02:00
|
|
|
ok(hbm2 != 0, "no bitmap 2\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
hbm3 = CreateBitmap(48, 48, 1, 1, bitmap_bits);
|
2004-09-02 22:08:15 +02:00
|
|
|
ok(hbm3 != 0, "no bitmap 3\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
|
|
|
|
/* add three */
|
2018-01-24 13:47:09 +01:00
|
|
|
ok(0 == pImageList_Add(himl, hbm1, 0),"failed to add bitmap 1\n");
|
|
|
|
ok(1 == pImageList_Add(himl, hbm2, 0),"failed to add bitmap 2\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
|
2007-12-10 01:25:15 +01:00
|
|
|
if (pImageList_SetImageCount)
|
|
|
|
{
|
|
|
|
ok(pImageList_SetImageCount(himl,3),"Setimage count failed\n");
|
|
|
|
/*ok(2==ImageList_Add(himl, hbm3, NULL),"failed to add bitmap 3\n"); */
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(pImageList_Replace(himl, 2, hbm3, 0),"failed to replace bitmap 3\n");
|
2007-12-10 01:25:15 +01:00
|
|
|
}
|
2004-08-24 20:41:52 +02:00
|
|
|
|
2004-10-07 19:34:56 +02:00
|
|
|
memset(&imldp, 0, sizeof (imldp));
|
2004-09-02 22:08:15 +02:00
|
|
|
ok(!pImageList_DrawIndirect(&imldp), "zero data succeeded!\n");
|
2010-08-19 07:38:36 +02:00
|
|
|
imldp.cbSize = IMAGELISTDRAWPARAMS_V3_SIZE;
|
2004-09-02 22:08:15 +02:00
|
|
|
ok(!pImageList_DrawIndirect(&imldp), "zero hdc succeeded!\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
imldp.hdcDst = hdc;
|
2004-09-02 22:08:15 +02:00
|
|
|
ok(!pImageList_DrawIndirect(&imldp),"zero himl succeeded!\n");
|
2011-09-19 15:32:16 +02:00
|
|
|
imldp.himl = (HIMAGELIST)0xdeadbeef;
|
|
|
|
ok(!pImageList_DrawIndirect(&imldp),"bad himl succeeded!\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
imldp.himl = himl;
|
2010-08-19 07:38:36 +02:00
|
|
|
|
2015-11-15 13:54:01 +01:00
|
|
|
force_redraw(hwndfortest);
|
2004-10-07 19:34:56 +02:00
|
|
|
|
2004-08-24 20:41:52 +02:00
|
|
|
imldp.fStyle = SRCCOPY;
|
|
|
|
imldp.rgbBk = CLR_DEFAULT;
|
|
|
|
imldp.rgbFg = CLR_DEFAULT;
|
|
|
|
imldp.y = 100;
|
|
|
|
imldp.x = 100;
|
2004-10-07 19:34:56 +02:00
|
|
|
ok(pImageList_DrawIndirect(&imldp),"should succeed\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
imldp.i ++;
|
2004-10-07 19:34:56 +02:00
|
|
|
ok(pImageList_DrawIndirect(&imldp),"should succeed\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
imldp.i ++;
|
2004-10-07 19:34:56 +02:00
|
|
|
ok(pImageList_DrawIndirect(&imldp),"should succeed\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
imldp.i ++;
|
2004-09-02 22:08:15 +02:00
|
|
|
ok(!pImageList_DrawIndirect(&imldp),"should fail\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
|
|
|
|
/* remove three */
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(pImageList_Remove(himl, 0), "removing 1st bitmap\n");
|
|
|
|
ok(pImageList_Remove(himl, 0), "removing 2nd bitmap\n");
|
|
|
|
ok(pImageList_Remove(himl, 0), "removing 3rd bitmap\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
|
|
|
|
/* destroy it */
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(pImageList_Destroy(himl), "Failed to destroy imagelist.\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
|
2004-10-07 19:34:56 +02:00
|
|
|
/* bitmaps should not be deleted by the imagelist */
|
2004-09-02 22:08:15 +02:00
|
|
|
ok(DeleteObject(hbm1),"bitmap 1 can't be deleted\n");
|
|
|
|
ok(DeleteObject(hbm2),"bitmap 2 can't be deleted\n");
|
|
|
|
ok(DeleteObject(hbm3),"bitmap 3 can't be deleted\n");
|
2004-08-24 20:41:52 +02:00
|
|
|
|
|
|
|
ReleaseDC(hwndfortest, hdc);
|
|
|
|
DestroyWindow(hwndfortest);
|
|
|
|
}
|
|
|
|
|
2013-02-27 21:47:43 +01:00
|
|
|
static int get_color_format(HBITMAP bmp)
|
|
|
|
{
|
|
|
|
BITMAPINFO bmi;
|
|
|
|
HDC hdc = CreateCompatibleDC(0);
|
|
|
|
HBITMAP hOldBmp = SelectObject(hdc, bmp);
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
memset(&bmi, 0, sizeof(bmi));
|
|
|
|
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
|
|
|
ret = GetDIBits(hdc, bmp, 0, 0, 0, &bmi, DIB_RGB_COLORS);
|
|
|
|
ok(ret, "GetDIBits failed\n");
|
|
|
|
|
|
|
|
SelectObject(hdc, hOldBmp);
|
|
|
|
DeleteDC(hdc);
|
|
|
|
return bmi.bmiHeader.biBitCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_merge_colors(void)
|
|
|
|
{
|
|
|
|
HIMAGELIST himl[8], hmerge;
|
|
|
|
int sizes[] = { ILC_COLOR, ILC_COLOR | ILC_MASK, ILC_COLOR4, ILC_COLOR8, ILC_COLOR16, ILC_COLOR24, ILC_COLOR32, ILC_COLORDDB };
|
|
|
|
HICON hicon1;
|
|
|
|
IMAGEINFO info;
|
|
|
|
int bpp, i, j;
|
|
|
|
|
|
|
|
hicon1 = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
|
|
|
|
ok(hicon1 != NULL, "failed to create hicon1\n");
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
{
|
2017-12-22 13:30:47 +01:00
|
|
|
himl[i] = pImageList_Create(32, 32, sizes[i], 0, 3);
|
2013-02-27 21:47:43 +01:00
|
|
|
ok(himl[i] != NULL, "failed to create himl[%d]\n", i);
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(0 == pImageList_ReplaceIcon(himl[i], -1, hicon1), "Failed to add icon1 to himl[%d].\n", i);
|
2013-02-27 21:47:43 +01:00
|
|
|
if (i == 0 || i == 1 || i == 7)
|
|
|
|
{
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_GetImageInfo(himl[i], 0, &info);
|
2013-02-27 21:47:43 +01:00
|
|
|
sizes[i] = get_color_format(info.hbmImage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DestroyIcon(hicon1);
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
for (j = 0; j < 8; j++)
|
|
|
|
{
|
2017-12-22 13:30:47 +01:00
|
|
|
hmerge = pImageList_Merge(himl[i], 0, himl[j], 0, 0, 0);
|
2013-02-27 21:47:43 +01:00
|
|
|
ok(hmerge != NULL, "merge himl[%d], himl[%d] failed\n", i, j);
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_GetImageInfo(hmerge, 0, &info);
|
2013-02-27 21:47:43 +01:00
|
|
|
bpp = get_color_format(info.hbmImage);
|
|
|
|
/* ILC_COLOR[X] is defined as [X] */
|
|
|
|
if (i == 4 && j == 7)
|
|
|
|
ok(bpp == 16, /* merging ILC_COLOR16 with ILC_COLORDDB seems to be a special case */
|
|
|
|
"wrong biBitCount %d when merging lists %d (%d) and %d (%d)\n", bpp, i, sizes[i], j, sizes[j]);
|
|
|
|
else
|
|
|
|
ok(bpp == (i > j ? sizes[i] : sizes[j]),
|
|
|
|
"wrong biBitCount %d when merging lists %d (%d) and %d (%d)\n", bpp, i, sizes[i], j, sizes[j]);
|
|
|
|
ok(info.hbmMask != 0, "Imagelist merged from %d and %d had no mask\n", i, j);
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(hmerge);
|
2013-02-27 21:47:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++)
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(himl[i]);
|
2013-02-27 21:47:43 +01:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:32:09 +02:00
|
|
|
static void test_merge(void)
|
2004-10-07 19:34:56 +02:00
|
|
|
{
|
|
|
|
HIMAGELIST himl1, himl2, hmerge;
|
|
|
|
HICON hicon1;
|
2017-12-22 13:30:47 +01:00
|
|
|
HWND hwnd = create_window();
|
2004-10-07 19:34:56 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl1 = pImageList_Create(32, 32, 0, 0, 3);
|
2004-10-07 19:34:56 +02:00
|
|
|
ok(himl1 != NULL,"failed to create himl1\n");
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl2 = pImageList_Create(32, 32, 0, 0, 3);
|
2004-10-07 19:34:56 +02:00
|
|
|
ok(himl2 != NULL,"failed to create himl2\n");
|
|
|
|
|
|
|
|
hicon1 = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
|
|
|
|
ok(hicon1 != NULL, "failed to create hicon1\n");
|
|
|
|
|
|
|
|
if (!himl1 || !himl2 || !hicon1)
|
|
|
|
return;
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(0 == pImageList_ReplaceIcon(himl2, -1, hicon1), "Failed to add icon1 to himl2.\n");
|
2004-10-07 19:34:56 +02:00
|
|
|
check_bits(hwnd, himl2, 0, 32, icon_bits, "add icon1 to himl2");
|
|
|
|
|
|
|
|
/* If himl1 has no images, merge still succeeds */
|
2017-12-22 13:30:47 +01:00
|
|
|
hmerge = pImageList_Merge(himl1, -1, himl2, 0, 0, 0);
|
2004-10-07 19:34:56 +02:00
|
|
|
ok(hmerge != NULL, "merge himl1,-1 failed\n");
|
|
|
|
check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl1,-1");
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(hmerge);
|
2004-10-07 19:34:56 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
hmerge = pImageList_Merge(himl1, 0, himl2, 0, 0, 0);
|
2004-10-07 19:34:56 +02:00
|
|
|
ok(hmerge != NULL,"merge himl1,0 failed\n");
|
|
|
|
check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl1,0");
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(hmerge);
|
2004-10-07 19:34:56 +02:00
|
|
|
|
2004-10-23 00:27:51 +02:00
|
|
|
/* Same happens if himl2 is empty */
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(himl2);
|
|
|
|
himl2 = pImageList_Create(32, 32, 0, 0, 3);
|
2004-10-07 19:34:56 +02:00
|
|
|
ok(himl2 != NULL,"failed to recreate himl2\n");
|
|
|
|
if (!himl2)
|
|
|
|
return;
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
hmerge = pImageList_Merge(himl1, -1, himl2, -1, 0, 0);
|
2004-10-07 19:34:56 +02:00
|
|
|
ok(hmerge != NULL, "merge himl2,-1 failed\n");
|
|
|
|
check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl2,-1");
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(hmerge);
|
2004-10-07 19:34:56 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
hmerge = pImageList_Merge(himl1, -1, himl2, 0, 0, 0);
|
2004-10-07 19:34:56 +02:00
|
|
|
ok(hmerge != NULL, "merge himl2,0 failed\n");
|
|
|
|
check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl2,0");
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(hmerge);
|
2004-10-07 19:34:56 +02:00
|
|
|
|
|
|
|
/* Now try merging an image with itself */
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(0 == pImageList_ReplaceIcon(himl2, -1, hicon1), "Failed to re-add icon1 to himl2.\n");
|
2004-10-07 19:34:56 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
hmerge = pImageList_Merge(himl2, 0, himl2, 0, 0, 0);
|
2004-10-07 19:34:56 +02:00
|
|
|
ok(hmerge != NULL, "merge himl2 with itself failed\n");
|
|
|
|
check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl2 with itself");
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(hmerge);
|
2004-10-07 19:34:56 +02:00
|
|
|
|
|
|
|
/* Try merging 2 different image lists */
|
2017-12-22 13:30:47 +01:00
|
|
|
ok(0 == pImageList_ReplaceIcon(himl1, -1, hicon1), "Failed to add icon1 to himl1.\n");
|
2004-10-07 19:34:56 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
hmerge = pImageList_Merge(himl1, 0, himl2, 0, 0, 0);
|
2004-10-07 19:34:56 +02:00
|
|
|
ok(hmerge != NULL, "merge himl1 with himl2 failed\n");
|
|
|
|
check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl1 with himl2");
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(hmerge);
|
2004-10-07 19:34:56 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
hmerge = pImageList_Merge(himl1, 0, himl2, 0, 8, 16);
|
2004-10-07 19:34:56 +02:00
|
|
|
ok(hmerge != NULL, "merge himl1 with himl2 8,16 failed\n");
|
|
|
|
check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl1 with himl2, 8,16");
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(hmerge);
|
2004-10-07 19:34:56 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(himl1);
|
|
|
|
pImageList_Destroy(himl2);
|
2007-02-17 21:18:58 +01:00
|
|
|
DestroyIcon(hicon1);
|
2004-10-07 19:34:56 +02:00
|
|
|
DestroyWindow(hwnd);
|
|
|
|
}
|
|
|
|
|
2007-04-23 13:39:18 +02:00
|
|
|
/*********************** imagelist storage test ***************************/
|
|
|
|
|
|
|
|
#define BMP_CX 48
|
|
|
|
|
2017-02-01 06:08:12 +01:00
|
|
|
struct memstream
|
2007-04-23 13:39:18 +02:00
|
|
|
{
|
2011-09-27 10:21:55 +02:00
|
|
|
IStream IStream_iface;
|
2017-02-01 06:08:12 +01:00
|
|
|
IStream *stream;
|
2007-04-23 13:39:18 +02:00
|
|
|
};
|
|
|
|
|
2017-02-01 06:08:12 +01:00
|
|
|
static struct memstream *impl_from_IStream(IStream *iface)
|
2011-09-27 10:21:55 +02:00
|
|
|
{
|
2017-02-01 06:08:12 +01:00
|
|
|
return CONTAINING_RECORD(iface, struct memstream, IStream_iface);
|
2011-09-27 10:21:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT STDMETHODCALLTYPE Test_Stream_QueryInterface(IStream *iface, REFIID riid,
|
|
|
|
void **ppvObject)
|
2007-04-23 13:39:18 +02:00
|
|
|
{
|
2013-07-03 12:09:07 +02:00
|
|
|
ok(0, "unexpected call\n");
|
2007-04-23 13:39:18 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2011-09-27 10:21:55 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE Test_Stream_AddRef(IStream *iface)
|
2007-04-23 13:39:18 +02:00
|
|
|
{
|
2013-07-03 12:09:07 +02:00
|
|
|
ok(0, "unexpected call\n");
|
2007-04-23 13:39:18 +02:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2011-09-27 10:21:55 +02:00
|
|
|
static ULONG STDMETHODCALLTYPE Test_Stream_Release(IStream *iface)
|
2007-04-23 13:39:18 +02:00
|
|
|
{
|
2013-07-03 12:09:07 +02:00
|
|
|
ok(0, "unexpected call\n");
|
2007-04-23 13:39:18 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-09-27 10:21:55 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE Test_Stream_Read(IStream *iface, void *pv, ULONG cb,
|
|
|
|
ULONG *pcbRead)
|
2007-04-23 13:39:18 +02:00
|
|
|
{
|
2017-02-01 06:08:12 +01:00
|
|
|
struct memstream *stream = impl_from_IStream(iface);
|
|
|
|
return IStream_Read(stream->stream, pv, cb, pcbRead);
|
2007-04-23 13:39:18 +02:00
|
|
|
}
|
|
|
|
|
2011-09-27 10:21:55 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE Test_Stream_Write(IStream *iface, const void *pv, ULONG cb,
|
|
|
|
ULONG *pcbWritten)
|
2007-04-23 13:39:18 +02:00
|
|
|
{
|
2017-02-01 06:08:12 +01:00
|
|
|
struct memstream *stream = impl_from_IStream(iface);
|
|
|
|
return IStream_Write(stream->stream, pv, cb, pcbWritten);
|
2007-04-23 13:39:18 +02:00
|
|
|
}
|
|
|
|
|
2017-12-27 11:51:38 +01:00
|
|
|
static HRESULT STDMETHODCALLTYPE Test_Stream_Seek(IStream *iface, LARGE_INTEGER offset, DWORD origin,
|
|
|
|
ULARGE_INTEGER *new_pos)
|
2007-04-23 13:39:18 +02:00
|
|
|
{
|
2017-12-27 11:51:38 +01:00
|
|
|
struct memstream *stream = impl_from_IStream(iface);
|
|
|
|
|
|
|
|
if (is_v6_test())
|
|
|
|
{
|
|
|
|
ok(origin == STREAM_SEEK_CUR, "Unexpected origin %d.\n", origin);
|
|
|
|
ok(offset.QuadPart == 0, "Unexpected offset %s.\n", wine_dbgstr_longlong(offset.QuadPart));
|
|
|
|
ok(new_pos != NULL, "Unexpected out position pointer.\n");
|
|
|
|
return IStream_Seek(stream->stream, offset, origin, new_pos);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(0, "unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2007-04-23 13:39:18 +02:00
|
|
|
}
|
|
|
|
|
2011-09-27 10:21:55 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE Test_Stream_SetSize(IStream *iface, ULARGE_INTEGER libNewSize)
|
2007-04-23 13:39:18 +02:00
|
|
|
{
|
2013-07-03 12:09:07 +02:00
|
|
|
ok(0, "unexpected call\n");
|
2007-04-23 13:39:18 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2011-09-27 10:21:55 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE Test_Stream_CopyTo(IStream *iface, IStream *pstm,
|
|
|
|
ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead,
|
|
|
|
ULARGE_INTEGER *pcbWritten)
|
2007-04-23 13:39:18 +02:00
|
|
|
{
|
2013-07-03 12:09:07 +02:00
|
|
|
ok(0, "unexpected call\n");
|
2007-04-23 13:39:18 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2011-09-27 10:21:55 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE Test_Stream_Commit(IStream *iface, DWORD grfCommitFlags)
|
2007-04-23 13:39:18 +02:00
|
|
|
{
|
2013-07-03 12:09:07 +02:00
|
|
|
ok(0, "unexpected call\n");
|
2007-04-23 13:39:18 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2011-09-27 10:21:55 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE Test_Stream_Revert(IStream *iface)
|
2007-04-23 13:39:18 +02:00
|
|
|
{
|
2013-07-03 12:09:07 +02:00
|
|
|
ok(0, "unexpected call\n");
|
2007-04-23 13:39:18 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2011-09-27 10:21:55 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE Test_Stream_LockRegion(IStream *iface, ULARGE_INTEGER libOffset,
|
|
|
|
ULARGE_INTEGER cb, DWORD dwLockType)
|
2007-04-23 13:39:18 +02:00
|
|
|
{
|
2013-07-03 12:09:07 +02:00
|
|
|
ok(0, "unexpected call\n");
|
2007-04-23 13:39:18 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2011-09-27 10:21:55 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE Test_Stream_UnlockRegion(IStream *iface, ULARGE_INTEGER libOffset,
|
|
|
|
ULARGE_INTEGER cb, DWORD dwLockType)
|
2007-04-23 13:39:18 +02:00
|
|
|
{
|
2013-07-03 12:09:07 +02:00
|
|
|
ok(0, "unexpected call\n");
|
2007-04-23 13:39:18 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2011-09-27 10:21:55 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE Test_Stream_Stat(IStream *iface, STATSTG *pstatstg,
|
|
|
|
DWORD grfStatFlag)
|
2007-04-23 13:39:18 +02:00
|
|
|
{
|
2013-07-03 12:09:07 +02:00
|
|
|
ok(0, "unexpected call\n");
|
2007-04-23 13:39:18 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2011-09-27 10:21:55 +02:00
|
|
|
static HRESULT STDMETHODCALLTYPE Test_Stream_Clone(IStream *iface, IStream **ppstm)
|
2007-04-23 13:39:18 +02:00
|
|
|
{
|
2013-07-03 12:09:07 +02:00
|
|
|
ok(0, "unexpected call\n");
|
2007-04-23 13:39:18 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IStreamVtbl Test_Stream_Vtbl =
|
|
|
|
{
|
|
|
|
Test_Stream_QueryInterface,
|
|
|
|
Test_Stream_AddRef,
|
|
|
|
Test_Stream_Release,
|
|
|
|
Test_Stream_Read,
|
|
|
|
Test_Stream_Write,
|
|
|
|
Test_Stream_Seek,
|
|
|
|
Test_Stream_SetSize,
|
|
|
|
Test_Stream_CopyTo,
|
|
|
|
Test_Stream_Commit,
|
|
|
|
Test_Stream_Revert,
|
|
|
|
Test_Stream_LockRegion,
|
|
|
|
Test_Stream_UnlockRegion,
|
|
|
|
Test_Stream_Stat,
|
|
|
|
Test_Stream_Clone
|
|
|
|
};
|
|
|
|
|
2017-02-01 06:08:12 +01:00
|
|
|
static void init_memstream(struct memstream *stream)
|
|
|
|
{
|
2017-12-28 13:20:17 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
2017-02-01 06:08:12 +01:00
|
|
|
stream->IStream_iface.lpVtbl = &Test_Stream_Vtbl;
|
2017-12-28 13:20:17 +01:00
|
|
|
hr = CreateStreamOnHGlobal(NULL, TRUE, &stream->stream);
|
|
|
|
ok(hr == S_OK, "Failed to create a stream, hr %#x.\n", hr);
|
2017-02-01 06:08:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cleanup_memstream(struct memstream *stream)
|
|
|
|
{
|
|
|
|
IStream_Release(stream->stream);
|
|
|
|
}
|
|
|
|
|
2007-04-23 13:39:18 +02:00
|
|
|
static INT DIB_GetWidthBytes( int width, int bpp )
|
|
|
|
{
|
2011-08-29 12:03:27 +02:00
|
|
|
return ((width * bpp + 31) / 8) & ~3;
|
2007-04-23 13:39:18 +02:00
|
|
|
}
|
|
|
|
|
2017-12-27 11:51:38 +01:00
|
|
|
static ULONG check_bitmap_data(const ILHEAD *header, const char *bm_data,
|
|
|
|
ULONG bm_data_size, const SIZE *bmpsize, INT bpp, const char *comment)
|
2007-04-23 13:39:18 +02:00
|
|
|
{
|
|
|
|
const BITMAPFILEHEADER *bmfh = (const BITMAPFILEHEADER *)bm_data;
|
|
|
|
const BITMAPINFOHEADER *bmih = (const BITMAPINFOHEADER *)(bm_data + sizeof(*bmfh));
|
|
|
|
ULONG hdr_size, image_size;
|
|
|
|
|
|
|
|
hdr_size = sizeof(*bmfh) + sizeof(*bmih);
|
|
|
|
if (bmih->biBitCount <= 8) hdr_size += (1 << bpp) * sizeof(RGBQUAD);
|
|
|
|
|
|
|
|
ok(bmfh->bfType == (('M' << 8) | 'B'), "wrong bfType 0x%02x\n", bmfh->bfType);
|
|
|
|
ok(bmfh->bfSize == hdr_size, "wrong bfSize 0x%02x\n", bmfh->bfSize);
|
|
|
|
ok(bmfh->bfReserved1 == 0, "wrong bfReserved1 0x%02x\n", bmfh->bfReserved1);
|
|
|
|
ok(bmfh->bfReserved2 == 0, "wrong bfReserved2 0x%02x\n", bmfh->bfReserved2);
|
|
|
|
ok(bmfh->bfOffBits == hdr_size, "wrong bfOffBits 0x%02x\n", bmfh->bfOffBits);
|
|
|
|
|
|
|
|
ok(bmih->biSize == sizeof(*bmih), "wrong biSize %d\n", bmih->biSize);
|
|
|
|
ok(bmih->biPlanes == 1, "wrong biPlanes %d\n", bmih->biPlanes);
|
|
|
|
ok(bmih->biBitCount == bpp, "wrong biBitCount %d\n", bmih->biBitCount);
|
|
|
|
|
|
|
|
image_size = DIB_GetWidthBytes(bmih->biWidth, bmih->biBitCount) * bmih->biHeight;
|
|
|
|
ok(bmih->biSizeImage == image_size, "wrong biSizeImage %u\n", bmih->biSizeImage);
|
2017-12-27 11:51:38 +01:00
|
|
|
ok(bmih->biWidth == bmpsize->cx && bmih->biHeight == bmpsize->cy, "Unexpected bitmap size %d x %d, "
|
|
|
|
"expected %d x %d\n", bmih->biWidth, bmih->biHeight, bmpsize->cx, bmpsize->cy);
|
2014-01-22 22:32:17 +01:00
|
|
|
|
|
|
|
if (0)
|
2007-04-23 13:39:18 +02:00
|
|
|
{
|
|
|
|
char fname[256];
|
|
|
|
FILE *f;
|
|
|
|
sprintf(fname, "bmp_%s.bmp", comment);
|
|
|
|
f = fopen(fname, "wb");
|
|
|
|
fwrite(bm_data, 1, bm_data_size, f);
|
|
|
|
fclose(f);
|
|
|
|
}
|
2014-01-22 22:32:17 +01:00
|
|
|
|
2011-12-16 13:07:45 +01:00
|
|
|
return hdr_size + image_size;
|
2007-04-23 13:39:18 +02:00
|
|
|
}
|
|
|
|
|
2017-12-27 11:51:38 +01:00
|
|
|
static BOOL is_v6_header(const ILHEAD *header)
|
2007-04-23 13:39:18 +02:00
|
|
|
{
|
2017-12-27 11:51:38 +01:00
|
|
|
return (header->usVersion & 0xff00) == 0x600;
|
|
|
|
}
|
2007-04-23 13:39:18 +02:00
|
|
|
|
2017-12-27 11:51:38 +01:00
|
|
|
static void check_ilhead_data(const ILHEAD *ilh, INT cx, INT cy, INT cur, INT max, INT grow, INT flags)
|
|
|
|
{
|
2018-01-23 12:44:21 +01:00
|
|
|
INT grow_aligned;
|
|
|
|
|
2007-04-23 13:39:18 +02:00
|
|
|
ok(ilh->usMagic == IMAGELIST_MAGIC, "wrong usMagic %4x (expected %02x)\n", ilh->usMagic, IMAGELIST_MAGIC);
|
2017-12-27 11:51:38 +01:00
|
|
|
ok(ilh->usVersion == 0x101 ||
|
|
|
|
ilh->usVersion == 0x600 || /* WinXP/W2k3 */
|
|
|
|
ilh->usVersion == 0x620, "Unknown usVersion %#x.\n", ilh->usVersion);
|
2007-04-23 13:39:18 +02:00
|
|
|
ok(ilh->cCurImage == cur, "wrong cCurImage %d (expected %d)\n", ilh->cCurImage, cur);
|
2018-01-23 12:44:21 +01:00
|
|
|
|
|
|
|
grow = max(grow, 1);
|
|
|
|
grow_aligned = (WORD)(grow + 3) & ~3;
|
|
|
|
|
|
|
|
if (is_v6_header(ilh))
|
2017-12-27 11:51:38 +01:00
|
|
|
{
|
2018-01-23 12:44:21 +01:00
|
|
|
grow = (WORD)(grow + 2 + 3) & ~3;
|
|
|
|
ok(ilh->cGrow == grow || broken(ilh->cGrow == grow_aligned) /* XP/Vista */,
|
|
|
|
"Unexpected cGrow %d, expected %d\n", ilh->cGrow, grow);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-12-27 11:51:38 +01:00
|
|
|
ok(ilh->cMaxImage == max, "wrong cMaxImage %d (expected %d)\n", ilh->cMaxImage, max);
|
2018-01-23 12:44:21 +01:00
|
|
|
ok(ilh->cGrow == grow_aligned, "Unexpected cGrow %d, expected %d\n", ilh->cGrow, grow_aligned);
|
2017-12-27 11:51:38 +01:00
|
|
|
}
|
2018-01-23 12:44:21 +01:00
|
|
|
|
2007-04-23 13:39:18 +02:00
|
|
|
ok(ilh->cx == cx, "wrong cx %d (expected %d)\n", ilh->cx, cx);
|
|
|
|
ok(ilh->cy == cy, "wrong cy %d (expected %d)\n", ilh->cy, cy);
|
|
|
|
ok(ilh->bkcolor == CLR_NONE, "wrong bkcolor %x\n", ilh->bkcolor);
|
2011-12-16 19:47:27 +01:00
|
|
|
ok(ilh->flags == flags || broken(!(ilh->flags & 0xfe) && (flags & 0xfe) == ILC_COLOR4), /* <= w2k */
|
|
|
|
"wrong flags %04x\n", ilh->flags);
|
2011-09-27 10:25:00 +02:00
|
|
|
ok(ilh->ovls[0] == -1, "wrong ovls[0] %04x\n", ilh->ovls[0]);
|
|
|
|
ok(ilh->ovls[1] == -1, "wrong ovls[1] %04x\n", ilh->ovls[1]);
|
|
|
|
ok(ilh->ovls[2] == -1, "wrong ovls[2] %04x\n", ilh->ovls[2]);
|
|
|
|
ok(ilh->ovls[3] == -1, "wrong ovls[3] %04x\n", ilh->ovls[3]);
|
2007-04-23 13:39:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HBITMAP create_bitmap(INT cx, INT cy, COLORREF color, const char *comment)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
2012-12-11 22:18:15 +01:00
|
|
|
BITMAPINFO bmi;
|
2007-04-23 13:39:18 +02:00
|
|
|
HBITMAP hbmp, hbmp_old;
|
|
|
|
HBRUSH hbrush;
|
|
|
|
RECT rc = { 0, 0, cx, cy };
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
|
2012-12-11 22:18:15 +01:00
|
|
|
memset(&bmi, 0, sizeof(bmi));
|
|
|
|
bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
|
|
|
|
bmi.bmiHeader.biHeight = cx;
|
|
|
|
bmi.bmiHeader.biWidth = cy;
|
|
|
|
bmi.bmiHeader.biBitCount = 24;
|
|
|
|
bmi.bmiHeader.biPlanes = 1;
|
|
|
|
bmi.bmiHeader.biCompression = BI_RGB;
|
|
|
|
hbmp = CreateDIBSection(hdc, &bmi, DIB_RGB_COLORS, NULL, NULL, 0);
|
2007-04-23 13:39:18 +02:00
|
|
|
|
|
|
|
hbmp_old = SelectObject(hdc, hbmp);
|
|
|
|
|
|
|
|
hbrush = CreateSolidBrush(color);
|
|
|
|
FillRect(hdc, &rc, hbrush);
|
|
|
|
DeleteObject(hbrush);
|
|
|
|
|
2013-10-22 17:12:18 +02:00
|
|
|
DrawTextA(hdc, comment, -1, &rc, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
|
2007-04-23 13:39:18 +02:00
|
|
|
|
|
|
|
SelectObject(hdc, hbmp_old);
|
|
|
|
DeleteDC(hdc);
|
|
|
|
|
|
|
|
return hbmp;
|
|
|
|
}
|
|
|
|
|
2017-12-27 11:51:38 +01:00
|
|
|
static inline void imagelist_get_bitmap_size(const ILHEAD *header, SIZE *sz)
|
|
|
|
{
|
|
|
|
const int tile_count = 4;
|
|
|
|
|
|
|
|
if (is_v6_header(header))
|
|
|
|
{
|
|
|
|
sz->cx = header->cx;
|
|
|
|
sz->cy = header->cMaxImage * header->cy;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sz->cx = header->cx * tile_count;
|
|
|
|
sz->cy = ((header->cMaxImage + tile_count - 1) / tile_count) * header->cy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-23 12:44:21 +01:00
|
|
|
/* Grow argument matches what was used when imagelist was created. */
|
2010-06-23 10:57:39 +02:00
|
|
|
static void check_iml_data(HIMAGELIST himl, INT cx, INT cy, INT cur, INT max, INT grow,
|
2017-12-27 11:51:38 +01:00
|
|
|
INT flags, const char *comment)
|
2007-04-23 13:39:18 +02:00
|
|
|
{
|
2011-12-16 13:07:45 +01:00
|
|
|
INT ret, cxx, cyy, size;
|
2017-02-01 06:08:12 +01:00
|
|
|
struct memstream stream;
|
2017-12-27 11:51:38 +01:00
|
|
|
const ILHEAD *header;
|
2017-02-01 06:08:12 +01:00
|
|
|
LARGE_INTEGER mv;
|
|
|
|
HIMAGELIST himl2;
|
|
|
|
HGLOBAL hglobal;
|
|
|
|
STATSTG stat;
|
|
|
|
char *data;
|
|
|
|
HRESULT hr;
|
2017-12-27 11:51:38 +01:00
|
|
|
SIZE bmpsize;
|
|
|
|
BOOL b;
|
2007-04-24 11:33:59 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_GetImageCount(himl);
|
2017-04-21 13:03:57 +02:00
|
|
|
ok(ret == cur, "%s: expected image count %d got %d\n", comment, cur, ret);
|
2007-04-24 11:33:59 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_GetIconSize(himl, &cxx, &cyy);
|
2007-04-24 11:33:59 +02:00
|
|
|
ok(ret, "ImageList_GetIconSize failed\n");
|
2017-04-21 13:03:57 +02:00
|
|
|
ok(cxx == cx, "%s: wrong cx %d (expected %d)\n", comment, cxx, cx);
|
|
|
|
ok(cyy == cy, "%s: wrong cy %d (expected %d)\n", comment, cyy, cy);
|
2007-04-23 13:39:18 +02:00
|
|
|
|
2017-02-01 06:08:12 +01:00
|
|
|
init_memstream(&stream);
|
2017-12-27 11:51:38 +01:00
|
|
|
b = pImageList_Write(himl, &stream.IStream_iface);
|
|
|
|
ok(b, "%s: ImageList_Write failed\n", comment);
|
2007-04-23 13:39:18 +02:00
|
|
|
|
2017-02-01 06:08:12 +01:00
|
|
|
hr = GetHGlobalFromStream(stream.stream, &hglobal);
|
2017-04-21 13:03:57 +02:00
|
|
|
ok(hr == S_OK, "%s: Failed to get hglobal, %#x\n", comment, hr);
|
2017-02-01 06:08:12 +01:00
|
|
|
|
2017-12-28 13:20:17 +01:00
|
|
|
hr = IStream_Stat(stream.stream, &stat, STATFLAG_NONAME);
|
|
|
|
ok(hr == S_OK, "Stat() failed, hr %#x.\n", hr);
|
2007-04-23 13:39:18 +02:00
|
|
|
|
2017-02-01 06:08:12 +01:00
|
|
|
data = GlobalLock(hglobal);
|
|
|
|
|
2017-04-21 13:03:57 +02:00
|
|
|
ok(data != 0, "%s: ImageList_Write didn't write any data\n", comment);
|
|
|
|
ok(stat.cbSize.LowPart > sizeof(ILHEAD), "%s: ImageList_Write wrote not enough data\n", comment);
|
2017-02-01 06:08:12 +01:00
|
|
|
|
2017-12-27 11:51:38 +01:00
|
|
|
header = (const ILHEAD *)data;
|
|
|
|
check_ilhead_data(header, cx, cy, cur, max, grow, flags);
|
|
|
|
imagelist_get_bitmap_size(header, &bmpsize);
|
|
|
|
size = check_bitmap_data(header, data + sizeof(ILHEAD), stat.cbSize.LowPart - sizeof(ILHEAD),
|
|
|
|
&bmpsize, flags & 0xfe, comment);
|
|
|
|
if (!is_v6_header(header) && size < stat.cbSize.LowPart - sizeof(ILHEAD)) /* mask is present */
|
2011-12-16 13:07:45 +01:00
|
|
|
{
|
2017-04-21 13:03:57 +02:00
|
|
|
ok( flags & ILC_MASK, "%s: extra data %u/%u but mask not expected\n", comment, stat.cbSize.LowPart, size );
|
2017-12-27 11:51:38 +01:00
|
|
|
check_bitmap_data(header, data + sizeof(ILHEAD) + size, stat.cbSize.LowPart - sizeof(ILHEAD) - size,
|
|
|
|
&bmpsize, 1, comment);
|
2011-12-16 13:07:45 +01:00
|
|
|
}
|
2017-02-01 06:08:12 +01:00
|
|
|
|
|
|
|
/* rewind and reconstruct from stream */
|
|
|
|
mv.QuadPart = 0;
|
|
|
|
IStream_Seek(stream.stream, mv, STREAM_SEEK_SET, NULL);
|
2017-12-22 13:30:47 +01:00
|
|
|
himl2 = pImageList_Read(&stream.IStream_iface);
|
2017-04-21 13:03:57 +02:00
|
|
|
ok(himl2 != NULL, "%s: Failed to deserialize imagelist\n", comment);
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(himl2);
|
2017-02-01 06:08:12 +01:00
|
|
|
|
|
|
|
GlobalUnlock(hglobal);
|
|
|
|
cleanup_memstream(&stream);
|
2007-04-23 13:39:18 +02:00
|
|
|
}
|
|
|
|
|
2018-01-23 12:44:20 +01:00
|
|
|
static void image_list_add_bitmap(HIMAGELIST himl, BYTE grey, int i)
|
2010-06-23 10:57:39 +02:00
|
|
|
{
|
|
|
|
char comment[16];
|
2018-01-23 12:44:20 +01:00
|
|
|
HBITMAP hbm;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
sprintf(comment, "%d", i);
|
|
|
|
hbm = create_bitmap(BMP_CX, BMP_CX, RGB(grey, grey, grey), comment);
|
|
|
|
ret = pImageList_Add(himl, hbm, NULL);
|
|
|
|
ok(ret != -1, "Failed to add image to imagelist.\n");
|
|
|
|
DeleteObject(hbm);
|
|
|
|
}
|
|
|
|
|
2018-01-23 12:44:21 +01:00
|
|
|
static void image_list_init(HIMAGELIST himl, INT grow)
|
2018-01-23 12:44:20 +01:00
|
|
|
{
|
|
|
|
unsigned int i;
|
2010-06-23 10:57:39 +02:00
|
|
|
static const struct test_data
|
|
|
|
{
|
|
|
|
BYTE grey;
|
2018-01-23 12:44:21 +01:00
|
|
|
INT cx, cy, cur, max, bpp;
|
2010-06-23 10:57:39 +02:00
|
|
|
const char *comment;
|
|
|
|
} td[] =
|
|
|
|
{
|
2018-01-23 12:44:21 +01:00
|
|
|
{ 255, BMP_CX, BMP_CX, 1, 2, 24, "total 1" },
|
|
|
|
{ 170, BMP_CX, BMP_CX, 2, 7, 24, "total 2" },
|
|
|
|
{ 85, BMP_CX, BMP_CX, 3, 7, 24, "total 3" },
|
|
|
|
{ 0, BMP_CX, BMP_CX, 4, 7, 24, "total 4" },
|
|
|
|
{ 0, BMP_CX, BMP_CX, 5, 7, 24, "total 5" },
|
|
|
|
{ 85, BMP_CX, BMP_CX, 6, 7, 24, "total 6" },
|
|
|
|
{ 170, BMP_CX, BMP_CX, 7, 12, 24, "total 7" },
|
|
|
|
{ 255, BMP_CX, BMP_CX, 8, 12, 24, "total 8" },
|
|
|
|
{ 255, BMP_CX, BMP_CX, 9, 12, 24, "total 9" },
|
|
|
|
{ 170, BMP_CX, BMP_CX, 10, 12, 24, "total 10" },
|
|
|
|
{ 85, BMP_CX, BMP_CX, 11, 12, 24, "total 11" },
|
|
|
|
{ 0, BMP_CX, BMP_CX, 12, 17, 24, "total 12" },
|
|
|
|
{ 0, BMP_CX, BMP_CX, 13, 17, 24, "total 13" },
|
|
|
|
{ 85, BMP_CX, BMP_CX, 14, 17, 24, "total 14" },
|
|
|
|
{ 170, BMP_CX, BMP_CX, 15, 17, 24, "total 15" },
|
|
|
|
{ 255, BMP_CX, BMP_CX, 16, 17, 24, "total 16" },
|
|
|
|
{ 255, BMP_CX, BMP_CX, 17, 22, 24, "total 17" },
|
|
|
|
{ 170, BMP_CX, BMP_CX, 18, 22, 24, "total 18" },
|
|
|
|
{ 85, BMP_CX, BMP_CX, 19, 22, 24, "total 19" },
|
|
|
|
{ 0, BMP_CX, BMP_CX, 20, 22, 24, "total 20" },
|
|
|
|
{ 0, BMP_CX, BMP_CX, 21, 22, 24, "total 21" },
|
|
|
|
{ 85, BMP_CX, BMP_CX, 22, 27, 24, "total 22" },
|
|
|
|
{ 170, BMP_CX, BMP_CX, 23, 27, 24, "total 23" },
|
|
|
|
{ 255, BMP_CX, BMP_CX, 24, 27, 24, "total 24" }
|
2010-06-23 10:57:39 +02:00
|
|
|
};
|
|
|
|
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 2, grow, ILC_COLOR24, "total 0");
|
2010-06-23 10:57:39 +02:00
|
|
|
|
2018-06-06 20:36:15 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(td); i++)
|
2010-06-23 10:57:39 +02:00
|
|
|
{
|
2018-01-23 12:44:20 +01:00
|
|
|
image_list_add_bitmap(himl, td[i].grey, i + 1);
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, td[i].cx, td[i].cy, td[i].cur, td[i].max, grow, td[i].bpp, td[i].comment);
|
2010-06-23 10:57:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-23 13:39:18 +02:00
|
|
|
static void test_imagelist_storage(void)
|
|
|
|
{
|
|
|
|
HIMAGELIST himl;
|
2018-01-23 12:44:21 +01:00
|
|
|
INT ret, grow;
|
2010-06-23 10:57:39 +02:00
|
|
|
HBITMAP hbm;
|
2011-12-16 13:07:45 +01:00
|
|
|
HICON icon;
|
2007-04-23 13:39:18 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR24, 1, 1);
|
2007-04-23 13:39:18 +02:00
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
|
|
|
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 2, 1, ILC_COLOR24, "empty");
|
2007-04-23 13:39:18 +02:00
|
|
|
|
2018-01-23 12:44:21 +01:00
|
|
|
image_list_init(himl, 1);
|
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 24, 27, 1, ILC_COLOR24, "orig");
|
2007-04-23 13:39:18 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Remove(himl, 4);
|
2007-04-23 13:39:18 +02:00
|
|
|
ok(ret, "ImageList_Remove failed\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 23, 27, 1, ILC_COLOR24, "1");
|
2007-04-23 13:39:18 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Remove(himl, 5);
|
2007-04-23 13:39:18 +02:00
|
|
|
ok(ret, "ImageList_Remove failed\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 22, 27, 1, ILC_COLOR24, "2");
|
2007-04-23 13:39:18 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Remove(himl, 6);
|
2007-04-23 13:39:18 +02:00
|
|
|
ok(ret, "ImageList_Remove failed\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 21, 27, 1, ILC_COLOR24, "3");
|
2007-04-23 13:39:18 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Remove(himl, 7);
|
2007-04-23 13:39:18 +02:00
|
|
|
ok(ret, "ImageList_Remove failed\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 20, 27, 1, ILC_COLOR24, "4");
|
2007-04-23 13:39:18 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Remove(himl, -2);
|
2007-04-24 11:33:59 +02:00
|
|
|
ok(!ret, "ImageList_Remove(-2) should fail\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 20, 27, 1, ILC_COLOR24, "5");
|
2007-04-24 11:33:59 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Remove(himl, 20);
|
2007-04-24 11:33:59 +02:00
|
|
|
ok(!ret, "ImageList_Remove(20) should fail\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 20, 27, 1, ILC_COLOR24, "6");
|
2007-04-24 11:33:59 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Remove(himl, -1);
|
2007-04-24 11:33:59 +02:00
|
|
|
ok(ret, "ImageList_Remove(-1) failed\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 4, 1, ILC_COLOR24, "7");
|
2007-04-24 11:33:59 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Destroy(himl);
|
2007-04-23 13:39:18 +02:00
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
|
|
|
|
2010-06-23 10:57:39 +02:00
|
|
|
/* test ImageList_Create storage allocation */
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR24, 0, 32);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
2017-12-27 11:51:38 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 1, 32, ILC_COLOR24, "init 0 grow 32");
|
2010-06-23 10:57:39 +02:00
|
|
|
hbm = create_bitmap(BMP_CX * 9, BMP_CX, 0, "9");
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Add(himl, hbm, NULL);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(ret == 0, "ImageList_Add returned %d, expected 0\n", ret);
|
2017-12-27 11:51:38 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 1, 34, 32, ILC_COLOR24, "add 1 x 9");
|
2010-06-23 10:57:39 +02:00
|
|
|
DeleteObject(hbm);
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Destroy(himl);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR24, 4, 4);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
2017-12-27 11:51:38 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 5, 4, ILC_COLOR24, "init 4 grow 4");
|
2010-06-23 10:57:39 +02:00
|
|
|
hbm = create_bitmap(BMP_CX, BMP_CX * 9, 0, "9");
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Add(himl, hbm, NULL);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(ret == 0, "ImageList_Add returned %d, expected 0\n", ret);
|
2017-12-27 11:51:38 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 9, 15, 4, ILC_COLOR24, "add 9 x 1");
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Add(himl, hbm, NULL);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(ret == 9, "ImageList_Add returned %d, expected 9\n", ret);
|
2017-12-27 11:51:38 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 18, 25, 4, ILC_COLOR24, "add 9 x 1");
|
2010-06-23 10:57:39 +02:00
|
|
|
DeleteObject(hbm);
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Destroy(himl);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR24, 207, 209);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 208, 209, ILC_COLOR24, "init 207 grow 209");
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Destroy(himl);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR24, 209, 207);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 210, 207, ILC_COLOR24, "init 209 grow 207");
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Destroy(himl);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR24, 14, 4);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
2017-12-27 11:51:38 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 15, 4, ILC_COLOR24, "init 14 grow 4");
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Destroy(himl);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR24, 5, 9);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 6, 9, ILC_COLOR24, "init 5 grow 9");
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Destroy(himl);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR24, 9, 5);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 10, 5, ILC_COLOR24, "init 9 grow 5");
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Destroy(himl);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR24, 2, 4);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
2017-12-27 11:51:38 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 3, 4, ILC_COLOR24, "init 2 grow 4");
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Destroy(himl);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR24, 4, 2);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 5, 2, ILC_COLOR24, "init 4 grow 2");
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Destroy(himl);
|
2011-12-16 13:07:45 +01:00
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR8, 4, 2);
|
2011-12-16 13:07:45 +01:00
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 5, 2, ILC_COLOR8, "bpp 8");
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Destroy(himl);
|
2011-12-16 13:07:45 +01:00
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR4, 4, 2);
|
2011-12-16 13:07:45 +01:00
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 5, 2, ILC_COLOR4, "bpp 4");
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Destroy(himl);
|
2011-12-16 13:07:45 +01:00
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(BMP_CX, BMP_CX, 0, 4, 2);
|
2011-12-16 13:07:45 +01:00
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 5, 2, ILC_COLOR4, "bpp default");
|
2011-12-16 13:07:45 +01:00
|
|
|
icon = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
|
2017-12-22 13:30:47 +01:00
|
|
|
ok( pImageList_ReplaceIcon(himl, -1, icon) == 0, "Failed to add icon.\n");
|
|
|
|
ok( pImageList_ReplaceIcon(himl, -1, icon) == 1, "Failed to add icon.\n");
|
2011-12-16 13:07:45 +01:00
|
|
|
DestroyIcon( icon );
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 2, 5, 2, ILC_COLOR4, "bpp default");
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Destroy(himl);
|
2011-12-16 13:07:45 +01:00
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR24|ILC_MASK, 4, 2);
|
2011-12-16 13:07:45 +01:00
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 5, 2, ILC_COLOR24|ILC_MASK, "bpp 24 + mask");
|
2011-12-16 13:07:45 +01:00
|
|
|
icon = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
|
2017-12-22 13:30:47 +01:00
|
|
|
ok( pImageList_ReplaceIcon(himl, -1, icon) == 0, "Failed to add icon.\n");
|
|
|
|
ok( pImageList_ReplaceIcon(himl, -1, icon) == 1, "Failed to add icon.\n");
|
2011-12-16 13:07:45 +01:00
|
|
|
DestroyIcon( icon );
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 2, 5, 2, ILC_COLOR24|ILC_MASK, "bpp 24 + mask");
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Destroy(himl);
|
2011-12-16 13:07:45 +01:00
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR4|ILC_MASK, 4, 2);
|
2011-12-16 13:07:45 +01:00
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 5, 2, ILC_COLOR4|ILC_MASK, "bpp 4 + mask");
|
2011-12-16 13:07:45 +01:00
|
|
|
icon = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
|
2017-12-22 13:30:47 +01:00
|
|
|
ok( pImageList_ReplaceIcon(himl, -1, icon) == 0, "Failed to add icon.\n");
|
|
|
|
ok( pImageList_ReplaceIcon(himl, -1, icon) == 1, "Failed to add icon.\n");
|
2011-12-16 13:07:45 +01:00
|
|
|
DestroyIcon( icon );
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 2, 5, 2, ILC_COLOR4|ILC_MASK, "bpp 4 + mask");
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Destroy(himl);
|
2010-06-23 10:57:39 +02:00
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
2012-01-11 12:32:14 +01:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR4|ILC_MASK, 2, 99);
|
2012-01-11 12:32:14 +01:00
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 3, 99, ILC_COLOR4|ILC_MASK, "init 2 grow 99");
|
2012-01-11 12:32:14 +01:00
|
|
|
icon = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
|
2017-12-22 13:30:47 +01:00
|
|
|
ok( pImageList_ReplaceIcon(himl, -1, icon) == 0, "Failed to add icon.\n");
|
|
|
|
ok( pImageList_ReplaceIcon(himl, -1, icon) == 1, "Failed to add icon.\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 2, 3, 99, ILC_COLOR4|ILC_MASK, "init 2 grow 99 2 icons");
|
2017-12-22 13:30:47 +01:00
|
|
|
ok( pImageList_ReplaceIcon(himl, -1, icon) == 2, "Failed to add icon\n");
|
2012-01-11 12:32:14 +01:00
|
|
|
DestroyIcon( icon );
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 3, 104, 99, ILC_COLOR4|ILC_MASK, "init 2 grow 99 3 icons");
|
2017-12-22 13:30:47 +01:00
|
|
|
ok( pImageList_Remove(himl, -1) == TRUE, "Failed to remove icon.\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 100, 99, ILC_COLOR4|ILC_MASK, "init 2 grow 99 empty");
|
2017-12-22 13:30:47 +01:00
|
|
|
ok( pImageList_SetImageCount(himl, 22) == TRUE, "Failed to set image count.\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 22, 23, 99, ILC_COLOR4|ILC_MASK, "init 2 grow 99 set count 22");
|
2017-12-22 13:30:47 +01:00
|
|
|
ok( pImageList_SetImageCount(himl, 0) == TRUE, "Failed to set image count.\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 1, 99, ILC_COLOR4|ILC_MASK, "init 2 grow 99 set count 0");
|
2017-12-22 13:30:47 +01:00
|
|
|
ok( pImageList_SetImageCount(himl, 42) == TRUE, "Failed to set image count.\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 42, 43, 99, ILC_COLOR4|ILC_MASK, "init 2 grow 99 set count 42");
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Destroy(himl);
|
2012-01-11 12:32:14 +01:00
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
|
|
|
|
2018-01-23 12:44:21 +01:00
|
|
|
for (grow = 1; grow <= 16; grow++)
|
|
|
|
{
|
|
|
|
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR4|ILC_MASK, 2, grow);
|
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 3, grow, ILC_COLOR4|ILC_MASK, "grow test");
|
|
|
|
ret = pImageList_Destroy(himl);
|
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
|
|
|
}
|
|
|
|
|
2017-12-27 11:51:38 +01:00
|
|
|
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR4|ILC_MASK, 2, -20);
|
2012-01-11 12:32:14 +01:00
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 3, -20, ILC_COLOR4|ILC_MASK, "init 2 grow -20");
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Destroy(himl);
|
2012-01-11 12:32:14 +01:00
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
|
|
|
|
2017-12-27 11:51:38 +01:00
|
|
|
/* Version 6 implementation hangs on large grow values. */
|
|
|
|
if (!is_v6_test())
|
|
|
|
{
|
|
|
|
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR4|ILC_MASK, 2, 65536+12);
|
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 3, 65536+12, ILC_COLOR4|ILC_MASK, "init 2 grow 65536+12");
|
2017-12-27 11:51:38 +01:00
|
|
|
ret = pImageList_Destroy(himl);
|
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
2012-01-11 12:32:14 +01:00
|
|
|
|
2017-12-27 11:51:38 +01:00
|
|
|
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR4|ILC_MASK, 2, 65535);
|
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
2018-01-23 12:44:21 +01:00
|
|
|
check_iml_data(himl, BMP_CX, BMP_CX, 0, 3, 65535, ILC_COLOR4|ILC_MASK, "init 2 grow 65535");
|
2017-12-27 11:51:38 +01:00
|
|
|
ret = pImageList_Destroy(himl);
|
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
|
|
|
}
|
2007-04-23 13:39:18 +02:00
|
|
|
}
|
|
|
|
|
2009-08-12 22:51:28 +02:00
|
|
|
static void test_shell_imagelist(void)
|
|
|
|
{
|
2015-10-13 23:15:32 +02:00
|
|
|
HRESULT (WINAPI *pSHGetImageList)(INT, REFIID, void**);
|
2009-08-12 22:51:28 +02:00
|
|
|
IImageList *iml = NULL;
|
|
|
|
HMODULE hShell32;
|
|
|
|
HRESULT hr;
|
|
|
|
int out = 0;
|
|
|
|
RECT rect;
|
2009-11-18 22:35:07 +01:00
|
|
|
int cx, cy;
|
2009-08-12 22:51:28 +02:00
|
|
|
|
|
|
|
/* Try to load function from shell32 */
|
2013-10-01 23:09:53 +02:00
|
|
|
hShell32 = LoadLibraryA("shell32.dll");
|
2009-08-12 22:51:28 +02:00
|
|
|
pSHGetImageList = (void*)GetProcAddress(hShell32, (LPCSTR) 727);
|
|
|
|
|
|
|
|
if (!pSHGetImageList)
|
|
|
|
{
|
|
|
|
win_skip("SHGetImageList not available, skipping test\n");
|
2013-01-09 02:42:13 +01:00
|
|
|
FreeLibrary(hShell32);
|
2009-08-12 22:51:28 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get system image list */
|
2015-10-13 23:15:32 +02:00
|
|
|
hr = pSHGetImageList(SHIL_SYSSMALL, &IID_IImageList, (void**)&iml);
|
2009-11-16 20:27:32 +01:00
|
|
|
ok(SUCCEEDED(hr), "SHGetImageList failed, hr=%x\n", hr);
|
2009-08-12 22:51:28 +02:00
|
|
|
|
2013-01-09 02:42:13 +01:00
|
|
|
if (hr != S_OK) {
|
|
|
|
FreeLibrary(hShell32);
|
2009-08-12 22:51:28 +02:00
|
|
|
return;
|
2013-01-09 02:42:13 +01:00
|
|
|
}
|
2009-08-12 22:51:28 +02:00
|
|
|
|
|
|
|
IImageList_GetImageCount(iml, &out);
|
2009-11-16 20:27:32 +01:00
|
|
|
ok(out > 0, "IImageList_GetImageCount returned out <= 0\n");
|
2009-08-12 22:51:28 +02:00
|
|
|
|
2009-11-18 22:35:07 +01:00
|
|
|
/* Fetch the small icon size */
|
|
|
|
cx = GetSystemMetrics(SM_CXSMICON);
|
|
|
|
cy = GetSystemMetrics(SM_CYSMICON);
|
|
|
|
|
|
|
|
/* Check icon size matches */
|
2009-08-12 22:51:28 +02:00
|
|
|
IImageList_GetImageRect(iml, 0, &rect);
|
2009-11-18 22:35:07 +01:00
|
|
|
ok(((rect.right == cx) && (rect.bottom == cy)),
|
2009-08-19 09:12:30 +02:00
|
|
|
"IImageList_GetImageRect returned r:%d,b:%d\n",
|
2009-08-12 22:51:28 +02:00
|
|
|
rect.right, rect.bottom);
|
|
|
|
|
|
|
|
IImageList_Release(iml);
|
|
|
|
FreeLibrary(hShell32);
|
|
|
|
}
|
|
|
|
|
2020-03-06 10:56:50 +01:00
|
|
|
static HBITMAP create_test_bitmap(HDC hdc, UINT width, UINT height, WORD bpp, const UINT32 *bits)
|
2009-10-09 00:28:49 +02:00
|
|
|
{
|
|
|
|
HBITMAP hBitmap;
|
|
|
|
UINT32 *buffer = NULL;
|
2020-03-06 10:56:50 +01:00
|
|
|
UINT stride = ((width * bpp + 31) >> 3) & ~3;
|
|
|
|
BITMAPINFO bitmapInfo = { { sizeof(BITMAPINFOHEADER), width, - height, 1, bpp, BI_RGB, 0, 0, 0, 0, 0 } };
|
2009-10-09 00:28:49 +02:00
|
|
|
|
|
|
|
hBitmap = CreateDIBSection(hdc, &bitmapInfo, DIB_RGB_COLORS, (void**)&buffer, NULL, 0);
|
|
|
|
ok(hBitmap != NULL && buffer != NULL, "CreateDIBSection failed.\n");
|
|
|
|
|
|
|
|
if(!hBitmap || !buffer)
|
|
|
|
{
|
|
|
|
DeleteObject(hBitmap);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-03-06 10:56:50 +01:00
|
|
|
memcpy(buffer, bits, stride * height);
|
2009-10-09 00:28:49 +02:00
|
|
|
|
|
|
|
return hBitmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL colour_match(UINT32 x, UINT32 y)
|
|
|
|
{
|
|
|
|
const INT32 tolerance = 8;
|
|
|
|
|
|
|
|
const INT32 dr = abs((INT32)(x & 0x000000FF) - (INT32)(y & 0x000000FF));
|
|
|
|
const INT32 dg = abs((INT32)((x & 0x0000FF00) >> 8) - (INT32)((y & 0x0000FF00) >> 8));
|
|
|
|
const INT32 db = abs((INT32)((x & 0x00FF0000) >> 16) - (INT32)((y & 0x00FF0000) >> 16));
|
2020-04-14 04:39:28 +02:00
|
|
|
const INT32 da = abs((INT32)((x & 0xFF000000) >> 24) - (INT32)((y & 0xFF000000) >> 24));
|
2009-10-09 00:28:49 +02:00
|
|
|
|
2020-04-14 04:39:28 +02:00
|
|
|
return (dr <= tolerance && dg <= tolerance && db <= tolerance && da <= tolerance);
|
2009-10-09 00:28:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void check_ImageList_DrawIndirect(IMAGELISTDRAWPARAMS *ildp, UINT32 *bits,
|
|
|
|
UINT32 expected, int line)
|
|
|
|
{
|
2020-04-14 04:39:28 +02:00
|
|
|
bits[0] = 0xFFFFFFFF;
|
2009-10-09 00:28:49 +02:00
|
|
|
pImageList_DrawIndirect(ildp);
|
|
|
|
ok(colour_match(bits[0], expected),
|
|
|
|
"ImageList_DrawIndirect: Pixel %08X, Expected a close match to %08X from line %d\n",
|
2020-04-14 04:39:28 +02:00
|
|
|
bits[0], expected, line);
|
2009-10-09 00:28:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void check_ImageList_DrawIndirect_fStyle(HDC hdc, HIMAGELIST himl, UINT32 *bits, int i,
|
|
|
|
UINT fStyle, UINT32 expected, int line)
|
|
|
|
{
|
|
|
|
IMAGELISTDRAWPARAMS ildp = {sizeof(IMAGELISTDRAWPARAMS), himl, i, hdc,
|
|
|
|
0, 0, 0, 0, 0, 0, CLR_NONE, CLR_NONE, fStyle, 0, ILS_NORMAL, 0, 0x00000000};
|
|
|
|
check_ImageList_DrawIndirect(&ildp, bits, expected, line);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void check_ImageList_DrawIndirect_ILD_ROP(HDC hdc, HIMAGELIST himl, UINT32 *bits, int i,
|
|
|
|
DWORD dwRop, UINT32 expected, int line)
|
|
|
|
{
|
|
|
|
IMAGELISTDRAWPARAMS ildp = {sizeof(IMAGELISTDRAWPARAMS), himl, i, hdc,
|
|
|
|
0, 0, 0, 0, 0, 0, CLR_NONE, CLR_NONE, ILD_IMAGE | ILD_ROP, dwRop, ILS_NORMAL, 0, 0x00000000};
|
|
|
|
check_ImageList_DrawIndirect(&ildp, bits, expected, line);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void check_ImageList_DrawIndirect_fState(HDC hdc, HIMAGELIST himl, UINT32 *bits, int i, UINT fStyle,
|
|
|
|
UINT fState, DWORD Frame, UINT32 expected, int line)
|
|
|
|
{
|
|
|
|
IMAGELISTDRAWPARAMS ildp = {sizeof(IMAGELISTDRAWPARAMS), himl, i, hdc,
|
|
|
|
0, 0, 0, 0, 0, 0, CLR_NONE, CLR_NONE, fStyle, 0, fState, Frame, 0x00000000};
|
|
|
|
check_ImageList_DrawIndirect(&ildp, bits, expected, line);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void check_ImageList_DrawIndirect_broken(HDC hdc, HIMAGELIST himl, UINT32 *bits, int i,
|
|
|
|
UINT fStyle, UINT fState, DWORD Frame, UINT32 expected,
|
|
|
|
UINT32 broken_expected, int line)
|
|
|
|
{
|
|
|
|
IMAGELISTDRAWPARAMS ildp = {sizeof(IMAGELISTDRAWPARAMS), himl, i, hdc,
|
|
|
|
0, 0, 0, 0, 0, 0, CLR_NONE, CLR_NONE, fStyle, 0, fState, Frame, 0x00000000};
|
2020-04-14 04:39:28 +02:00
|
|
|
bits[0] = 0xFFFFFFFF;
|
2009-10-09 00:28:49 +02:00
|
|
|
pImageList_DrawIndirect(&ildp);
|
|
|
|
ok(colour_match(bits[0], expected) ||
|
|
|
|
broken(colour_match(bits[0], broken_expected)),
|
|
|
|
"ImageList_DrawIndirect: Pixel %08X, Expected a close match to %08X from line %d\n",
|
2020-04-14 04:39:28 +02:00
|
|
|
bits[0], expected, line);
|
2009-10-09 00:28:49 +02:00
|
|
|
}
|
|
|
|
|
2020-03-06 10:57:28 +01:00
|
|
|
static void check_ImageList_DrawIndirect_grayscale(HDC hdc, HIMAGELIST himl, UINT32 *dst_bits, const UINT32 *bitmap_bits,
|
|
|
|
int index, UINT width, UINT height, int line)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
BOOL has_alpha = FALSE;
|
|
|
|
IMAGELISTDRAWPARAMS ildp = { sizeof(IMAGELISTDRAWPARAMS), himl, index, hdc,
|
|
|
|
0, 0, 0, 0, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL, 0, ILS_SATURATE, 0, 0x00000000 };
|
|
|
|
memset(dst_bits, 0, width * height * sizeof(*dst_bits));
|
|
|
|
pImageList_DrawIndirect(&ildp);
|
|
|
|
|
|
|
|
for (i = 0; i < width * height; i++)
|
|
|
|
if ((has_alpha = ((bitmap_bits[i] & 0xFF000000) != 0))) break;
|
|
|
|
|
|
|
|
for (i = 0; i < width * height; i++)
|
|
|
|
{
|
|
|
|
UINT32 expected, expected_winxp;
|
|
|
|
UINT32 red = (bitmap_bits[i] & 0x00FF0000) >> 16;
|
|
|
|
UINT32 green = (bitmap_bits[i] & 0x0000FF00) >> 8;
|
|
|
|
UINT32 blue = (bitmap_bits[i] & 0x000000FF) >> 0;
|
|
|
|
UINT32 gray = (red * 299 + green * 587 + blue * 114 + 500) / 1000;
|
|
|
|
UINT32 gray_winxp = (red + green + blue) / 3;
|
|
|
|
if (has_alpha)
|
|
|
|
{
|
|
|
|
UINT32 alpha = (bitmap_bits[i] & 0xFF000000) >> 24;
|
|
|
|
gray = gray * alpha / 0xff * alpha / 0xff;
|
|
|
|
gray_winxp = gray_winxp * alpha / 0xff * 0x96 / 0xff;
|
2020-04-14 04:39:28 +02:00
|
|
|
expected = (alpha << 24) | (gray << 16) | (gray << 8) | gray;
|
|
|
|
expected_winxp = ((alpha * 0x96 / 0xff) << 24) | (gray_winxp << 16) | (gray_winxp << 8) | gray_winxp;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
expected = ((UINT32)0xFF << 24) | (gray << 16) | (gray << 8) | gray;
|
|
|
|
expected_winxp = (gray_winxp << 16) | (gray_winxp << 8) | gray_winxp;
|
2020-03-06 10:57:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ok(colour_match(dst_bits[i], expected) || broken(colour_match(dst_bits[i], expected_winxp)),
|
|
|
|
"ImageList_DrawIndirect: got Pixel(%d,%d) %08X, Expected a close match to %08X from line %d\n",
|
2020-04-14 04:39:28 +02:00
|
|
|
i % width, i / width, dst_bits[i], expected, line);
|
2020-03-06 10:57:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-09 00:28:49 +02:00
|
|
|
static void test_ImageList_DrawIndirect(void)
|
|
|
|
{
|
2020-03-06 10:56:50 +01:00
|
|
|
const UINT32 bits_image[] = { 0x00ABCDEF, 0x00ABCDEF };
|
|
|
|
const UINT32 bits_alpha[] = { 0x89ABCDEF, 0x89ABCDEF };
|
|
|
|
const UINT32 bits_transparent[] = { 0x00ABCDEF, 0x89ABCDEF };
|
|
|
|
|
2020-03-06 10:57:43 +01:00
|
|
|
const UINT32 bits_4x4[] = { 0x00ABCDEF, 0x89ABCDEF, 0xFFABCDEF, 0xFEDCBA98,
|
|
|
|
0x00345678, 0x12345678, 0xFF345678, 0x87654321,
|
|
|
|
0x00987654, 0xBA987654, 0xFF987654, 0x456789AB,
|
|
|
|
0x00000000, 0xFF000000, 0xFFFFFFFF, 0x00FFFFFF };
|
|
|
|
|
2009-10-09 00:28:49 +02:00
|
|
|
HIMAGELIST himl = NULL;
|
|
|
|
int ret;
|
|
|
|
HDC hdcDst = NULL;
|
|
|
|
HBITMAP hbmOld = NULL, hbmDst = NULL;
|
|
|
|
HBITMAP hbmMask = NULL, hbmInverseMask = NULL;
|
2020-03-06 10:57:43 +01:00
|
|
|
HBITMAP hbmImage = NULL, hbmAlphaImage = NULL, hbmTransparentImage = NULL, hbm4x4 = NULL;
|
2009-10-09 00:28:49 +02:00
|
|
|
int iImage = -1, iAlphaImage = -1, iTransparentImage = -1;
|
|
|
|
UINT32 *bits = 0;
|
|
|
|
UINT32 maskBits = 0x00000000, inverseMaskBits = 0xFFFFFFFF;
|
2020-03-19 13:04:54 +01:00
|
|
|
IImageList *imgl;
|
|
|
|
DWORD flags;
|
|
|
|
HRESULT hr;
|
2009-10-09 00:28:49 +02:00
|
|
|
|
|
|
|
BITMAPINFO bitmapInfo = {{sizeof(BITMAPINFOHEADER), 2, 1, 1, 32, BI_RGB,
|
|
|
|
0, 0, 0, 0, 0}};
|
|
|
|
|
|
|
|
hdcDst = CreateCompatibleDC(0);
|
|
|
|
ok(hdcDst != 0, "CreateCompatibleDC(0) failed to return a valid DC\n");
|
|
|
|
if (!hdcDst)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hbmMask = CreateBitmap(2, 1, 1, 1, &maskBits);
|
|
|
|
ok(hbmMask != 0, "CreateBitmap failed\n");
|
|
|
|
|
|
|
|
hbmInverseMask = CreateBitmap(2, 1, 1, 1, &inverseMaskBits);
|
|
|
|
ok(hbmInverseMask != 0, "CreateBitmap failed\n");
|
|
|
|
|
|
|
|
himl = pImageList_Create(2, 1, ILC_COLOR32, 0, 1);
|
|
|
|
ok(himl != 0, "ImageList_Create failed\n");
|
|
|
|
|
2020-03-19 13:04:54 +01:00
|
|
|
hr = pHIMAGELIST_QueryInterface(himl, &IID_IImageList, (void **) &imgl);
|
|
|
|
ok(hr == S_OK, "Failed to get interface, hr %#x.\n", hr);
|
|
|
|
|
2009-10-09 00:28:49 +02:00
|
|
|
/* Add a no-alpha image */
|
2020-03-06 10:56:50 +01:00
|
|
|
hbmImage = create_test_bitmap(hdcDst, 2, 1, 32, bits_image);
|
2020-03-23 16:53:39 +01:00
|
|
|
ok(hbmImage != NULL, "Failed to create test bitmap.\n");
|
2009-10-09 00:28:49 +02:00
|
|
|
|
|
|
|
iImage = pImageList_Add(himl, hbmImage, hbmMask);
|
|
|
|
ok(iImage != -1, "ImageList_Add failed\n");
|
|
|
|
|
2020-03-19 13:04:54 +01:00
|
|
|
hr = IImageList_GetItemFlags(imgl, 1000, &flags);
|
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IImageList_GetItemFlags(imgl, 1000, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
|
|
|
|
|
|
|
hr = IImageList_GetItemFlags(imgl, iImage, &flags);
|
|
|
|
ok(hr == S_OK, "Failed to get item flags, hr %#x.\n", hr);
|
|
|
|
ok(!flags, "Unexpected flags %#x.\n", flags);
|
|
|
|
|
2009-10-09 00:28:49 +02:00
|
|
|
/* Add an alpha image */
|
2020-03-06 10:56:50 +01:00
|
|
|
hbmAlphaImage = create_test_bitmap(hdcDst, 2, 1, 32, bits_alpha);
|
2020-03-23 16:53:39 +01:00
|
|
|
ok(hbmAlphaImage != NULL, "Failed to create test bitmap.\n");
|
2009-10-09 00:28:49 +02:00
|
|
|
|
|
|
|
iAlphaImage = pImageList_Add(himl, hbmAlphaImage, hbmMask);
|
|
|
|
ok(iAlphaImage != -1, "ImageList_Add failed\n");
|
|
|
|
|
2020-03-19 13:04:54 +01:00
|
|
|
hr = IImageList_GetItemFlags(imgl, iAlphaImage, &flags);
|
|
|
|
ok(hr == S_OK, "Failed to get item flags, hr %#x.\n", hr);
|
|
|
|
ok(flags & ILIF_ALPHA, "Unexpected flags %#x.\n", flags);
|
|
|
|
|
2009-10-09 00:28:49 +02:00
|
|
|
/* Add a transparent alpha image */
|
2020-03-06 10:56:50 +01:00
|
|
|
hbmTransparentImage = create_test_bitmap(hdcDst, 2, 1, 32, bits_transparent);
|
2020-03-23 16:53:39 +01:00
|
|
|
ok(hbmTransparentImage != NULL, "Failed to create test bitmap.\n");
|
2009-10-09 00:28:49 +02:00
|
|
|
|
|
|
|
iTransparentImage = pImageList_Add(himl, hbmTransparentImage, hbmMask);
|
|
|
|
ok(iTransparentImage != -1, "ImageList_Add failed\n");
|
|
|
|
|
2020-03-19 13:04:54 +01:00
|
|
|
hr = IImageList_GetItemFlags(imgl, iTransparentImage, &flags);
|
|
|
|
ok(hr == S_OK, "Failed to get item flags, hr %#x.\n", hr);
|
|
|
|
ok(flags & ILIF_ALPHA, "Unexpected flags %#x.\n", flags);
|
|
|
|
|
2009-10-09 00:28:49 +02:00
|
|
|
/* 32-bit Tests */
|
|
|
|
bitmapInfo.bmiHeader.biBitCount = 32;
|
|
|
|
hbmDst = CreateDIBSection(hdcDst, &bitmapInfo, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
|
|
|
|
ok (hbmDst && bits, "CreateDIBSection failed to return a valid bitmap and buffer\n");
|
|
|
|
hbmOld = SelectObject(hdcDst, hbmDst);
|
|
|
|
|
|
|
|
check_ImageList_DrawIndirect_fStyle(hdcDst, himl, bits, iImage, ILD_NORMAL, 0x00ABCDEF, __LINE__);
|
|
|
|
check_ImageList_DrawIndirect_fStyle(hdcDst, himl, bits, iImage, ILD_TRANSPARENT, 0x00ABCDEF, __LINE__);
|
|
|
|
check_ImageList_DrawIndirect_fStyle(hdcDst, himl, bits, iImage, ILD_MASK, 0x00ABCDEF, __LINE__);
|
|
|
|
check_ImageList_DrawIndirect_fStyle(hdcDst, himl, bits, iImage, ILD_IMAGE, 0x00ABCDEF, __LINE__);
|
|
|
|
check_ImageList_DrawIndirect_fStyle(hdcDst, himl, bits, iImage, ILD_PRESERVEALPHA, 0x00ABCDEF, __LINE__);
|
|
|
|
|
2020-04-14 04:39:28 +02:00
|
|
|
check_ImageList_DrawIndirect_fStyle(hdcDst, himl, bits, iAlphaImage, ILD_NORMAL, 0xFFD3E5F7, __LINE__);
|
|
|
|
check_ImageList_DrawIndirect_fStyle(hdcDst, himl, bits, iAlphaImage, ILD_TRANSPARENT, 0xFFD3E5F7, __LINE__);
|
2009-10-09 00:28:49 +02:00
|
|
|
|
2020-04-20 06:51:01 +02:00
|
|
|
/* broken on winxp */
|
|
|
|
todo_wine check_ImageList_DrawIndirect_broken(hdcDst, himl, bits, iAlphaImage, ILD_BLEND25, ILS_NORMAL, 0, 0xFFE8F1FA, 0xFFD4D9DD, __LINE__);
|
|
|
|
todo_wine check_ImageList_DrawIndirect_broken(hdcDst, himl, bits, iAlphaImage, ILD_BLEND50, ILS_NORMAL, 0, 0xFFE8F1FA, 0xFFB4BDC4, __LINE__);
|
|
|
|
|
2020-04-14 04:39:28 +02:00
|
|
|
check_ImageList_DrawIndirect_fStyle(hdcDst, himl, bits, iAlphaImage, ILD_MASK, 0xFFD3E5F7, __LINE__);
|
|
|
|
check_ImageList_DrawIndirect_fStyle(hdcDst, himl, bits, iAlphaImage, ILD_IMAGE, 0xFFD3E5F7, __LINE__);
|
2020-04-14 04:39:50 +02:00
|
|
|
|
2020-04-14 04:40:16 +02:00
|
|
|
check_ImageList_DrawIndirect_fStyle(hdcDst, himl, bits, iAlphaImage, ILD_PRESERVEALPHA, 0x895D6F81, __LINE__);
|
2020-04-14 04:39:50 +02:00
|
|
|
check_ImageList_DrawIndirect_broken(hdcDst, himl, bits, iAlphaImage, ILD_PRESERVEALPHA, ILS_ALPHA, 127, 0xFFE9F2FB, 0xFFAEB7C0, __LINE__);
|
|
|
|
check_ImageList_DrawIndirect_broken(hdcDst, himl, bits, iAlphaImage, ILD_PRESERVEALPHA, ILS_SATURATE, 0, 0xFFAFAFAF, 0xFFF0F0F0, __LINE__);
|
2009-10-09 00:28:49 +02:00
|
|
|
|
2020-04-14 04:39:28 +02:00
|
|
|
check_ImageList_DrawIndirect_fStyle(hdcDst, himl, bits, iTransparentImage, ILD_NORMAL, 0xFFFFFFFF, __LINE__);
|
2009-10-09 00:28:49 +02:00
|
|
|
|
|
|
|
check_ImageList_DrawIndirect_ILD_ROP(hdcDst, himl, bits, iImage, SRCCOPY, 0x00ABCDEF, __LINE__);
|
2020-04-14 04:39:28 +02:00
|
|
|
check_ImageList_DrawIndirect_ILD_ROP(hdcDst, himl, bits, iImage, SRCINVERT, 0xFF543210, __LINE__);
|
2009-10-09 00:28:49 +02:00
|
|
|
|
|
|
|
/* ILD_ROP is ignored when the image has an alpha channel */
|
2020-04-14 04:39:28 +02:00
|
|
|
check_ImageList_DrawIndirect_ILD_ROP(hdcDst, himl, bits, iAlphaImage, SRCCOPY, 0xFFD3E5F7, __LINE__);
|
|
|
|
check_ImageList_DrawIndirect_ILD_ROP(hdcDst, himl, bits, iAlphaImage, SRCINVERT, 0xFFD3E5F7, __LINE__);
|
2009-10-09 00:28:49 +02:00
|
|
|
|
2020-03-06 10:57:28 +01:00
|
|
|
check_ImageList_DrawIndirect_grayscale(hdcDst, himl, bits, bits_image, iImage, 2, 1, __LINE__);
|
|
|
|
check_ImageList_DrawIndirect_grayscale(hdcDst, himl, bits, bits_alpha, iAlphaImage, 2, 1, __LINE__);
|
|
|
|
check_ImageList_DrawIndirect_grayscale(hdcDst, himl, bits, bits_transparent, iTransparentImage, 2, 1, __LINE__);
|
2009-10-09 00:28:49 +02:00
|
|
|
|
2020-04-14 04:39:28 +02:00
|
|
|
check_ImageList_DrawIndirect_broken(hdcDst, himl, bits, iImage, ILD_NORMAL, ILS_GLOW, 0, 0x00ABCDEF, 0xFFABCDEF, __LINE__);
|
|
|
|
check_ImageList_DrawIndirect_broken(hdcDst, himl, bits, iImage, ILD_NORMAL, ILS_SHADOW, 0, 0x00ABCDEF, 0xFFABCDEF, __LINE__);
|
2009-10-09 00:28:49 +02:00
|
|
|
|
2020-04-14 04:39:28 +02:00
|
|
|
check_ImageList_DrawIndirect_fState(hdcDst, himl, bits, iImage, ILD_NORMAL, ILS_ALPHA, 127, 0xFFD5E6F7, __LINE__);
|
|
|
|
check_ImageList_DrawIndirect_broken(hdcDst, himl, bits, iAlphaImage, ILD_NORMAL, ILS_ALPHA, 127, 0xFFE9F2FB, 0xFFAEB7C0, __LINE__);
|
|
|
|
check_ImageList_DrawIndirect_fState(hdcDst, himl, bits, iAlphaImage, ILD_NORMAL, ILS_NORMAL, 127, 0xFFD3E5F7, __LINE__);
|
2009-10-09 00:28:49 +02:00
|
|
|
|
2020-03-06 10:57:43 +01:00
|
|
|
/* 4x4 bitmap tests */
|
|
|
|
SelectObject(hdcDst, hbmOld);
|
|
|
|
DeleteObject(hbmDst);
|
|
|
|
bitmapInfo.bmiHeader.biWidth = 4;
|
|
|
|
bitmapInfo.bmiHeader.biHeight = -4;
|
|
|
|
hbmDst = CreateDIBSection(hdcDst, &bitmapInfo, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
|
|
|
|
ok (hbmDst && bits, "CreateDIBSection failed to return a valid bitmap and buffer\n");
|
|
|
|
SelectObject(hdcDst, hbmDst);
|
|
|
|
|
|
|
|
hbm4x4 = create_test_bitmap(hdcDst, 4, 4, 32, bits_4x4);
|
2020-03-23 16:53:39 +01:00
|
|
|
ok(hbm4x4 != NULL, "Failed to create a test bitmap.\n");
|
2020-03-06 10:57:43 +01:00
|
|
|
|
|
|
|
ret = pImageList_SetIconSize(himl, 4, 4);
|
|
|
|
ok(ret, "ImageList_SetIconSize failed\n");
|
|
|
|
|
|
|
|
ret = pImageList_Add(himl, hbm4x4, NULL);
|
|
|
|
ok(ret != -1, "ImageList_Add failed\n");
|
|
|
|
|
|
|
|
check_ImageList_DrawIndirect_grayscale(hdcDst, himl, bits, bits_4x4, 0, 4, 4, __LINE__);
|
|
|
|
|
2009-10-09 00:28:49 +02:00
|
|
|
if(hbmOld)
|
|
|
|
SelectObject(hdcDst, hbmOld);
|
|
|
|
if(hbmDst)
|
|
|
|
DeleteObject(hbmDst);
|
|
|
|
|
2019-03-01 21:08:23 +01:00
|
|
|
DeleteDC(hdcDst);
|
2009-10-09 00:28:49 +02:00
|
|
|
|
|
|
|
if(hbmMask)
|
|
|
|
DeleteObject(hbmMask);
|
|
|
|
if(hbmInverseMask)
|
|
|
|
DeleteObject(hbmInverseMask);
|
|
|
|
|
|
|
|
if(hbmImage)
|
|
|
|
DeleteObject(hbmImage);
|
|
|
|
if(hbmAlphaImage)
|
|
|
|
DeleteObject(hbmAlphaImage);
|
|
|
|
if(hbmTransparentImage)
|
|
|
|
DeleteObject(hbmTransparentImage);
|
2020-03-06 10:57:43 +01:00
|
|
|
if(hbm4x4)
|
|
|
|
DeleteObject(hbm4x4);
|
2009-10-09 00:28:49 +02:00
|
|
|
|
|
|
|
if(himl)
|
|
|
|
{
|
2018-01-24 13:47:09 +01:00
|
|
|
ret = pImageList_Destroy(himl);
|
2009-10-09 00:28:49 +02:00
|
|
|
ok(ret, "ImageList_Destroy failed\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-12 17:27:44 +01:00
|
|
|
static void test_iimagelist(void)
|
|
|
|
{
|
2010-08-21 17:17:34 +02:00
|
|
|
IImageList *imgl, *imgl2;
|
2014-06-10 06:21:32 +02:00
|
|
|
IImageList2 *imagelist;
|
2009-11-12 17:27:44 +01:00
|
|
|
HIMAGELIST himl;
|
|
|
|
HRESULT hr;
|
2009-11-15 13:13:48 +01:00
|
|
|
ULONG ret;
|
2009-11-12 17:27:44 +01:00
|
|
|
|
2009-11-15 13:13:48 +01:00
|
|
|
if (!pHIMAGELIST_QueryInterface)
|
|
|
|
{
|
|
|
|
win_skip("XP imagelist functions not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* test reference counting on destruction */
|
|
|
|
imgl = (IImageList*)createImageList(32, 32);
|
2012-08-19 17:19:41 +02:00
|
|
|
ret = IImageList_AddRef(imgl);
|
2009-11-15 13:13:48 +01:00
|
|
|
ok(ret == 2, "Expected 2, got %d\n", ret);
|
2018-01-24 13:47:09 +01:00
|
|
|
ret = pImageList_Destroy((HIMAGELIST)imgl);
|
2009-11-15 13:13:48 +01:00
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
2018-01-24 13:47:09 +01:00
|
|
|
ret = pImageList_Destroy((HIMAGELIST)imgl);
|
2009-11-15 13:13:48 +01:00
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
2018-01-24 13:47:09 +01:00
|
|
|
ret = pImageList_Destroy((HIMAGELIST)imgl);
|
2009-11-15 13:13:48 +01:00
|
|
|
ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
|
|
|
|
|
|
|
|
imgl = (IImageList*)createImageList(32, 32);
|
2012-08-19 17:19:41 +02:00
|
|
|
ret = IImageList_AddRef(imgl);
|
2009-11-15 13:13:48 +01:00
|
|
|
ok(ret == 2, "Expected 2, got %d\n", ret);
|
2018-01-24 13:47:09 +01:00
|
|
|
ret = pImageList_Destroy((HIMAGELIST)imgl);
|
2009-11-15 13:13:48 +01:00
|
|
|
ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
|
|
|
|
ret = IImageList_Release(imgl);
|
|
|
|
ok(ret == 0, "Expected 0, got %d\n", ret);
|
2018-01-24 13:47:09 +01:00
|
|
|
ret = pImageList_Destroy((HIMAGELIST)imgl);
|
2009-11-15 13:13:48 +01:00
|
|
|
ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
|
|
|
|
|
2010-08-21 17:17:34 +02:00
|
|
|
/* ref counting, HIMAGELIST_QueryInterface adds a reference */
|
|
|
|
imgl = (IImageList*)createImageList(32, 32);
|
|
|
|
hr = pHIMAGELIST_QueryInterface((HIMAGELIST)imgl, &IID_IImageList, (void**)&imgl2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(imgl2 == imgl, "got different pointer\n");
|
|
|
|
ret = IImageList_Release(imgl);
|
|
|
|
ok(ret == 1, "got %u\n", ret);
|
|
|
|
IImageList_Release(imgl);
|
|
|
|
|
2009-11-15 13:13:48 +01:00
|
|
|
if (!pImageList_CoCreateInstance)
|
2009-11-12 17:27:44 +01:00
|
|
|
{
|
|
|
|
win_skip("Vista imagelist functions not available\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = pImageList_CoCreateInstance(&CLSID_ImageList, NULL, &IID_IImageList, (void **) &imgl);
|
|
|
|
ok(SUCCEEDED(hr), "ImageList_CoCreateInstance failed, hr=%x\n", hr);
|
|
|
|
|
|
|
|
if (hr == S_OK)
|
|
|
|
IImageList_Release(imgl);
|
|
|
|
|
|
|
|
himl = createImageList(32, 32);
|
|
|
|
|
|
|
|
if (!himl)
|
|
|
|
return;
|
|
|
|
|
2020-03-19 13:04:54 +01:00
|
|
|
hr = pHIMAGELIST_QueryInterface(himl, &IID_IImageList, (void **) &imgl);
|
2009-11-12 17:27:44 +01:00
|
|
|
ok(SUCCEEDED(hr), "HIMAGELIST_QueryInterface failed, hr=%x\n", hr);
|
|
|
|
|
|
|
|
if (hr == S_OK)
|
|
|
|
IImageList_Release(imgl);
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(himl);
|
2014-06-10 06:21:32 +02:00
|
|
|
|
|
|
|
/* IImageList2 */
|
|
|
|
hr = pImageList_CoCreateInstance(&CLSID_ImageList, NULL, &IID_IImageList2, (void**)&imagelist);
|
|
|
|
if (hr != S_OK)
|
|
|
|
{
|
|
|
|
win_skip("IImageList2 is not supported.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
IImageList2_Release(imagelist);
|
2009-11-12 17:27:44 +01:00
|
|
|
}
|
|
|
|
|
2010-08-19 07:32:09 +02:00
|
|
|
static void test_IImageList_Add_Remove(void)
|
2009-11-13 18:14:27 +01:00
|
|
|
{
|
|
|
|
IImageList *imgl;
|
|
|
|
HIMAGELIST himl;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
HICON hicon1;
|
|
|
|
HICON hicon2;
|
|
|
|
HICON hicon3;
|
|
|
|
|
2010-08-19 08:15:38 +02:00
|
|
|
int ret;
|
2009-11-13 18:14:27 +01:00
|
|
|
|
|
|
|
/* create an imagelist to play with */
|
2018-01-24 13:47:09 +01:00
|
|
|
himl = pImageList_Create(84, 84, ILC_COLOR16, 0, 3);
|
2009-11-13 18:14:27 +01:00
|
|
|
ok(himl != 0,"failed to create imagelist\n");
|
|
|
|
|
|
|
|
imgl = (IImageList *) himl;
|
|
|
|
|
|
|
|
/* load the icons to add to the image list */
|
|
|
|
hicon1 = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
|
|
|
|
ok(hicon1 != 0, "no hicon1\n");
|
|
|
|
hicon2 = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
|
|
|
|
ok(hicon2 != 0, "no hicon2\n");
|
|
|
|
hicon3 = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
|
|
|
|
ok(hicon3 != 0, "no hicon3\n");
|
|
|
|
|
|
|
|
/* remove when nothing exists */
|
|
|
|
hr = IImageList_Remove(imgl, 0);
|
2010-08-19 08:13:43 +02:00
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2009-11-13 18:14:27 +01:00
|
|
|
|
|
|
|
/* removing everything from an empty imagelist should succeed */
|
|
|
|
hr = IImageList_Remove(imgl, -1);
|
2010-08-19 07:32:09 +02:00
|
|
|
ok(hr == S_OK, "removed nonexistent icon\n");
|
2009-11-13 18:14:27 +01:00
|
|
|
|
|
|
|
/* add three */
|
2010-08-19 08:15:38 +02:00
|
|
|
ret = -1;
|
2010-08-19 07:32:09 +02:00
|
|
|
ok( IImageList_ReplaceIcon(imgl, -1, hicon1, &ret) == S_OK && (ret == 0),"failed to add icon1\n");
|
2010-08-19 08:15:38 +02:00
|
|
|
ret = -1;
|
2010-08-19 07:32:09 +02:00
|
|
|
ok( IImageList_ReplaceIcon(imgl, -1, hicon2, &ret) == S_OK && (ret == 1),"failed to add icon2\n");
|
2010-08-19 08:15:38 +02:00
|
|
|
ret = -1;
|
2010-08-19 07:32:09 +02:00
|
|
|
ok( IImageList_ReplaceIcon(imgl, -1, hicon3, &ret) == S_OK && (ret == 2),"failed to add icon3\n");
|
2009-11-13 18:14:27 +01:00
|
|
|
|
|
|
|
/* remove an index out of range */
|
2010-08-19 08:13:43 +02:00
|
|
|
ok( IImageList_Remove(imgl, 4711) == E_INVALIDARG, "got 0x%08x\n", hr);
|
2009-11-13 18:14:27 +01:00
|
|
|
|
|
|
|
/* remove three */
|
2010-08-19 07:32:09 +02:00
|
|
|
ok( IImageList_Remove(imgl,0) == S_OK, "can't remove 0\n");
|
|
|
|
ok( IImageList_Remove(imgl,0) == S_OK, "can't remove 0\n");
|
|
|
|
ok( IImageList_Remove(imgl,0) == S_OK, "can't remove 0\n");
|
2009-11-13 18:14:27 +01:00
|
|
|
|
|
|
|
/* remove one extra */
|
2010-08-19 08:13:43 +02:00
|
|
|
ok( IImageList_Remove(imgl, 0) == E_INVALIDARG, "got 0x%08x\n", hr);
|
2009-11-13 18:14:27 +01:00
|
|
|
|
2010-08-19 07:32:09 +02:00
|
|
|
IImageList_Release(imgl);
|
2009-11-13 18:14:27 +01:00
|
|
|
ok(DestroyIcon(hicon1),"icon 1 wasn't deleted\n");
|
|
|
|
ok(DestroyIcon(hicon2),"icon 2 wasn't deleted\n");
|
|
|
|
ok(DestroyIcon(hicon3),"icon 3 wasn't deleted\n");
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:32:09 +02:00
|
|
|
static void test_IImageList_Get_SetImageCount(void)
|
|
|
|
{
|
|
|
|
IImageList *imgl;
|
|
|
|
HIMAGELIST himl;
|
|
|
|
HRESULT hr;
|
|
|
|
INT ret;
|
|
|
|
|
|
|
|
/* create an imagelist to play with */
|
2018-01-24 13:47:09 +01:00
|
|
|
himl = pImageList_Create(84, 84, ILC_COLOR16, 0, 3);
|
2010-08-19 07:32:09 +02:00
|
|
|
ok(himl != 0,"failed to create imagelist\n");
|
|
|
|
|
|
|
|
imgl = (IImageList *) himl;
|
|
|
|
|
|
|
|
/* check SetImageCount/GetImageCount */
|
|
|
|
hr = IImageList_SetImageCount(imgl, 3);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ret = 0;
|
|
|
|
hr = IImageList_GetImageCount(imgl, &ret);
|
|
|
|
ok(hr == S_OK && ret == 3, "invalid image count after increase\n");
|
|
|
|
hr = IImageList_SetImageCount(imgl, 1);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ret = 0;
|
|
|
|
hr = IImageList_GetImageCount(imgl, &ret);
|
|
|
|
ok(hr == S_OK && ret == 1, "invalid image count after decrease to 1\n");
|
|
|
|
hr = IImageList_SetImageCount(imgl, 0);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ret = -1;
|
|
|
|
hr = IImageList_GetImageCount(imgl, &ret);
|
|
|
|
ok(hr == S_OK && ret == 0, "invalid image count after decrease to 0\n");
|
|
|
|
|
|
|
|
IImageList_Release(imgl);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_IImageList_Draw(void)
|
2009-11-13 18:14:34 +01:00
|
|
|
{
|
|
|
|
IImageList *imgl;
|
|
|
|
HIMAGELIST himl;
|
|
|
|
|
|
|
|
HBITMAP hbm1;
|
|
|
|
HBITMAP hbm2;
|
|
|
|
HBITMAP hbm3;
|
|
|
|
|
|
|
|
IMAGELISTDRAWPARAMS imldp;
|
|
|
|
HWND hwndfortest;
|
2010-08-19 07:32:09 +02:00
|
|
|
HRESULT hr;
|
2009-11-13 18:14:34 +01:00
|
|
|
HDC hdc;
|
|
|
|
int ret;
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
hwndfortest = create_window();
|
2009-11-13 18:14:34 +01:00
|
|
|
hdc = GetDC(hwndfortest);
|
|
|
|
ok(hdc!=NULL, "couldn't get DC\n");
|
|
|
|
|
|
|
|
/* create an imagelist to play with */
|
2018-01-24 13:47:09 +01:00
|
|
|
himl = pImageList_Create(48, 48, ILC_COLOR16, 0, 3);
|
2009-11-13 18:14:34 +01:00
|
|
|
ok(himl!=0,"failed to create imagelist\n");
|
|
|
|
|
|
|
|
imgl = (IImageList *) himl;
|
|
|
|
|
|
|
|
/* load the icons to add to the image list */
|
|
|
|
hbm1 = CreateBitmap(48, 48, 1, 1, bitmap_bits);
|
|
|
|
ok(hbm1 != 0, "no bitmap 1\n");
|
|
|
|
hbm2 = CreateBitmap(48, 48, 1, 1, bitmap_bits);
|
|
|
|
ok(hbm2 != 0, "no bitmap 2\n");
|
|
|
|
hbm3 = CreateBitmap(48, 48, 1, 1, bitmap_bits);
|
|
|
|
ok(hbm3 != 0, "no bitmap 3\n");
|
|
|
|
|
|
|
|
/* add three */
|
2010-08-19 07:32:09 +02:00
|
|
|
ret = -1;
|
|
|
|
ok( IImageList_Add(imgl, hbm1, 0, &ret) == S_OK && (ret == 0), "failed to add bitmap 1\n");
|
|
|
|
ret = -1;
|
|
|
|
ok( IImageList_Add(imgl, hbm2, 0, &ret) == S_OK && (ret == 1), "failed to add bitmap 2\n");
|
2009-11-13 18:14:34 +01:00
|
|
|
|
2010-08-19 07:32:09 +02:00
|
|
|
ok( IImageList_SetImageCount(imgl, 3) == S_OK, "Setimage count failed\n");
|
|
|
|
ok( IImageList_Replace(imgl, 2, hbm3, 0) == S_OK, "failed to replace bitmap 3\n");
|
2009-11-13 18:14:34 +01:00
|
|
|
|
2010-08-19 07:42:44 +02:00
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* crashes on native */
|
2011-02-05 01:08:42 +01:00
|
|
|
IImageList_Draw(imgl, NULL);
|
2010-08-19 07:42:44 +02:00
|
|
|
}
|
|
|
|
|
2009-11-13 18:14:34 +01:00
|
|
|
memset(&imldp, 0, sizeof (imldp));
|
2010-08-19 07:32:09 +02:00
|
|
|
hr = IImageList_Draw(imgl, &imldp);
|
2010-08-19 07:42:44 +02:00
|
|
|
ok( hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
2009-11-18 22:40:44 +01:00
|
|
|
|
2010-08-19 07:38:36 +02:00
|
|
|
imldp.cbSize = IMAGELISTDRAWPARAMS_V3_SIZE;
|
2009-11-13 18:14:34 +01:00
|
|
|
imldp.hdcDst = hdc;
|
2009-11-18 22:40:44 +01:00
|
|
|
imldp.himl = himl;
|
|
|
|
|
2015-11-15 13:54:01 +01:00
|
|
|
force_redraw(hwndfortest);
|
2009-11-13 18:14:34 +01:00
|
|
|
|
|
|
|
imldp.fStyle = SRCCOPY;
|
|
|
|
imldp.rgbBk = CLR_DEFAULT;
|
|
|
|
imldp.rgbFg = CLR_DEFAULT;
|
|
|
|
imldp.y = 100;
|
|
|
|
imldp.x = 100;
|
2010-08-19 07:32:09 +02:00
|
|
|
ok( IImageList_Draw(imgl, &imldp) == S_OK, "should succeed\n");
|
2009-11-13 18:14:34 +01:00
|
|
|
imldp.i ++;
|
2010-08-19 07:32:09 +02:00
|
|
|
ok( IImageList_Draw(imgl, &imldp) == S_OK, "should succeed\n");
|
2009-11-13 18:14:34 +01:00
|
|
|
imldp.i ++;
|
2010-08-19 07:32:09 +02:00
|
|
|
ok( IImageList_Draw(imgl, &imldp) == S_OK, "should succeed\n");
|
2009-11-13 18:14:34 +01:00
|
|
|
imldp.i ++;
|
2010-08-19 07:42:44 +02:00
|
|
|
ok( IImageList_Draw(imgl, &imldp) == E_INVALIDARG, "should fail\n");
|
2009-11-13 18:14:34 +01:00
|
|
|
|
|
|
|
/* remove three */
|
2010-08-19 07:32:09 +02:00
|
|
|
ok( IImageList_Remove(imgl, 0) == S_OK, "removing 1st bitmap\n");
|
|
|
|
ok( IImageList_Remove(imgl, 0) == S_OK, "removing 2nd bitmap\n");
|
|
|
|
ok( IImageList_Remove(imgl, 0) == S_OK, "removing 3rd bitmap\n");
|
2009-11-13 18:14:34 +01:00
|
|
|
|
|
|
|
/* destroy it */
|
2010-08-19 07:32:09 +02:00
|
|
|
IImageList_Release(imgl);
|
2009-11-13 18:14:34 +01:00
|
|
|
|
|
|
|
/* bitmaps should not be deleted by the imagelist */
|
|
|
|
ok(DeleteObject(hbm1),"bitmap 1 can't be deleted\n");
|
|
|
|
ok(DeleteObject(hbm2),"bitmap 2 can't be deleted\n");
|
|
|
|
ok(DeleteObject(hbm3),"bitmap 3 can't be deleted\n");
|
|
|
|
|
|
|
|
ReleaseDC(hwndfortest, hdc);
|
|
|
|
DestroyWindow(hwndfortest);
|
|
|
|
}
|
|
|
|
|
2010-08-19 07:32:09 +02:00
|
|
|
static void test_IImageList_Merge(void)
|
2009-11-16 20:27:20 +01:00
|
|
|
{
|
|
|
|
HIMAGELIST himl1, himl2;
|
|
|
|
IImageList *imgl1, *imgl2, *merge;
|
|
|
|
HICON hicon1;
|
2017-12-22 13:30:47 +01:00
|
|
|
HWND hwnd = create_window();
|
2009-11-16 20:27:20 +01:00
|
|
|
HRESULT hr;
|
|
|
|
int ret;
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
himl1 = pImageList_Create(32,32,0,0,3);
|
2009-11-16 20:27:20 +01:00
|
|
|
ok(himl1 != NULL,"failed to create himl1\n");
|
|
|
|
|
2018-01-24 13:47:09 +01:00
|
|
|
himl2 = pImageList_Create(32,32,0,0,3);
|
2009-11-16 20:27:20 +01:00
|
|
|
ok(himl2 != NULL,"failed to create himl2\n");
|
|
|
|
|
|
|
|
hicon1 = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
|
|
|
|
ok(hicon1 != NULL, "failed to create hicon1\n");
|
|
|
|
|
|
|
|
if (!himl1 || !himl2 || !hicon1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* cast to IImageList */
|
|
|
|
imgl1 = (IImageList *) himl1;
|
|
|
|
imgl2 = (IImageList *) himl2;
|
|
|
|
|
2010-08-19 07:32:09 +02:00
|
|
|
ret = -1;
|
|
|
|
ok( IImageList_ReplaceIcon(imgl2, -1, hicon1, &ret) == S_OK && (ret == 0),"add icon1 to himl2 failed\n");
|
2009-11-16 20:27:20 +01:00
|
|
|
|
2010-08-21 17:08:54 +02:00
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* null cases that crash on native */
|
2011-02-05 01:08:42 +01:00
|
|
|
IImageList_Merge(imgl1, -1, NULL, 0, 0, 0, &IID_IImageList, (void**)&merge);
|
|
|
|
IImageList_Merge(imgl1, -1, (IUnknown*) imgl2, 0, 0, 0, &IID_IImageList, NULL);
|
2010-08-21 17:08:54 +02:00
|
|
|
}
|
|
|
|
|
2009-11-16 20:27:20 +01:00
|
|
|
/* If himl1 has no images, merge still succeeds */
|
|
|
|
hr = IImageList_Merge(imgl1, -1, (IUnknown *) imgl2, 0, 0, 0, &IID_IImageList, (void **) &merge);
|
2010-08-19 07:32:09 +02:00
|
|
|
ok(hr == S_OK, "merge himl1,-1 failed\n");
|
|
|
|
if (hr == S_OK) IImageList_Release(merge);
|
2009-11-16 20:27:20 +01:00
|
|
|
|
|
|
|
hr = IImageList_Merge(imgl1, 0, (IUnknown *) imgl2, 0, 0, 0, &IID_IImageList, (void **) &merge);
|
2010-08-19 07:32:09 +02:00
|
|
|
ok(hr == S_OK, "merge himl1,0 failed\n");
|
|
|
|
if (hr == S_OK) IImageList_Release(merge);
|
2009-11-16 20:27:20 +01:00
|
|
|
|
|
|
|
/* Same happens if himl2 is empty */
|
|
|
|
IImageList_Release(imgl2);
|
2018-01-24 13:47:09 +01:00
|
|
|
himl2 = pImageList_Create(32,32,0,0,3);
|
2009-11-16 20:27:20 +01:00
|
|
|
ok(himl2 != NULL,"failed to recreate himl2\n");
|
|
|
|
|
|
|
|
imgl2 = (IImageList *) himl2;
|
|
|
|
|
|
|
|
hr = IImageList_Merge(imgl1, -1, (IUnknown *) imgl2, -1, 0, 0, &IID_IImageList, (void **) &merge);
|
2010-08-19 07:32:09 +02:00
|
|
|
ok(hr == S_OK, "merge himl2,-1 failed\n");
|
|
|
|
if (hr == S_OK) IImageList_Release(merge);
|
2009-11-16 20:27:20 +01:00
|
|
|
|
|
|
|
hr = IImageList_Merge(imgl1, -1, (IUnknown *) imgl2, 0, 0, 0, &IID_IImageList, (void **) &merge);
|
2010-08-19 07:32:09 +02:00
|
|
|
ok(hr == S_OK, "merge himl2,0 failed\n");
|
|
|
|
if (hr == S_OK) IImageList_Release(merge);
|
2009-11-16 20:27:20 +01:00
|
|
|
|
|
|
|
/* Now try merging an image with itself */
|
2010-08-19 07:32:09 +02:00
|
|
|
ret = -1;
|
|
|
|
ok( IImageList_ReplaceIcon(imgl2, -1, hicon1, &ret) == S_OK && (ret == 0),"re-add icon1 to himl2 failed\n");
|
2009-11-16 20:27:20 +01:00
|
|
|
|
|
|
|
hr = IImageList_Merge(imgl2, 0, (IUnknown *) imgl2, 0, 0, 0, &IID_IImageList, (void **) &merge);
|
2010-08-19 07:32:09 +02:00
|
|
|
ok(hr == S_OK, "merge himl2 with itself failed\n");
|
|
|
|
if (hr == S_OK) IImageList_Release(merge);
|
2009-11-16 20:27:20 +01:00
|
|
|
|
|
|
|
/* Try merging 2 different image lists */
|
2010-08-19 07:32:09 +02:00
|
|
|
ret = -1;
|
|
|
|
ok( IImageList_ReplaceIcon(imgl1, -1, hicon1, &ret) == S_OK && (ret == 0),"add icon1 to himl1 failed\n");
|
2009-11-16 20:27:20 +01:00
|
|
|
|
|
|
|
hr = IImageList_Merge(imgl1, 0, (IUnknown *) imgl2, 0, 0, 0, &IID_IImageList, (void **) &merge);
|
2010-08-19 07:32:09 +02:00
|
|
|
ok(hr == S_OK, "merge himl1 with himl2 failed\n");
|
|
|
|
if (hr == S_OK) IImageList_Release(merge);
|
2009-11-16 20:27:20 +01:00
|
|
|
|
|
|
|
hr = IImageList_Merge(imgl1, 0, (IUnknown *) imgl2, 0, 8, 16, &IID_IImageList, (void **) &merge);
|
2010-08-19 07:32:09 +02:00
|
|
|
ok(hr == S_OK, "merge himl1 with himl2 8,16 failed\n");
|
|
|
|
if (hr == S_OK) IImageList_Release(merge);
|
2009-11-16 20:27:20 +01:00
|
|
|
|
|
|
|
IImageList_Release(imgl1);
|
|
|
|
IImageList_Release(imgl2);
|
|
|
|
|
|
|
|
DestroyIcon(hicon1);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
}
|
|
|
|
|
2010-08-19 08:15:38 +02:00
|
|
|
static void test_iconsize(void)
|
|
|
|
{
|
|
|
|
HIMAGELIST himl;
|
|
|
|
INT cx, cy;
|
|
|
|
BOOL ret;
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(16, 16, ILC_COLOR16, 0, 3);
|
2010-08-19 08:15:38 +02:00
|
|
|
/* null pointers, not zero imagelist dimensions */
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_GetIconSize(himl, NULL, NULL);
|
2010-08-19 08:18:16 +02:00
|
|
|
ok(!ret, "got %d\n", ret);
|
2010-08-19 08:15:38 +02:00
|
|
|
|
|
|
|
/* doesn't touch return pointers */
|
2011-06-05 15:35:32 +02:00
|
|
|
cx = 0x1abe11ed;
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_GetIconSize(himl, &cx, NULL);
|
2010-08-19 08:15:38 +02:00
|
|
|
ok(!ret, "got %d\n", ret);
|
2011-06-05 15:35:32 +02:00
|
|
|
ok(cx == 0x1abe11ed, "got %d\n", cx);
|
2010-08-19 08:18:16 +02:00
|
|
|
|
2011-06-05 15:35:32 +02:00
|
|
|
cy = 0x1abe11ed;
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_GetIconSize(himl, NULL, &cy);
|
2010-08-19 08:15:38 +02:00
|
|
|
ok(!ret, "got %d\n", ret);
|
2011-06-05 15:35:32 +02:00
|
|
|
ok(cy == 0x1abe11ed, "got %d\n", cy);
|
2010-08-19 08:18:16 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(himl);
|
2011-09-19 15:32:16 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_GetIconSize((HIMAGELIST)0xdeadbeef, &cx, &cy);
|
2011-09-19 15:32:16 +02:00
|
|
|
ok(!ret, "got %d\n", ret);
|
2010-08-19 08:15:38 +02:00
|
|
|
}
|
|
|
|
|
2011-09-19 15:32:16 +02:00
|
|
|
static void test_create_destroy(void)
|
2010-08-19 08:15:38 +02:00
|
|
|
{
|
|
|
|
HIMAGELIST himl;
|
2015-11-19 14:53:04 +01:00
|
|
|
INT cx, cy;
|
2011-09-19 15:32:16 +02:00
|
|
|
BOOL rc;
|
2015-11-19 14:53:04 +01:00
|
|
|
INT ret;
|
2010-08-19 08:15:38 +02:00
|
|
|
|
|
|
|
/* list with zero or negative image dimensions */
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(0, 0, ILC_COLOR16, 0, 3);
|
2010-08-19 08:15:38 +02:00
|
|
|
ok(himl == NULL, "got %p\n", himl);
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(0, 16, ILC_COLOR16, 0, 3);
|
2010-08-19 08:15:38 +02:00
|
|
|
ok(himl == NULL, "got %p\n", himl);
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(16, 0, ILC_COLOR16, 0, 3);
|
2010-08-19 08:15:38 +02:00
|
|
|
ok(himl == NULL, "got %p\n", himl);
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(16, -1, ILC_COLOR16, 0, 3);
|
2010-08-19 08:15:38 +02:00
|
|
|
ok(himl == NULL, "got %p\n", himl);
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(-1, 16, ILC_COLOR16, 0, 3);
|
2010-08-19 08:15:38 +02:00
|
|
|
ok(himl == NULL, "got %p\n", himl);
|
2011-09-19 15:32:16 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
rc = pImageList_Destroy((HIMAGELIST)0xdeadbeef);
|
2011-09-19 15:32:16 +02:00
|
|
|
ok(rc == FALSE, "ImageList_Destroy(0xdeadbeef) should fail and not crash\n");
|
2015-11-19 14:53:04 +01:00
|
|
|
|
|
|
|
/* DDB image lists */
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(0, 14, ILC_COLORDDB, 4, 4);
|
2015-11-19 14:53:04 +01:00
|
|
|
ok(himl != NULL, "got %p\n", himl);
|
2017-12-22 13:30:47 +01:00
|
|
|
|
|
|
|
pImageList_GetIconSize(himl, &cx, &cy);
|
2015-11-19 14:53:04 +01:00
|
|
|
ok (cx == 0, "Wrong cx (%i)\n", cx);
|
|
|
|
ok (cy == 14, "Wrong cy (%i)\n", cy);
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(himl);
|
2015-11-19 14:53:04 +01:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(0, 0, ILC_COLORDDB, 4, 4);
|
2015-11-19 14:53:04 +01:00
|
|
|
ok(himl != NULL, "got %p\n", himl);
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_GetIconSize(himl, &cx, &cy);
|
2015-11-19 14:53:04 +01:00
|
|
|
ok (cx == 0, "Wrong cx (%i)\n", cx);
|
|
|
|
ok (cy == 0, "Wrong cy (%i)\n", cy);
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(himl);
|
2015-11-19 14:53:04 +01:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(0, 0, ILC_COLORDDB, 0, 4);
|
2015-11-19 14:53:04 +01:00
|
|
|
ok(himl != NULL, "got %p\n", himl);
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_GetIconSize(himl, &cx, &cy);
|
2015-11-19 14:53:04 +01:00
|
|
|
ok (cx == 0, "Wrong cx (%i)\n", cx);
|
|
|
|
ok (cy == 0, "Wrong cy (%i)\n", cy);
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_SetImageCount(himl, 3);
|
|
|
|
ret = pImageList_GetImageCount(himl);
|
|
|
|
ok(ret == 3, "Unexpected image count after increase\n");
|
2015-11-19 14:53:04 +01:00
|
|
|
|
|
|
|
/* Trying to actually add an image causes a crash on Windows */
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(himl);
|
2015-11-19 14:53:04 +01:00
|
|
|
|
|
|
|
/* Negative values fail */
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(-1, -1, ILC_COLORDDB, 4, 4);
|
2015-11-19 14:53:04 +01:00
|
|
|
ok(himl == NULL, "got %p\n", himl);
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(-1, 1, ILC_COLORDDB, 4, 4);
|
2015-11-19 14:53:04 +01:00
|
|
|
ok(himl == NULL, "got %p\n", himl);
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(1, -1, ILC_COLORDDB, 4, 4);
|
2015-11-19 14:53:04 +01:00
|
|
|
ok(himl == NULL, "got %p\n", himl);
|
2010-08-19 08:15:38 +02:00
|
|
|
}
|
|
|
|
|
2017-01-30 19:54:07 +01:00
|
|
|
static void check_color_table(const char *name, HDC hdc, HIMAGELIST himl, UINT ilc,
|
|
|
|
RGBQUAD *expect, RGBQUAD *broken_expect)
|
|
|
|
{
|
|
|
|
IMAGEINFO info;
|
|
|
|
INT ret;
|
|
|
|
char bmi_buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
|
|
|
|
BITMAPINFO *bmi = (BITMAPINFO *)bmi_buffer;
|
|
|
|
int i, depth = ilc & 0xfe;
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_GetImageInfo(himl, 0, &info);
|
2017-01-30 19:54:07 +01:00
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
ok(info.hbmImage != NULL, "got %p\n", info.hbmImage);
|
|
|
|
|
|
|
|
memset(bmi_buffer, 0, sizeof(bmi_buffer));
|
|
|
|
bmi->bmiHeader.biSize = sizeof(bmi->bmiHeader);
|
|
|
|
ret = GetDIBits(hdc, info.hbmImage, 0, 0, NULL, bmi, DIB_RGB_COLORS);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
ok(bmi->bmiHeader.biBitCount == depth, "got %d\n", bmi->bmiHeader.biBitCount);
|
|
|
|
|
|
|
|
ret = GetDIBits(hdc, info.hbmImage, 0, 0, NULL, bmi, DIB_RGB_COLORS);
|
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
ok(bmi->bmiHeader.biBitCount == depth, "got %d\n", bmi->bmiHeader.biBitCount);
|
|
|
|
|
|
|
|
for (i = 0; i < (1 << depth); i++)
|
|
|
|
ok((bmi->bmiColors[i].rgbRed == expect[i].rgbRed &&
|
|
|
|
bmi->bmiColors[i].rgbGreen == expect[i].rgbGreen &&
|
|
|
|
bmi->bmiColors[i].rgbBlue == expect[i].rgbBlue) ||
|
2018-03-16 22:57:15 +01:00
|
|
|
(broken_expect && broken(bmi->bmiColors[i].rgbRed == broken_expect[i].rgbRed &&
|
2017-01-30 19:54:07 +01:00
|
|
|
bmi->bmiColors[i].rgbGreen == broken_expect[i].rgbGreen &&
|
2018-03-16 22:57:15 +01:00
|
|
|
bmi->bmiColors[i].rgbBlue == broken_expect[i].rgbBlue)),
|
2017-01-30 19:54:07 +01:00
|
|
|
"%d: %s: got color[%d] %02x %02x %02x expect %02x %02x %02x\n", depth, name, i,
|
|
|
|
bmi->bmiColors[i].rgbRed, bmi->bmiColors[i].rgbGreen, bmi->bmiColors[i].rgbBlue,
|
|
|
|
expect[i].rgbRed, expect[i].rgbGreen, expect[i].rgbBlue);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void get_default_color_table(HDC hdc, int bpp, RGBQUAD *table)
|
|
|
|
{
|
|
|
|
char bmi_buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
|
|
|
|
BITMAPINFO *bmi = (BITMAPINFO *)bmi_buffer;
|
|
|
|
HBITMAP tmp;
|
|
|
|
int i;
|
|
|
|
HPALETTE pal;
|
|
|
|
PALETTEENTRY entries[256];
|
|
|
|
|
|
|
|
switch (bpp)
|
|
|
|
{
|
|
|
|
case 4:
|
|
|
|
tmp = CreateBitmap( 1, 1, 1, 1, NULL );
|
|
|
|
memset(bmi_buffer, 0, sizeof(bmi_buffer));
|
|
|
|
bmi->bmiHeader.biSize = sizeof(bmi->bmiHeader);
|
|
|
|
bmi->bmiHeader.biHeight = 1;
|
|
|
|
bmi->bmiHeader.biWidth = 1;
|
|
|
|
bmi->bmiHeader.biBitCount = bpp;
|
|
|
|
bmi->bmiHeader.biPlanes = 1;
|
|
|
|
bmi->bmiHeader.biCompression = BI_RGB;
|
|
|
|
GetDIBits( hdc, tmp, 0, 0, NULL, bmi, DIB_RGB_COLORS );
|
|
|
|
|
|
|
|
memcpy(table, bmi->bmiColors, (1 << bpp) * sizeof(RGBQUAD));
|
|
|
|
table[7] = bmi->bmiColors[8];
|
|
|
|
table[8] = bmi->bmiColors[7];
|
|
|
|
DeleteObject( tmp );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
pal = CreateHalftonePalette(hdc);
|
|
|
|
GetPaletteEntries(pal, 0, 256, entries);
|
|
|
|
for (i = 0; i < 256; i++)
|
|
|
|
{
|
|
|
|
table[i].rgbRed = entries[i].peRed;
|
|
|
|
table[i].rgbGreen = entries[i].peGreen;
|
|
|
|
table[i].rgbBlue = entries[i].peBlue;
|
|
|
|
table[i].rgbReserved = 0;
|
|
|
|
}
|
|
|
|
DeleteObject(pal);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ok(0, "unhandled depth %d\n", bpp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_color_table(UINT ilc)
|
|
|
|
{
|
|
|
|
HIMAGELIST himl;
|
|
|
|
INT ret;
|
|
|
|
char bmi_buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
|
|
|
|
BITMAPINFO *bmi = (BITMAPINFO *)bmi_buffer;
|
|
|
|
HDC hdc = CreateCompatibleDC(0);
|
|
|
|
HBITMAP dib4, dib8, dib32;
|
|
|
|
RGBQUAD rgb[256], default_table[256];
|
|
|
|
|
|
|
|
get_default_color_table(hdc, ilc & 0xfe, default_table);
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(16, 16, ilc, 0, 3);
|
2017-01-30 19:54:07 +01:00
|
|
|
ok(himl != NULL, "got %p\n", himl);
|
|
|
|
|
|
|
|
memset(bmi_buffer, 0, sizeof(bmi_buffer));
|
|
|
|
bmi->bmiHeader.biSize = sizeof(bmi->bmiHeader);
|
|
|
|
bmi->bmiHeader.biHeight = 16;
|
|
|
|
bmi->bmiHeader.biWidth = 16;
|
|
|
|
bmi->bmiHeader.biBitCount = 8;
|
|
|
|
bmi->bmiHeader.biPlanes = 1;
|
|
|
|
bmi->bmiHeader.biCompression = BI_RGB;
|
|
|
|
bmi->bmiColors[0].rgbRed = 0xff;
|
|
|
|
bmi->bmiColors[1].rgbGreen = 0xff;
|
|
|
|
bmi->bmiColors[2].rgbBlue = 0xff;
|
|
|
|
|
|
|
|
dib8 = CreateDIBSection(hdc, bmi, DIB_RGB_COLORS, NULL, NULL, 0);
|
|
|
|
|
|
|
|
bmi->bmiHeader.biBitCount = 4;
|
|
|
|
bmi->bmiColors[0].rgbRed = 0xff;
|
|
|
|
bmi->bmiColors[0].rgbGreen = 0x00;
|
|
|
|
bmi->bmiColors[0].rgbBlue = 0xff;
|
|
|
|
bmi->bmiColors[1].rgbRed = 0xff;
|
|
|
|
bmi->bmiColors[1].rgbGreen = 0xff;
|
|
|
|
bmi->bmiColors[1].rgbBlue = 0x00;
|
|
|
|
bmi->bmiColors[2].rgbRed = 0x00;
|
|
|
|
bmi->bmiColors[2].rgbGreen = 0xff;
|
|
|
|
bmi->bmiColors[2].rgbBlue = 0xff;
|
|
|
|
|
|
|
|
dib4 = CreateDIBSection(hdc, bmi, DIB_RGB_COLORS, NULL, NULL, 0);
|
|
|
|
|
|
|
|
bmi->bmiHeader.biBitCount = 32;
|
|
|
|
|
|
|
|
dib32 = CreateDIBSection(hdc, bmi, DIB_RGB_COLORS, NULL, NULL, 0);
|
|
|
|
|
|
|
|
/* add 32 first then 8. This won't set the color table */
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Add(himl, dib32, NULL);
|
2017-01-30 19:54:07 +01:00
|
|
|
ok(ret == 0, "got %d\n", ret);
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Add(himl, dib8, NULL);
|
2017-01-30 19:54:07 +01:00
|
|
|
ok(ret == 1, "got %d\n", ret);
|
|
|
|
|
|
|
|
check_color_table("add 32, 8", hdc, himl, ilc, default_table, NULL);
|
|
|
|
|
|
|
|
/* since the previous _Adds didn't set the color table, this one will */
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Remove(himl, -1);
|
2017-01-30 19:54:07 +01:00
|
|
|
ok(ret, "got %d\n", ret);
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Add(himl, dib8, NULL);
|
2017-01-30 19:54:07 +01:00
|
|
|
ok(ret == 0, "got %d\n", ret);
|
|
|
|
|
|
|
|
memset(rgb, 0, sizeof(rgb));
|
|
|
|
rgb[0].rgbRed = 0xff;
|
|
|
|
rgb[1].rgbGreen = 0xff;
|
|
|
|
rgb[2].rgbBlue = 0xff;
|
|
|
|
check_color_table("remove all, add 8", hdc, himl, ilc, rgb, default_table);
|
|
|
|
|
2019-09-02 04:30:40 +02:00
|
|
|
/* remove all, add 4. Color table remains the same since it's implicitly
|
2017-01-30 19:54:07 +01:00
|
|
|
been set by the previous _Add */
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Remove(himl, -1);
|
2017-01-30 19:54:07 +01:00
|
|
|
ok(ret, "got %d\n", ret);
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Add(himl, dib4, NULL);
|
2017-01-30 19:54:07 +01:00
|
|
|
ok(ret == 0, "got %d\n", ret);
|
|
|
|
check_color_table("remove all, add 4", hdc, himl, ilc, rgb, default_table);
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(himl);
|
|
|
|
himl = pImageList_Create(16, 16, ilc, 0, 3);
|
2017-01-30 19:54:07 +01:00
|
|
|
ok(himl != NULL, "got %p\n", himl);
|
|
|
|
|
|
|
|
/* add 4 */
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Add(himl, dib4, NULL);
|
2017-01-30 19:54:07 +01:00
|
|
|
ok(ret == 0, "got %d\n", ret);
|
|
|
|
|
|
|
|
memset(rgb, 0, 16 * sizeof(rgb[0]));
|
|
|
|
rgb[0].rgbRed = 0xff;
|
|
|
|
rgb[0].rgbBlue = 0xff;
|
|
|
|
rgb[1].rgbRed = 0xff;
|
|
|
|
rgb[1].rgbGreen = 0xff;
|
|
|
|
rgb[2].rgbGreen = 0xff;
|
|
|
|
rgb[2].rgbBlue = 0xff;
|
|
|
|
memcpy(rgb + 16, default_table + 16, 240 * sizeof(rgb[0]));
|
|
|
|
|
|
|
|
check_color_table("add 4", hdc, himl, ilc, rgb, default_table);
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(himl);
|
|
|
|
himl = pImageList_Create(16, 16, ilc, 0, 3);
|
2017-01-30 19:54:07 +01:00
|
|
|
ok(himl != NULL, "got %p\n", himl);
|
|
|
|
|
|
|
|
/* set color table, add 8 */
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Remove(himl, -1);
|
2017-01-30 19:54:07 +01:00
|
|
|
ok(ret, "got %d\n", ret);
|
|
|
|
memset(rgb, 0, sizeof(rgb));
|
|
|
|
rgb[0].rgbRed = 0xcc;
|
|
|
|
rgb[1].rgbBlue = 0xcc;
|
|
|
|
ret = pImageList_SetColorTable(himl, 0, 2, rgb);
|
|
|
|
ok(ret == 2, "got %d\n", ret);
|
|
|
|
/* the table is set, so this doesn't change it */
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Add(himl, dib8, NULL);
|
2017-01-30 19:54:07 +01:00
|
|
|
ok(ret == 0, "got %d\n", ret);
|
|
|
|
|
|
|
|
memcpy(rgb + 2, default_table + 2, 254 * sizeof(rgb[0]));
|
|
|
|
check_color_table("SetColorTable", hdc, himl, ilc, rgb, NULL);
|
|
|
|
|
|
|
|
DeleteObject(dib32);
|
|
|
|
DeleteObject(dib8);
|
|
|
|
DeleteObject(dib4);
|
|
|
|
DeleteDC(hdc);
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(himl);
|
2017-01-30 19:54:07 +01:00
|
|
|
}
|
|
|
|
|
2017-04-05 15:25:44 +02:00
|
|
|
static void test_copy(void)
|
|
|
|
{
|
|
|
|
HIMAGELIST dst, src;
|
|
|
|
BOOL ret;
|
|
|
|
int count;
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
dst = pImageList_Create(5, 11, ILC_COLOR, 1, 1);
|
|
|
|
count = pImageList_GetImageCount(dst);
|
2017-04-05 15:25:44 +02:00
|
|
|
ok(!count, "ImageList not empty.\n");
|
|
|
|
src = createImageList(7, 13);
|
2017-12-22 13:30:47 +01:00
|
|
|
count = pImageList_GetImageCount(src);
|
2017-04-05 15:25:44 +02:00
|
|
|
ok(count > 2, "Tests need an ImageList with more than 2 images\n");
|
|
|
|
|
|
|
|
/* ImageList_Copy() cannot copy between two ImageLists */
|
2017-12-22 13:30:47 +01:00
|
|
|
ret = pImageList_Copy(dst, 0, src, 2, ILCF_MOVE);
|
2017-04-05 15:25:44 +02:00
|
|
|
ok(!ret, "ImageList_Copy() should have returned FALSE\n");
|
2017-12-22 13:30:47 +01:00
|
|
|
count = pImageList_GetImageCount(dst);
|
2017-04-05 15:25:44 +02:00
|
|
|
ok(count == 0, "Expected no image in dst ImageList, got %d\n", count);
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy(dst);
|
|
|
|
pImageList_Destroy(src);
|
2017-04-05 15:25:44 +02:00
|
|
|
}
|
|
|
|
|
2017-11-20 14:26:16 +01:00
|
|
|
static void test_loadimage(void)
|
|
|
|
{
|
|
|
|
HIMAGELIST list;
|
|
|
|
DWORD flags;
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
list = pImageList_LoadImageW( hinst, MAKEINTRESOURCEW(IDB_BITMAP_128x15), 16, 1, CLR_DEFAULT,
|
2017-11-20 14:26:16 +01:00
|
|
|
IMAGE_BITMAP, LR_CREATEDIBSECTION );
|
|
|
|
ok( list != NULL, "got %p\n", list );
|
|
|
|
flags = pImageList_GetFlags( list );
|
|
|
|
ok( flags == (ILC_COLOR4 | ILC_MASK), "got %08x\n", flags );
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy( list );
|
2017-11-20 14:26:16 +01:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
list = pImageList_LoadImageW( hinst, MAKEINTRESOURCEW(IDB_BITMAP_128x15), 16, 1, CLR_NONE,
|
2017-11-20 14:26:16 +01:00
|
|
|
IMAGE_BITMAP, LR_CREATEDIBSECTION );
|
|
|
|
ok( list != NULL, "got %p\n", list );
|
|
|
|
flags = pImageList_GetFlags( list );
|
|
|
|
ok( flags == ILC_COLOR4, "got %08x\n", flags );
|
2017-12-22 13:30:47 +01:00
|
|
|
pImageList_Destroy( list );
|
2017-11-20 14:26:16 +01:00
|
|
|
}
|
|
|
|
|
2020-03-02 03:30:44 +01:00
|
|
|
#define GetAValue(argb) ((BYTE) ((argb) >> 24))
|
|
|
|
|
|
|
|
static void get_image_alpha(HIMAGELIST himl, int index, int width, int height, UINT32 *alpha)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
HBITMAP hbm_dst;
|
|
|
|
void *bitmap_bits;
|
|
|
|
BITMAPINFO bitmap_info = {{sizeof(BITMAPINFOHEADER), width, height, 1, 32, BI_RGB, 0, 0, 0, 0, 0}};
|
|
|
|
|
|
|
|
HDC hdc_dst = CreateCompatibleDC(0);
|
|
|
|
hbm_dst = CreateDIBSection(hdc_dst, &bitmap_info, DIB_RGB_COLORS, &bitmap_bits, NULL, 0);
|
|
|
|
SelectObject(hdc_dst, hbm_dst);
|
|
|
|
|
|
|
|
pImageList_Draw(himl, index, hdc_dst, 0, 0, ILD_TRANSPARENT);
|
|
|
|
memcpy(alpha, bitmap_bits, (size_t)(width * height * 32 / 8));
|
|
|
|
for (i = 0; i < width * height; i++)
|
|
|
|
alpha[i] = GetAValue(alpha[i]);
|
|
|
|
|
|
|
|
DeleteObject(hbm_dst);
|
|
|
|
DeleteDC(hdc_dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_alpha(void)
|
|
|
|
{
|
|
|
|
/* each line is a 2*1 bitmap */
|
|
|
|
const static UINT32 test_bitmaps[] =
|
|
|
|
{
|
|
|
|
0x00654321, 0x00ABCDEF,
|
|
|
|
0x00654321, 0xFFABCDEF,
|
|
|
|
0x00654321, 0x89ABCDEF,
|
|
|
|
0xFF654321, 0x00ABCDEF,
|
|
|
|
0xFF654321, 0xFFABCDEF,
|
|
|
|
0xFF654321, 0x89ABCDEF,
|
|
|
|
0x87654321, 0x00ABCDEF,
|
|
|
|
0x87654321, 0xFFABCDEF,
|
|
|
|
0x87654321, 0x89ABCDEF
|
|
|
|
};
|
|
|
|
|
|
|
|
int i, ret;
|
|
|
|
HDC hdc;
|
|
|
|
HBITMAP hbm_test;
|
|
|
|
HIMAGELIST himl;
|
|
|
|
UINT32 alpha[2];
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
himl = pImageList_Create(2, 1, ILC_COLOR32 | ILC_MASK, 0, 10);
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(test_bitmaps); i += 2)
|
|
|
|
{
|
2020-03-06 10:56:50 +01:00
|
|
|
hbm_test = create_test_bitmap(hdc, 2, 1, 32, test_bitmaps + i);
|
2020-03-02 03:30:44 +01:00
|
|
|
ret = pImageList_AddMasked(himl, hbm_test, CLR_NONE);
|
|
|
|
ok(ret == i / 2, "ImageList_AddMasked returned %d, expected %d\n", ret, i / 2);
|
|
|
|
DeleteObject(hbm_test);
|
|
|
|
|
|
|
|
get_image_alpha(himl, i / 2, 2, 1, alpha);
|
|
|
|
ok(alpha[0] == GetAValue(test_bitmaps[i]) && alpha[1] == GetAValue(test_bitmaps[i + 1]),
|
|
|
|
"Bitmap [%08X, %08X] returned alpha value [%02X, %02X], expected [%02X, %02X]\n",
|
|
|
|
test_bitmaps[i], test_bitmaps[i + 1], alpha[0], alpha[1],
|
|
|
|
GetAValue(test_bitmaps[i]), GetAValue(test_bitmaps[i + 1]));
|
|
|
|
}
|
|
|
|
|
|
|
|
pImageList_Destroy(himl);
|
|
|
|
DeleteDC(hdc);
|
|
|
|
}
|
|
|
|
|
2010-08-21 17:14:23 +02:00
|
|
|
static void test_IImageList_Clone(void)
|
|
|
|
{
|
|
|
|
IImageList *imgl, *imgl2;
|
|
|
|
HIMAGELIST himl;
|
|
|
|
HRESULT hr;
|
2010-08-21 17:17:34 +02:00
|
|
|
ULONG ref;
|
2010-08-21 17:14:23 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(16, 16, ILC_COLOR16, 0, 3);
|
2010-08-21 17:14:23 +02:00
|
|
|
imgl = (IImageList*)himl;
|
|
|
|
|
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* crashes on native */
|
2011-02-05 01:08:42 +01:00
|
|
|
IImageList_Clone(imgl, &IID_IImageList, NULL);
|
2010-08-21 17:14:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hr = IImageList_Clone(imgl, &IID_IImageList, (void**)&imgl2);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
2010-08-21 17:17:34 +02:00
|
|
|
ref = IImageList_Release(imgl2);
|
|
|
|
ok(ref == 0, "got %u\n", ref);
|
2010-08-21 17:14:23 +02:00
|
|
|
|
|
|
|
IImageList_Release(imgl);
|
|
|
|
}
|
|
|
|
|
2010-08-21 17:20:11 +02:00
|
|
|
static void test_IImageList_GetBkColor(void)
|
|
|
|
{
|
|
|
|
IImageList *imgl;
|
|
|
|
HIMAGELIST himl;
|
|
|
|
COLORREF color;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(16, 16, ILC_COLOR16, 0, 3);
|
2010-08-21 17:20:11 +02:00
|
|
|
imgl = (IImageList*)himl;
|
|
|
|
|
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* crashes on native */
|
2011-02-05 01:08:42 +01:00
|
|
|
IImageList_GetBkColor(imgl, NULL);
|
2010-08-21 17:20:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hr = IImageList_GetBkColor(imgl, &color);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
IImageList_Release(imgl);
|
|
|
|
}
|
|
|
|
|
2010-08-21 17:22:34 +02:00
|
|
|
static void test_IImageList_SetBkColor(void)
|
|
|
|
{
|
|
|
|
IImageList *imgl;
|
|
|
|
HIMAGELIST himl;
|
|
|
|
COLORREF color;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(16, 16, ILC_COLOR16, 0, 3);
|
2010-08-21 17:22:34 +02:00
|
|
|
imgl = (IImageList*)himl;
|
|
|
|
|
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* crashes on native */
|
2011-02-05 01:08:42 +01:00
|
|
|
IImageList_SetBkColor(imgl, RGB(0, 0, 0), NULL);
|
2010-08-21 17:22:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
hr = IImageList_SetBkColor(imgl, CLR_NONE, &color);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IImageList_SetBkColor(imgl, CLR_NONE, &color);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
color = 0xdeadbeef;
|
|
|
|
hr = IImageList_GetBkColor(imgl, &color);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(color == CLR_NONE, "got %x\n", color);
|
|
|
|
|
|
|
|
IImageList_Release(imgl);
|
|
|
|
}
|
|
|
|
|
2010-08-21 17:31:29 +02:00
|
|
|
static void test_IImageList_GetImageCount(void)
|
|
|
|
{
|
|
|
|
IImageList *imgl;
|
|
|
|
HIMAGELIST himl;
|
|
|
|
int count;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(16, 16, ILC_COLOR16, 0, 3);
|
2010-08-21 17:31:29 +02:00
|
|
|
imgl = (IImageList*)himl;
|
|
|
|
|
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* crashes on native */
|
2011-02-05 01:08:42 +01:00
|
|
|
IImageList_GetImageCount(imgl, NULL);
|
2010-08-21 17:31:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
count = -1;
|
|
|
|
hr = IImageList_GetImageCount(imgl, &count);
|
|
|
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
ok(count == 0, "got %d\n", count);
|
|
|
|
|
|
|
|
IImageList_Release(imgl);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_IImageList_GetIconSize(void)
|
|
|
|
{
|
|
|
|
IImageList *imgl;
|
|
|
|
HIMAGELIST himl;
|
|
|
|
int cx, cy;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
himl = pImageList_Create(16, 16, ILC_COLOR16, 0, 3);
|
2010-08-21 17:31:29 +02:00
|
|
|
imgl = (IImageList*)himl;
|
|
|
|
|
|
|
|
hr = IImageList_GetIconSize(imgl, NULL, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IImageList_GetIconSize(imgl, &cx, NULL);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = IImageList_GetIconSize(imgl, NULL, &cy);
|
|
|
|
ok(hr == E_INVALIDARG, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
IImageList_Release(imgl);
|
|
|
|
}
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
static void init_functions(void)
|
|
|
|
{
|
2018-01-24 13:47:09 +01:00
|
|
|
HMODULE hComCtl32 = LoadLibraryA("comctl32.dll");
|
2017-12-22 13:30:47 +01:00
|
|
|
|
|
|
|
#define X(f) p##f = (void*)GetProcAddress(hComCtl32, #f);
|
|
|
|
#define X2(f, ord) p##f = (void*)GetProcAddress(hComCtl32, (const char *)ord);
|
|
|
|
X(ImageList_Create);
|
|
|
|
X(ImageList_Destroy);
|
|
|
|
X(ImageList_Add);
|
2020-03-02 03:30:44 +01:00
|
|
|
X(ImageList_AddMasked);
|
2017-12-22 13:30:47 +01:00
|
|
|
X(ImageList_DrawIndirect);
|
|
|
|
X(ImageList_SetImageCount);
|
|
|
|
X2(ImageList_SetColorTable, 390);
|
|
|
|
X(ImageList_GetFlags);
|
|
|
|
X(ImageList_BeginDrag);
|
|
|
|
X(ImageList_GetDragImage);
|
|
|
|
X(ImageList_EndDrag);
|
|
|
|
X(ImageList_GetImageCount);
|
|
|
|
X(ImageList_SetDragCursorImage);
|
|
|
|
X(ImageList_GetIconSize);
|
2020-03-06 10:57:43 +01:00
|
|
|
X(ImageList_SetIconSize);
|
2017-12-22 13:30:47 +01:00
|
|
|
X(ImageList_Remove);
|
|
|
|
X(ImageList_ReplaceIcon);
|
|
|
|
X(ImageList_Replace);
|
|
|
|
X(ImageList_Merge);
|
|
|
|
X(ImageList_GetImageInfo);
|
|
|
|
X(ImageList_Write);
|
|
|
|
X(ImageList_Read);
|
|
|
|
X(ImageList_Copy);
|
|
|
|
X(ImageList_LoadImageW);
|
|
|
|
X(ImageList_CoCreateInstance);
|
|
|
|
X(HIMAGELIST_QueryInterface);
|
2018-01-24 13:47:09 +01:00
|
|
|
X(ImageList_Draw);
|
2017-12-22 13:30:47 +01:00
|
|
|
#undef X
|
|
|
|
#undef X2
|
|
|
|
}
|
|
|
|
|
2004-08-22 03:59:55 +02:00
|
|
|
START_TEST(imagelist)
|
|
|
|
{
|
2009-08-12 22:51:28 +02:00
|
|
|
ULONG_PTR ctx_cookie;
|
2009-10-20 19:57:48 +02:00
|
|
|
HANDLE hCtx;
|
2009-08-12 22:51:28 +02:00
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
init_functions();
|
2007-12-10 01:25:15 +01:00
|
|
|
|
2004-08-24 20:41:52 +02:00
|
|
|
hinst = GetModuleHandleA(NULL);
|
2004-08-22 03:59:55 +02:00
|
|
|
|
2011-09-19 15:32:16 +02:00
|
|
|
test_create_destroy();
|
2014-10-07 01:01:56 +02:00
|
|
|
test_begindrag();
|
2010-08-19 07:32:09 +02:00
|
|
|
test_hotspot();
|
|
|
|
test_add_remove();
|
|
|
|
test_imagecount();
|
|
|
|
test_DrawIndirect();
|
|
|
|
test_merge();
|
2013-02-27 21:47:43 +01:00
|
|
|
test_merge_colors();
|
2007-04-23 13:39:18 +02:00
|
|
|
test_imagelist_storage();
|
2010-08-19 08:15:38 +02:00
|
|
|
test_iconsize();
|
2017-01-30 19:54:07 +01:00
|
|
|
test_color_table(ILC_COLOR4);
|
|
|
|
test_color_table(ILC_COLOR8);
|
2017-04-05 15:25:44 +02:00
|
|
|
test_copy();
|
2017-11-20 14:26:16 +01:00
|
|
|
test_loadimage();
|
2009-08-12 22:51:28 +02:00
|
|
|
|
|
|
|
/* Now perform v6 tests */
|
2009-10-20 19:57:48 +02:00
|
|
|
if (!load_v6_module(&ctx_cookie, &hCtx))
|
2009-08-12 22:51:28 +02:00
|
|
|
return;
|
|
|
|
|
2017-12-22 13:30:47 +01:00
|
|
|
init_functions();
|
2009-11-12 17:27:44 +01:00
|
|
|
|
|
|
|
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
2009-10-09 00:28:49 +02:00
|
|
|
|
|
|
|
/* Do v6.0 tests */
|
2017-12-22 13:30:47 +01:00
|
|
|
test_add_remove();
|
|
|
|
test_imagecount();
|
|
|
|
test_DrawIndirect();
|
|
|
|
test_merge();
|
2017-12-27 11:51:38 +01:00
|
|
|
test_imagelist_storage();
|
2017-12-22 13:30:47 +01:00
|
|
|
test_iconsize();
|
|
|
|
test_color_table(ILC_COLOR4);
|
|
|
|
test_color_table(ILC_COLOR8);
|
|
|
|
test_copy();
|
|
|
|
test_loadimage();
|
2020-03-02 03:30:44 +01:00
|
|
|
test_alpha();
|
2017-12-22 13:30:47 +01:00
|
|
|
|
2009-10-09 00:28:49 +02:00
|
|
|
test_ImageList_DrawIndirect();
|
2009-08-12 22:51:28 +02:00
|
|
|
test_shell_imagelist();
|
2009-11-12 17:27:44 +01:00
|
|
|
test_iimagelist();
|
2009-11-16 20:27:30 +01:00
|
|
|
|
2010-08-19 07:32:09 +02:00
|
|
|
test_IImageList_Add_Remove();
|
|
|
|
test_IImageList_Get_SetImageCount();
|
|
|
|
test_IImageList_Draw();
|
|
|
|
test_IImageList_Merge();
|
2010-08-21 17:14:23 +02:00
|
|
|
test_IImageList_Clone();
|
2010-08-21 17:20:11 +02:00
|
|
|
test_IImageList_GetBkColor();
|
2010-08-21 17:22:34 +02:00
|
|
|
test_IImageList_SetBkColor();
|
2010-08-21 17:31:29 +02:00
|
|
|
test_IImageList_GetImageCount();
|
|
|
|
test_IImageList_GetIconSize();
|
2009-11-12 17:27:44 +01:00
|
|
|
|
|
|
|
CoUninitialize();
|
2009-08-12 22:51:28 +02:00
|
|
|
|
2009-10-20 19:57:48 +02:00
|
|
|
unload_v6_module(ctx_cookie, hCtx);
|
2004-08-22 03:59:55 +02:00
|
|
|
}
|