ReactOS  0.4.14-dev-831-gef8c9239
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;
13  BITMAP bitmap;
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 */
49  ok_ptr(NtGdiCreateBitmap(1, -2, 1, 1, BitmapData), NULL);
51 
52  /* Test negative cy and invalid bits */
54  ok_ptr(NtGdiCreateBitmap(1, -2, 1, 1, (BYTE*)0x80001234), NULL);
56 
57  /* Test huge size */
59  ok_ptr(NtGdiCreateBitmap(100000, 100000, 1, 1, NULL), NULL);
61 
62  /* Test huge size and valid bits */
64  TEST(NtGdiCreateBitmap(1000, 1000, 1, 1, BitmapData) == NULL);
66 
67  /* Test huge size and invalid bits */
69  ok_ptr(NtGdiCreateBitmap(100000, 100000, 1, 1, (BYTE*)0x80001234), NULL);
71 
72  /* Test cPlanes == 0 */
74  ok((hBmp = NtGdiCreateBitmap(1, 1, 0, 1, NULL)) != NULL, "hBmp was NULL.\n");
76  ok_int(GetObject(hBmp, sizeof(BITMAP), &bitmap), (int)sizeof(BITMAP));
77  ok_int(bitmap.bmType, 0);
78  ok_int(bitmap.bmWidth, 1);
79  ok_int(bitmap.bmHeight, 1);
80  ok_int(bitmap.bmWidthBytes, 2);
81  ok_int(bitmap.bmPlanes, 1);
82  ok_int(bitmap.bmBitsPixel, 1);
83  DeleteObject(hBmp);
84 
85  /* Test big cPlanes */
87  ok((hBmp = NtGdiCreateBitmap(1, 1, 32, 1, NULL)) != NULL, "hBmp was NULL.\n");
89  DeleteObject(hBmp);
90 
91  ok_ptr(NtGdiCreateBitmap(1, 1, 33, 1, NULL), NULL);
93 
94  /* Test cBPP == 0 */
96  ok((hBmp = NtGdiCreateBitmap(1, 1, 1, 0, NULL)) != NULL, "hBmp was NULL.\n");
98  ok_int(GetObject(hBmp, sizeof(BITMAP), &bitmap), (int)sizeof(BITMAP));
99  ok_int(bitmap.bmType, 0);
100  ok_int(bitmap.bmWidth, 1);
101  ok_int(bitmap.bmHeight, 1);
102  ok_int(bitmap.bmWidthBytes, 2);
103  ok_int(bitmap.bmPlanes, 1);
104  ok_int(bitmap.bmBitsPixel, 1);
105  DeleteObject(hBmp);
106 
107  /* Test negative cBPP */
109  ok_ptr(NtGdiCreateBitmap(1, 1, 1, -1, NULL), NULL);
111 
112  /* Test bad cBPP */
114  ok((hBmp = NtGdiCreateBitmap(1, 1, 1, 3, NULL)) != NULL, "hBmp was NULL.\n");
115  ok_int(GetObject(hBmp, sizeof(BITMAP), &bitmap), (int)sizeof(BITMAP));
116  ok_int(bitmap.bmBitsPixel, 4);
117  DeleteObject(hBmp);
118 
119  ok((hBmp = NtGdiCreateBitmap(1, 1, 1, 6, NULL)) != NULL, "hBmp was NULL.\n");
120  ok_int(GetObject(hBmp, sizeof(BITMAP), &bitmap), (int)sizeof(BITMAP));
121  ok_int(bitmap.bmBitsPixel, 8);
122  DeleteObject(hBmp);
123 
124  ok((hBmp = NtGdiCreateBitmap(1, 1, 1, 15, NULL)) != NULL, "hBmp was NULL.\n");
125  ok_int(GetObject(hBmp, sizeof(BITMAP), &bitmap), (int)sizeof(BITMAP));
126  ok_int(bitmap.bmBitsPixel, 16);
127  DeleteObject(hBmp);
128 
129  ok((hBmp = NtGdiCreateBitmap(1, 1, 1, 17, NULL)) != NULL, "hBmp was NULL.\n");
130  ok_int(GetObject(hBmp, sizeof(BITMAP), &bitmap), (int)sizeof(BITMAP));
131  ok_int(bitmap.bmBitsPixel, 24);
132  DeleteObject(hBmp);
133 
134  ok((hBmp = NtGdiCreateBitmap(1, 1, 3, 7, NULL)) != NULL, "hBmp was NULL.\n");
135  ok_int(GetObject(hBmp, sizeof(BITMAP), &bitmap), (int)sizeof(BITMAP));
136  ok_int(bitmap.bmBitsPixel, 24);
137  DeleteObject(hBmp);
138 
139  ok((hBmp = NtGdiCreateBitmap(1, 1, 1, 25, NULL)) != NULL, "hBmp was NULL.\n");
140  ok_int(GetObject(hBmp, sizeof(BITMAP), &bitmap), (int)sizeof(BITMAP));
141  ok_int(bitmap.bmBitsPixel, 32);
142  DeleteObject(hBmp);
143 
145 
146  ok_ptr(NtGdiCreateBitmap(1, 1, 1, 33, NULL), NULL);
148 
149  /* Test bad pointer */
151  ok_ptr(NtGdiCreateBitmap(1, 1, 1, 1, (BYTE*)0x80001234), NULL);
153 
154  /* Test pointer alignment */
156  ok((hBmp = NtGdiCreateBitmap(1, 1, 1, 1, &BitmapData[1])) != NULL, "hBmp was NULL.\n");
158  DeleteObject(hBmp);
159 
160  /* Test normal params */
162  ok((hBmp = NtGdiCreateBitmap(5, 7, 2, 4, NULL)) != NULL, "hBmp was NULL.\n");
164  ok_int(GetObject(hBmp, sizeof(BITMAP), &bitmap), (int)sizeof(BITMAP));
165  ok_int(bitmap.bmType, 0);
166  ok_int(bitmap.bmWidth, 5);
167  ok_int(bitmap.bmHeight, 7);
168  ok_int(bitmap.bmWidthBytes, 6);
169  ok_int(bitmap.bmPlanes, 1);
170  ok_int(bitmap.bmBitsPixel, 8);
171  DeleteObject(hBmp);
172 
173 
174  /* Test height 0 params */
176  ok_ptr(NtGdiCreateBitmap(1, 0, 1, 1, NULL), NULL);
178 
179  /* Test height -1 params */
181  ok_ptr(NtGdiCreateBitmap(1, -1, 1, 1, NULL), NULL);
183 
184  /* Test witdth 0 params */
186  ok_ptr(NtGdiCreateBitmap(0, 1, 1, 1, NULL), NULL);
188 
189  /* Test witdth -1 params */
191  ok_ptr(NtGdiCreateBitmap(-1, 0, 1, 1, NULL), NULL);
193 
194  /* Test witdth -1 params */
196  ok_ptr(NtGdiCreateBitmap(0, 0, 1, 1, NULL), NULL);
198 }
199 
201 {
202 
204 // Test_NtGdiCreateBitmap_Pixel();
205 
206 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
__kernel_entry W32KAPI HBITMAP APIENTRY NtGdiCreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBPP, _In_opt_ LPBYTE pjInit)
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
void Test_NtGdiCreateBitmap_Params(void)
#define ok_ptr(expression, result)
Definition: atltest.h:108
#define ok_long(expression, result)
Definition: atltest.h:133
smooth NULL
Definition: ftsmooth.c:416
#define ok_int(expression, result)
Definition: atltest.h:134
START_TEST(NtGdiCreateBitmap)
Definition: uimain.c:88
#define TEST(x)
Definition: precomp.h:20
#define SetLastError(x)
Definition: compat.h:417
#define GetObject
Definition: wingdi.h:4467
unsigned char BYTE
Definition: mem.h:68
#define ok(value,...)
Definition: atltest.h:57
Definition: bl.h:1331
static HBITMAP bitmap
Definition: clipboard.c:1344
static HBITMAP
Definition: button.c:44