ReactOS 0.4.16-dev-550-g2186ce3
CopyImage.c File Reference
#include "precomp.h"
#include <versionhelpers.h>
Include dependency graph for CopyImage.c:

Go to the source code of this file.

Macros

#define COPYIMAGE_VALID_FLAGS
 
#define LR_UNKNOWN_0x10000   0x10000
 

Functions

static HANDLE CreateTestImage (UINT uType)
 
static VOID Test_CopyImage_Flags (UINT uType)
 
static VOID Test_CopyImage_hImage_NULL (void)
 
 START_TEST (CopyImage)
 

Macro Definition Documentation

◆ COPYIMAGE_VALID_FLAGS

#define COPYIMAGE_VALID_FLAGS
Value:
( \
)
#define LR_VGACOLOR
Definition: winuser.h:1099
#define LR_COLOR
Definition: winuser.h:1092
#define LR_LOADTRANSPARENT
Definition: winuser.h:1096
#define LR_LOADFROMFILE
Definition: winuser.h:1095
#define LR_LOADREALSIZE
Definition: winuser.h:1098
#define LR_COPYFROMRESOURCE
Definition: winuser.h:1102
#define LR_CREATEDIBSECTION
Definition: winuser.h:1101
#define LR_MONOCHROME
Definition: winuser.h:1091
#define LR_COPYRETURNORG
Definition: winuser.h:1093
#define LR_COPYDELETEORG
Definition: winuser.h:1094
#define LR_SHARED
Definition: winuser.h:1103
#define LR_DEFAULTSIZE
Definition: winuser.h:1097
#define LR_LOADMAP3DCOLORS
Definition: winuser.h:1100

Definition at line 12 of file CopyImage.c.

◆ LR_UNKNOWN_0x10000

#define LR_UNKNOWN_0x10000   0x10000

Definition at line 18 of file CopyImage.c.

Function Documentation

◆ CreateTestImage()

static HANDLE CreateTestImage ( UINT  uType)
static

Definition at line 20 of file CopyImage.c.

21{
22 HANDLE hImage;
23 switch (uType)
24 {
25 case IMAGE_BITMAP:
26 {
28 hImage = (HANDLE)CreateCompatibleBitmap(hDC, 10, 10);
30 break;
31 }
32 case IMAGE_CURSOR:
33 hImage = (HANDLE)LoadCursor(NULL, IDC_ARROW);
34 break;
35 case IMAGE_ICON:
37 break;
38 }
39 return hImage;
40}
static HDC hDC
Definition: 3dtext.c:33
#define NULL
Definition: types.h:112
static HDC
Definition: imagelist.c:88
PVOID HANDLE
Definition: typedefs.h:73
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
BOOL WINAPI DeleteDC(_In_ HDC)
#define IMAGE_BITMAP
Definition: winuser.h:211
#define IMAGE_ICON
Definition: winuser.h:212
#define IDC_ARROW
Definition: winuser.h:687
#define IDI_APPLICATION
Definition: winuser.h:704
#define LoadIcon
Definition: winuser.h:5825
#define LoadCursor
Definition: winuser.h:5824
#define IMAGE_CURSOR
Definition: winuser.h:213

Referenced by Test_CopyImage_Flags(), and Test_CopyImage_hImage_NULL().

◆ START_TEST()

START_TEST ( CopyImage  )

Definition at line 131 of file CopyImage.c.

132{
137}
static VOID Test_CopyImage_Flags(UINT uType)
Definition: CopyImage.c:43
static VOID Test_CopyImage_hImage_NULL(void)
Definition: CopyImage.c:81

◆ Test_CopyImage_Flags()

static VOID Test_CopyImage_Flags ( UINT  uType)
static

Definition at line 43 of file CopyImage.c.

44{
45 UINT iBit, uBit, uValidFlags = COPYIMAGE_VALID_FLAGS;
46 HANDLE hImage, hCopiedImage;
47
49 uValidFlags |= LR_UNKNOWN_0x10000;
50
51 hImage = CreateTestImage(uType);
52 for (iBit = 0; iBit < sizeof(UINT) * CHAR_BIT; ++iBit)
53 {
54 uBit = (1 << iBit);
55
56 SetLastError(0xDEADFACE);
57 hCopiedImage = CopyImage(hImage, uType, 0, 0, uBit);
58
59 if (uValidFlags & uBit) // Valid flag?
60 {
61 ok(hCopiedImage != NULL, "iBit %u: uType %u: hCopiedImage was NULL\n", iBit, uType);
62 }
63 else
64 {
65 ok(hCopiedImage == NULL, "iBit %u: uType %u: hCopiedImage was %p\n", iBit, uType, hCopiedImage);
67 }
68
69 if (hCopiedImage)
70 DeleteObject(hCopiedImage);
71
72 /* If the original image was deleted, re-create it */
73 if (uBit & LR_COPYDELETEORG)
74 hImage = CreateTestImage(uType);
75 }
76
77 DeleteObject(hImage);
78}
static HANDLE CreateTestImage(UINT uType)
Definition: CopyImage.c:20
#define COPYIMAGE_VALID_FLAGS
Definition: CopyImage.c:12
#define LR_UNKNOWN_0x10000
Definition: CopyImage.c:18
#define ok(value,...)
Definition: atltest.h:57
#define ok_err(error)
Definition: atltest.h:124
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define CHAR_BIT
Definition: urlcache.c:62
pKey DeleteObject()
unsigned int UINT
Definition: ndis.h:50
VERSIONHELPERAPI IsWindowsVistaOrGreater()
HANDLE WINAPI CopyImage(_In_ HANDLE, _In_ UINT, _In_ int, _In_ int, _In_ UINT)
Definition: cursoricon.c:2024

Referenced by START_TEST().

◆ Test_CopyImage_hImage_NULL()

static VOID Test_CopyImage_hImage_NULL ( void  )
static

Definition at line 81 of file CopyImage.c.

82{
83 HANDLE hImg;
84 DWORD LastError;
85
86 /* Test NULL HANDLE return and GetLastError return. */
87 SetLastError(0xdeadbeef);
89 LastError = GetLastError();
90 ok(LastError == ERROR_INVALID_CURSOR_HANDLE, "Wrong error 0x%08lx returned\n", LastError);
91 ok(!hImg, "Image returned should have been NULL, hImg was %p\n", hImg);
92
93 SetLastError(0xdeadbeef);
95 LastError = GetLastError();
96 ok(LastError == ERROR_INVALID_HANDLE, "Wrong error 0x%08lx returned\n", LastError);
97 ok(!hImg, "Image returned should have been NULL, hImg was %p\n", hImg);
98
99
100 SetLastError(0xdeadbeef);
102 LastError = GetLastError();
103 ok(LastError == ERROR_INVALID_CURSOR_HANDLE, "Wrong error 0x%08lx returned\n", LastError);
104 ok(!hImg, "Image returned should have been NULL, hImg was %p\n", hImg);
105
106 /* Test bad Flags for Invalid Parameter return */
107 SetLastError(0xdeadbeef);
108 /* 0x80000000 is an invalid flag value */
109 hImg = CopyImage(NULL, IMAGE_BITMAP, 16, 16, 0x80000000);
110 LastError = GetLastError();
111 ok(LastError == ERROR_INVALID_PARAMETER, "Wrong error 0x%08lx returned\n", LastError);
112 ok(!hImg, "Image returned should have been NULL, hImg was %p\n", hImg);
113
114 /* Test bad Type (5) GetLastError return value. Not Icon, Cursor, or Bitmap. */
115 SetLastError(0xdeadbeef);
116 hImg = CopyImage(NULL, 5, 16, 16, LR_COPYFROMRESOURCE);
117 LastError = GetLastError();
118 ok(LastError == ERROR_INVALID_PARAMETER, "Wrong error 0x%08lx returned\n", LastError);
119 ok(!hImg, "Image returned should have been NULL, hImg was %p\n", hImg);
120
121 /* Test bad type (5) GetLastError return value with good HANDLE */
123 SetLastError(0xdeadbeef);
124 hImg = CopyImage(hImg, 5, 16, 16, LR_COPYFROMRESOURCE);
125 LastError = GetLastError();
126 ok(LastError == ERROR_INVALID_PARAMETER, "Wrong error 0x%08lx returned\n", LastError);
127 ok(!hImg, "Image returned should have been NULL, hImg was %p\n", hImg);
128 DeleteObject(hImg);
129}
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_INVALID_CURSOR_HANDLE
Definition: winerror.h:883

Referenced by START_TEST().