Ziqing Hui : user32/tests: Test CreateIconFromResourceEx() with resource bits.

Alexandre Julliard julliard at winehq.org
Wed Dec 8 15:46:30 CST 2021


Module: wine
Branch: master
Commit: 1746ed9c7d5c67c0f695bc78ccc2c01c11663a91
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=1746ed9c7d5c67c0f695bc78ccc2c01c11663a91

Author: Ziqing Hui <zhui at codeweavers.com>
Date:   Tue Dec  7 18:06:44 2021 +0800

user32/tests: Test CreateIconFromResourceEx() with resource bits.

Signed-off-by: Ziqing Hui <zhui at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/tests/cursoricon.c | 49 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c
index b1a8c48b35d..fac330bd7e9 100644
--- a/dlls/user32/tests/cursoricon.c
+++ b/dlls/user32/tests/cursoricon.c
@@ -1539,6 +1539,13 @@ static void test_LoadImage(void)
     test_LoadImage_working_directory();
 }
 
+static BOOL CALLBACK find_res_proc(HMODULE module, LPCSTR type, LPSTR name, LONG_PTR param)
+{
+    char **res_name = (char **)param;
+    *res_name = name;
+    return FALSE;
+}
+
 static void test_CreateIconFromResource(void)
 {
     HANDLE handle, old_handle;
@@ -1547,6 +1554,13 @@ static void test_CreateIconFromResource(void)
     BITMAPINFOHEADER *icon_header;
     INT16 *hotspot;
     ICONINFO icon_info;
+    HMODULE user32;
+    char *res_name;
+    HRSRC rsrc;
+    HGLOBAL res;
+    BYTE *bits;
+    UINT size;
+
 
 #define ICON_RES_WIDTH 32
 #define ICON_RES_HEIGHT 32
@@ -1706,6 +1720,41 @@ static void test_CreateIconFromResource(void)
     ok(handle != old_handle, "Expect a different handle.\n");
 
     HeapFree(GetProcessHeap(), 0, hotspot);
+
+    /* Get icon resource bits */
+    user32 = GetModuleHandleA("user32.dll");
+    EnumResourceNamesA(user32, (const char *)RT_GROUP_ICON, find_res_proc, (LONG_PTR)&res_name);
+    rsrc = FindResourceA(user32, res_name, (const char *)RT_GROUP_ICON);
+    ok(rsrc != NULL, "Find resource failed, error %u.\n", GetLastError());
+    res = LoadResource(user32, rsrc);
+    ok(res != NULL, "Load resource failed, error %u.\n", GetLastError());
+    bits = LockResource(res);
+    ok(bits != NULL, "Lock resource failed, error %u.\n", GetLastError());
+
+    res_name = MAKEINTRESOURCEA(LookupIconIdFromDirectory(bits, TRUE));
+    rsrc = FindResourceA(user32, res_name, (const char *)RT_ICON);
+    ok(rsrc != NULL, "Find resource failed, error %u.\n", GetLastError());
+    size = SizeofResource(user32, rsrc);
+    ok(size != 0, "Get resource size failed, error %u.\n", GetLastError());
+    res = LoadResource(user32, rsrc);
+    ok(res != NULL, "Load resource failed, error %u.\n", GetLastError());
+    bits = LockResource(res);
+    ok(bits != NULL, "Lock resource failed, error %u.\n", GetLastError());
+
+    /* Test creating and destroying a shared icon from resource bits. */
+    handle = CreateIconFromResourceEx(bits, size, TRUE, 0x00030000, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
+    ok(handle != NULL, "Create icon failed, error %u\n", GetLastError());
+    ret = DestroyIcon(handle);
+    ok(ret, "Destroy icon failed, error %u.\n", GetLastError());
+    ret = GetIconInfo(handle, &icon_info);
+    todo_wine
+    ok(ret, "Get info failed, error %u.\n", GetLastError());
+
+    /* Test creating a shared icon from resource bits that has been created before. */
+    old_handle = handle;
+    handle = CreateIconFromResourceEx(bits, size, TRUE, 0x00030000, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
+    ok(handle != NULL, "Create icon failed, error %u.\n", GetLastError());
+    ok(handle != old_handle, "Expect a different handle.\n");
 }
 
 static int check_cursor_data( HDC hdc, HCURSOR hCursor, void *data, int length)




More information about the wine-cvs mailing list