Add basic tests for GetDIBits

svn path=/trunk/; revision=29190
This commit is contained in:
Ged Murphy
2007-09-24 15:02:20 +00:00
parent 2cbc032859
commit f26bd07f86
2 changed files with 51 additions and 0 deletions
+2
View File
@@ -13,6 +13,7 @@
#include "tests/GetClipRgn.c"
#include "tests/GetObject.c"
#include "tests/GetStockObject.c"
#include "tests/GetDIBits.c"
#include "tests/SelectObject.c"
#include "tests/SetDCPenColor.c"
#include "tests/SetSysColors.c"
@@ -30,6 +31,7 @@ TESTENTRY TestList[] =
{ L"GetClipRgn", Test_GetClipRgn },
{ L"GetObject", Test_GetObject },
{ L"GetStockObject", Test_GetStockObject },
{ L"GetDIBits", Test_GetDIBits },
{ L"SetSysColors", Test_SetSysColors },
{ L"SelectObject", Test_SelectObject },
{ L"SetDCPenColor", Test_SetDCPenColor },
@@ -0,0 +1,49 @@
INT
Test_GetDIBits(PTESTINFO pti)
{
HDC hDCScreen;
HBITMAP hBitmap;
BITMAPINFO bi;
INT ScreenBpp;
hDCScreen = GetDC(NULL);
if (hDCScreen == NULL)
{
return FALSE;
}
hBitmap = CreateCompatibleBitmap(hDCScreen, 16, 16);
RTEST(hBitmap != NULL);
SetLastError(ERROR_SUCCESS);
RTEST(GetDIBits(0, 0, 0, 0, NULL, NULL, 0) == 0);
RTEST(GetLastError() == ERROR_INVALID_PARAMETER);
SetLastError(ERROR_SUCCESS);
RTEST(GetDIBits((HDC)2345, 0, 0, 0, NULL, NULL, 0) == 0);
RTEST(GetLastError() == ERROR_INVALID_PARAMETER);
SetLastError(ERROR_SUCCESS);
RTEST(GetDIBits((HDC)2345, hBitmap, 0, 0, NULL, NULL, 0) == 0);
RTEST(GetLastError() == ERROR_INVALID_PARAMETER);
SetLastError(ERROR_SUCCESS);
RTEST(GetDIBits((HDC)2345, hBitmap, 0, 15, NULL, &bi, 0) == 0);
RTEST(GetLastError() == ERROR_INVALID_PARAMETER);
SetLastError(ERROR_SUCCESS);
ZeroMemory(&bi, sizeof(BITMAPINFO));
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
RTEST(GetDIBits(hDCScreen, hBitmap, 0, 15, NULL, &bi, DIB_RGB_COLORS) > 0);
RTEST(GetLastError() == ERROR_SUCCESS);
ScreenBpp = GetDeviceCaps(hDCScreen, BITSPIXEL);
RTEST(bi.bmiHeader.biWidth == 16);
RTEST(bi.bmiHeader.biHeight == 16);
RTEST(bi.bmiHeader.biBitCount == ScreenBpp);
RTEST(bi.bmiHeader.biSizeImage == (16 * 16) * (ScreenBpp / 8));
DeleteObject(hBitmap);
ReleaseDC(NULL, hDCScreen);
return APISTATUS_NORMAL;
}