gdi32_test:

a lot of testcases especially for GetObject

svn path=/trunk/; revision=26569
This commit is contained in:
Timo Kreuzer 2007-04-29 01:43:41 +00:00
parent ec3552fddf
commit a0d7f57718
13 changed files with 753 additions and 0 deletions

View file

@ -0,0 +1,49 @@
#include <stdio.h>
#include <stdlib.h>
#include "gditest.h"
int main(int argc, char *argv[])
{
INT Num = NumTests();
INT i, j;
INT passed, failed, opassed, ofailed;
opassed = 0;
ofailed = 0;
printf("GDI tests\n");
if (argc > 1)
{
for (i = 1; i < argc; i++)
{
for (j = 0; j < NumTests(); j++)
{
if (stricmp(argv[i], TestList[j].Test) == 0)
{
passed = 0;
failed = 0;
TestList[j].Proc(&passed, &failed);
opassed += passed;
ofailed += failed;
printf(" tests: %d, passed: %d, failed: %d\n\n", passed+failed, passed, failed);
}
}
}
}
else
{
for (i = 0; i < Num; i++)
{
passed = 0;
failed = 0;
printf("Test: %s\n", TestList[i].Test);
TestList[i].Proc(&passed, &failed);
opassed += passed;
ofailed += failed;
printf(" tests: %d, passed: %d, failed: %d\n\n", passed+failed, passed, failed);
}
}
printf("\nOverall tests: %d, passed: %d, failed: %d\n", opassed+ofailed, opassed, ofailed);
return ofailed;
}

View file

@ -0,0 +1,10 @@
<module name="gdi32_test" type="win32cui">
<include base="gdi32_test">.</include>
<define name="__USE_W32API" />
<define name="_WIN32_WINNT">0x0501</define>
<library>kernel32</library>
<library>user32</library>
<library>gdi32</library>
<file>gdi32_test.c</file>
<file>testlist.c</file>
</module>

View file

@ -0,0 +1,72 @@
#ifndef _GDITEST_H
#define _GDITEST_H
#define WINVER 0x501
//#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <windows.h>
#define TEST(x) \
if (x)\
{\
(*passed)++;\
} else {\
(*failed)++;\
printf("Test failed in file %s line %d\n", __FILE__, __LINE__);\
};
#define GDI_HANDLE_INDEX_MASK 0x00003fff // (GDI_HANDLE_COUNT - 1)
#define GDI_HANDLE_TYPE_MASK 0x007f0000
#define GDI_HANDLE_STOCK_MASK 0x00800000
#define GDI_HANDLE_REUSE_MASK 0xff000000
#define GDI_HANDLE_GET_INDEX(h) \
(((ULONG_PTR)(h)) & GDI_HANDLE_INDEX_MASK)
#define GDI_HANDLE_GET_TYPE(h) \
(((ULONG_PTR)(h)) & GDI_HANDLE_TYPE_MASK)
#define GDI_HANDLE_PEN_TO_BRUSH(h) \
(HBRUSH)((((ULONG_PTR)(h)) & ~GDI_HANDLE_TYPE_MASK) | GDI_OBJECT_TYPE_PEN)
#define GDI_OBJECT_TYPE_DC 0x00010000
#define GDI_OBJECT_TYPE_REGION 0x00040000
#define GDI_OBJECT_TYPE_BITMAP 0x00050000
#define GDI_OBJECT_TYPE_PALETTE 0x00080000
#define GDI_OBJECT_TYPE_FONT 0x000a0000
#define GDI_OBJECT_TYPE_BRUSH 0x00100000
#define GDI_OBJECT_TYPE_EMF 0x00210000
#define GDI_OBJECT_TYPE_PEN 0x00300000
#define GDI_OBJECT_TYPE_EXTPEN 0x00500000
#define GDI_OBJECT_TYPE_COLORSPACE 0x00090000
#define GDI_OBJECT_TYPE_METADC 0x00660000
#define GDI_OBJECT_TYPE_METAFILE 0x00260000
#define GDI_OBJECT_TYPE_ENHMETAFILE 0x00460000
/* Following object types made up for ROS */
#define GDI_OBJECT_TYPE_ENHMETADC 0x00740000
#define GDI_OBJECT_TYPE_MEMDC 0x00750000
#define GDI_OBJECT_TYPE_DCE 0x00770000
#define GDI_OBJECT_TYPE_DONTCARE 0x007f0000
/* The type definitions */
typedef BOOL (*TESTPROC)(INT*, INT*);
typedef struct tagTEST
{
CHAR* Test;
TESTPROC Proc;
} TEST, *PTEST;
extern TEST TestList[];
INT NumTests(void);
#endif /* _GDITEST_H */
/* EOF */

View file

@ -0,0 +1,37 @@
#ifndef _GDITESTLIST_H
#define _GDITESTLIST_H
#include "gditest.h"
/* include the tests */
#include "tests/CreateCompatibleDC.c"
#include "tests/CreatePen.c"
#include "tests/ExtCreatePen.c"
#include "tests/GetObject.c"
#include "tests/GetStockObject.c"
#include "tests/SelectObject.c"
#include "tests/SetDCPenColor.c"
#include "tests/SetSysColors.c"
/* The List of tests */
TEST TestList[] =
{
{ "CreateCompatibleDC", Test_CreateCompatibleDC },
{ "CreatePen", Test_CreatePen },
{ "ExtCreatePen", Test_ExtCreatePen },
{ "GetStockObject", Test_GetStockObject },
{ "SetSysColors", Test_SetSysColors },
{ "SelectObject", Test_SelectObject },
{ "SetDCPenColor", Test_SetDCPenColor },
{ "GetObject", Test_GetObject }
};
/* The function that gives us the number of tests */
INT NumTests(void)
{
return sizeof(TestList) / sizeof(TEST);
}
#endif /* _GDITESTLIST_H */
/* EOF */

View file

@ -0,0 +1,37 @@
#include "..\gditest.h"
BOOL Test_CreateCompatibleDC(INT* passed, INT* failed)
{
HDC hDCScreen, hOldDC, hDC, hDC2;
// Create a DC
hDCScreen = GetDC(NULL);
if (hDCScreen == NULL)
{
return FALSE;
}
hDC = CreateCompatibleDC(hDCScreen);
TEST(hDC != NULL);
// Test if first selected pen is BLACK_PEN (? or same as screen DC's pen?)
TEST(SelectObject(hDC, GetStockObject(DC_PEN)) == GetStockObject(BLACK_PEN));
TEST(SelectObject(hDC, GetStockObject(BLACK_PEN)) == GetStockObject(DC_PEN));
// Test for the starting Color == RGB(0,0,0)
TEST(SetDCPenColor(hDC, RGB(1,2,3)) == RGB(0,0,0));
// Check for reuse counter
hOldDC = hDC;
DeleteDC(hDC);
hDC = CreateCompatibleDC(hDCScreen);
hDC2 = CreateCompatibleDC(hOldDC);
TEST(hDC2 == NULL);
if (hDC2 != NULL) DeleteDC(hDC2);
// cleanup
DeleteDC(hDC);
ReleaseDC(NULL, hDCScreen);
return TRUE;
}

View file

@ -0,0 +1,17 @@
#include "..\gditest.h"
BOOL
Test_CreatePen(INT* passed, INT* failed)
{
HPEN hPen;
hPen = CreatePen(PS_COSMETIC, 1, RGB(1,2,3));
if (!hPen) return FALSE;
/* Test if we have a PEN */
TEST(GDI_HANDLE_GET_TYPE(hPen) == GDI_OBJECT_TYPE_PEN);
DeleteObject(hPen);
return TRUE;
}

View file

@ -0,0 +1,23 @@
#include "..\gditest.h"
BOOL
Test_ExtCreatePen(INT* passed, INT* failed)
{
HPEN hPen;
LOGBRUSH logbrush;
logbrush.lbStyle = BS_SOLID;
logbrush.lbColor = RGB(1,2,3);
logbrush.lbHatch = 0;
hPen = ExtCreatePen(PS_COSMETIC, 1,&logbrush, 0, 0);
if (!hPen) return FALSE;
/* Test if we have an EXTPEN */
TEST(GDI_HANDLE_GET_TYPE(hPen) == GDI_OBJECT_TYPE_EXTPEN);
DeleteObject(hPen);
return TRUE;
}

View file

@ -0,0 +1,398 @@
#include "..\gditest.h"
BOOL
Test_General(INT* passed, INT* failed)
{
/* Test null pointer and invalid handles */
SetLastError(ERROR_SUCCESS);
TEST(GetObjectA(0, 0, NULL) == 0);
TEST(GetObjectA((HANDLE)-1, 0, NULL) == 0);
TEST(GetObjectA((HANDLE)0x00380000, 0, NULL) == 0);
TEST(GetLastError() == ERROR_SUCCESS);
SetLastError(ERROR_SUCCESS);
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_DC, 0, NULL) == 0);
TEST(GetLastError() == ERROR_INVALID_HANDLE);
SetLastError(ERROR_SUCCESS);
TEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_DC, 0, NULL) == 0);
TEST(GetLastError() == ERROR_INVALID_HANDLE);
SetLastError(ERROR_SUCCESS);
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_REGION, 0, NULL) == 0);
TEST(GetLastError() == ERROR_INVALID_HANDLE);
SetLastError(ERROR_SUCCESS);
TEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_REGION, 0, NULL) == 0);
TEST(GetLastError() == ERROR_INVALID_HANDLE);
SetLastError(ERROR_SUCCESS);
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_EMF, 0, NULL) == 0);
TEST(GetLastError() == ERROR_INVALID_HANDLE);
SetLastError(ERROR_SUCCESS);
TEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_EMF, 0, NULL) == 0);
TEST(GetLastError() == ERROR_INVALID_HANDLE);
SetLastError(ERROR_SUCCESS);
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METAFILE, 0, NULL) == 0);
TEST(GetLastError() == ERROR_INVALID_HANDLE);
SetLastError(ERROR_SUCCESS);
TEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_METAFILE, 0, NULL) == 0);
TEST(GetLastError() == ERROR_INVALID_HANDLE);
SetLastError(ERROR_SUCCESS);
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_ENHMETAFILE, 0, NULL) == 0);
TEST(GetLastError() == ERROR_INVALID_HANDLE);
SetLastError(ERROR_SUCCESS);
TEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_ENHMETAFILE, 0, NULL) == 0);
TEST(GetLastError() == ERROR_INVALID_HANDLE);
return TRUE;
}
BOOL
Test_Bitmap(INT* passed, INT* failed)
{
HBITMAP hBitmap;
BITMAP bitmap;
DIBSECTION dibsection;
BYTE bData[100] = {0};
BYTE Buffer[100] = {48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,0};
FillMemory(&bitmap, sizeof(BITMAP), 0x77);
hBitmap = CreateBitmap(10,10,1,8,bData);
if (!hBitmap) return FALSE;
SetLastError(ERROR_SUCCESS);
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BITMAP, 0, NULL) == sizeof(BITMAP));
TEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_BITMAP, 0, NULL) == sizeof(BITMAP));
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BITMAP, sizeof(BITMAP), NULL) == sizeof(BITMAP));
TEST(GetObjectA(hBitmap, sizeof(DIBSECTION), NULL) == sizeof(BITMAP));
TEST(GetObjectA(hBitmap, 0, NULL) == sizeof(BITMAP));
TEST(GetObjectA((HANDLE)((UINT)hBitmap & 0x0000ffff), 0, NULL) == sizeof(BITMAP));
TEST(GetObjectA(hBitmap, 5, NULL) == sizeof(BITMAP));
TEST(GetObjectA(hBitmap, -5, NULL) == sizeof(BITMAP));
TEST(GetObjectA(hBitmap, 0, Buffer) == 0);
TEST(GetObjectA(hBitmap, 5, Buffer) == 0);
TEST(GetObjectA(hBitmap, sizeof(BITMAP), &bitmap) == sizeof(BITMAP));
TEST(GetObjectA(hBitmap, sizeof(BITMAP)+2, &bitmap) == sizeof(BITMAP));
TEST(GetObjectA(hBitmap, sizeof(DIBSECTION), &dibsection) == sizeof(BITMAP));
TEST(GetObjectA(hBitmap, -5, &bitmap) == sizeof(BITMAP));
TEST(GetLastError() == ERROR_SUCCESS);
// todo: test invalid handle + buffer
DeleteObject(hBitmap);
return TRUE;
}
BOOL
Test_Dibsection(INT* passed, INT* failed)
{
BITMAPINFO bmi = {{sizeof(BITMAPINFOHEADER), 10, 10, 1, 8, BI_RGB, 0, 10, 10, 0,0}};
HBITMAP hBitmap;
DIBSECTION dibsection;
PVOID pData;
FillMemory(&dibsection, sizeof(DIBSECTION), 0x77);
HDC hDC = GetDC(0);
hBitmap = CreateDIBSection(hDC, &bmi, DIB_RGB_COLORS, &pData, NULL, 0);
if(!hBitmap) return FALSE;
SetLastError(ERROR_SUCCESS);
TEST(GetObject(hBitmap, sizeof(DIBSECTION), NULL) == sizeof(BITMAP));
TEST(GetObject(hBitmap, 0, NULL) == sizeof(BITMAP));
TEST(GetObject(hBitmap, 5, NULL) == sizeof(BITMAP));
TEST(GetObject(hBitmap, -5, NULL) == sizeof(BITMAP));
TEST(GetObject(hBitmap, 0, &dibsection) == 0);
TEST(GetObject(hBitmap, 5, &dibsection) == 0);
TEST(GetObject(hBitmap, sizeof(BITMAP), &dibsection) == sizeof(BITMAP));
TEST(GetObject(hBitmap, sizeof(BITMAP)+2, &dibsection) == sizeof(BITMAP));
TEST(GetObject(hBitmap, sizeof(DIBSECTION), &dibsection) == sizeof(DIBSECTION));
TEST(GetObject(hBitmap, sizeof(DIBSECTION)+2, &dibsection) == sizeof(DIBSECTION));
TEST(GetObject(hBitmap, -5, &dibsection) == sizeof(DIBSECTION));
TEST(GetLastError() == ERROR_SUCCESS);
DeleteObject(hBitmap);
ReleaseDC(0, hDC);
return TRUE;
}
BOOL Test_Palette(INT* passed, INT* failed)
{
LOGPALETTE logpal;
HPALETTE hPalette;
WORD wPalette;
FillMemory(&wPalette, sizeof(WORD), 0x77);
logpal.palVersion = 0x0300;
logpal.palNumEntries = 1;
logpal.palPalEntry[0].peRed = 0;
logpal.palPalEntry[0].peGreen = 0;
logpal.palPalEntry[0].peBlue = 0;
logpal.palPalEntry[0].peFlags = PC_EXPLICIT;
hPalette = CreatePalette(&logpal);
if (!hPalette) return FALSE;
SetLastError(ERROR_SUCCESS);
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_PALETTE, 0, NULL) == sizeof(WORD));
TEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PALETTE, 0, NULL) == sizeof(WORD));
TEST(GetObject(hPalette, sizeof(WORD), NULL) == sizeof(WORD));
TEST(GetObject(hPalette, 0, NULL) == sizeof(WORD));
TEST(GetObject(hPalette, 5, NULL) == sizeof(WORD));
TEST(GetObject(hPalette, -5, NULL) == sizeof(WORD));
TEST(GetObject(hPalette, sizeof(WORD), &wPalette) == sizeof(WORD));
TEST(GetObject(hPalette, sizeof(WORD)+2, &wPalette) == sizeof(WORD));
TEST(GetObject(hPalette, 0, &wPalette) == 0);
TEST(GetObject(hPalette, 1, &wPalette) == 0);
TEST(GetObject(hPalette, -1, &wPalette) == sizeof(WORD));
TEST(GetLastError() == ERROR_SUCCESS);
DeleteObject(hPalette);
return TRUE;
}
BOOL Test_Brush(INT* passed, INT* failed)
{
LOGBRUSH logbrush;
HBRUSH hBrush;
FillMemory(&logbrush, sizeof(LOGBRUSH), 0x77);
hBrush = CreateSolidBrush(RGB(1,2,3));
if (!hBrush) return FALSE;
SetLastError(ERROR_SUCCESS);
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_BRUSH, 0, NULL) == sizeof(LOGBRUSH));
TEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_BRUSH, 0, NULL) == sizeof(LOGBRUSH));
TEST(GetObject(hBrush, sizeof(WORD), NULL) == sizeof(LOGBRUSH));
TEST(GetObject(hBrush, 0, NULL) == sizeof(LOGBRUSH));
TEST(GetObject(hBrush, 5, NULL) == sizeof(LOGBRUSH));
TEST(GetObject(hBrush, -5, NULL) == sizeof(LOGBRUSH));
TEST(GetObject(hBrush, 0, &logbrush) == 0);
TEST(logbrush.lbStyle == 0x77777777);
TEST(GetObject(hBrush, 5, &logbrush) == sizeof(LOGBRUSH));
TEST(logbrush.lbStyle == 0);
TEST(logbrush.lbColor == 0x77777701);
TEST(GetObject(hBrush, sizeof(LOGBRUSH), &logbrush) == sizeof(LOGBRUSH));
TEST(GetObject(hBrush, sizeof(LOGBRUSH)+2, &logbrush) == sizeof(LOGBRUSH));
TEST(GetObject(hBrush, -1, &logbrush) == sizeof(LOGBRUSH));
// TODO: test all members
TEST(GetLastError() == ERROR_SUCCESS);
DeleteObject(hBrush);
return TRUE;
}
BOOL Test_Pen(INT* passed, INT* failed)
{
LOGPEN logpen;
HPEN hPen;
FillMemory(&logpen, sizeof(LOGPEN), 0x77);
hPen = CreatePen(PS_SOLID, 3, RGB(4,5,6));
if (!hPen) return FALSE;
SetLastError(ERROR_SUCCESS);
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_PEN, 0, NULL) == sizeof(LOGPEN));
TEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_PEN, 0, NULL) == sizeof(LOGPEN));
TEST(GetObject(hPen, sizeof(BITMAP), NULL) == sizeof(LOGPEN));
TEST(GetObject(hPen, 0, NULL) == sizeof(LOGPEN));
TEST(GetObject(hPen, 5, NULL) == sizeof(LOGPEN));
TEST(GetObject(hPen, -5, NULL) == sizeof(LOGPEN));
TEST(GetObject(hPen, sizeof(LOGPEN), &logpen) == sizeof(LOGPEN));
TEST(GetObject(hPen, sizeof(LOGPEN)+2, &logpen) == sizeof(LOGPEN));
TEST(GetObject(hPen, 0, &logpen) == 0);
TEST(GetObject(hPen, 5, &logpen) == 0);
TEST(GetObject(hPen, -5, &logpen) == sizeof(LOGPEN));
TEST(GetLastError() == ERROR_SUCCESS);
DeleteObject(hPen);
return TRUE;
}
BOOL Test_ExtPen(INT* passed, INT* failed)
{
HPEN hPen;
EXTLOGPEN extlogpen;
LOGBRUSH logbrush;
SetLastError(ERROR_SUCCESS);
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0);
TEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0);
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
FillMemory(&extlogpen, sizeof(EXTLOGPEN), 0x77);
logbrush.lbStyle = BS_SOLID;
logbrush.lbColor = RGB(1,2,3);
logbrush.lbHatch = 0;
hPen = ExtCreatePen(PS_GEOMETRIC | PS_SOLID, 5, &logbrush, 0, NULL);
TEST(GDI_HANDLE_GET_TYPE(hPen) == GDI_OBJECT_TYPE_EXTPEN);
TEST(GetObject((HANDLE)GDI_OBJECT_TYPE_EXTPEN, 0, NULL) == 0);
TEST(GetObject(hPen, sizeof(EXTLOGPEN), NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD));
TEST(GetObject(hPen, 0, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD));
TEST(GetObject((HANDLE)GDI_HANDLE_GET_INDEX(hPen), 0, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD));
TEST(GetObject(hPen, 5, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD));
TEST(GetObject(hPen, -5, NULL) == sizeof(EXTLOGPEN)-sizeof(DWORD));
TEST(GetObject(hPen, 0, &extlogpen) == 0);
TEST(GetObject(hPen, 4, &extlogpen) == 0);
/* Nothing should be filled */
TEST(extlogpen.elpPenStyle == 0x77777777);
TEST(extlogpen.elpWidth == 0x77777777);
TEST(GetObject(hPen, sizeof(EXTLOGPEN), &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD));
TEST(GetObject(hPen, sizeof(EXTLOGPEN)+2, &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD));
TEST(GetObject(hPen, -5, &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD));
/* test if the fields are filled correctly */
TEST(extlogpen.elpPenStyle == PS_GEOMETRIC);
TEST(extlogpen.elpWidth == 5);
TEST(extlogpen.elpBrushStyle == 0);
TEST(extlogpen.elpColor == RGB(1,2,3));
TEST(extlogpen.elpHatch == 0);
TEST(extlogpen.elpNumEntries == 0);
DeleteObject(hPen);
return TRUE;
}
BOOL Test_Font(INT* passed, INT* failed)
{
HFONT hFont;
LOGFONTA logfonta;
LOGFONTW logfontw;
EXTLOGFONTA extlogfonta;
EXTLOGFONTW extlogfontw;
ENUMLOGFONTEXA enumlogfontexa;
ENUMLOGFONTEXW enumlogfontexw;
ENUMLOGFONTEXDVA enumlogfontexdva;
ENUMLOGFONTEXDVW enumlogfontexdvw;
ENUMLOGFONTA enumlogfonta;
ENUMLOGFONTW enumlogfontw;
BYTE bData[270];
FillMemory(&logfonta, sizeof(LOGFONTA), 0x77);
hFont = CreateFont(8, 8, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS,
ANTIALIASED_QUALITY, DEFAULT_PITCH, "testfont");
TEST(hFont);
SetLastError(ERROR_SUCCESS);
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, 0, NULL) == sizeof(LOGFONTA));
TEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, 0, NULL) == sizeof(LOGFONTW));
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(LOGFONTA), NULL) == sizeof(LOGFONTA)); // 60
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTA), NULL) == sizeof(LOGFONTA)); // 156
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXA), NULL) == sizeof(LOGFONTA)); // 188
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(EXTLOGFONTA), NULL) == sizeof(LOGFONTA)); // 192
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVA), NULL) == sizeof(LOGFONTA)); // 260
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVA)+1, NULL) == sizeof(LOGFONTA)); // 260
TEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(LOGFONTW), NULL) == sizeof(LOGFONTW)); // 92
TEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTW), NULL) == sizeof(LOGFONTW)); // 284
TEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(EXTLOGFONTW), NULL) == sizeof(LOGFONTW)); // 320
TEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXW), NULL) == sizeof(LOGFONTW)); // 348
TEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVW), NULL) == sizeof(LOGFONTW)); // 420
TEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_FONT, sizeof(ENUMLOGFONTEXDVW)+1, NULL) == sizeof(LOGFONTW)); // 356!
TEST(GetObjectA(hFont, sizeof(LOGFONTA), NULL) == sizeof(LOGFONTA));
TEST(GetObjectA(hFont, 0, NULL) == sizeof(LOGFONTA));
TEST(GetObjectA(hFont, 5, NULL) == sizeof(LOGFONTA));
TEST(GetObjectA(hFont, -5, NULL) == sizeof(LOGFONTA));
TEST(GetObjectA(hFont, 0, &logfonta) == 0);
TEST(logfonta.lfHeight == 0x77777777);
TEST(GetObjectA(hFont, 5, &logfonta) == 5);
TEST(logfonta.lfHeight == 8);
TEST(logfonta.lfWidth == 0x77777708);
TEST(GetObjectA(hFont, sizeof(LOGFONTA), &logfonta) == sizeof(LOGFONTA)); // 60
TEST(GetObjectA(hFont, sizeof(LOGFONTW), &logfontw) == sizeof(LOGFONTA)); // 92
TEST(GetObjectA(hFont, sizeof(EXTLOGFONTA), &extlogfonta) == sizeof(EXTLOGFONTA)); // 192
TEST(GetObjectA(hFont, sizeof(EXTLOGFONTA)+1, &extlogfonta) == sizeof(EXTLOGFONTA)+1); // 192
TEST(GetObjectA(hFont, sizeof(EXTLOGFONTW), &extlogfontw) == sizeof(ENUMLOGFONTEXDVA)); // 320
TEST(GetObjectA(hFont, 261, &bData) == 260); // no
/* LOGFONT / GetObjectW */
FillMemory(&logfontw, sizeof(LOGFONTW), 0x77);
TEST(GetObjectW(hFont, sizeof(LOGFONTW), NULL) == sizeof(LOGFONTW));
TEST(GetObjectW(hFont, 0, NULL) == sizeof(LOGFONTW));
TEST(GetObjectW(hFont, 5, NULL) == sizeof(LOGFONTW));
TEST(GetObjectW(hFont, -5, NULL) == sizeof(LOGFONTW));
TEST(GetObjectW(hFont, 0, &logfontw) == 0);
TEST(logfontw.lfHeight == 0x77777777);
TEST(GetObjectW(hFont, 5, &logfontw) == 5);
TEST(logfontw.lfHeight == 8);
TEST(logfontw.lfWidth == 0x77777708);
TEST(GetObjectA(hFont, sizeof(LOGFONTA), &logfonta) == sizeof(LOGFONTA)); // 60
TEST(logfonta.lfHeight == 8);
TEST(GetObjectA(hFont, sizeof(ENUMLOGFONTA), &enumlogfonta) == sizeof(ENUMLOGFONTA)); // 156
TEST(GetObjectA(hFont, sizeof(ENUMLOGFONTEXA), &enumlogfontexa) == sizeof(ENUMLOGFONTEXA)); // 188
TEST(GetObjectA(hFont, sizeof(EXTLOGFONTA), &extlogfonta) == sizeof(EXTLOGFONTA)); // 192
TEST(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA), &enumlogfontexdva) == sizeof(ENUMLOGFONTEXDVA)); // 260
TEST(GetObjectA(hFont, sizeof(ENUMLOGFONTEXDVA)+1, &enumlogfontexdva) == sizeof(ENUMLOGFONTEXDVA)); // 260
TEST(GetObjectW(hFont, sizeof(LOGFONTW), &logfontw) == sizeof(LOGFONTW)); // 92
TEST(GetObjectW(hFont, sizeof(ENUMLOGFONTW), &enumlogfontw) == sizeof(ENUMLOGFONTW)); // 284
TEST(GetObjectW(hFont, sizeof(EXTLOGFONTW), &extlogfontw) == sizeof(EXTLOGFONTW)); // 320
TEST(GetObjectW(hFont, sizeof(ENUMLOGFONTEXW), &enumlogfontexw) == sizeof(ENUMLOGFONTEXW)); // 348
TEST(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW), &enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD)); // 420
TEST(GetObjectW(hFont, sizeof(ENUMLOGFONTEXDVW)+1, &enumlogfontexdvw) == sizeof(ENUMLOGFONTEXW) + 2*sizeof(DWORD)); // 356!
TEST(GetObjectW(hFont, 356, &bData) == 356);
TEST(GetLastError() == ERROR_SUCCESS);
DeleteObject(hFont);
return TRUE;
}
BOOL Test_Colorspace(INT* passed, INT* failed)
{
SetLastError(ERROR_SUCCESS);
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL) == 60);// FIXME: what structure?
TEST(GetLastError() == ERROR_INSUFFICIENT_BUFFER);
SetLastError(ERROR_SUCCESS);
TEST(GetObjectW((HANDLE)GDI_OBJECT_TYPE_COLORSPACE, 0, NULL) == 0);
TEST(GetLastError() == ERROR_INSUFFICIENT_BUFFER);
return TRUE;
}
BOOL Test_MetaDC(INT* passed, INT* failed)
{
/* Windows does not SetLastError() on a metadc, but it doesn't seem to do anything with it */
HDC hMetaDC;
BYTE buffer[100];
hMetaDC = CreateMetaFile(NULL);
if(!hMetaDC) return FALSE;
if(((UINT)hMetaDC & GDI_HANDLE_TYPE_MASK) != GDI_OBJECT_TYPE_METADC) return FALSE;
SetLastError(ERROR_SUCCESS);
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METADC, 0, NULL) == 0);
TEST(GetObjectA((HANDLE)GDI_OBJECT_TYPE_METADC, 100, &buffer) == 0);
TEST(GetObjectA(hMetaDC, 0, NULL) == 0);
TEST(GetObjectA(hMetaDC, 100, &buffer) == 0);
TEST(GetLastError() == ERROR_SUCCESS);
return TRUE;
}
BOOL Test_GetObject(INT* passed, INT* failed)
{
HRGN hRgn;
hRgn = CreateRectRgn(0,0,5,5);
SetLastError(ERROR_SUCCESS);
TEST(GetObjectW(hRgn, 0, NULL) == 0);
TEST(GetLastError() == ERROR_INVALID_HANDLE);
DeleteObject(hRgn);
Test_Font(passed, failed);
Test_Colorspace(passed, failed);
Test_General(passed, failed);
Test_Bitmap(passed, failed);
Test_Dibsection(passed, failed);
Test_Palette(passed, failed);
Test_Brush(passed, failed);
Test_Pen(passed, failed);
// Test_ExtPpen(passed, failed); // not implemented yet in ROS
Test_MetaDC(passed, failed);
return TRUE;
}

View file

@ -0,0 +1,26 @@
#include "..\gditest.h"
BOOL Test_GetStockObject(INT* passed, INT* failed)
{
/* Test limits and error */
SetLastError(ERROR_SUCCESS);
TEST(GetStockObject(0) != NULL);
TEST(GetStockObject(21) != NULL);
TEST(GetStockObject(-1) == NULL);
TEST(GetStockObject(9) == NULL);
TEST(GetStockObject(22) == NULL);
TEST(GetLastError() == ERROR_SUCCESS);
/* Test for the stock bit */
TEST((UINT)GetStockObject(WHITE_BRUSH) && GDI_HANDLE_STOCK_MASK);
/* Test for correct types */
TEST(GDI_HANDLE_GET_TYPE(GetStockObject(WHITE_BRUSH)) == GDI_OBJECT_TYPE_BRUSH);
TEST(GDI_HANDLE_GET_TYPE(GetStockObject(DC_BRUSH)) == GDI_OBJECT_TYPE_BRUSH);
TEST(GDI_HANDLE_GET_TYPE(GetStockObject(WHITE_PEN)) == GDI_OBJECT_TYPE_PEN);
TEST(GDI_HANDLE_GET_TYPE(GetStockObject(DC_PEN)) == GDI_OBJECT_TYPE_PEN);
TEST(GDI_HANDLE_GET_TYPE(GetStockObject(ANSI_VAR_FONT)) == GDI_OBJECT_TYPE_FONT);
TEST(GDI_HANDLE_GET_TYPE(GetStockObject(DEFAULT_PALETTE)) == GDI_OBJECT_TYPE_PALETTE);
return TRUE;
}

View file

@ -0,0 +1,7 @@
#include "..\gditest.h"
BOOL Test_SelectObject(INT* passed, INT* failed)
{
return TRUE;
}

View file

@ -0,0 +1,42 @@
#include "..\gditest.h"
BOOL Test_SetDCPenColor(INT* passed, INT* failed)
{
HDC hScreenDC, hDC;
// Test an incorrect DC
TEST(SetDCPenColor(0, RGB(0,0,0)) == CLR_INVALID);
// Get the Screen DC
hScreenDC = GetDC(NULL);
if (hScreenDC == NULL) return FALSE;
// Test the screen DC
SetDCPenColor(hScreenDC, RGB(1,2,3));
TEST(SetDCPenColor(hScreenDC, RGB(4,5,6)) == RGB(1,2,3));
// Create a new DC
hDC = CreateCompatibleDC(hScreenDC);
ReleaseDC(0, hScreenDC);
if (hDC == NULL)
{
return FALSE;
}
// Select the DC_PEN and check if the pen returned by a new call is DC_PEN
SelectObject(hDC, GetStockObject(DC_PEN));
TEST(SelectObject(hDC, GetStockObject(BLACK_PEN)) == GetStockObject(DC_PEN));
// Test an incorrect color, yes windows sets the color!
SetDCPenColor(hDC, 0x21123456);
TEST(SetDCPenColor(hDC, RGB(0,0,0)) == 0x21123456);
// Test CLR_INVALID, it sets CLR_INVALID!
SetDCPenColor(hDC, CLR_INVALID);
TEST(SetDCPenColor(hDC, RGB(0,0,0)) == CLR_INVALID);
// Delete the DC
DeleteDC(hDC);
return TRUE;
}

View file

@ -0,0 +1,32 @@
#include "..\gditest.h"
#define NUM_SYSCOLORS 31
BOOL Test_SetSysColors(INT* passed, INT* failed)
{
INT i;
INT nElements[NUM_SYSCOLORS];
COLORREF crOldColors[NUM_SYSCOLORS];
COLORREF crColors[3] = {RGB(212, 208, 200),2,3};
return TRUE; // This is because codeblocks doesn't like changing syscolors ;-(
/* First save the Old colors */
for (i = 0; i < NUM_SYSCOLORS; i++)
{
nElements[i] = i;
crOldColors[i] = GetSysColor(i);
}
TEST((UINT)SetSysColors(0, nElements, crColors) == 1);
TEST((UINT)SetSysColors(1, nElements, crColors) == 1);
TEST((UINT)SetSysColors(2, nElements, crColors) == 1);
/* try more than NUM_SYSCOLORS */
TEST((UINT)SetSysColors(55, nElements, crColors) == 1);
/* restore old SysColors */
SetSysColors(NUM_SYSCOLORS, nElements, crOldColors);
return TRUE;
}

View file

@ -4,6 +4,9 @@
<directory name="cmd">
<xi:include href="cmd/cmd_test.rbuild" />
</directory>
<directory name="gdi32">
<xi:include href="gdi32/gdi32_test.rbuild" />
</directory>
<directory name="kernel32">
<xi:include href="kernel32/directory.rbuild" />
</directory>