6924492bf9eccbfd3866e5cdc526a78d6e249d39
[reactos.git] / modules / rostests / apitests / win32nt / ntgdi / NtGdiSetBitmapBits.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for NtGdiSetBitmapBits
5 * PROGRAMMERS:
6 */
7
8 #include <win32nt.h>
9
10 START_TEST(NtGdiSetBitmapBits)
11 {
12 BYTE Bits[50] = {0,1,2,3,4,5,6,7,8,9};
13 HBITMAP hBitmap;
14
15 SetLastError(ERROR_SUCCESS);
16 ok_long(NtGdiSetBitmapBits(0, 0, 0), 0);
17 ok_long(GetLastError(), ERROR_SUCCESS);
18
19 /* Test NULL bitnap handle */
20 SetLastError(ERROR_SUCCESS);
21 ok_long(NtGdiSetBitmapBits(0, 5, Bits), 0);
22 ok_long(GetLastError(), ERROR_INVALID_HANDLE);
23
24 /* Test invalid bitmap handle */
25 hBitmap = (HBITMAP)CreatePen(PS_SOLID, 1, RGB(1,2,3));
26 SetLastError(ERROR_SUCCESS);
27 ok_long(NtGdiSetBitmapBits(hBitmap, 5, Bits), 0);
28 ok_long(GetLastError(), ERROR_INVALID_HANDLE);
29 DeleteObject(hBitmap);
30
31 hBitmap = CreateBitmap(3, 3, 1, 8, NULL);
32 SetLastError(ERROR_SUCCESS);
33
34 /* test NULL pointer and count buffer size != 0 */
35 ok_long(NtGdiSetBitmapBits(hBitmap, 5, NULL), 0);
36
37 /* test NULL pointer and buffer size == 0*/
38 ok_long(NtGdiSetBitmapBits(hBitmap, 0, NULL), 0);
39
40 /* test bad pointer */
41 ok_long(NtGdiSetBitmapBits(hBitmap, 5, (PBYTE)0x500), 0);
42
43 /* Test if we can set a number of bytes between lines */
44 ok_long(NtGdiSetBitmapBits(hBitmap, 5, Bits), 5);
45
46 /* Test alignment */
47 ok_long(NtGdiSetBitmapBits(hBitmap, 4, Bits+1), 4);
48
49 /* Test 1 byte too much */
50 ok_long(NtGdiSetBitmapBits(hBitmap, 10, Bits), 10);
51
52 /* Test one row too much */
53 ok_long(NtGdiSetBitmapBits(hBitmap, 12, Bits), 12);
54
55 ok_long(NtGdiSetBitmapBits(hBitmap, 13, Bits), 12);
56
57 ok_long(NtGdiSetBitmapBits(hBitmap, 100, Bits), 12);
58
59 /* Test huge bytes count */
60 ok_long(NtGdiSetBitmapBits(hBitmap, 12345678, Bits), 0);
61
62 /* Test negative bytes count */
63 ok_long(NtGdiSetBitmapBits(hBitmap, -5, Bits), 0);
64
65 ok_long(GetLastError(), ERROR_SUCCESS);
66
67 DeleteObject(hBitmap);
68 }