2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for CreateBitmap
5 * PROGRAMMERS: Timo Kreuzer
12 #define DEFAULT_BITMAP 21
14 void Test_CreateBitmap_Params()
18 /* All of these should get us the default bitmap */
19 hbmp
= CreateBitmap(0, 0, 0, 0, NULL
);
20 ok(hbmp
== GetStockObject(21), "should get the default bitmap\n");
21 hbmp
= CreateBitmap(1, 0, 0, 0, NULL
);
22 ok(hbmp
== GetStockObject(21), "should get the default bitmap\n");
23 hbmp
= CreateBitmap(0, 1, 0, 0, NULL
);
24 ok(hbmp
== GetStockObject(21), "should get the default bitmap\n");
25 hbmp
= CreateBitmap(0, 1, 1, 0, NULL
);
26 ok(hbmp
== GetStockObject(21), "should get the default bitmap\n");
27 hbmp
= CreateBitmap(0, 1, 63, 33, NULL
);
28 ok(hbmp
== GetStockObject(21), "should get the default bitmap\n");
29 hbmp
= CreateBitmap(0, -4, -32, 233, NULL
);
30 ok(hbmp
== GetStockObject(21), "should get the default bitmap\n");
33 hbmp
= CreateBitmap(1, -1, 1, 0, NULL
);
35 ok_err(ERROR_INVALID_PARAMETER
);
38 hbmp
= CreateBitmap(-1, 1, 1, 0, NULL
);
40 ok_err(ERROR_INVALID_PARAMETER
);
43 hbmp
= CreateBitmap(-1, 1, 1, 1, NULL
);
45 ok_err(ERROR_INVALID_PARAMETER
);
48 hbmp
= CreateBitmap(1, -1, 1, 1, NULL
);
50 ok_err(ERROR_INVALID_PARAMETER
);
52 /* Check if an overflow in cPlanes * cBitsPixel is handled */
54 hbmp
= CreateBitmap(1, 1, 2, 0x80000004, NULL
);
56 ok_err(ERROR_INVALID_PARAMETER
);
58 /* Check for maximum width */
59 hbmp
= CreateBitmap(0x7FFFFFF, 1, 1, 1, NULL
);
63 hbmp
= CreateBitmap(0x8000000, 1, 1, 1, NULL
);
65 ok_err(ERROR_INVALID_PARAMETER
);
67 /* Check for maximum height */
68 hbmp
= CreateBitmap(1, 0x1FFFFF00, 1, 1, NULL
);
72 hbmp
= CreateBitmap(1, 0x1FFFFFFF, 1, 1, NULL
);
76 /* Check for overflow in width * height */
77 hbmp
= CreateBitmap(0x20000, 0x1FFFF, 1, 1, NULL
);
81 hbmp
= CreateBitmap(0x20000, 0x20000, 1, 1, NULL
);
85 /* Check huge allocation */
87 hbmp
= CreateBitmap(0x2000, 0x20000, 32, 1, NULL
);
89 ok_err(ERROR_INVALID_PARAMETER
);
93 void Test_CreateBitmap()
99 hbmp
= CreateBitmap(0, 0, 0, 0, NULL
);
100 ok(hbmp
!= 0, "should get a 1x1 bitmap\n");
101 ok(hbmp
== GetStockObject(DEFAULT_BITMAP
), "\n");
102 result
= GetObject(hbmp
, sizeof(bitmap
), &bitmap
);
103 ok(result
> 0, "result = %d\n", result
);
104 ok(bitmap
.bmType
== 0, "bmType = %ld\n", bitmap
.bmType
);
105 ok(bitmap
.bmWidth
== 1, "bmWidth = %ld\n", bitmap
.bmWidth
);
106 ok(bitmap
.bmHeight
== 1, "bmHeight = %ld\n", bitmap
.bmHeight
);
107 ok(bitmap
.bmWidthBytes
== 2, "bmWidthBytes = %ld\n", bitmap
.bmWidthBytes
);
108 ok(bitmap
.bmPlanes
== 1, "bmPlanes = %d\n", bitmap
.bmPlanes
);
109 ok(bitmap
.bmBitsPixel
== 1, "bmBitsPixel = %d\n", bitmap
.bmBitsPixel
);
110 ok(bitmap
.bmBits
== 0, "bmBits = %p\n", bitmap
.bmBits
);
113 hbmp
= CreateBitmap(1, 2, 1, 1, NULL
);
114 ok(hbmp
!= 0, "should get a 1x2 bitmap\n");
115 result
= GetObject(hbmp
, sizeof(bitmap
), &bitmap
);
116 ok(result
> 0, "result = %d\n", result
);
117 ok(bitmap
.bmType
== 0, "bmType = %ld\n", bitmap
.bmType
);
118 ok(bitmap
.bmWidth
== 1, "bmWidth = %ld\n", bitmap
.bmWidth
);
119 ok(bitmap
.bmHeight
== 2, "bmHeight = %ld\n", bitmap
.bmHeight
);
120 ok(bitmap
.bmWidthBytes
== 2, "bmWidthBytes = %ld\n", bitmap
.bmWidthBytes
);
121 ok(bitmap
.bmPlanes
== 1, "bmPlanes = %d\n", bitmap
.bmPlanes
);
122 ok(bitmap
.bmBitsPixel
== 1, "bmBitsPixel = %d\n", bitmap
.bmBitsPixel
);
123 ok(bitmap
.bmBits
== 0, "bmBits = %p\n", bitmap
.bmBits
);
129 START_TEST(CreateBitmap
)
131 Test_CreateBitmap_Params();