diff --git "a/modules/rostests/apitests/user32/CopyImage.c" "b/modules/rostests/apitests/user32/CopyImage.c" index bad7c472f4f..9843e733e6c 100644 --- "a/modules/rostests/apitests/user32/CopyImage.c" +++ "b/modules/rostests/apitests/user32/CopyImage.c" @@ -3,6 +3,7 @@ * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+) * PURPOSE: Test for SetFocus/GetFocus/GetGUIThreadInfo * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ +* Copyright 2024 Doug Lyons */ #include "precomp.h" @@ -76,9 +77,53 @@ Test_CopyImage_Flags(UINT uType) DeleteObject(hImage); } +static VOID +Test_CopyImage_hImage_NULL(void) +{ + HANDLE hImg; + DWORD LastError; + + /* Test NULL HANDLE return and GetLastError return. */ + SetLastError(0xdeadbeef); + hImg = CopyImage(NULL, IMAGE_ICON, 16, 16, 0x4000); + LastError = GetLastError(); + ok(LastError == ERROR_INVALID_CURSOR_HANDLE, "Wrong error 0x%08lx returned\n", LastError); + ok(!hImg, "Image returned should have been NULL\n"); + + SetLastError(0xdeadbeef); + hImg = CopyImage(NULL, IMAGE_BITMAP, 16, 16, 0x4000); + LastError = GetLastError(); + ok(LastError == ERROR_INVALID_HANDLE, "Wrong error 0x%08lx returned\n", LastError); + ok(!hImg, "Image returned should have been NULL\n"); + + + SetLastError(0xdeadbeef); + hImg = CopyImage(NULL, IMAGE_CURSOR, 16, 16, 0x4000); + LastError = GetLastError(); + ok(LastError == ERROR_INVALID_CURSOR_HANDLE, "Wrong error 0x%08lx returned\n", LastError); + ok(!hImg, "Image returned should have been NULL\n"); + + /* Test bad Type (5) GetLastError return value. Not Icon, Cursor, or Bitmap. */ + SetLastError(0xdeadbeef); + hImg = CopyImage(NULL, 5, 16, 16, 0x4000); + LastError = GetLastError(); + ok(LastError == ERROR_INVALID_PARAMETER, "Wrong error 0x%08lx returned\n", LastError); + ok(!hImg, "Image returned should have been NULL\n"); + + /* Test bad type (5) GetLastError return value with good HANDLE */ + hImg = CreateTestImage(IMAGE_ICON); + SetLastError(0xdeadbeef); + hImg = CopyImage(hImg, 5, 16, 16, 0x4000); + LastError = GetLastError(); + ok(LastError == ERROR_INVALID_PARAMETER, "Wrong error 0x%08lx returned\n", LastError); + ok(!hImg, "Image returned should have been NULL\n"); + DeleteObject(hImg); +} + START_TEST(CopyImage) { Test_CopyImage_Flags(IMAGE_BITMAP); Test_CopyImage_Flags(IMAGE_CURSOR); Test_CopyImage_Flags(IMAGE_ICON); + Test_CopyImage_hImage_NULL(); }