From 5a07018dec6d54a16394189a16ba4801d7c9208b Mon Sep 17 00:00:00 2001 From: Andrew Riedi Date: Tue, 25 Nov 2008 22:24:42 -0800 Subject: [PATCH] user32: Improve the LoadImage() test. --- dlls/user32/tests/cursoricon.c | 47 +++++++++++++++++++++++++++++++++++---- 1 files changed, 42 insertions(+), 5 deletions(-) diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c index 5d1cf2b..d167918 100644 --- a/dlls/user32/tests/cursoricon.c +++ b/dlls/user32/tests/cursoricon.c @@ -789,7 +789,7 @@ static void test_LoadImage(void) /* Set icon data. */ icon_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ICON_SIZE); icon_data->idReserved = 0; - icon_data->idType = 1; + icon_data->idType = 1; /* .ico */ icon_data->idCount = 1; icon_entry = icon_data->idEntries; @@ -797,8 +797,8 @@ static void test_LoadImage(void) icon_entry->bHeight = ICON_HEIGHT; icon_entry->bColorCount = 0; icon_entry->bReserved = 0; - icon_entry->xHotspot = 1; - icon_entry->yHotspot = 1; + icon_entry->xHotspot = 1; /* Color planes for .ico. */ + icon_entry->yHotspot = ICON_BPP; /* BPP for .ico. */ icon_entry->dwDIBSize = ICON_SIZE - sizeof(CURSORICONFILEDIR); icon_entry->dwDIBOffset = sizeof(CURSORICONFILEDIR); @@ -837,9 +837,13 @@ static void test_LoadImage(void) if (ret) { - ok(icon_info.fIcon == FALSE, "fIcon != FALSE.\n"); + ok(icon_info.fIcon == FALSE, "fIcon == TRUE.\n"); + /* LoadImage(..., IMAGE_CURSOR, ...) ignores icon_data->idType and as + * a result assigns the color planes and BPP values to the xHotspot + * and yHotspot, respectively. In short, a .ico is just assumed to be + * a .cur file with such a call to LoadImage(). */ ok(icon_info.xHotspot == 1, "xHotspot is %u.\n", icon_info.xHotspot); - ok(icon_info.yHotspot == 1, "yHotspot is %u.\n", icon_info.yHotspot); + ok(icon_info.yHotspot == 32, "yHotspot is %u.\n", icon_info.yHotspot); ok(icon_info.hbmColor != NULL, "No hbmColor!\n"); ok(icon_info.hbmMask != NULL, "No hbmMask!\n"); } @@ -851,6 +855,39 @@ static void test_LoadImage(void) error = GetLastError(); ok(error == 0xdeadbeef, "Last error: %u\n", error); + /* Test loading an icon as an icon. */ + SetLastError(0xdeadbeef); + handle = LoadImageA(NULL, "icon.ico", IMAGE_ICON, 0, 0, LR_LOADFROMFILE); + ok(handle != NULL, "LoadImage() failed.\n"); + error = GetLastError(); + ok(error == 0 || + broken(error == 0xdeadbeef) || /* Win9x */ + broken(error == ERROR_BAD_PATHNAME), /* Win98, WinMe */ + "Last error: %u\n", error); + + /* Test the icon information. */ + SetLastError(0xdeadbeef); + ret = GetIconInfo(handle, &icon_info); + ok(ret, "GetIconInfo() failed.\n"); + error = GetLastError(); + ok(error == 0xdeadbeef, "Last error: %u\n", error); + + if (ret) + { + ok(icon_info.fIcon == TRUE, "fIcon == FALSE.\n"); + ok(icon_info.xHotspot == 16, "xHotspot is %u.\n", icon_info.xHotspot); + ok(icon_info.yHotspot == 16, "yHotspot is %u.\n", icon_info.yHotspot); + ok(icon_info.hbmColor != NULL, "No hbmColor!\n"); + ok(icon_info.hbmMask != NULL, "No hbmMask!\n"); + } + + /* Clean up. */ + SetLastError(0xdeadbeef); + ret = DestroyIcon(handle); + ok(ret, "DestroyIcon() failed.\n"); + error = GetLastError(); + ok(error == 0xdeadbeef, "Last error: %u\n", error); + HeapFree(GetProcessHeap(), 0, icon_data); DeleteFileA("icon.ico"); -- 1.5.6.3