ReactOS 0.4.16-dev-197-g92996da
NtGdiCreateBitmap.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for NtGdiCreateBitmap
5 * PROGRAMMERS:
6 */
7
8#include "../win32nt.h"
9
11{
12 HBITMAP hBmp;
14 BYTE BitmapData[10] = {0x11, 0x22, 0x33};
15
16 /* Test simple params */
18 ok((hBmp = NtGdiCreateBitmap(1, 1, 1, 1, NULL)) != NULL, "hBmp was NULL.\n");
20 DeleteObject(hBmp);
21
22 /* Test all zero */
24 ok_ptr(NtGdiCreateBitmap(0, 0, 0, 0, NULL), NULL);
26
27 /* Test cx == 0 */
29 ok_ptr(NtGdiCreateBitmap(0, 1, 1, 1, NULL), NULL);
31
32 /* Test negative cx */
34 ok_ptr(NtGdiCreateBitmap(-10, 1, 1, 1, NULL), NULL);
36
37 /* Test cy == 0 */
39 ok_ptr(NtGdiCreateBitmap(1, 0, 1, 1, NULL), NULL);
41
42 /* Test negative cy */
44 ok_ptr(NtGdiCreateBitmap(1, -2, 1, 1, NULL), NULL);
46
47 /* Test negative cy and valid bits */
51
52 /* Test negative cy and invalid bits */
54 ok_ptr(NtGdiCreateBitmap(1, -2, 1, 1, (BYTE*)(LONG_PTR)0x80001234), NULL);
56
57#ifndef _WIN64 // Win64 doesn't fail here
58 /* Test huge size */
60 ok_ptr(NtGdiCreateBitmap(100000, 100000, 1, 1, NULL), NULL);
62#endif
63
64 /* Test too huge size */
66 ok_ptr(NtGdiCreateBitmap(100000, 100000, 1, 32, NULL), NULL);
68
69 /* Test huge size and valid bits */
71 TEST(NtGdiCreateBitmap(1000, 1000, 1, 1, BitmapData) == NULL);
73
74 /* Test huge size and invalid bits */
76 ok_ptr(NtGdiCreateBitmap(100000, 100000, 1, 1, (BYTE*)(LONG_PTR)0x80001234), NULL);
78
79 /* Test cPlanes == 0 */
81 ok((hBmp = NtGdiCreateBitmap(1, 1, 0, 1, NULL)) != NULL, "hBmp was NULL.\n");
83 ok_int(GetObject(hBmp, sizeof(BITMAP), &bitmap), (int)sizeof(BITMAP));
84 ok_int(bitmap.bmType, 0);
85 ok_int(bitmap.bmWidth, 1);
86 ok_int(bitmap.bmHeight, 1);
87 ok_int(bitmap.bmWidthBytes, 2);
88 ok_int(bitmap.bmPlanes, 1);
89 ok_int(bitmap.bmBitsPixel, 1);
90 DeleteObject(hBmp);
91
92 /* Test big cPlanes */
94 ok((hBmp = NtGdiCreateBitmap(1, 1, 32, 1, NULL)) != NULL, "hBmp was NULL.\n");
96 DeleteObject(hBmp);
97
98 ok_ptr(NtGdiCreateBitmap(1, 1, 33, 1, NULL), NULL);
100
101 /* Test cBPP == 0 */
103 ok((hBmp = NtGdiCreateBitmap(1, 1, 1, 0, NULL)) != NULL, "hBmp was NULL.\n");
105 ok_int(GetObject(hBmp, sizeof(BITMAP), &bitmap), (int)sizeof(BITMAP));
106 ok_int(bitmap.bmType, 0);
107 ok_int(bitmap.bmWidth, 1);
108 ok_int(bitmap.bmHeight, 1);
109 ok_int(bitmap.bmWidthBytes, 2);
110 ok_int(bitmap.bmPlanes, 1);
111 ok_int(bitmap.bmBitsPixel, 1);
112 DeleteObject(hBmp);
113
114 /* Test negative cBPP */
116 ok_ptr(NtGdiCreateBitmap(1, 1, 1, -1, NULL), NULL);
118
119 /* Test bad cBPP */
121 ok((hBmp = NtGdiCreateBitmap(1, 1, 1, 3, NULL)) != NULL, "hBmp was NULL.\n");
122 ok_int(GetObject(hBmp, sizeof(BITMAP), &bitmap), (int)sizeof(BITMAP));
123 ok_int(bitmap.bmBitsPixel, 4);
124 DeleteObject(hBmp);
125
126 ok((hBmp = NtGdiCreateBitmap(1, 1, 1, 6, NULL)) != NULL, "hBmp was NULL.\n");
127 ok_int(GetObject(hBmp, sizeof(BITMAP), &bitmap), (int)sizeof(BITMAP));
128 ok_int(bitmap.bmBitsPixel, 8);
129 DeleteObject(hBmp);
130
131 ok((hBmp = NtGdiCreateBitmap(1, 1, 1, 15, NULL)) != NULL, "hBmp was NULL.\n");
132 ok_int(GetObject(hBmp, sizeof(BITMAP), &bitmap), (int)sizeof(BITMAP));
133 ok_int(bitmap.bmBitsPixel, 16);
134 DeleteObject(hBmp);
135
136 ok((hBmp = NtGdiCreateBitmap(1, 1, 1, 17, NULL)) != NULL, "hBmp was NULL.\n");
137 ok_int(GetObject(hBmp, sizeof(BITMAP), &bitmap), (int)sizeof(BITMAP));
138 ok_int(bitmap.bmBitsPixel, 24);
139 DeleteObject(hBmp);
140
141 ok((hBmp = NtGdiCreateBitmap(1, 1, 3, 7, NULL)) != NULL, "hBmp was NULL.\n");
142 ok_int(GetObject(hBmp, sizeof(BITMAP), &bitmap), (int)sizeof(BITMAP));
143 ok_int(bitmap.bmBitsPixel, 24);
144 DeleteObject(hBmp);
145
146 ok((hBmp = NtGdiCreateBitmap(1, 1, 1, 25, NULL)) != NULL, "hBmp was NULL.\n");
147 ok_int(GetObject(hBmp, sizeof(BITMAP), &bitmap), (int)sizeof(BITMAP));
148 ok_int(bitmap.bmBitsPixel, 32);
149 DeleteObject(hBmp);
150
152
153 ok_ptr(NtGdiCreateBitmap(1, 1, 1, 33, NULL), NULL);
155
156 /* Test bad pointer */
158 ok_ptr(NtGdiCreateBitmap(1, 1, 1, 1, (BYTE*)(LONG_PTR)0x80001234), NULL);
160
161 /* Test pointer alignment */
163 ok((hBmp = NtGdiCreateBitmap(1, 1, 1, 1, &BitmapData[1])) != NULL, "hBmp was NULL.\n");
165 DeleteObject(hBmp);
166
167 /* Test normal params */
169 ok((hBmp = NtGdiCreateBitmap(5, 7, 2, 4, NULL)) != NULL, "hBmp was NULL.\n");
171 ok_int(GetObject(hBmp, sizeof(BITMAP), &bitmap), (int)sizeof(BITMAP));
172 ok_int(bitmap.bmType, 0);
173 ok_int(bitmap.bmWidth, 5);
174 ok_int(bitmap.bmHeight, 7);
175 ok_int(bitmap.bmWidthBytes, 6);
176 ok_int(bitmap.bmPlanes, 1);
177 ok_int(bitmap.bmBitsPixel, 8);
178 DeleteObject(hBmp);
179
180
181 /* Test height 0 params */
183 ok_ptr(NtGdiCreateBitmap(1, 0, 1, 1, NULL), NULL);
185
186 /* Test height -1 params */
188 ok_ptr(NtGdiCreateBitmap(1, -1, 1, 1, NULL), NULL);
190
191 /* Test witdth 0 params */
193 ok_ptr(NtGdiCreateBitmap(0, 1, 1, 1, NULL), NULL);
195
196 /* Test witdth -1 params */
198 ok_ptr(NtGdiCreateBitmap(-1, 0, 1, 1, NULL), NULL);
200
201 /* Test witdth -1 params */
203 ok_ptr(NtGdiCreateBitmap(0, 0, 1, 1, NULL), NULL);
205}
206
208{
209
211// Test_NtGdiCreateBitmap_Pixel();
212
213}
void Test_NtGdiCreateBitmap_Params(void)
#define ok_long(expression, result)
Definition: atltest.h:133
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
#define ok_ptr(expression, result)
Definition: atltest.h:108
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
pKey DeleteObject()
#define TEST(x)
Definition: precomp.h:20
static HBITMAP
Definition: button.c:44
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
__kernel_entry W32KAPI HBITMAP APIENTRY NtGdiCreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBPP, _In_opt_ LPBYTE pjInit)
Definition: bl.h:1331
Definition: uimain.c:89
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define GetObject
Definition: wingdi.h:4468
unsigned char BYTE
Definition: xxhash.c:193