Commit 7902e432 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

comctl32/tests: Enable cGrow field tests for version 6 serialization format.

parent f09deaca
......@@ -898,16 +898,30 @@ static BOOL is_v6_header(const ILHEAD *header)
static void check_ilhead_data(const ILHEAD *ilh, INT cx, INT cy, INT cur, INT max, INT grow, INT flags)
{
INT grow_aligned;
ok(ilh->usMagic == IMAGELIST_MAGIC, "wrong usMagic %4x (expected %02x)\n", ilh->usMagic, IMAGELIST_MAGIC);
ok(ilh->usVersion == 0x101 ||
ilh->usVersion == 0x600 || /* WinXP/W2k3 */
ilh->usVersion == 0x620, "Unknown usVersion %#x.\n", ilh->usVersion);
ok(ilh->cCurImage == cur, "wrong cCurImage %d (expected %d)\n", ilh->cCurImage, cur);
if (!is_v6_header(ilh))
grow = max(grow, 1);
grow_aligned = (WORD)(grow + 3) & ~3;
if (is_v6_header(ilh))
{
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
{
grow = (WORD)(grow + 3) & ~3;
ok(ilh->cMaxImage == max, "wrong cMaxImage %d (expected %d)\n", ilh->cMaxImage, max);
ok(ilh->cGrow == grow, "Unexpected cGrow %d (expected %d)\n", ilh->cGrow, grow);
ok(ilh->cGrow == grow_aligned, "Unexpected cGrow %d, expected %d\n", ilh->cGrow, grow_aligned);
}
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);
......@@ -968,6 +982,7 @@ static inline void imagelist_get_bitmap_size(const ILHEAD *header, SIZE *sz)
}
}
/* Grow argument matches what was used when imagelist was created. */
static void check_iml_data(HIMAGELIST himl, INT cx, INT cy, INT cur, INT max, INT grow,
INT flags, const char *comment)
{
......@@ -1042,93 +1057,93 @@ static void image_list_add_bitmap(HIMAGELIST himl, BYTE grey, int i)
DeleteObject(hbm);
}
static void image_list_init(HIMAGELIST himl)
static void image_list_init(HIMAGELIST himl, INT grow)
{
unsigned int i;
static const struct test_data
{
BYTE grey;
INT cx, cy, cur, max, grow, bpp;
INT cx, cy, cur, max, bpp;
const char *comment;
} td[] =
{
{ 255, BMP_CX, BMP_CX, 1, 2, 4, 24, "total 1" },
{ 170, BMP_CX, BMP_CX, 2, 7, 4, 24, "total 2" },
{ 85, BMP_CX, BMP_CX, 3, 7, 4, 24, "total 3" },
{ 0, BMP_CX, BMP_CX, 4, 7, 4, 24, "total 4" },
{ 0, BMP_CX, BMP_CX, 5, 7, 4, 24, "total 5" },
{ 85, BMP_CX, BMP_CX, 6, 7, 4, 24, "total 6" },
{ 170, BMP_CX, BMP_CX, 7, 12, 4, 24, "total 7" },
{ 255, BMP_CX, BMP_CX, 8, 12, 4, 24, "total 8" },
{ 255, BMP_CX, BMP_CX, 9, 12, 4, 24, "total 9" },
{ 170, BMP_CX, BMP_CX, 10, 12, 4, 24, "total 10" },
{ 85, BMP_CX, BMP_CX, 11, 12, 4, 24, "total 11" },
{ 0, BMP_CX, BMP_CX, 12, 17, 4, 24, "total 12" },
{ 0, BMP_CX, BMP_CX, 13, 17, 4, 24, "total 13" },
{ 85, BMP_CX, BMP_CX, 14, 17, 4, 24, "total 14" },
{ 170, BMP_CX, BMP_CX, 15, 17, 4, 24, "total 15" },
{ 255, BMP_CX, BMP_CX, 16, 17, 4, 24, "total 16" },
{ 255, BMP_CX, BMP_CX, 17, 22, 4, 24, "total 17" },
{ 170, BMP_CX, BMP_CX, 18, 22, 4, 24, "total 18" },
{ 85, BMP_CX, BMP_CX, 19, 22, 4, 24, "total 19" },
{ 0, BMP_CX, BMP_CX, 20, 22, 4, 24, "total 20" },
{ 0, BMP_CX, BMP_CX, 21, 22, 4, 24, "total 21" },
{ 85, BMP_CX, BMP_CX, 22, 27, 4, 24, "total 22" },
{ 170, BMP_CX, BMP_CX, 23, 27, 4, 24, "total 23" },
{ 255, BMP_CX, BMP_CX, 24, 27, 4, 24, "total 24" }
{ 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" }
};
check_iml_data(himl, BMP_CX, BMP_CX, 0, 2, 4, ILC_COLOR24, "total 0");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 2, grow, ILC_COLOR24, "total 0");
for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
{
image_list_add_bitmap(himl, td[i].grey, i + 1);
check_iml_data(himl, td[i].cx, td[i].cy, td[i].cur, td[i].max, td[i].grow, td[i].bpp, td[i].comment);
check_iml_data(himl, td[i].cx, td[i].cy, td[i].cur, td[i].max, grow, td[i].bpp, td[i].comment);
}
}
static void test_imagelist_storage(void)
{
HIMAGELIST himl;
INT ret, grow;
HBITMAP hbm;
HICON icon;
INT ret;
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR24, 1, 1);
ok(himl != 0, "ImageList_Create failed\n");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 2, 4, ILC_COLOR24, "empty");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 2, 1, ILC_COLOR24, "empty");
image_list_init(himl);
check_iml_data(himl, BMP_CX, BMP_CX, 24, 27, 4, ILC_COLOR24, "orig");
image_list_init(himl, 1);
check_iml_data(himl, BMP_CX, BMP_CX, 24, 27, 1, ILC_COLOR24, "orig");
ret = pImageList_Remove(himl, 4);
ok(ret, "ImageList_Remove failed\n");
check_iml_data(himl, BMP_CX, BMP_CX, 23, 27, 4, ILC_COLOR24, "1");
check_iml_data(himl, BMP_CX, BMP_CX, 23, 27, 1, ILC_COLOR24, "1");
ret = pImageList_Remove(himl, 5);
ok(ret, "ImageList_Remove failed\n");
check_iml_data(himl, BMP_CX, BMP_CX, 22, 27, 4, ILC_COLOR24, "2");
check_iml_data(himl, BMP_CX, BMP_CX, 22, 27, 1, ILC_COLOR24, "2");
ret = pImageList_Remove(himl, 6);
ok(ret, "ImageList_Remove failed\n");
check_iml_data(himl, BMP_CX, BMP_CX, 21, 27, 4, ILC_COLOR24, "3");
check_iml_data(himl, BMP_CX, BMP_CX, 21, 27, 1, ILC_COLOR24, "3");
ret = pImageList_Remove(himl, 7);
ok(ret, "ImageList_Remove failed\n");
check_iml_data(himl, BMP_CX, BMP_CX, 20, 27, 4, ILC_COLOR24, "4");
check_iml_data(himl, BMP_CX, BMP_CX, 20, 27, 1, ILC_COLOR24, "4");
ret = pImageList_Remove(himl, -2);
ok(!ret, "ImageList_Remove(-2) should fail\n");
check_iml_data(himl, BMP_CX, BMP_CX, 20, 27, 4, ILC_COLOR24, "5");
check_iml_data(himl, BMP_CX, BMP_CX, 20, 27, 1, ILC_COLOR24, "5");
ret = pImageList_Remove(himl, 20);
ok(!ret, "ImageList_Remove(20) should fail\n");
check_iml_data(himl, BMP_CX, BMP_CX, 20, 27, 4, ILC_COLOR24, "6");
check_iml_data(himl, BMP_CX, BMP_CX, 20, 27, 1, ILC_COLOR24, "6");
ret = pImageList_Remove(himl, -1);
ok(ret, "ImageList_Remove(-1) failed\n");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 4, 4, ILC_COLOR24, "7");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 4, 1, ILC_COLOR24, "7");
ret = pImageList_Destroy(himl);
ok(ret, "ImageList_Destroy failed\n");
......@@ -1162,13 +1177,13 @@ static void test_imagelist_storage(void)
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR24, 207, 209);
ok(himl != 0, "ImageList_Create failed\n");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 208, 212, ILC_COLOR24, "init 207 grow 209");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 208, 209, ILC_COLOR24, "init 207 grow 209");
ret = pImageList_Destroy(himl);
ok(ret, "ImageList_Destroy failed\n");
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR24, 209, 207);
ok(himl != 0, "ImageList_Create failed\n");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 210, 208, ILC_COLOR24, "init 209 grow 207");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 210, 207, ILC_COLOR24, "init 209 grow 207");
ret = pImageList_Destroy(himl);
ok(ret, "ImageList_Destroy failed\n");
......@@ -1180,13 +1195,13 @@ static void test_imagelist_storage(void)
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR24, 5, 9);
ok(himl != 0, "ImageList_Create failed\n");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 6, 12, ILC_COLOR24, "init 5 grow 9");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 6, 9, ILC_COLOR24, "init 5 grow 9");
ret = pImageList_Destroy(himl);
ok(ret, "ImageList_Destroy failed\n");
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR24, 9, 5);
ok(himl != 0, "ImageList_Create failed\n");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 10, 8, ILC_COLOR24, "init 9 grow 5");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 10, 5, ILC_COLOR24, "init 9 grow 5");
ret = pImageList_Destroy(himl);
ok(ret, "ImageList_Destroy failed\n");
......@@ -1198,79 +1213,88 @@ static void test_imagelist_storage(void)
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR24, 4, 2);
ok(himl != 0, "ImageList_Create failed\n");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 5, 4, ILC_COLOR24, "init 4 grow 2");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 5, 2, ILC_COLOR24, "init 4 grow 2");
ret = pImageList_Destroy(himl);
ok(ret, "ImageList_Destroy failed\n");
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR8, 4, 2);
ok(himl != 0, "ImageList_Create failed\n");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 5, 4, ILC_COLOR8, "bpp 8");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 5, 2, ILC_COLOR8, "bpp 8");
ret = pImageList_Destroy(himl);
ok(ret, "ImageList_Destroy failed\n");
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR4, 4, 2);
ok(himl != 0, "ImageList_Create failed\n");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 5, 4, ILC_COLOR4, "bpp 4");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 5, 2, ILC_COLOR4, "bpp 4");
ret = pImageList_Destroy(himl);
ok(ret, "ImageList_Destroy failed\n");
himl = pImageList_Create(BMP_CX, BMP_CX, 0, 4, 2);
ok(himl != 0, "ImageList_Create failed\n");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 5, 4, ILC_COLOR4, "bpp default");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 5, 2, ILC_COLOR4, "bpp default");
icon = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
ok( pImageList_ReplaceIcon(himl, -1, icon) == 0, "Failed to add icon.\n");
ok( pImageList_ReplaceIcon(himl, -1, icon) == 1, "Failed to add icon.\n");
DestroyIcon( icon );
check_iml_data(himl, BMP_CX, BMP_CX, 2, 5, 4, ILC_COLOR4, "bpp default");
check_iml_data(himl, BMP_CX, BMP_CX, 2, 5, 2, ILC_COLOR4, "bpp default");
ret = pImageList_Destroy(himl);
ok(ret, "ImageList_Destroy failed\n");
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR24|ILC_MASK, 4, 2);
ok(himl != 0, "ImageList_Create failed\n");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 5, 4, ILC_COLOR24|ILC_MASK, "bpp 24 + mask");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 5, 2, ILC_COLOR24|ILC_MASK, "bpp 24 + mask");
icon = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
ok( pImageList_ReplaceIcon(himl, -1, icon) == 0, "Failed to add icon.\n");
ok( pImageList_ReplaceIcon(himl, -1, icon) == 1, "Failed to add icon.\n");
DestroyIcon( icon );
check_iml_data(himl, BMP_CX, BMP_CX, 2, 5, 4, ILC_COLOR24|ILC_MASK, "bpp 24 + mask");
check_iml_data(himl, BMP_CX, BMP_CX, 2, 5, 2, ILC_COLOR24|ILC_MASK, "bpp 24 + mask");
ret = pImageList_Destroy(himl);
ok(ret, "ImageList_Destroy failed\n");
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR4|ILC_MASK, 4, 2);
ok(himl != 0, "ImageList_Create failed\n");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 5, 4, ILC_COLOR4|ILC_MASK, "bpp 4 + mask");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 5, 2, ILC_COLOR4|ILC_MASK, "bpp 4 + mask");
icon = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
ok( pImageList_ReplaceIcon(himl, -1, icon) == 0, "Failed to add icon.\n");
ok( pImageList_ReplaceIcon(himl, -1, icon) == 1, "Failed to add icon.\n");
DestroyIcon( icon );
check_iml_data(himl, BMP_CX, BMP_CX, 2, 5, 4, ILC_COLOR4|ILC_MASK, "bpp 4 + mask");
check_iml_data(himl, BMP_CX, BMP_CX, 2, 5, 2, ILC_COLOR4|ILC_MASK, "bpp 4 + mask");
ret = pImageList_Destroy(himl);
ok(ret, "ImageList_Destroy failed\n");
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR4|ILC_MASK, 2, 99);
ok(himl != 0, "ImageList_Create failed\n");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 3, 100, ILC_COLOR4|ILC_MASK, "init 2 grow 99");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 3, 99, ILC_COLOR4|ILC_MASK, "init 2 grow 99");
icon = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
ok( pImageList_ReplaceIcon(himl, -1, icon) == 0, "Failed to add icon.\n");
ok( pImageList_ReplaceIcon(himl, -1, icon) == 1, "Failed to add icon.\n");
check_iml_data(himl, BMP_CX, BMP_CX, 2, 3, 100, ILC_COLOR4|ILC_MASK, "init 2 grow 99 2 icons");
check_iml_data(himl, BMP_CX, BMP_CX, 2, 3, 99, ILC_COLOR4|ILC_MASK, "init 2 grow 99 2 icons");
ok( pImageList_ReplaceIcon(himl, -1, icon) == 2, "Failed to add icon\n");
DestroyIcon( icon );
check_iml_data(himl, BMP_CX, BMP_CX, 3, 104, 100, ILC_COLOR4|ILC_MASK, "init 2 grow 99 3 icons");
check_iml_data(himl, BMP_CX, BMP_CX, 3, 104, 99, ILC_COLOR4|ILC_MASK, "init 2 grow 99 3 icons");
ok( pImageList_Remove(himl, -1) == TRUE, "Failed to remove icon.\n");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 100, 100, ILC_COLOR4|ILC_MASK, "init 2 grow 99 empty");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 100, 99, ILC_COLOR4|ILC_MASK, "init 2 grow 99 empty");
ok( pImageList_SetImageCount(himl, 22) == TRUE, "Failed to set image count.\n");
check_iml_data(himl, BMP_CX, BMP_CX, 22, 23, 100, ILC_COLOR4|ILC_MASK, "init 2 grow 99 set count 22");
check_iml_data(himl, BMP_CX, BMP_CX, 22, 23, 99, ILC_COLOR4|ILC_MASK, "init 2 grow 99 set count 22");
ok( pImageList_SetImageCount(himl, 0) == TRUE, "Failed to set image count.\n");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 1, 100, ILC_COLOR4|ILC_MASK, "init 2 grow 99 set count 0");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 1, 99, ILC_COLOR4|ILC_MASK, "init 2 grow 99 set count 0");
ok( pImageList_SetImageCount(himl, 42) == TRUE, "Failed to set image count.\n");
check_iml_data(himl, BMP_CX, BMP_CX, 42, 43, 100, ILC_COLOR4|ILC_MASK, "init 2 grow 99 set count 42");
check_iml_data(himl, BMP_CX, BMP_CX, 42, 43, 99, ILC_COLOR4|ILC_MASK, "init 2 grow 99 set count 42");
ret = pImageList_Destroy(himl);
ok(ret, "ImageList_Destroy failed\n");
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");
}
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR4|ILC_MASK, 2, -20);
ok(himl != 0, "ImageList_Create failed\n");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 3, 4, ILC_COLOR4|ILC_MASK, "init 2 grow -20");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 3, -20, ILC_COLOR4|ILC_MASK, "init 2 grow -20");
ret = pImageList_Destroy(himl);
ok(ret, "ImageList_Destroy failed\n");
......@@ -1279,13 +1303,13 @@ static void test_imagelist_storage(void)
{
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR4|ILC_MASK, 2, 65536+12);
ok(himl != 0, "ImageList_Create failed\n");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 3, 12, ILC_COLOR4|ILC_MASK, "init 2 grow 65536+12");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 3, 65536+12, ILC_COLOR4|ILC_MASK, "init 2 grow 65536+12");
ret = pImageList_Destroy(himl);
ok(ret, "ImageList_Destroy failed\n");
himl = pImageList_Create(BMP_CX, BMP_CX, ILC_COLOR4|ILC_MASK, 2, 65535);
ok(himl != 0, "ImageList_Create failed\n");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 3, 0, ILC_COLOR4|ILC_MASK, "init 2 grow 65535");
check_iml_data(himl, BMP_CX, BMP_CX, 0, 3, 65535, ILC_COLOR4|ILC_MASK, "init 2 grow 65535");
ret = pImageList_Destroy(himl);
ok(ret, "ImageList_Destroy failed\n");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment