2009-08-09 11:27:25 +00:00
|
|
|
|
|
|
|
INT
|
|
|
|
Test_SelectDIBSection(PTESTINFO pti)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
HBITMAP hbmp;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
BITMAPINFOHEADER bmiHeader;
|
|
|
|
RGBQUAD bmiColors[100];
|
|
|
|
} bmi;
|
|
|
|
PBITMAPINFO pbmi = (PBITMAPINFO)&bmi;
|
|
|
|
PVOID pvBits;
|
|
|
|
|
|
|
|
hdc = CreateCompatibleDC(0);
|
|
|
|
ASSERT(hdc);
|
|
|
|
|
|
|
|
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
|
|
|
bmi.bmiHeader.biWidth = 2;
|
|
|
|
bmi.bmiHeader.biHeight = 2;
|
|
|
|
bmi.bmiHeader.biPlanes = 1;
|
|
|
|
bmi.bmiHeader.biBitCount = 1;
|
|
|
|
bmi.bmiHeader.biCompression = BI_RGB;
|
|
|
|
bmi.bmiHeader.biSizeImage = 0;
|
|
|
|
bmi.bmiHeader.biXPelsPerMeter = 100;
|
|
|
|
bmi.bmiHeader.biYPelsPerMeter = 100;
|
|
|
|
bmi.bmiHeader.biClrUsed = 2;
|
|
|
|
bmi.bmiHeader.biClrImportant = 2;
|
|
|
|
|
|
|
|
hbmp = CreateDIBSection(hdc, pbmi, DIB_PAL_COLORS, &pvBits, NULL, 0);
|
|
|
|
ASSERT(hbmp);
|
|
|
|
|
|
|
|
TEST(NtGdiSelectBitmap(hdc, hbmp) != 0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-30 00:09:28 +00:00
|
|
|
INT
|
|
|
|
Test_NtGdiSelectBitmap(PTESTINFO pti)
|
|
|
|
{
|
|
|
|
HDC hDC;
|
|
|
|
HBITMAP hBmp, hOldBmp;
|
Add tests for NtGdiCombineRgn (14), NtGdiCreateCompatibleDC (4), NtGdiDoPalette (1), NtGdiFlushUserBatch (10), NtGdiPolyPolyDraw (60), NtGdiselectBitmap (4), NtGdiSelectPen (6), NtGdiSetDIBitsToDeviceInternal (2), NtUserEnumDisplayMonitors (7), NtUserGetClassInfo (15), NtUserProcessConnect (1), NtUserSelectPalette (13), NtUserSystemParametersInfo (1) (= 138 new tests)
svn path=/trunk/; revision=38044
2008-12-13 16:48:01 +00:00
|
|
|
HPALETTE hOldPalette, hPalette;
|
|
|
|
LOGPALETTE logpal = {0x300, 1, {{12,13,14,15}}};
|
|
|
|
|
|
|
|
hBmp = CreateBitmap(2,2,1,1,NULL);
|
|
|
|
ASSERT(hBmp);
|
|
|
|
|
|
|
|
/* We cannot select a bitmap into a display DC */
|
|
|
|
hDC = GetDC(NULL);
|
|
|
|
ASSERT(hDC);
|
|
|
|
hOldBmp = NtGdiSelectBitmap(hDC, hBmp);
|
|
|
|
TEST(hOldBmp == NULL);
|
2007-11-30 00:09:28 +00:00
|
|
|
|
|
|
|
hDC = CreateCompatibleDC(GetDC(NULL));
|
|
|
|
ASSERT(hDC);
|
|
|
|
|
Add tests for NtGdiCombineRgn (14), NtGdiCreateCompatibleDC (4), NtGdiDoPalette (1), NtGdiFlushUserBatch (10), NtGdiPolyPolyDraw (60), NtGdiselectBitmap (4), NtGdiSelectPen (6), NtGdiSetDIBitsToDeviceInternal (2), NtUserEnumDisplayMonitors (7), NtUserGetClassInfo (15), NtUserProcessConnect (1), NtUserSelectPalette (13), NtUserSystemParametersInfo (1) (= 138 new tests)
svn path=/trunk/; revision=38044
2008-12-13 16:48:01 +00:00
|
|
|
/* Check the palette before we mess it up*/
|
|
|
|
hPalette = CreatePalette(&logpal);
|
|
|
|
hOldPalette = SelectPalette(hDC, hPalette, 0);
|
|
|
|
TEST(hOldPalette == GetStockObject(DEFAULT_PALETTE));
|
2007-11-30 00:09:28 +00:00
|
|
|
|
|
|
|
/* Test NULL DC */
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
hOldBmp = NtGdiSelectBitmap(NULL, hBmp);
|
|
|
|
TEST(hOldBmp == NULL);
|
|
|
|
TEST(GetLastError() == ERROR_SUCCESS);
|
|
|
|
|
|
|
|
/* Test invalid DC */
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
hOldBmp = NtGdiSelectBitmap((HDC)((ULONG_PTR)hDC & 0x0000ffff), hBmp);
|
|
|
|
TEST(hOldBmp == NULL);
|
|
|
|
TEST(GetLastError() == ERROR_SUCCESS);
|
|
|
|
|
|
|
|
/* Test NULL bitmap */
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
hOldBmp = NtGdiSelectBitmap(hDC, NULL);
|
|
|
|
TEST(hOldBmp == NULL);
|
|
|
|
TEST(GetLastError() == ERROR_SUCCESS);
|
|
|
|
|
Add tests for NtGdiCombineRgn (14), NtGdiCreateCompatibleDC (4), NtGdiDoPalette (1), NtGdiFlushUserBatch (10), NtGdiPolyPolyDraw (60), NtGdiselectBitmap (4), NtGdiSelectPen (6), NtGdiSetDIBitsToDeviceInternal (2), NtUserEnumDisplayMonitors (7), NtUserGetClassInfo (15), NtUserProcessConnect (1), NtUserSelectPalette (13), NtUserSystemParametersInfo (1) (= 138 new tests)
svn path=/trunk/; revision=38044
2008-12-13 16:48:01 +00:00
|
|
|
/* Test bitmap with only index */
|
2007-11-30 00:09:28 +00:00
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
hOldBmp = NtGdiSelectBitmap(hDC, (HBITMAP)((ULONG_PTR)hBmp & 0x0000ffff));
|
|
|
|
TEST(hOldBmp == NULL);
|
|
|
|
TEST(GetLastError() == ERROR_SUCCESS);
|
|
|
|
|
Add tests for NtGdiCombineRgn (14), NtGdiCreateCompatibleDC (4), NtGdiDoPalette (1), NtGdiFlushUserBatch (10), NtGdiPolyPolyDraw (60), NtGdiselectBitmap (4), NtGdiSelectPen (6), NtGdiSetDIBitsToDeviceInternal (2), NtUserEnumDisplayMonitors (7), NtUserGetClassInfo (15), NtUserProcessConnect (1), NtUserSelectPalette (13), NtUserSystemParametersInfo (1) (= 138 new tests)
svn path=/trunk/; revision=38044
2008-12-13 16:48:01 +00:00
|
|
|
/* Test valid bitmap */
|
2007-11-30 00:09:28 +00:00
|
|
|
SetLastError(ERROR_SUCCESS);
|
|
|
|
hOldBmp = NtGdiSelectBitmap(hDC, hBmp);
|
|
|
|
TEST(hOldBmp != NULL);
|
Add tests for NtGdiCombineRgn (14), NtGdiCreateCompatibleDC (4), NtGdiDoPalette (1), NtGdiFlushUserBatch (10), NtGdiPolyPolyDraw (60), NtGdiselectBitmap (4), NtGdiSelectPen (6), NtGdiSetDIBitsToDeviceInternal (2), NtUserEnumDisplayMonitors (7), NtUserGetClassInfo (15), NtUserProcessConnect (1), NtUserSelectPalette (13), NtUserSystemParametersInfo (1) (= 138 new tests)
svn path=/trunk/; revision=38044
2008-12-13 16:48:01 +00:00
|
|
|
/* The default bitmap should be GetStockObject(21) */
|
|
|
|
TEST(hOldBmp == GetStockObject(21));
|
|
|
|
|
|
|
|
/* Check the palette */
|
|
|
|
hOldPalette = SelectPalette(hDC, hOldPalette, 0);
|
|
|
|
TEST(hOldPalette == hPalette);
|
|
|
|
DeleteObject(hPalette);
|
|
|
|
|
|
|
|
/* Select the old one again and check */
|
2007-11-30 00:09:28 +00:00
|
|
|
hOldBmp = NtGdiSelectBitmap(hDC, hOldBmp);
|
|
|
|
TEST(hOldBmp == hBmp);
|
|
|
|
TEST(GetLastError() == ERROR_SUCCESS);
|
|
|
|
|
Add tests for NtGdiCombineRgn (14), NtGdiCreateCompatibleDC (4), NtGdiDoPalette (1), NtGdiFlushUserBatch (10), NtGdiPolyPolyDraw (60), NtGdiselectBitmap (4), NtGdiSelectPen (6), NtGdiSetDIBitsToDeviceInternal (2), NtUserEnumDisplayMonitors (7), NtUserGetClassInfo (15), NtUserProcessConnect (1), NtUserSelectPalette (13), NtUserSystemParametersInfo (1) (= 138 new tests)
svn path=/trunk/; revision=38044
2008-12-13 16:48:01 +00:00
|
|
|
/* cleanup */
|
2007-11-30 00:09:28 +00:00
|
|
|
DeleteObject(hBmp);
|
|
|
|
DeleteDC(hDC);
|
|
|
|
|
2009-08-09 11:27:25 +00:00
|
|
|
Test_SelectDIBSection(pti);
|
|
|
|
|
2007-11-30 00:09:28 +00:00
|
|
|
return APISTATUS_NORMAL;
|
|
|
|
}
|
|
|
|
|