[GDI32_APITEST]

More tests for CreateBitmap by Victor Martinez

svn path=/trunk/; revision=56605
This commit is contained in:
Timo Kreuzer 2012-05-17 18:51:47 +00:00
parent d20ffb99ef
commit 62d76ebae8

View file

@ -59,6 +59,7 @@ void Test_CreateBitmap_Params()
hbmp = CreateBitmap(0x7FFFFFF, 1, 1, 1, NULL); hbmp = CreateBitmap(0x7FFFFFF, 1, 1, 1, NULL);
ok(hbmp != 0, "\n"); ok(hbmp != 0, "\n");
DeleteObject(hbmp); DeleteObject(hbmp);
SetLastError(0); SetLastError(0);
hbmp = CreateBitmap(0x8000000, 1, 1, 1, NULL); hbmp = CreateBitmap(0x8000000, 1, 1, 1, NULL);
ok(hbmp == 0, "\n"); ok(hbmp == 0, "\n");
@ -68,6 +69,7 @@ void Test_CreateBitmap_Params()
hbmp = CreateBitmap(1, 0x1FFFFF00, 1, 1, NULL); hbmp = CreateBitmap(1, 0x1FFFFF00, 1, 1, NULL);
//ok(hbmp != 0, "\n"); // fails on windows 2003 //ok(hbmp != 0, "\n"); // fails on windows 2003
DeleteObject(hbmp); DeleteObject(hbmp);
SetLastError(0); SetLastError(0);
hbmp = CreateBitmap(1, 0x1FFFFFFF, 1, 1, NULL); hbmp = CreateBitmap(1, 0x1FFFFFFF, 1, 1, NULL);
ok(hbmp == 0, "\n"); ok(hbmp == 0, "\n");
@ -77,6 +79,7 @@ void Test_CreateBitmap_Params()
hbmp = CreateBitmap(0x20000, 0x1FFFF, 1, 1, NULL); hbmp = CreateBitmap(0x20000, 0x1FFFF, 1, 1, NULL);
//ok(hbmp != 0, "\n"); // fails on windows 2003 //ok(hbmp != 0, "\n"); // fails on windows 2003
DeleteObject(hbmp); DeleteObject(hbmp);
SetLastError(0); SetLastError(0);
hbmp = CreateBitmap(0x20000, 0x20000, 1, 1, NULL); hbmp = CreateBitmap(0x20000, 0x20000, 1, 1, NULL);
ok(hbmp == 0, "\n"); ok(hbmp == 0, "\n");
@ -94,41 +97,72 @@ void Test_CreateBitmap()
{ {
HBITMAP hbmp; HBITMAP hbmp;
BITMAP bitmap; BITMAP bitmap;
int result; ULONG cjWidthBytes, cBitsPixel, cExpectedBitsPixel;
hbmp = CreateBitmap(0, 0, 0, 0, NULL); hbmp = CreateBitmap(0, 0, 0, 0, NULL);
ok(hbmp != 0, "should get a 1x1 bitmap\n"); ok(hbmp != 0, "should get a 1x1 bitmap\n");
ok(hbmp == GetStockObject(DEFAULT_BITMAP), "\n"); ok(hbmp == GetStockObject(DEFAULT_BITMAP), "\n");
result = GetObject(hbmp, sizeof(bitmap), &bitmap); ok_int(GetObject(hbmp, sizeof(bitmap), &bitmap), sizeof(BITMAP));
ok(result > 0, "result = %d\n", result); ok_int(bitmap.bmType, 0);
ok(bitmap.bmType == 0, "bmType = %ld\n", bitmap.bmType); ok_int(bitmap.bmWidth, 1);
ok(bitmap.bmWidth == 1, "bmWidth = %ld\n", bitmap.bmWidth); ok_int(bitmap.bmHeight, 1);
ok(bitmap.bmHeight == 1, "bmHeight = %ld\n", bitmap.bmHeight); ok_int(bitmap.bmWidthBytes, 2);
ok(bitmap.bmWidthBytes == 2, "bmWidthBytes = %ld\n", bitmap.bmWidthBytes); ok_int(bitmap.bmPlanes, 1);
ok(bitmap.bmPlanes == 1, "bmPlanes = %d\n", bitmap.bmPlanes); ok_int(bitmap.bmBitsPixel, 1);
ok(bitmap.bmBitsPixel == 1, "bmBitsPixel = %d\n", bitmap.bmBitsPixel); ok_ptr(bitmap.bmBits, 0);
ok(bitmap.bmBits == 0, "bmBits = %p\n", bitmap.bmBits);
DeleteObject(hbmp); DeleteObject(hbmp);
hbmp = CreateBitmap(1, 2, 1, 1, NULL); hbmp = CreateBitmap(1, 2, 1, 1, NULL);
ok(hbmp != 0, "should get a 1x2 bitmap\n"); ok(hbmp != 0, "should get a 1x2 bitmap\n");
result = GetObject(hbmp, sizeof(bitmap), &bitmap); ok_int(GetObject(hbmp, sizeof(bitmap), &bitmap), sizeof(BITMAP));
ok(result > 0, "result = %d\n", result); ok_int(bitmap.bmType, 0);
ok(bitmap.bmType == 0, "bmType = %ld\n", bitmap.bmType); ok_int(bitmap.bmWidth, 1);
ok(bitmap.bmWidth == 1, "bmWidth = %ld\n", bitmap.bmWidth); ok_int(bitmap.bmHeight, 2);
ok(bitmap.bmHeight == 2, "bmHeight = %ld\n", bitmap.bmHeight); ok_int(bitmap.bmWidthBytes, 2);
ok(bitmap.bmWidthBytes == 2, "bmWidthBytes = %ld\n", bitmap.bmWidthBytes); ok_int(bitmap.bmPlanes, 1);
ok(bitmap.bmPlanes == 1, "bmPlanes = %d\n", bitmap.bmPlanes); ok_int(bitmap.bmBitsPixel, 1);
ok(bitmap.bmBitsPixel == 1, "bmBitsPixel = %d\n", bitmap.bmBitsPixel); ok_ptr(bitmap.bmBits, 0);
ok(bitmap.bmBits == 0, "bmBits = %p\n", bitmap.bmBits);
DeleteObject(hbmp); DeleteObject(hbmp);
for (cBitsPixel = 0; cBitsPixel <= 32; cBitsPixel++)
{
/* CreateBitmap API accepts any number as BitsPixels param.
but it just can create 1, 4, 8, 16, 24, 32 bpp Bitmaps */
if (cBitsPixel <= 1) cExpectedBitsPixel = 1;
else if (cBitsPixel <= 4) cExpectedBitsPixel = 4;
else if (cBitsPixel <= 8) cExpectedBitsPixel = 8;
else if (cBitsPixel <= 16) cExpectedBitsPixel = 16;
else if (cBitsPixel <= 24) cExpectedBitsPixel = 24;
else if (cBitsPixel <= 32) cExpectedBitsPixel = 32;
hbmp = CreateBitmap(1, 2, 1, cBitsPixel, NULL);
ok(hbmp != 0, "should get a 1x2 bitmap %ld\n", cBitsPixel);
ok_int(GetObject(hbmp, sizeof(bitmap), &bitmap), sizeof(BITMAP));
/* calculate expected line width */
cjWidthBytes = ((((ULONG)bitmap.bmWidth) * ((ULONG)bitmap.bmBitsPixel) + 15) & ~15) >> 3;
ok_int(bitmap.bmType, 0);
ok_int(bitmap.bmWidth, 1);
ok_int(bitmap.bmHeight, 2);
ok_int(bitmap.bmPlanes, 1);
ok_int(bitmap.bmBitsPixel, cExpectedBitsPixel);
ok_int(bitmap.bmWidthBytes, cjWidthBytes);
ok_ptr(bitmap.bmBits, 0);
DeleteObject(hbmp);
}
hbmp = CreateBitmap(1, 2, 1, 33, NULL);
ok(hbmp == 0, "Expected failure for 33 bpp\n");
} }
START_TEST(CreateBitmap) START_TEST(CreateBitmap)
{ {
Test_CreateBitmap_Params(); //Test_CreateBitmap_Params();
Test_CreateBitmap(); Test_CreateBitmap();
}
}