e13aabd2e24783ecfb9d32f85f0e4c80beacc05e
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for NtGdiSetBitmapBits
5 * PROGRAMMERS: Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
10 START_TEST(NtGdiSetBitmapBits
)
12 BYTE Bits
[50] = {0,1,2,3,4,5,6,7,8,9};
18 SetLastError(ERROR_SUCCESS
);
19 ok_long(NtGdiSetBitmapBits(0, 0, 0), 0);
20 ok_long(GetLastError(), ERROR_SUCCESS
);
22 /* Test NULL bitnap handle */
23 SetLastError(ERROR_SUCCESS
);
24 ok_long(NtGdiSetBitmapBits(0, 5, Bits
), 0);
25 ok_long(GetLastError(), ERROR_INVALID_HANDLE
);
27 /* Test invalid bitmap handle */
28 hBitmap
= (HBITMAP
)CreatePen(PS_SOLID
, 1, RGB(1,2,3));
29 SetLastError(ERROR_SUCCESS
);
30 ok_long(NtGdiSetBitmapBits(hBitmap
, 5, Bits
), 0);
31 ok_long(GetLastError(), ERROR_INVALID_HANDLE
);
32 DeleteObject(hBitmap
);
34 hBitmap
= CreateBitmap(3, 3, 1, 8, NULL
);
35 SetLastError(ERROR_SUCCESS
);
37 /* test NULL pointer and count buffer size != 0 */
38 ok_long(NtGdiSetBitmapBits(hBitmap
, 5, NULL
), 0);
40 /* test NULL pointer and buffer size == 0*/
41 ok_long(NtGdiSetBitmapBits(hBitmap
, 0, NULL
), 0);
43 /* test bad pointer */
44 ok_long(NtGdiSetBitmapBits(hBitmap
, 5, (PBYTE
)0x500), 0);
46 /* Test if we can set a number of bytes between lines */
47 ok_long(NtGdiSetBitmapBits(hBitmap
, 5, Bits
), 5);
50 ok_long(NtGdiSetBitmapBits(hBitmap
, 4, Bits
+1), 4);
52 /* Test 1 byte too much */
53 ok_long(NtGdiSetBitmapBits(hBitmap
, 10, Bits
), 10);
55 /* Test one row too much */
56 ok_long(NtGdiSetBitmapBits(hBitmap
, 12, Bits
), 12);
58 ok_long(NtGdiSetBitmapBits(hBitmap
, 13, Bits
), 12);
60 ok_long(NtGdiSetBitmapBits(hBitmap
, 100, Bits
), 12);
62 /* Test huge bytes count */
63 ok_long(NtGdiSetBitmapBits(hBitmap
, 12345678, Bits
), 0);
65 /* Test negative bytes count */
66 ok_long(NtGdiSetBitmapBits(hBitmap
, -5, Bits
), 0);
68 ok_long(GetLastError(), ERROR_SUCCESS
);
70 DeleteObject(hBitmap
);
72 /* ------------------------- */
74 hBitmap
= CreateBitmap(16, 16, 1, 1, NULL
);
75 ok(hBitmap
!= NULL
, "hBitmap was NULL.\n");
77 FillMemory(Bits
, sizeof(Bits
), 0x55);
78 ok_long(NtGdiGetBitmapBits(hBitmap
, 0, Bits
), 0);
79 ok_int(Bits
[0], 0x55);
81 FillMemory(Bits
, sizeof(Bits
), 0x55);
82 ok_long(NtGdiGetBitmapBits(hBitmap
, 1, Bits
), 1);
84 ok_int(Bits
[1], 0x55);
86 FillMemory(Bits
, sizeof(Bits
), 0x55);
87 ok_long(NtGdiGetBitmapBits(hBitmap
, 2, Bits
), 2);
90 ok_int(Bits
[2], 0x55);
92 FillMemory(Bits
, sizeof(Bits
), 0x33);
93 ok_long(NtGdiSetBitmapBits(hBitmap
, 10, Bits
), 10);
95 FillMemory(Bits
, sizeof(Bits
), 0xAA);
96 ok_long(NtGdiSetBitmapBits(hBitmap
, 1, Bits
), 1);
97 FillMemory(Bits
, sizeof(Bits
), 0x55);
98 ok_long(NtGdiGetBitmapBits(hBitmap
, 1, Bits
), 1);
99 ok_int(Bits
[0], 0xAA);
100 ok_int(Bits
[1], 0x55);
101 ok_long(NtGdiGetBitmapBits(hBitmap
, 2, Bits
), 2);
102 ok_int(Bits
[0], 0xAA);
103 ok_int(Bits
[1], 0x33);
104 ok_int(Bits
[2], 0x55);
106 FillMemory(Bits
, sizeof(Bits
), 0xAA);
107 ok_long(NtGdiSetBitmapBits(hBitmap
, 2, Bits
), 2);
108 FillMemory(Bits
, sizeof(Bits
), 0x55);
109 ok_long(NtGdiGetBitmapBits(hBitmap
, 2, Bits
), 2);
110 ok_int(Bits
[0], 0xAA);
111 ok_int(Bits
[1], 0xAA);
112 ok_int(Bits
[2], 0x55);
113 ok_long(NtGdiGetBitmapBits(hBitmap
, 3, Bits
), 3);
114 ok_int(Bits
[0], 0xAA);
115 ok_int(Bits
[1], 0xAA);
116 ok_int(Bits
[2], 0x33);
117 ok_int(Bits
[3], 0x55);
119 FillMemory(Bits
, sizeof(Bits
), 0xAA);
120 ok_long(NtGdiSetBitmapBits(hBitmap
, 3, Bits
), 3);
121 FillMemory(Bits
, sizeof(Bits
), 0x55);
122 ok_long(NtGdiGetBitmapBits(hBitmap
, 3, Bits
), 3);
123 ok_int(Bits
[0], 0xAA);
124 ok_int(Bits
[1], 0xAA);
125 ok_int(Bits
[2], 0xAA);
126 ok_int(Bits
[3], 0x55);
127 ok_long(NtGdiGetBitmapBits(hBitmap
, 4, Bits
), 4);
128 ok_int(Bits
[0], 0xAA);
129 ok_int(Bits
[1], 0xAA);
130 ok_int(Bits
[2], 0xAA);
131 ok_int(Bits
[3], 0x33);
132 ok_int(Bits
[4], 0x55);
134 DeleteObject(hBitmap
);
136 /* ------------------------- */
138 hDC
= CreateCompatibleDC(NULL
);
140 ZeroMemory(&bmi
, sizeof(bmi
));
141 bmi
.bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
142 bmi
.bmiHeader
.biWidth
= 15;
143 bmi
.bmiHeader
.biHeight
= 15;
144 bmi
.bmiHeader
.biPlanes
= 1;
145 bmi
.bmiHeader
.biBitCount
= 24;
146 hBitmap
= CreateDIBSection(hDC
, &bmi
, DIB_RGB_COLORS
, &pvBits
, NULL
, 0);
147 ok(hBitmap
!= NULL
, "hBitmap was NULL.\n");
149 FillMemory(Bits
, sizeof(Bits
), 0x55);
150 ok_long(NtGdiGetBitmapBits(hBitmap
, 0, Bits
), 0);
151 ok_int(Bits
[0], 0x55);
153 FillMemory(Bits
, sizeof(Bits
), 0x55);
154 ok_long(NtGdiGetBitmapBits(hBitmap
, 1, Bits
), 1);
156 ok_int(Bits
[1], 0x55);
158 FillMemory(Bits
, sizeof(Bits
), 0x55);
159 ok_long(NtGdiGetBitmapBits(hBitmap
, 2, Bits
), 2);
162 ok_int(Bits
[2], 0x55);
164 FillMemory(Bits
, sizeof(Bits
), 0x33);
165 ok_long(NtGdiSetBitmapBits(hBitmap
, 10, Bits
), 10);
167 FillMemory(Bits
, sizeof(Bits
), 0xAA);
168 ok_long(NtGdiSetBitmapBits(hBitmap
, 1, Bits
), 1);
169 FillMemory(Bits
, sizeof(Bits
), 0x55);
170 ok_long(NtGdiGetBitmapBits(hBitmap
, 1, Bits
), 1);
171 ok_int(Bits
[0], 0xAA);
172 ok_int(Bits
[1], 0x55);
173 ok_long(NtGdiGetBitmapBits(hBitmap
, 2, Bits
), 2);
174 ok_int(Bits
[0], 0xAA);
175 ok_int(Bits
[1], 0x33);
176 ok_int(Bits
[2], 0x55);
178 FillMemory(Bits
, sizeof(Bits
), 0xAA);
179 ok_long(NtGdiSetBitmapBits(hBitmap
, 2, Bits
), 2);
180 FillMemory(Bits
, sizeof(Bits
), 0x55);
181 ok_long(NtGdiGetBitmapBits(hBitmap
, 2, Bits
), 2);
182 ok_int(Bits
[0], 0xAA);
183 ok_int(Bits
[1], 0xAA);
184 ok_int(Bits
[2], 0x55);
185 ok_long(NtGdiGetBitmapBits(hBitmap
, 3, Bits
), 3);
186 ok_int(Bits
[0], 0xAA);
187 ok_int(Bits
[1], 0xAA);
188 ok_int(Bits
[2], 0x33);
189 ok_int(Bits
[3], 0x55);
191 FillMemory(Bits
, sizeof(Bits
), 0xAA);
192 ok_long(NtGdiSetBitmapBits(hBitmap
, 3, Bits
), 3);
193 FillMemory(Bits
, sizeof(Bits
), 0x55);
194 ok_long(NtGdiGetBitmapBits(hBitmap
, 3, Bits
), 3);
195 ok_int(Bits
[0], 0xAA);
196 ok_int(Bits
[1], 0xAA);
197 ok_int(Bits
[2], 0xAA);
198 ok_int(Bits
[3], 0x55);
199 ok_long(NtGdiGetBitmapBits(hBitmap
, 4, Bits
), 4);
200 ok_int(Bits
[0], 0xAA);
201 ok_int(Bits
[1], 0xAA);
202 ok_int(Bits
[2], 0xAA);
203 ok_int(Bits
[3], 0x33);
204 ok_int(Bits
[4], 0x55);
206 DeleteObject(hBitmap
);