Ziqing Hui : user32/tests: Call Destroy{icon, cursor}() before GetIconInfo().

Alexandre Julliard julliard at winehq.org
Thu Dec 9 15:34:27 CST 2021


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

Author: Ziqing Hui <zhui at codeweavers.com>
Date:   Thu Dec  9 11:20:55 2021 +0800

user32/tests: Call Destroy{icon, cursor}() before GetIconInfo().

For icons/cursors created by CreateIconFromResource(),
GetIconInfo() still succeed after they were destroyed,
which indicates that these icons/cursors are shared.

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

---

 dlls/user32/tests/cursoricon.c | 37 ++++++++++++++++---------------------
 1 file changed, 16 insertions(+), 21 deletions(-)

diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c
index a4bdc4f13cf..d73650e08f7 100644
--- a/dlls/user32/tests/cursoricon.c
+++ b/dlls/user32/tests/cursoricon.c
@@ -1589,12 +1589,16 @@ static void test_CreateIconFromResource(void)
     SetLastError(0xdeadbeef);
     handle = CreateIconFromResource((PBYTE) hotspot, CRSR_RES_SIZE, FALSE, 0x00030000);
     ok(handle != NULL, "Create cursor failed.\n");
+    ret = DestroyCursor(handle);
+    ok(ret, "Destroy cursor failed, error %u.\n", GetLastError());
 
     /* Test the icon information. */
     SetLastError(0xdeadbeef);
     ret = GetIconInfo(handle, &icon_info);
+    todo_wine
     ok(ret, "GetIconInfo() failed.\n");
     error = GetLastError();
+    todo_wine
     ok(error == 0xdeadbeef, "Last error: %u\n", error);
 
     if (ret)
@@ -1612,30 +1616,31 @@ static void test_CreateIconFromResource(void)
         ICONINFOEXA infoex;
         infoex.cbSize = sizeof(infoex);
         ret = pGetIconInfoExA( handle, &infoex );
+        todo_wine
         ok( ret, "GetIconInfoEx failed err %d\n", GetLastError() );
+        if (ret)
+        {
         ok( infoex.wResID == 0, "GetIconInfoEx wrong resid %x\n", infoex.wResID );
         ok( infoex.szModName[0] == 0, "GetIconInfoEx wrong module %s\n", infoex.szModName );
         ok( infoex.szResName[0] == 0, "GetIconInfoEx wrong name %s\n", infoex.szResName );
+        }
     }
 
-    /* Clean up. */
-    SetLastError(0xdeadbeef);
-    ret = DestroyCursor(handle);
-    ok(ret, "DestroyCursor() failed.\n");
-    error = GetLastError();
-    ok(error == 0xdeadbeef, "Last error: %u\n", error);
-
     /* Test creating an icon. */
     SetLastError(0xdeadbeef);
     handle = CreateIconFromResource((PBYTE) icon_header, ICON_RES_SIZE, TRUE,
 				    0x00030000);
     ok(handle != NULL, "Create icon failed.\n");
+    ret = DestroyIcon(handle);
+    ok(ret, "Destroy icon failed, error %u.\n", GetLastError());
 
     /* Test the icon information. */
     SetLastError(0xdeadbeef);
     ret = GetIconInfo(handle, &icon_info);
+    todo_wine
     ok(ret, "GetIconInfo() failed.\n");
     error = GetLastError();
+    todo_wine
     ok(error == 0xdeadbeef, "Last error: %u\n", error);
 
     if (ret)
@@ -1648,13 +1653,6 @@ static void test_CreateIconFromResource(void)
         ok(icon_info.hbmMask != NULL, "No hbmMask!\n");
     }
 
-    /* Clean up. */
-    SetLastError(0xdeadbeef);
-    ret = DestroyCursor(handle);
-    ok(ret, "DestroyCursor() failed.\n");
-    error = GetLastError();
-    ok(error == 0xdeadbeef, "Last error: %u\n", error);
-
     /* Rejection of NULL pointer crashes at least on WNT4WSSP6, W2KPROSP4, WXPPROSP3
      *
      * handle = CreateIconFromResource(NULL, ICON_RES_SIZE, TRUE, 0x00030000);
@@ -1667,12 +1665,16 @@ static void test_CreateIconFromResource(void)
     empty_anicursor.frames[0].data.icon_info.idEntries[0].yHotspot = 3;
     handle = CreateIconFromResource((PBYTE) &empty_anicursor, sizeof(empty_anicursor), FALSE, 0x00030000);
     ok(handle != NULL, "Create cursor failed.\n");
+    ret = DestroyCursor(handle);
+    ok(ret, "Destroy cursor failed, error %u.\n", GetLastError());
 
     /* Test the animated cursor's information. */
     SetLastError(0xdeadbeef);
     ret = GetIconInfo(handle, &icon_info);
+    todo_wine
     ok(ret, "GetIconInfo() failed.\n");
     error = GetLastError();
+    todo_wine
     ok(error == 0xdeadbeef, "Last error: %u\n", error);
 
     if (ret)
@@ -1685,13 +1687,6 @@ static void test_CreateIconFromResource(void)
         ok(icon_info.hbmMask != NULL, "No hbmMask!\n");
     }
 
-    /* Clean up. */
-    SetLastError(0xdeadbeef);
-    ret = DestroyCursor(handle);
-    ok(ret, "DestroyCursor() failed.\n");
-    error = GetLastError();
-    ok(error == 0xdeadbeef, "Last error: %u\n", error);
-
     /* Test creating and destroying a non-shared icon. */
     handle = CreateIconFromResourceEx((BYTE *)icon_header, ICON_RES_SIZE, TRUE, 0x00030000,
                                        0, 0, LR_DEFAULTSIZE);




More information about the wine-cvs mailing list