1 /* 2 * PROJECT: ReactOS API tests 3 * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+) 4 * PURPOSE: Test for SetFocus/GetFocus/GetGUIThreadInfo 5 * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com> 6 */ 7 8 #include "precomp.h" 9 #include <versionhelpers.h> 10 11 #define COPYIMAGE_VALID_FLAGS ( \ 12 LR_SHARED | LR_COPYFROMRESOURCE | LR_CREATEDIBSECTION | LR_LOADMAP3DCOLORS | 0x800 | \ 13 LR_VGACOLOR | LR_LOADREALSIZE | LR_DEFAULTSIZE | LR_LOADTRANSPARENT | LR_LOADFROMFILE | \ 14 LR_COPYDELETEORG | LR_COPYRETURNORG | LR_COLOR | LR_MONOCHROME \ 15 ) 16 17 #define LR_UNKNOWN_0x10000 0x10000 18 19 static HANDLE CreateTestImage(UINT uType) 20 { 21 HANDLE hImage; 22 switch (uType) 23 { 24 case IMAGE_BITMAP: 25 { 26 HDC hDC = CreateCompatibleDC(NULL); 27 hImage = (HANDLE)CreateCompatibleBitmap(hDC, 10, 10); 28 DeleteDC(hDC); 29 break; 30 } 31 case IMAGE_CURSOR: 32 hImage = (HANDLE)LoadCursor(NULL, IDC_ARROW); 33 break; 34 case IMAGE_ICON: 35 hImage = (HANDLE)LoadIcon(NULL, IDI_APPLICATION); 36 break; 37 } 38 return hImage; 39 } 40 41 static VOID 42 Test_CopyImage_Flags(UINT uType) 43 { 44 UINT iBit, uBit, uValidFlags = COPYIMAGE_VALID_FLAGS; 45 HANDLE hImage, hCopiedImage; 46 47 if (IsWindowsVistaOrGreater()) 48 uValidFlags |= LR_UNKNOWN_0x10000; 49 50 hImage = CreateTestImage(uType); 51 for (iBit = 0; iBit < sizeof(UINT) * CHAR_BIT; ++iBit) 52 { 53 uBit = (1 << iBit); 54 55 SetLastError(0xDEADFACE); 56 hCopiedImage = CopyImage(hImage, uType, 0, 0, uBit); 57 58 if (uValidFlags & uBit) // Valid flag? 59 { 60 ok(hCopiedImage != NULL, "iBit %u: uType %u: hCopiedImage was NULL\n", iBit, uType); 61 } 62 else 63 { 64 ok(hCopiedImage == NULL, "iBit %u: uType %u: hCopiedImage was %p\n", iBit, uType, hCopiedImage); 65 ok_err(ERROR_INVALID_PARAMETER); 66 } 67 68 if (hCopiedImage) 69 DeleteObject(hCopiedImage); 70 71 /* If the original image was deleted, re-create it */ 72 if (uBit & LR_COPYDELETEORG) 73 hImage = CreateTestImage(uType); 74 } 75 76 DeleteObject(hImage); 77 } 78 79 START_TEST(CopyImage) 80 { 81 Test_CopyImage_Flags(IMAGE_BITMAP); 82 Test_CopyImage_Flags(IMAGE_CURSOR); 83 Test_CopyImage_Flags(IMAGE_ICON); 84 } 85