mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 16:36:33 +00:00
[GDI32_APITEST]
Add/fix some tests for CreateDIBPatternBrush, GetDIBits, PatBlt and SetWindowExtEx svn path=/trunk/; revision=67051
This commit is contained in:
parent
d030b7f8a7
commit
dd4901282a
4 changed files with 90 additions and 15 deletions
|
@ -10,6 +10,9 @@
|
||||||
#include <wingdi.h>
|
#include <wingdi.h>
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
|
|
||||||
|
/* New color use parameter. See support.microsoft.com/kb/kbview/108497 */
|
||||||
|
#define DIB_PAL_INDICES 2
|
||||||
|
|
||||||
void Test_CreateDIBPatternBrush()
|
void Test_CreateDIBPatternBrush()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -30,6 +33,7 @@ void Test_CreateDIBPatternBrushPt()
|
||||||
};
|
};
|
||||||
HBRUSH hbr, hbrOld;
|
HBRUSH hbr, hbrOld;
|
||||||
HPALETTE hpalOld;
|
HPALETTE hpalOld;
|
||||||
|
LOGBRUSH logbrush;
|
||||||
|
|
||||||
SetLastError(0);
|
SetLastError(0);
|
||||||
ok_hdl(CreateDIBPatternBrushPt(NULL, 0), NULL);
|
ok_hdl(CreateDIBPatternBrushPt(NULL, 0), NULL);
|
||||||
|
@ -59,6 +63,13 @@ void Test_CreateDIBPatternBrushPt()
|
||||||
ok(hbr != 0, "CreateDIBPatternBrushPt failed, skipping tests.\n");
|
ok(hbr != 0, "CreateDIBPatternBrushPt failed, skipping tests.\n");
|
||||||
if (!hbr) return;
|
if (!hbr) return;
|
||||||
|
|
||||||
|
/* Check the logbrush */
|
||||||
|
ok(GetObject(hbr, sizeof(logbrush), &logbrush), "GetObject() failed\n");
|
||||||
|
ok_int(logbrush.lbStyle, BS_DIBPATTERN);
|
||||||
|
ok_hex(logbrush.lbColor, 0);
|
||||||
|
ok(logbrush.lbHatch == (ULONG_PTR)&PackedDIB,
|
||||||
|
"invalid lbHatch. Got %p, expected %p\n", (PVOID)logbrush.lbHatch, &PackedDIB);
|
||||||
|
|
||||||
/* Select the brush into the dc */
|
/* Select the brush into the dc */
|
||||||
hbrOld = SelectObject(ghdcDIB32, hbr);
|
hbrOld = SelectObject(ghdcDIB32, hbr);
|
||||||
|
|
||||||
|
@ -100,11 +111,18 @@ void Test_CreateDIBPatternBrushPt()
|
||||||
PackedDIB.ajBuffer[2] = 1;
|
PackedDIB.ajBuffer[2] = 1;
|
||||||
PackedDIB.ajBuffer[3] = 0;
|
PackedDIB.ajBuffer[3] = 0;
|
||||||
|
|
||||||
/* Create a DIB brush with unkdocumented iUsage == 2 */
|
/* Create a DIB brush with DIB_PAL_INDICES */
|
||||||
hbr = CreateDIBPatternBrushPt(&PackedDIB, 2);
|
hbr = CreateDIBPatternBrushPt(&PackedDIB, DIB_PAL_INDICES);
|
||||||
ok(hbr != 0, "CreateSolidBrush failed, skipping tests.\n");
|
ok(hbr != 0, "CreateSolidBrush failed, skipping tests.\n");
|
||||||
if (!hbr) return;
|
if (!hbr) return;
|
||||||
|
|
||||||
|
/* Check the logbrush */
|
||||||
|
ok(GetObject(hbr, sizeof(logbrush), &logbrush), "GetObject() failed\n");
|
||||||
|
ok_int(logbrush.lbStyle, BS_DIBPATTERN);
|
||||||
|
ok_hex(logbrush.lbColor, 0);
|
||||||
|
ok(logbrush.lbHatch == (ULONG_PTR)&PackedDIB,
|
||||||
|
"invalid lbHatch. Got %p, expected %p\n", (PVOID)logbrush.lbHatch, &PackedDIB);
|
||||||
|
|
||||||
/* Select the brush into the dc */
|
/* Select the brush into the dc */
|
||||||
hbrOld = SelectObject(ghdcDIB32, hbr);
|
hbrOld = SelectObject(ghdcDIB32, hbr);
|
||||||
ok(hbrOld != 0, "CreateSolidBrush failed, skipping tests.\n");
|
ok(hbrOld != 0, "CreateSolidBrush failed, skipping tests.\n");
|
||||||
|
@ -155,8 +173,7 @@ void Test_CreateDIBPatternBrushPt_RLE8()
|
||||||
|
|
||||||
/* Create a DIB brush with palette indices */
|
/* Create a DIB brush with palette indices */
|
||||||
hbr = CreateDIBPatternBrushPt(&PackedDIB, DIB_PAL_COLORS);
|
hbr = CreateDIBPatternBrushPt(&PackedDIB, DIB_PAL_COLORS);
|
||||||
ok(hbr != 0, "CreateDIBPatternBrushPt failed, skipping tests.\n");
|
ok(hbr == 0, "CreateDIBPatternBrushPt should fail.\n");
|
||||||
if (!hbr) return;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,11 +271,25 @@ void Test_GetDIBits()
|
||||||
|
|
||||||
/* Test with different biBitCount set */
|
/* Test with different biBitCount set */
|
||||||
pbi->bmiHeader.biBitCount = 4;
|
pbi->bmiHeader.biBitCount = 4;
|
||||||
pbi->bmiHeader.biSizeImage = 0;
|
pbi->bmiHeader.biSizeImage = 1;
|
||||||
ok_int(GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS), 1);
|
ok_int(GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS), 1);
|
||||||
ok_int(pbi->bmiHeader.biSizeImage, 36);
|
ok_int(pbi->bmiHeader.biSizeImage, 36);
|
||||||
ok_int(pbi->bmiHeader.biBitCount, 4);
|
ok_int(pbi->bmiHeader.biBitCount, 4);
|
||||||
|
|
||||||
|
/* Test with different biBitCount set */
|
||||||
|
pbi->bmiHeader.biBitCount = 8;
|
||||||
|
pbi->bmiHeader.biSizeImage = 1000;
|
||||||
|
ok_int(GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS), 1);
|
||||||
|
ok_int(pbi->bmiHeader.biSizeImage, 60);
|
||||||
|
ok_int(pbi->bmiHeader.biBitCount, 8);
|
||||||
|
|
||||||
|
/* Test with invalid biBitCount set */
|
||||||
|
pbi->bmiHeader.biBitCount = 123;
|
||||||
|
pbi->bmiHeader.biSizeImage = -12;
|
||||||
|
ok_int(GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS), 0);
|
||||||
|
ok_int(pbi->bmiHeader.biSizeImage, -12);
|
||||||
|
ok_int(pbi->bmiHeader.biBitCount, 123);
|
||||||
|
|
||||||
/* Set bitmap dimensions */
|
/* Set bitmap dimensions */
|
||||||
ok_int(SetBitmapDimensionEx(hbmp, 110, 220, NULL), 1);
|
ok_int(SetBitmapDimensionEx(hbmp, 110, 220, NULL), 1);
|
||||||
ZeroMemory(pbi, bisize);
|
ZeroMemory(pbi, bisize);
|
||||||
|
@ -320,16 +334,21 @@ void Test_GetDIBits()
|
||||||
ok_int(pbi->bmiHeader.biCompression, 0);
|
ok_int(pbi->bmiHeader.biCompression, 0);
|
||||||
ok_int(pbi->bmiHeader.biSizeImage, 0);
|
ok_int(pbi->bmiHeader.biSizeImage, 0);
|
||||||
|
|
||||||
/* Get the bitmap bits */
|
/* Get the bitmap info */
|
||||||
pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
pbi->bmiHeader.biWidth = 4;
|
pbi->bmiHeader.biWidth = 4;
|
||||||
pbi->bmiHeader.biHeight = 4;
|
pbi->bmiHeader.biHeight = 4;
|
||||||
pbi->bmiHeader.biPlanes = 1;
|
pbi->bmiHeader.biPlanes = 3;
|
||||||
pbi->bmiHeader.biBitCount = 32;
|
pbi->bmiHeader.biBitCount = 32;
|
||||||
pbi->bmiHeader.biCompression = BI_RGB;
|
pbi->bmiHeader.biCompression = BI_RGB;
|
||||||
ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 1);
|
ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 1);
|
||||||
|
ok_int(pbi->bmiHeader.biSizeImage, 64);
|
||||||
|
ok_int(pbi->bmiHeader.biPlanes, 1);
|
||||||
pbi->bmiHeader.biWidth = 0;
|
pbi->bmiHeader.biWidth = 0;
|
||||||
ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
|
ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
|
||||||
|
pbi->bmiHeader.biWidth = 2;
|
||||||
|
ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 1);
|
||||||
|
ok_int(pbi->bmiHeader.biSizeImage, 32);
|
||||||
pbi->bmiHeader.biWidth = -3;
|
pbi->bmiHeader.biWidth = -3;
|
||||||
ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
|
ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
|
||||||
pbi->bmiHeader.biWidth = 4;
|
pbi->bmiHeader.biWidth = 4;
|
||||||
|
@ -343,12 +362,24 @@ void Test_GetDIBits()
|
||||||
pbi->bmiHeader.biPlanes = 23;
|
pbi->bmiHeader.biPlanes = 23;
|
||||||
ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 1);
|
ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 1);
|
||||||
ok_int(pbi->bmiHeader.biPlanes, 1);
|
ok_int(pbi->bmiHeader.biPlanes, 1);
|
||||||
|
SetLastError(0xdeadbabe);
|
||||||
|
ok_int(GetDIBits((HDC)0xff00ff00, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
|
||||||
|
ok_err(0x57);
|
||||||
|
SetLastError(0xdeadbabe);
|
||||||
|
ok_int(GetDIBits(hdcScreen, (HBITMAP)0xff00ff00, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
|
||||||
|
ok_err(0xdeadbabe);
|
||||||
|
SetLastError(0xdeadbabe);
|
||||||
|
ok_int(GetDIBits((HDC)0xff00ff00, (HBITMAP)0xff00ff00, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
|
||||||
|
ok_err(0x57);
|
||||||
|
SetLastError(0xdeadbabe);
|
||||||
|
ok_int(GetDIBits(NULL, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
|
||||||
|
ok_err(0x57);
|
||||||
|
|
||||||
pbi->bmiHeader.biCompression = BI_JPEG;
|
pbi->bmiHeader.biCompression = BI_JPEG;
|
||||||
ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
|
ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
|
||||||
pbi->bmiHeader.biCompression = BI_PNG;
|
pbi->bmiHeader.biCompression = BI_PNG;
|
||||||
ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
|
ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
|
||||||
|
|
||||||
|
|
||||||
/* Get the bitmap bits */
|
/* Get the bitmap bits */
|
||||||
pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
pbi->bmiHeader.biWidth = 4;
|
pbi->bmiHeader.biWidth = 4;
|
||||||
|
@ -364,10 +395,22 @@ void Test_GetDIBits()
|
||||||
cjSizeImage = ((pbi->bmiHeader.biWidth * pbi->bmiHeader.biBitCount + 31) / 32) * 4 * pbi->bmiHeader.biHeight;
|
cjSizeImage = ((pbi->bmiHeader.biWidth * pbi->bmiHeader.biBitCount + 31) / 32) * 4 * pbi->bmiHeader.biHeight;
|
||||||
pvBits = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 512);
|
pvBits = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 512);
|
||||||
ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 4);
|
ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 4);
|
||||||
|
ok_int(pbi->bmiHeader.biSize, sizeof(BITMAPINFOHEADER));
|
||||||
|
ok_int(pbi->bmiHeader.biWidth, 4);
|
||||||
|
ok_int(pbi->bmiHeader.biHeight, 4);
|
||||||
|
ok_int(pbi->bmiHeader.biPlanes, 1);
|
||||||
|
ok_int(pbi->bmiHeader.biBitCount, 32);
|
||||||
|
ok_int(pbi->bmiHeader.biCompression, BI_RGB);
|
||||||
|
ok_int(pbi->bmiHeader.biSizeImage, 64);
|
||||||
|
ok_int(pbi->bmiHeader.biXPelsPerMeter, 0);
|
||||||
|
ok_int(pbi->bmiHeader.biYPelsPerMeter, 0);
|
||||||
|
ok_int(pbi->bmiHeader.biClrUsed, 0);
|
||||||
|
ok_int(pbi->bmiHeader.biClrImportant, 0);
|
||||||
|
|
||||||
/* Set biBitCount to 0 */
|
/* Set biBitCount to 0 */
|
||||||
pbi->bmiHeader.biBitCount = 0;
|
pbi->bmiHeader.biBitCount = 0;
|
||||||
ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 0);
|
ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 0);
|
||||||
|
ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, (PVOID)(LONG_PTR)-1, pbi, DIB_RGB_COLORS), 0);
|
||||||
ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, NULL, pbi, DIB_RGB_COLORS), 1);
|
ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, NULL, pbi, DIB_RGB_COLORS), 1);
|
||||||
ok_int(GetDIBits(NULL, hbmp, 0, 4, NULL, pbi, DIB_RGB_COLORS), 0);
|
ok_int(GetDIBits(NULL, hbmp, 0, 4, NULL, pbi, DIB_RGB_COLORS), 0);
|
||||||
|
|
||||||
|
@ -381,6 +424,10 @@ void Test_GetDIBits()
|
||||||
pbi->bmiHeader.biWidth = 3;
|
pbi->bmiHeader.biWidth = 3;
|
||||||
ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 4);
|
ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 4);
|
||||||
|
|
||||||
|
/* Try invalid biBitCount */
|
||||||
|
pbi->bmiHeader.biBitCount = 17;
|
||||||
|
ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 0);
|
||||||
|
|
||||||
/* Set only biBitCount and pjInit */
|
/* Set only biBitCount and pjInit */
|
||||||
ZeroMemory(pbi, bisize);
|
ZeroMemory(pbi, bisize);
|
||||||
pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||||
|
@ -405,19 +452,19 @@ void Test_GetDIBits()
|
||||||
pbi->bmiHeader.biSizeImage = 0;
|
pbi->bmiHeader.biSizeImage = 0;
|
||||||
ok_int(GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS), 0);
|
ok_int(GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS), 0);
|
||||||
|
|
||||||
|
/* Calculate bitmap size and allocate a buffer */
|
||||||
cjSizeImage = ((pbi->bmiHeader.biWidth * pbi->bmiHeader.biBitCount + 31) / 32) * 4 * pbi->bmiHeader.biHeight;
|
cjSizeImage = ((pbi->bmiHeader.biWidth * pbi->bmiHeader.biBitCount + 31) / 32) * 4 * pbi->bmiHeader.biHeight;
|
||||||
|
ok_int(cjSizeImage, 20);
|
||||||
pvBits = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cjSizeImage);
|
pvBits = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cjSizeImage);
|
||||||
|
|
||||||
|
/* Test using a compatible DC */
|
||||||
hdcMem = CreateCompatibleDC(0);
|
hdcMem = CreateCompatibleDC(0);
|
||||||
ok(hdcMem != 0, "CreateCompatibleDC failed, skipping tests\n");
|
ok(hdcMem != 0, "CreateCompatibleDC failed, skipping tests\n");
|
||||||
if (hdcMem == NULL) return;
|
if (hdcMem == NULL) return;
|
||||||
|
ok_int(GetDIBits(hdcMem, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 0);
|
||||||
|
ok_int(GetDIBits(hdcMem, ghbmpDIB4, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 4);
|
||||||
|
|
||||||
// FIXME: broken
|
HeapFree(GetProcessHeap(), 0, pvBits);
|
||||||
//ok(SelectObject(hdcMem, ghbmpDIB4) != 0, "Failed to select 4bpp DIB %p into DC %p\n", ghbmpDIB4, hdcMem);;
|
|
||||||
//ok_int(GetDIBits(hdcMem, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 0);
|
|
||||||
//ok_int(GetDIBits(hdcMem, ghbmpDIB4, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 3);
|
|
||||||
|
|
||||||
|
|
||||||
DeleteDC(hdcMem);
|
DeleteDC(hdcMem);
|
||||||
ReleaseDC(NULL, hdcScreen);
|
ReleaseDC(NULL, hdcScreen);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,10 @@ void Test_PatBlt_Params()
|
||||||
ret = PatBlt(hdcTarget, 0, 0, 1, 1, PATCOPY & 0x00FF0000);
|
ret = PatBlt(hdcTarget, 0, 0, 1, 1, PATCOPY & 0x00FF0000);
|
||||||
ok_long(ret, 1);
|
ok_long(ret, 1);
|
||||||
|
|
||||||
|
/* Test a rop that contains arbitrary values outside the operation index */
|
||||||
|
ret = PatBlt(hdcTarget, 0, 0, 1, 1, (PATCOPY & 0x00FF0000) | 0xab00cdef);
|
||||||
|
ok_long(ret, 1);
|
||||||
|
|
||||||
/* Test an invalid rop */
|
/* Test an invalid rop */
|
||||||
SetLastError(0);
|
SetLastError(0);
|
||||||
ok_long(PatBlt(hdcTarget, 0, 0, 1, 1, SRCCOPY) , 0);
|
ok_long(PatBlt(hdcTarget, 0, 0, 1, 1, SRCCOPY) , 0);
|
||||||
|
|
|
@ -96,7 +96,14 @@ void Test_SetWindowExtEx()
|
||||||
//pDC_Attr = pEntry->UserData;
|
//pDC_Attr = pEntry->UserData;
|
||||||
//ASSERT(pDC_Attr);
|
//ASSERT(pDC_Attr);
|
||||||
|
|
||||||
/* Test setting it without changing the map mode (MM_TEXT) */
|
/* Test setting 0 extents without changing the map mode (MM_TEXT) */
|
||||||
|
ret = SetWindowExtEx(hDC, 0, 0, &WindowExt);
|
||||||
|
TEST(ret == 1);
|
||||||
|
TEST(WindowExt.cx == 1);
|
||||||
|
TEST(WindowExt.cy == 1);
|
||||||
|
|
||||||
|
/* Test setting proper extents without changing the map mode (MM_TEXT) */
|
||||||
|
WindowExt.cx = WindowExt.cy = 0;
|
||||||
ret = SetWindowExtEx(hDC, 10, 20, &WindowExt);
|
ret = SetWindowExtEx(hDC, 10, 20, &WindowExt);
|
||||||
TEST(ret == 1);
|
TEST(ret == 1);
|
||||||
TEST(WindowExt.cx == 1);
|
TEST(WindowExt.cx == 1);
|
||||||
|
|
Loading…
Reference in a new issue