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
10
void
Test_NtGdiCreateBitmap_Params
(
void
)
11
{
12
HBITMAP
hBmp;
13
BITMAP
bitmap
;
14
BYTE
BitmapData
[10] = {0x11, 0x22, 0x33};
15
16
/* Test simple params */
17
SetLastError
(
ERROR_SUCCESS
);
18
ok
((hBmp =
NtGdiCreateBitmap
(1, 1, 1, 1,
NULL
)) !=
NULL
,
"hBmp was NULL.\n"
);
19
ok_long
(
GetLastError
(),
ERROR_SUCCESS
);
20
DeleteObject
(hBmp);
21
22
/* Test all zero */
23
SetLastError
(
ERROR_SUCCESS
);
24
ok_ptr
(
NtGdiCreateBitmap
(0, 0, 0, 0,
NULL
),
NULL
);
25
ok_long
(
GetLastError
(),
ERROR_INVALID_PARAMETER
);
26
27
/* Test cx == 0 */
28
SetLastError
(
ERROR_SUCCESS
);
29
ok_ptr
(
NtGdiCreateBitmap
(0, 1, 1, 1,
NULL
),
NULL
);
30
ok_long
(
GetLastError
(),
ERROR_INVALID_PARAMETER
);
31
32
/* Test negative cx */
33
SetLastError
(
ERROR_SUCCESS
);
34
ok_ptr
(
NtGdiCreateBitmap
(-10, 1, 1, 1,
NULL
),
NULL
);
35
ok_long
(
GetLastError
(),
ERROR_INVALID_PARAMETER
);
36
37
/* Test cy == 0 */
38
SetLastError
(
ERROR_SUCCESS
);
39
ok_ptr
(
NtGdiCreateBitmap
(1, 0, 1, 1,
NULL
),
NULL
);
40
ok_long
(
GetLastError
(),
ERROR_INVALID_PARAMETER
);
41
42
/* Test negative cy */
43
SetLastError
(
ERROR_SUCCESS
);
44
ok_ptr
(
NtGdiCreateBitmap
(1, -2, 1, 1,
NULL
),
NULL
);
45
ok_long
(
GetLastError
(),
ERROR_INVALID_PARAMETER
);
46
47
/* Test negative cy and valid bits */
48
SetLastError
(
ERROR_SUCCESS
);
49
ok_ptr
(
NtGdiCreateBitmap
(1, -2, 1, 1,
BitmapData
),
NULL
);
50
ok_long
(
GetLastError
(),
ERROR_SUCCESS
);
51
52
/* Test negative cy and invalid bits */
53
SetLastError
(
ERROR_SUCCESS
);
54
ok_ptr
(
NtGdiCreateBitmap
(1, -2, 1, 1, (
BYTE
*)(
LONG_PTR
)0x80001234),
NULL
);
55
ok_long
(
GetLastError
(),
ERROR_SUCCESS
);
56
57
#ifndef _WIN64
// Win64 doesn't fail here
58
/* Test huge size */
59
SetLastError
(
ERROR_SUCCESS
);
60
ok_ptr
(
NtGdiCreateBitmap
(100000, 100000, 1, 1,
NULL
),
NULL
);
61
ok_long
(
GetLastError
(),
ERROR_NOT_ENOUGH_MEMORY
);
62
#endif
63
64
/* Test too huge size */
65
SetLastError
(
ERROR_SUCCESS
);
66
ok_ptr
(
NtGdiCreateBitmap
(100000, 100000, 1, 32,
NULL
),
NULL
);
67
ok_long
(
GetLastError
(),
ERROR_INVALID_PARAMETER
);
68
69
/* Test huge size and valid bits */
70
SetLastError
(
ERROR_SUCCESS
);
71
TEST
(
NtGdiCreateBitmap
(1000, 1000, 1, 1,
BitmapData
) ==
NULL
);
72
ok_long
(
GetLastError
(),
ERROR_SUCCESS
);
73
74
/* Test huge size and invalid bits */
75
SetLastError
(
ERROR_SUCCESS
);
76
ok_ptr
(
NtGdiCreateBitmap
(100000, 100000, 1, 1, (
BYTE
*)(
LONG_PTR
)0x80001234),
NULL
);
77
ok_long
(
GetLastError
(),
ERROR_SUCCESS
);
78
79
/* Test cPlanes == 0 */
80
SetLastError
(
ERROR_SUCCESS
);
81
ok
((hBmp =
NtGdiCreateBitmap
(1, 1, 0, 1,
NULL
)) !=
NULL
,
"hBmp was NULL.\n"
);
82
ok_long
(
GetLastError
(),
ERROR_SUCCESS
);
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 */
93
SetLastError
(
ERROR_SUCCESS
);
94
ok
((hBmp =
NtGdiCreateBitmap
(1, 1, 32, 1,
NULL
)) !=
NULL
,
"hBmp was NULL.\n"
);
95
ok_long
(
GetLastError
(),
ERROR_SUCCESS
);
96
DeleteObject
(hBmp);
97
98
ok_ptr
(
NtGdiCreateBitmap
(1, 1, 33, 1,
NULL
),
NULL
);
99
ok_long
(
GetLastError
(),
ERROR_INVALID_PARAMETER
);
100
101
/* Test cBPP == 0 */
102
SetLastError
(
ERROR_SUCCESS
);
103
ok
((hBmp =
NtGdiCreateBitmap
(1, 1, 1, 0,
NULL
)) !=
NULL
,
"hBmp was NULL.\n"
);
104
ok_long
(
GetLastError
(),
ERROR_SUCCESS
);
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 */
115
SetLastError
(
ERROR_SUCCESS
);
116
ok_ptr
(
NtGdiCreateBitmap
(1, 1, 1, -1,
NULL
),
NULL
);
117
ok_long
(
GetLastError
(),
ERROR_INVALID_PARAMETER
);
118
119
/* Test bad cBPP */
120
SetLastError
(
ERROR_SUCCESS
);
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
151
ok_long
(
GetLastError
(),
ERROR_SUCCESS
);
152
153
ok_ptr
(
NtGdiCreateBitmap
(1, 1, 1, 33,
NULL
),
NULL
);
154
ok_long
(
GetLastError
(),
ERROR_INVALID_PARAMETER
);
155
156
/* Test bad pointer */
157
SetLastError
(
ERROR_SUCCESS
);
158
ok_ptr
(
NtGdiCreateBitmap
(1, 1, 1, 1, (
BYTE
*)(
LONG_PTR
)0x80001234),
NULL
);
159
ok_long
(
GetLastError
(),
ERROR_SUCCESS
);
160
161
/* Test pointer alignment */
162
SetLastError
(
ERROR_SUCCESS
);
163
ok
((hBmp =
NtGdiCreateBitmap
(1, 1, 1, 1, &
BitmapData
[1])) !=
NULL
,
"hBmp was NULL.\n"
);
164
ok_long
(
GetLastError
(),
ERROR_SUCCESS
);
165
DeleteObject
(hBmp);
166
167
/* Test normal params */
168
SetLastError
(
ERROR_SUCCESS
);
169
ok
((hBmp =
NtGdiCreateBitmap
(5, 7, 2, 4,
NULL
)) !=
NULL
,
"hBmp was NULL.\n"
);
170
ok_long
(
GetLastError
(),
ERROR_SUCCESS
);
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 */
182
SetLastError
(
ERROR_SUCCESS
);
183
ok_ptr
(
NtGdiCreateBitmap
(1, 0, 1, 1,
NULL
),
NULL
);
184
ok_long
(
GetLastError
(),
ERROR_INVALID_PARAMETER
);
185
186
/* Test height -1 params */
187
SetLastError
(
ERROR_SUCCESS
);
188
ok_ptr
(
NtGdiCreateBitmap
(1, -1, 1, 1,
NULL
),
NULL
);
189
ok_long
(
GetLastError
(),
ERROR_INVALID_PARAMETER
);
190
191
/* Test witdth 0 params */
192
SetLastError
(
ERROR_SUCCESS
);
193
ok_ptr
(
NtGdiCreateBitmap
(0, 1, 1, 1,
NULL
),
NULL
);
194
ok_long
(
GetLastError
(),
ERROR_INVALID_PARAMETER
);
195
196
/* Test witdth -1 params */
197
SetLastError
(
ERROR_SUCCESS
);
198
ok_ptr
(
NtGdiCreateBitmap
(-1, 0, 1, 1,
NULL
),
NULL
);
199
ok_long
(
GetLastError
(),
ERROR_INVALID_PARAMETER
);
200
201
/* Test witdth -1 params */
202
SetLastError
(
ERROR_SUCCESS
);
203
ok_ptr
(
NtGdiCreateBitmap
(0, 0, 1, 1,
NULL
),
NULL
);
204
ok_long
(
GetLastError
(),
ERROR_INVALID_PARAMETER
);
205
}
206
207
START_TEST
(
NtGdiCreateBitmap
)
208
{
209
210
Test_NtGdiCreateBitmap_Params
();
211
// Test_NtGdiCreateBitmap_Pixel();
212
213
}
Test_NtGdiCreateBitmap_Params
void Test_NtGdiCreateBitmap_Params(void)
Definition:
NtGdiCreateBitmap.c:10
ok_long
#define ok_long(expression, result)
Definition:
atltest.h:133
ok
#define ok(value,...)
Definition:
atltest.h:57
START_TEST
#define START_TEST(x)
Definition:
atltest.h:75
ok_int
#define ok_int(expression, result)
Definition:
atltest.h:134
ok_ptr
#define ok_ptr(expression, result)
Definition:
atltest.h:108
ERROR_NOT_ENOUGH_MEMORY
#define ERROR_NOT_ENOUGH_MEMORY
Definition:
dderror.h:7
ERROR_SUCCESS
#define ERROR_SUCCESS
Definition:
deptool.c:10
NULL
#define NULL
Definition:
types.h:112
ERROR_INVALID_PARAMETER
#define ERROR_INVALID_PARAMETER
Definition:
compat.h:101
SetLastError
#define SetLastError(x)
Definition:
compat.h:752
DeleteObject
pKey DeleteObject()
TEST
#define TEST(x)
Definition:
precomp.h:20
HBITMAP
static HBITMAP
Definition:
button.c:44
LONG_PTR
__int3264 LONG_PTR
Definition:
mstsclib_h.h:276
NtGdiCreateBitmap
__kernel_entry W32KAPI HBITMAP APIENTRY NtGdiCreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBPP, _In_opt_ LPBYTE pjInit)
BitmapData
Definition:
gdiplusimaging.h:176
_BITMAP
Definition:
bl.h:1331
bitmap
Definition:
uimain.c:89
GetLastError
DWORD WINAPI GetLastError(void)
Definition:
except.c:1042
GetObject
#define GetObject
Definition:
wingdi.h:4468
BYTE
unsigned char BYTE
Definition:
xxhash.c:193
modules
rostests
apitests
win32nt
ntgdi
NtGdiCreateBitmap.c
Generated on Wed Oct 30 2024 06:07:39 for ReactOS by
1.9.6