Alexandre Julliard : user32/tests: Add more tests for DestroyCursor on the active cursor.

Alexandre Julliard julliard at winehq.org
Wed Oct 13 11:43:09 CDT 2010


Module: wine
Branch: master
Commit: 1aab7ea8372cf2f36610c635cc7a232ee94cf1be
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=1aab7ea8372cf2f36610c635cc7a232ee94cf1be

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Oct 13 13:58:19 2010 +0200

user32/tests: Add more tests for DestroyCursor on the active cursor.

---

 dlls/user32/tests/cursoricon.c |   94 +++++++++++++++++++++++++++++++++-------
 1 files changed, 78 insertions(+), 16 deletions(-)

diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c
index 10f0037..57419e5 100644
--- a/dlls/user32/tests/cursoricon.c
+++ b/dlls/user32/tests/cursoricon.c
@@ -1731,8 +1731,8 @@ static void test_ShowCursor(void)
 static void test_DestroyCursor(void)
 {
     static const BYTE bmp_bits[4096];
-    ICONINFO cursorInfo;
-    HCURSOR cursor, cursor2;
+    ICONINFO cursorInfo, new_info;
+    HCURSOR cursor, cursor2, new_cursor;
     BOOL ret;
     DWORD error;
     UINT display_bpp;
@@ -1760,23 +1760,85 @@ static void test_DestroyCursor(void)
     ok(!ret || broken(ret)  /* succeeds on win9x */, "DestroyCursor on the active cursor succeeded\n");
     error = GetLastError();
     ok(error == 0xdeadbeef, "Last error: %u\n", error);
-    if (!ret)
+
+    new_cursor = GetCursor();
+    if (ret)  /* win9x replaces cursor by another one on destroy */
+        ok(new_cursor != cursor, "GetCursor returned %p/%p\n", new_cursor, cursor);
+    else
+        ok(new_cursor == cursor, "GetCursor returned %p/%p\n", new_cursor, cursor);
+
+    SetLastError(0xdeadbeef);
+    ret = GetIconInfo( cursor, &new_info );
+    todo_wine ok( !ret || broken(ret), /* nt4 */ "GetIconInfo succeeded\n" );
+    todo_wine ok( GetLastError() == ERROR_INVALID_CURSOR_HANDLE ||
+        broken(GetLastError() == 0xdeadbeef), /* win9x */
+        "wrong error %u\n", GetLastError() );
+
+    if (ret)  /* nt4 delays destruction until cursor changes */
     {
-        cursor2 = GetCursor();
-        ok(cursor2 == cursor, "Active was set to %p when trying to destroy it\n", cursor2);
-        SetCursor(NULL);
-
-        /* Trying to destroy the cursor properly fails now with
-         * ERROR_INVALID_CURSOR_HANDLE.  This happens because we called
-         * DestroyCursor() 2+ times after calling SetCursor().  The calls to
-         * GetCursor() and SetCursor(NULL) in between make no difference. */
+        DeleteObject( new_info.hbmColor );
+        DeleteObject( new_info.hbmMask );
+
         SetLastError(0xdeadbeef);
-        ret = DestroyCursor(cursor);
-        todo_wine ok(!ret, "DestroyCursor succeeded.\n");
-        error = GetLastError();
-        ok(error == ERROR_INVALID_CURSOR_HANDLE || error == 0xdeadbeef, /* vista */
-           "Last error: 0x%08x\n", error);
+        ret = DestroyCursor( cursor );
+        ok( !ret, "DestroyCursor succeeded\n" );
+        ok( GetLastError() == ERROR_INVALID_CURSOR_HANDLE || GetLastError() == 0xdeadbeef,
+            "wrong error %u\n", GetLastError() );
+
+        SetLastError(0xdeadbeef);
+        cursor2 = SetCursor( cursor );
+        ok( cursor2 == cursor, "SetCursor returned %p/%p\n", cursor2, cursor);
+        ok( GetLastError() == ERROR_INVALID_CURSOR_HANDLE || GetLastError() == 0xdeadbeef,
+            "wrong error %u\n", GetLastError() );
     }
+    else
+    {
+        SetLastError(0xdeadbeef);
+        cursor2 = CopyCursor( cursor );
+        ok(!cursor2, "CopyCursor succeeded\n" );
+        ok( GetLastError() == ERROR_INVALID_CURSOR_HANDLE ||
+            broken(GetLastError() == 0xdeadbeef), /* win9x */
+            "wrong error %u\n", GetLastError() );
+
+        SetLastError(0xdeadbeef);
+        ret = DestroyCursor( cursor );
+        if (new_cursor != cursor)  /* win9x */
+            ok( ret, "DestroyCursor succeeded\n" );
+        else
+            ok( !ret, "DestroyCursor succeeded\n" );
+        ok( GetLastError() == ERROR_INVALID_CURSOR_HANDLE || GetLastError() == 0xdeadbeef,
+            "wrong error %u\n", GetLastError() );
+
+        SetLastError(0xdeadbeef);
+        cursor2 = SetCursor( cursor );
+        ok(!cursor2, "SetCursor returned %p/%p\n", cursor2, cursor);
+        ok( GetLastError() == ERROR_INVALID_CURSOR_HANDLE || GetLastError() == 0xdeadbeef,
+            "wrong error %u\n", GetLastError() );
+    }
+
+    cursor2 = GetCursor();
+    ok(cursor2 == new_cursor, "GetCursor returned %p/%p\n", cursor2, new_cursor);
+
+    SetLastError(0xdeadbeef);
+    cursor2 = SetCursor( 0 );
+    if (new_cursor != cursor)  /* win9x */
+        ok(cursor2 == new_cursor, "SetCursor returned %p/%p\n", cursor2, cursor);
+    else
+        todo_wine ok(!cursor2, "SetCursor returned %p/%p\n", cursor2, cursor);
+    ok( GetLastError() == 0xdeadbeef, "wrong error %u\n", GetLastError() );
+
+    cursor2 = GetCursor();
+    ok(!cursor2, "GetCursor returned %p/%p\n", cursor2, cursor);
+
+    SetLastError(0xdeadbeef);
+    ret = DestroyCursor(cursor);
+    if (new_cursor != cursor)  /* win9x */
+        ok( ret, "DestroyCursor succeeded\n" );
+    else
+        todo_wine ok( !ret, "DestroyCursor succeeded\n" );
+    error = GetLastError();
+    ok( GetLastError() == ERROR_INVALID_CURSOR_HANDLE || GetLastError() == 0xdeadbeef,
+        "wrong error %u\n", GetLastError() );
 
     DeleteObject(cursorInfo.hbmMask);
     DeleteObject(cursorInfo.hbmColor);




More information about the wine-cvs mailing list