From 58c6a293bc9a04594135957953af88b6257ced5e Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 5 Aug 2007 03:32:24 +0000 Subject: [PATCH] - make apitest.c into a static lib to be used by different tests - add a gdi32 api test, based on the one in the win32 folder - add a user32 api test - change type of test functions to int - implement a quick 'n dirty html api status output - uncomment NtGdiTransormPoints in w32kdll.def - add ASSERT1 macro (ASSERT is already used) - include some more headers svn path=/trunk/; revision=28169 --- rostests/apitests/apitest.c | 22 +- rostests/apitests/apitest.h | 4 +- rostests/apitests/directory.rbuild | 14 + rostests/apitests/gdi32api/gdi.h | 193 ++++++++ rostests/apitests/gdi32api/gdi32api.c | 19 + rostests/apitests/gdi32api/gdi32api.h | 11 + rostests/apitests/gdi32api/gdi32api.rbuild | 12 + rostests/apitests/gdi32api/testlist.c | 45 ++ .../gdi32api/tests/CreateCompatibleDC.c | 38 ++ rostests/apitests/gdi32api/tests/CreateFont.c | 24 + rostests/apitests/gdi32api/tests/CreatePen.c | 58 +++ .../apitests/gdi32api/tests/CreateRectRgn.c | 10 + .../apitests/gdi32api/tests/ExtCreatePen.c | 31 ++ rostests/apitests/gdi32api/tests/GetClipRgn.c | 11 + rostests/apitests/gdi32api/tests/GetObject.c | 446 ++++++++++++++++++ .../apitests/gdi32api/tests/GetStockObject.c | 27 ++ .../apitests/gdi32api/tests/SelectObject.c | 8 + .../apitests/gdi32api/tests/SetDCPenColor.c | 43 ++ .../apitests/gdi32api/tests/SetSysColors.c | 31 ++ rostests/apitests/user32api/testlist.c | 25 + rostests/apitests/user32api/tests/ScrollDC.c | 57 +++ .../apitests/user32api/tests/ScrollWindowEx.c | 47 ++ rostests/apitests/user32api/user32api.c | 18 + rostests/apitests/user32api/user32api.h | 10 + rostests/apitests/user32api/user32api.rbuild | 12 + rostests/apitests/w32kdll/w32kdll.def | 2 +- .../ntdd/NtGdiDdCreateDirectDrawObject.c | 11 +- .../ntdd/NtGdiDdDeleteDirectDrawObject.c | 4 +- .../ntdd/NtGdiDdQueryDirectDrawObject.c | 6 +- rostests/apitests/w32knapi/w32knapi.rbuild | 2 +- 30 files changed, 1217 insertions(+), 24 deletions(-) create mode 100644 rostests/apitests/gdi32api/gdi.h create mode 100644 rostests/apitests/gdi32api/gdi32api.c create mode 100644 rostests/apitests/gdi32api/gdi32api.h create mode 100644 rostests/apitests/gdi32api/gdi32api.rbuild create mode 100644 rostests/apitests/gdi32api/testlist.c create mode 100644 rostests/apitests/gdi32api/tests/CreateCompatibleDC.c create mode 100644 rostests/apitests/gdi32api/tests/CreateFont.c create mode 100644 rostests/apitests/gdi32api/tests/CreatePen.c create mode 100644 rostests/apitests/gdi32api/tests/CreateRectRgn.c create mode 100644 rostests/apitests/gdi32api/tests/ExtCreatePen.c create mode 100644 rostests/apitests/gdi32api/tests/GetClipRgn.c create mode 100644 rostests/apitests/gdi32api/tests/GetObject.c create mode 100644 rostests/apitests/gdi32api/tests/GetStockObject.c create mode 100644 rostests/apitests/gdi32api/tests/SelectObject.c create mode 100644 rostests/apitests/gdi32api/tests/SetDCPenColor.c create mode 100644 rostests/apitests/gdi32api/tests/SetSysColors.c create mode 100644 rostests/apitests/user32api/testlist.c create mode 100644 rostests/apitests/user32api/tests/ScrollDC.c create mode 100644 rostests/apitests/user32api/tests/ScrollWindowEx.c create mode 100644 rostests/apitests/user32api/user32api.c create mode 100644 rostests/apitests/user32api/user32api.h create mode 100644 rostests/apitests/user32api/user32api.rbuild diff --git a/rostests/apitests/apitest.c b/rostests/apitests/apitest.c index bb53ae2b54d..b0e9eec9ed3 100644 --- a/rostests/apitests/apitest.c +++ b/rostests/apitests/apitest.c @@ -20,10 +20,10 @@ WriteFileHeader(UINT hFile, LPWSTR pszModule) { char szHeader[100]; - write(hFile, szFileHeader, strlen(szFileHeader)); + _write(hFile, szFileHeader, strlen(szFileHeader)); sprintf(szHeader, "

Test results for %ls

", pszModule); - write(hFile, szHeader, strlen(szHeader)); - write(hFile, szTableHeader, strlen(szTableHeader)); + _write(hFile, szHeader, strlen(szHeader)); + _write(hFile, szTableHeader, strlen(szTableHeader)); return TRUE; } @@ -56,7 +56,7 @@ WriteRow(UINT hFile, LPWSTR pszFunction, PTESTINFO pti) sprintf(szLine + strlen(szLine), "%d / %d / %d%d\n", pti->passed+pti->failed, pti->passed, pti->failed, pti->rfailed); - write(hFile, szLine, strlen(szLine)); + _write(hFile, szLine, strlen(szLine)); return TRUE; } @@ -86,15 +86,15 @@ TestMain(LPWSTR pszName, LPWSTR pszModule) /* Get options */ for (i = 1; i < argc; i++) { - if (wcsicmp(argv[i], L"-r") == 0) + if (_wcsicmp(argv[i], L"-r") == 0) { ti.bRegress = TRUE; } - else if (wcsicmp(argv[i], L"all") == 0) + else if (_wcsicmp(argv[i], L"all") == 0) { bAll = TRUE; } - else if (wcsicmp(argv[i], L"status") == 0) + else if (_wcsicmp(argv[i], L"status") == 0) { bAll = TRUE; bStatus = TRUE; @@ -106,7 +106,7 @@ TestMain(LPWSTR pszName, LPWSTR pszModule) ti.bRegress = TRUE; char szOutputFile[MAX_PATH]; wsprintf(szOutputFile, "%ls.html", pszName); - hFile = open(szOutputFile, O_CREAT | O_TRUNC | O_RDWR, 00700); + hFile = _open(szOutputFile, O_CREAT | O_TRUNC | O_RDWR, 00700); if (hFile == -1) { printf("Could not create output file.\n"); @@ -119,7 +119,7 @@ TestMain(LPWSTR pszName, LPWSTR pszModule) { for (j = 1; j < argc; j++) { - if (bAll || wcsicmp(argv[j], TestList[i].Test) == 0) + if (bAll || _wcsicmp(argv[j], TestList[i].Test) == 0) { ti.passed = 0; ti.failed = 0; @@ -158,8 +158,8 @@ TestMain(LPWSTR pszName, LPWSTR pszModule) if (bStatus) { - write(hFile, szFileFooter, strlen(szFileFooter)); - close(hFile); + _write(hFile, szFileFooter, strlen(szFileFooter)); + _close(hFile); } if (ti.bRegress) diff --git a/rostests/apitests/apitest.h b/rostests/apitests/apitest.h index ea2c3e3fd73..007579eda2b 100644 --- a/rostests/apitests/apitest.h +++ b/rostests/apitests/apitest.h @@ -9,6 +9,8 @@ #include #include +#define open _open + #define APISTATUS_NORMAL 0 #define APISTATUS_NOT_FOUND 1 #define APISTATUS_UNIMPLEMENTED 2 @@ -83,7 +85,7 @@ typedef struct tagTEST } -#define ASSERT(x) \ +#define ASSERT1(x) \ if (!(x)) \ { \ printf("Assertion failed in %s:%d (%s)\n", __FILE__, __LINE__, #x);\ diff --git a/rostests/apitests/directory.rbuild b/rostests/apitests/directory.rbuild index 9fa19d588a0..756cffd4144 100644 --- a/rostests/apitests/directory.rbuild +++ b/rostests/apitests/directory.rbuild @@ -1,3 +1,17 @@ + + . + + 0x0501 + apitest.c + + + + + + + + + diff --git a/rostests/apitests/gdi32api/gdi.h b/rostests/apitests/gdi32api/gdi.h new file mode 100644 index 00000000000..0740edbb2e3 --- /dev/null +++ b/rostests/apitests/gdi32api/gdi.h @@ -0,0 +1,193 @@ +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0501 +#endif + +typedef struct _GDI_TABLE_ENTRY +{ + PVOID KernelData; /* Points to the kernel mode structure */ + HANDLE ProcessId; /* process id that created the object, 0 for stock objects */ + LONG Type; /* the first 16 bit is the object type including the stock obj flag, the last 16 bits is just the object type */ + PVOID UserData; /* Points to the user mode structure, usually NULL though */ +} GDI_TABLE_ENTRY, *PGDI_TABLE_ENTRY; + +typedef PGDI_TABLE_ENTRY (CALLBACK * GDIQUERYPROC) (void); + +/* GDI handle table can hold 0x4000 handles */ +#define GDI_HANDLE_COUNT 0x10000 +#define GDI_GLOBAL_PROCESS (0x0) + +/* Handle Masks and shifts */ +#define GDI_HANDLE_INDEX_MASK (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_REUSECNT_SHIFT 24 +#define GDI_HANDLE_UPPER_MASK 0xffff0000 + +/* Handle macros */ +#define GDI_HANDLE_CREATE(i, t) \ + ((HANDLE)(((i) & GDI_HANDLE_INDEX_MASK) | ((t) << 16))) + +#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_IS_TYPE(h, t) \ + ((t) == (((ULONG_PTR)(h)) & GDI_HANDLE_TYPE_MASK)) + +#define GDI_HANDLE_IS_STOCKOBJ(h) \ + (0 != (((ULONG_PTR)(h)) & GDI_HANDLE_STOCK_MASK)) + +#define GDI_HANDLE_SET_STOCKOBJ(h) \ + ((h) = (HANDLE)(((ULONG_PTR)(h)) | GDI_HANDLE_STOCK_MASK)) + +#define GDI_HANDLE_GET_UPPER(h) \ + (((ULONG_PTR)(h)) & GDI_HANDLE_UPPER_MASK) + +#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 +/** Not really an object type. Forces GDI_FreeObj to be silent. */ +#define GDI_OBJECT_TYPE_SILENT 0x80000000 + + + +/* Number Representation */ + +typedef LONG FIX; + +typedef struct _EFLOAT_S +{ + LONG lMant; + LONG lExp; +} EFLOAT_S; + +/* XFORM Structures */ +typedef struct _MATRIX_S +{ + EFLOAT_S efM11; + EFLOAT_S efM12; + EFLOAT_S efM21; + EFLOAT_S efM22; + EFLOAT_S efDx; + EFLOAT_S efDy; + FIX fxDx; + FIX fxDy; + FLONG flAccel; +} MATRIX; + +/* GDI object structures */ + +typedef struct _RGNATTR +{ + ULONG AttrFlags; + ULONG Flags; + RECTL Rect; +} RGNATTR,*PRGNATTR; + +// Local DC structure (_DC_ATTR) PVOID pvLDC; +typedef struct _LDC +{ + HDC hDC; + ULONG Flags; + INT iType; + PVOID pvEmfDC; /* Pointer to ENHMETAFILE structure */ + ABORTPROC pAbortProc; /* AbortProc for Printing */ + HANDLE hPrinter; /* Local or Remote Printer driver */ + INT iInitPage; /* Start/Stop */ + INT iInitDocument; +} LDC, *PLDC; + +typedef struct +{ + void * pvLDC; // 000 + ULONG ulDirty; + HBRUSH hbrush; + HPEN hpen; + + COLORREF crBackgroundClr; // 010 + ULONG ulBackgroundClr; + COLORREF crForegroundClr; + ULONG ulForegroundClr; + +#if (_WIN32_WINNT >= 0x0500) + unsigned unk020_00000000[4]; // 020 +#endif + int iCS_CP; // 030 + int iGraphicsMode; + BYTE jROP2; // 038 + BYTE jBkMode; + BYTE jFillMode; + BYTE jStretchBltMode; + + POINT ptlCurrent; // 03C + POINTFX ptfxCurrent; // 044 + long lBkMode; // 04C + + long lFillMode; // 050 + long lStretchBltMode; + +#if (_WIN32_WINNT >= 0x0500) + long flFontMapper; // 058 + long lIcmMode; + unsigned hcmXform; // 060 + HCOLORSPACE hColorSpace; + unsigned unk068_00000000; + unsigned IcmBrushColor; + unsigned IcmPenColor; // 070 + unsigned unk074_00000000; +#endif + + long flTextAlign; // 078 + long lTextAlign; + long lTextExtra; // 080 + long lRelAbs; + long lBreakExtra; + long cBreak; + + HFONT hlfntNew; // 090 + MATRIX mxWorldToDevice; // 094 + MATRIX mxDeviceToWorld; // 0D0 + MATRIX mxWorldToPage; // 10C + + unsigned unk048_00000000[8]; // 148 + + int iMapMode; // 168 + +#if (_WIN32_WINNT >= 0x0500) + DWORD dwLayout; // 16c + long lWindowOrgx; // 170 +#endif + POINT ptlWindowOrg; // 174 + SIZE szlWindowExt; // 17c + POINT ptlViewportOrg; // 184 + SIZE szlViewportExt; // 18c + + long flXform; // 194 + SIZE szlVirtualDevicePixel; // 198 + SIZE szlVirtualDeviceMm; // 1a0 + POINT ptlBrushOrigin; // 1a8 + + unsigned unk1b0_00000000[2]; // 1b0 + unsigned RectRegionFlag; // 1b4 + RECT VisRectRegion; // 1b8 +} DC_ATTR, *PDC_ATTR; + + diff --git a/rostests/apitests/gdi32api/gdi32api.c b/rostests/apitests/gdi32api/gdi32api.c new file mode 100644 index 00000000000..054cc10b806 --- /dev/null +++ b/rostests/apitests/gdi32api/gdi32api.c @@ -0,0 +1,19 @@ +#include "gdi32api.h" + +HINSTANCE g_hInstance; + +BOOL +IsFunctionPresent(LPWSTR lpszFunction) +{ + return TRUE; +} + +int APIENTRY +WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow) +{ + g_hInstance = hInstance; + return TestMain(L"gdi32api", L"gdi32.dll"); +} diff --git a/rostests/apitests/gdi32api/gdi32api.h b/rostests/apitests/gdi32api/gdi32api.h new file mode 100644 index 00000000000..c5d7db2a89e --- /dev/null +++ b/rostests/apitests/gdi32api/gdi32api.h @@ -0,0 +1,11 @@ +#ifndef _GDITEST_H +#define _GDITEST_H + +#include "../apitest.h" +#include "gdi.h" + +extern HINSTANCE g_hInstance; + +#endif /* _GDITEST_H */ + +/* EOF */ diff --git a/rostests/apitests/gdi32api/gdi32api.rbuild b/rostests/apitests/gdi32api/gdi32api.rbuild new file mode 100644 index 00000000000..99e4358e2a8 --- /dev/null +++ b/rostests/apitests/gdi32api/gdi32api.rbuild @@ -0,0 +1,12 @@ + + . + + 0x0501 + apitest + kernel32 + user32 + gdi32 + shell32 + gdi32api.c + testlist.c + diff --git a/rostests/apitests/gdi32api/testlist.c b/rostests/apitests/gdi32api/testlist.c new file mode 100644 index 00000000000..781b3e61f7e --- /dev/null +++ b/rostests/apitests/gdi32api/testlist.c @@ -0,0 +1,45 @@ +#ifndef _GDITESTLIST_H +#define _GDITESTLIST_H + +#include "gdi32api.h" + +/* include the tests */ +#include "tests/CreateCompatibleDC.c" +#include "tests/CreateFont.c" +#include "tests/CreatePen.c" +#include "tests/CreateRectRgn.c" +#include "tests/ExtCreatePen.c" +#include "tests/GetClipRgn.c" +#include "tests/GetObject.c" +#include "tests/GetStockObject.c" +#include "tests/SelectObject.c" +#include "tests/SetDCPenColor.c" +#include "tests/SetSysColors.c" +//#include "tests/SetWorldTransform.c" + +/* The List of tests */ +TESTENTRY TestList[] = +{ + { L"CreateCompatibleDC", Test_CreateCompatibleDC }, + { L"CreateFont", Test_CreateFont }, + { L"CreatePen", Test_CreatePen }, + { L"CreateRectRgn", Test_CreateRectRgn }, + { L"ExtCreatePen", Test_ExtCreatePen }, + { L"GetClipRgn", Test_GetClipRgn }, + { L"GetStockObject", Test_GetStockObject }, + { L"SetSysColors", Test_SetSysColors }, + { L"SelectObject", Test_SelectObject }, + { L"SetDCPenColor", Test_SetDCPenColor }, +// { L"SetWorldTransform", Test_SetWorldTransform }, + { L"GetObject", Test_GetObject } +}; + +/* The function that gives us the number of tests */ +INT NumTests(void) +{ + return sizeof(TestList) / sizeof(TESTENTRY); +} + +#endif /* _GDITESTLIST_H */ + +/* EOF */ diff --git a/rostests/apitests/gdi32api/tests/CreateCompatibleDC.c b/rostests/apitests/gdi32api/tests/CreateCompatibleDC.c new file mode 100644 index 00000000000..4ec35a44be6 --- /dev/null +++ b/rostests/apitests/gdi32api/tests/CreateCompatibleDC.c @@ -0,0 +1,38 @@ +#include "../gdi32api.h" + +INT +Test_CreateCompatibleDC(PTESTINFO pti) +{ + 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 APISTATUS_NORMAL; +} diff --git a/rostests/apitests/gdi32api/tests/CreateFont.c b/rostests/apitests/gdi32api/tests/CreateFont.c new file mode 100644 index 00000000000..cdb6ffadc01 --- /dev/null +++ b/rostests/apitests/gdi32api/tests/CreateFont.c @@ -0,0 +1,24 @@ +#include "..\gdi32api.h" + +#define INVALIDFONT "ThisFontDoesNotExist" + +INT +Test_CreateFont(PTESTINFO pti) +{ + HFONT hFont; + LOGFONTA logfonta; + + /* Test invalid font name */ + hFont = CreateFontA(15, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, + DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, + DEFAULT_QUALITY, DEFAULT_PITCH, INVALIDFONT); + TEST(hFont); + TEST(GetObjectA(hFont, sizeof(LOGFONTA), &logfonta) == sizeof(LOGFONTA)); + TEST(memcmp(logfonta.lfFaceName, INVALIDFONT, strlen(INVALIDFONT)) == 0); + TEST(logfonta.lfWeight == FW_DONTCARE); + + + return APISTATUS_NORMAL; +} + + diff --git a/rostests/apitests/gdi32api/tests/CreatePen.c b/rostests/apitests/gdi32api/tests/CreatePen.c new file mode 100644 index 00000000000..e5a60eae62d --- /dev/null +++ b/rostests/apitests/gdi32api/tests/CreatePen.c @@ -0,0 +1,58 @@ +#include "../gdi32api.h" + +INT +Test_CreatePen(PTESTINFO pti) +{ + HPEN hPen; + LOGPEN logpen; + + SetLastError(ERROR_SUCCESS); + hPen = CreatePen(PS_DASHDOT, 5, RGB(1,2,3)); + TEST(hPen); + + /* Test if we have a PEN */ + TEST(GDI_HANDLE_GET_TYPE(hPen) == GDI_OBJECT_TYPE_PEN); + + GetObject(hPen, sizeof(logpen), &logpen); + TEST(logpen.lopnStyle == PS_DASHDOT); + TEST(logpen.lopnWidth.x == 5); + TEST(logpen.lopnColor == RGB(1,2,3)); + DeleteObject(hPen); + + /* PS_GEOMETRIC | PS_DASHDOT = 0x00001011 will become PS_SOLID */ + logpen.lopnStyle = 22; + hPen = CreatePen(PS_GEOMETRIC | PS_DASHDOT, 5, RGB(1,2,3)); + TEST(hPen); + GetObject(hPen, sizeof(logpen), &logpen); + TEST(logpen.lopnStyle == PS_SOLID); + DeleteObject(hPen); + + /* PS_USERSTYLE will become PS_SOLID */ + logpen.lopnStyle = 22; + hPen = CreatePen(PS_USERSTYLE, 5, RGB(1,2,3)); + TEST(hPen); + GetObject(hPen, sizeof(logpen), &logpen); + TEST(logpen.lopnStyle == PS_SOLID); + DeleteObject(hPen); + + /* PS_ALTERNATE will become PS_SOLID */ + logpen.lopnStyle = 22; + hPen = CreatePen(PS_ALTERNATE, 5, RGB(1,2,3)); + TEST(hPen); + GetObject(hPen, sizeof(logpen), &logpen); + TEST(logpen.lopnStyle == PS_SOLID); + DeleteObject(hPen); + + /* PS_INSIDEFRAME is ok */ + logpen.lopnStyle = 22; + hPen = CreatePen(PS_INSIDEFRAME, 5, RGB(1,2,3)); + TEST(hPen); + GetObject(hPen, sizeof(logpen), &logpen); + TEST(logpen.lopnStyle == PS_INSIDEFRAME); + DeleteObject(hPen); + + TEST(GetLastError() == ERROR_SUCCESS); + + return APISTATUS_NORMAL; +} + diff --git a/rostests/apitests/gdi32api/tests/CreateRectRgn.c b/rostests/apitests/gdi32api/tests/CreateRectRgn.c new file mode 100644 index 00000000000..910619bfa2d --- /dev/null +++ b/rostests/apitests/gdi32api/tests/CreateRectRgn.c @@ -0,0 +1,10 @@ +#include "..\gdi32api.h" + +INT +Test_CreateRectRgn(PTESTINFO pti) +{ +// HRGN hRgn; + +// hRgn = CreateRectRgn( + return APISTATUS_NORMAL; +} diff --git a/rostests/apitests/gdi32api/tests/ExtCreatePen.c b/rostests/apitests/gdi32api/tests/ExtCreatePen.c new file mode 100644 index 00000000000..b8070c5ad29 --- /dev/null +++ b/rostests/apitests/gdi32api/tests/ExtCreatePen.c @@ -0,0 +1,31 @@ +#include "../gdi32api.h" + +INT +Test_ExtCreatePen(PTESTINFO pti) +{ + HPEN hPen; + LOGBRUSH logbrush; + DWORD dwStyles[17] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}; + + 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); + + /* test userstyles */ + hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 5, &logbrush, 17, (CONST DWORD*)&dwStyles); + TEST(hPen == 0); + hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 5, &logbrush, 16, (CONST DWORD*)&dwStyles); + TEST(hPen != 0); + + DeleteObject(hPen); + + return APISTATUS_NORMAL; +} + + diff --git a/rostests/apitests/gdi32api/tests/GetClipRgn.c b/rostests/apitests/gdi32api/tests/GetClipRgn.c new file mode 100644 index 00000000000..ab72ee464fd --- /dev/null +++ b/rostests/apitests/gdi32api/tests/GetClipRgn.c @@ -0,0 +1,11 @@ +#include "../gdi32api.h" + +INT +Test_GetClipRgn(PTESTINFO pti) +{ +// HRGN hRgn; + +// hRgn = CreateRectRgn( + return APISTATUS_NORMAL; +} + diff --git a/rostests/apitests/gdi32api/tests/GetObject.c b/rostests/apitests/gdi32api/tests/GetObject.c new file mode 100644 index 00000000000..5a4b82de5e9 --- /dev/null +++ b/rostests/apitests/gdi32api/tests/GetObject.c @@ -0,0 +1,446 @@ +#include "../gdi32api.h" + +static INT +Test_General(PTESTINFO pti) +{ + struct + { + LOGBRUSH logbrush; + BYTE additional[5]; + } TestStruct; + PLOGBRUSH plogbrush; + HBRUSH hBrush; + + /* 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); + + /* Test need of alignment */ + hBrush = GetStockObject(WHITE_BRUSH); + plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush); + TEST(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == sizeof(LOGBRUSH)); + plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush + 2); + TEST(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == sizeof(LOGBRUSH)); + plogbrush = (PVOID)((ULONG_PTR)&TestStruct.logbrush + 1); + TEST(GetObject(hBrush, sizeof(LOGBRUSH), plogbrush) == 0); + + return TRUE; +} + +static INT +Test_Bitmap(PTESTINFO pti) +{ + 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; +} + +static INT +Test_Dibsection(PTESTINFO pti) +{ + 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; +} + +static INT +Test_Palette(PTESTINFO pti) +{ + 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; +} + +static INT +Test_Brush(PTESTINFO pti) +{ + 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; +} + +static INT +Test_Pen(PTESTINFO pti) +{ + 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)-1, &logpen) == 0); + TEST(GetObject(hPen, sizeof(LOGPEN)+2, &logpen) == sizeof(LOGPEN)); + TEST(GetObject(hPen, 0, &logpen) == 0); + TEST(GetObject(hPen, -5, &logpen) == sizeof(LOGPEN)); + TEST(GetLastError() == ERROR_SUCCESS); + + /* test if the fields are filled correctly */ + TEST(logpen.lopnStyle == PS_SOLID); + + + DeleteObject(hPen); + return TRUE; +} + +static INT +Test_ExtPen(PTESTINFO pti) +{ + HPEN hPen; + EXTLOGPEN extlogpen; + LOGBRUSH logbrush; + DWORD dwStyles[17] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}; + struct + { + EXTLOGPEN extlogpen; + DWORD dwStyles[50]; + } elpUserStyle; + + 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 = 22; + hPen = ExtCreatePen(PS_GEOMETRIC | PS_DASH, 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)-sizeof(DWORD), &extlogpen) == sizeof(EXTLOGPEN)-sizeof(DWORD)); + TEST(GetObject(hPen, sizeof(EXTLOGPEN)-sizeof(DWORD)-1, &extlogpen) == 0); + 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 | PS_DASH)); + TEST(extlogpen.elpWidth == 5); + TEST(extlogpen.elpBrushStyle == 0); + TEST(extlogpen.elpColor == RGB(1,2,3)); + TEST(extlogpen.elpHatch == 22); + TEST(extlogpen.elpNumEntries == 0); + DeleteObject(hPen); + + /* A maximum of 16 Styles is allowed */ + hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 5, &logbrush, 16, (CONST DWORD*)&dwStyles); + TEST(GetObject(hPen, 0, NULL) == sizeof(EXTLOGPEN) + 15*sizeof(DWORD)); + TEST(GetObject(hPen, sizeof(EXTLOGPEN) + 15*sizeof(DWORD), &elpUserStyle) == sizeof(EXTLOGPEN) + 15*sizeof(DWORD)); + TEST(((EXTLOGPEN*)&elpUserStyle)->elpStyleEntry[0] == 0); + TEST(((EXTLOGPEN*)&elpUserStyle)->elpStyleEntry[1] == 1); + TEST(((EXTLOGPEN*)&elpUserStyle)->elpStyleEntry[15] == 15); + DeleteObject(hPen); + + return TRUE; +} + +static INT +Test_Font(PTESTINFO pti) +{ + 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; +} + +static INT +Test_Colorspace(PTESTINFO pti) +{ + 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; +} + +static INT +Test_MetaDC(PTESTINFO pti) +{ + /* 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; +} + +INT +Test_GetObject(PTESTINFO pti) +{ + + 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(pti); + Test_Colorspace(pti); + Test_General(pti); + Test_Bitmap(pti); + Test_Dibsection(pti); + Test_Palette(pti); + Test_Brush(pti); + Test_Pen(pti); + Test_ExtPen(pti); // not implemented yet in ROS + Test_MetaDC(pti); + + return APISTATUS_NORMAL; +} diff --git a/rostests/apitests/gdi32api/tests/GetStockObject.c b/rostests/apitests/gdi32api/tests/GetStockObject.c new file mode 100644 index 00000000000..8e4b5842de0 --- /dev/null +++ b/rostests/apitests/gdi32api/tests/GetStockObject.c @@ -0,0 +1,27 @@ +#include "../gdi32api.h" + +INT +Test_GetStockObject(PTESTINFO pti) +{ + /* 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 APISTATUS_NORMAL; +} diff --git a/rostests/apitests/gdi32api/tests/SelectObject.c b/rostests/apitests/gdi32api/tests/SelectObject.c new file mode 100644 index 00000000000..ee72b17227c --- /dev/null +++ b/rostests/apitests/gdi32api/tests/SelectObject.c @@ -0,0 +1,8 @@ +#include "../gdi32api.h" + +INT +Test_SelectObject(PTESTINFO pti) +{ + return APISTATUS_NORMAL; +} + diff --git a/rostests/apitests/gdi32api/tests/SetDCPenColor.c b/rostests/apitests/gdi32api/tests/SetDCPenColor.c new file mode 100644 index 00000000000..5e5e53ec338 --- /dev/null +++ b/rostests/apitests/gdi32api/tests/SetDCPenColor.c @@ -0,0 +1,43 @@ +#include "../gdi32api.h" + +INT +Test_SetDCPenColor(PTESTINFO pti) +{ + 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 APISTATUS_NORMAL; +} diff --git a/rostests/apitests/gdi32api/tests/SetSysColors.c b/rostests/apitests/gdi32api/tests/SetSysColors.c new file mode 100644 index 00000000000..1d91780e7d5 --- /dev/null +++ b/rostests/apitests/gdi32api/tests/SetSysColors.c @@ -0,0 +1,31 @@ +#include "../gdi32api.h" + +#define NUM_SYSCOLORS 31 + +INT +Test_SetSysColors(PTESTINFO pti) +{ + INT i; + INT nElements[NUM_SYSCOLORS]; + COLORREF crOldColors[NUM_SYSCOLORS]; + COLORREF crColors[3] = {RGB(212, 208, 200),2,3}; + + /* 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 APISTATUS_NORMAL; +} diff --git a/rostests/apitests/user32api/testlist.c b/rostests/apitests/user32api/testlist.c new file mode 100644 index 00000000000..f77cb30b1c6 --- /dev/null +++ b/rostests/apitests/user32api/testlist.c @@ -0,0 +1,25 @@ +#ifndef _USER32TESTLIST_H +#define _USER32TESTLIST_H + +#include "user32api.h" + +/* include the tests */ +#include "tests/ScrollDC.c" +#include "tests/ScrollWindowEx.c" + +/* The List of tests */ +TESTENTRY TestList[] = +{ + { L"ScrollDC", Test_ScrollDC }, + { L"ScrollWindowEx", Test_ScrollWindowEx } +}; + +/* The function that gives us the number of tests */ +INT NumTests(void) +{ + return sizeof(TestList) / sizeof(TESTENTRY); +} + +#endif /* _USER32TESTLIST_H */ + +/* EOF */ diff --git a/rostests/apitests/user32api/tests/ScrollDC.c b/rostests/apitests/user32api/tests/ScrollDC.c new file mode 100644 index 00000000000..be6f9159ff3 --- /dev/null +++ b/rostests/apitests/user32api/tests/ScrollDC.c @@ -0,0 +1,57 @@ +#include "../user32api.h" + +INT +Test_ScrollDC(PTESTINFO pti) +{ + HWND hWnd, hWnd2; + HDC hDC; + HRGN hrgn; + RECT rcClip; + + /* Create a window */ + hWnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE, + 100, 100, 100, 100, + NULL, NULL, g_hInstance, 0); + UpdateWindow(hWnd); + hDC = GetDC(hWnd); + + /* Assert that no update region is there */ + hrgn = CreateRectRgn(0,0,0,0); + ASSERT1(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION); + + /* Test normal scrolling */ + TEST(ScrollDC(hDC, 0, 0, NULL, NULL, hrgn, NULL) == TRUE); + + /* Scroll with invalid update region */ + DeleteObject(hrgn); + TEST(ScrollDC(hDC, 50, 0, NULL, NULL, hrgn, NULL) == FALSE); + hrgn = CreateRectRgn(0,0,0,0); + TEST(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION); + + /* Scroll with invalid update rect pointer */ + TEST(ScrollDC(hDC, 50, 0, NULL, NULL, NULL, (PRECT)1) == 0); + TEST(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION); + + /* Scroll with a clip rect */ + rcClip.left = 50; rcClip.top = 0; rcClip.right = 100; rcClip.bottom = 100; + TEST(ScrollDC(hDC, 50, 0, NULL, &rcClip, hrgn, NULL) == TRUE); + TEST(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION); + + /* Scroll with a clip rect */ + rcClip.left = 50; rcClip.top = 0; rcClip.right = 100; rcClip.bottom = 100; + TEST(ScrollDC(hDC, 50, 50, NULL, &rcClip, hrgn, NULL) == TRUE); + TEST(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION); + + /* Overlap with another window */ + hWnd2 = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE, + 30, 160, 100, 100, + NULL, NULL, g_hInstance, 0); + UpdateWindow(hWnd2); + + /* Cleanup */ + ReleaseDC(hWnd, hDC); + DestroyWindow(hWnd); + DestroyWindow(hWnd2); + + return APISTATUS_NORMAL; +} diff --git a/rostests/apitests/user32api/tests/ScrollWindowEx.c b/rostests/apitests/user32api/tests/ScrollWindowEx.c new file mode 100644 index 00000000000..29d8f0072f9 --- /dev/null +++ b/rostests/apitests/user32api/tests/ScrollWindowEx.c @@ -0,0 +1,47 @@ +#include "../user32api.h" + +INT +Test_ScrollWindowEx(PTESTINFO pti) +{ + HWND hWnd; + HRGN hrgn; + int Result; + + /* Create a window */ + hWnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE, + CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, + NULL, NULL, g_hInstance, 0); + UpdateWindow(hWnd); + + /* Assert that no update region is there */ + hrgn = CreateRectRgn(0,0,0,0); + ASSERT1(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION); + + Result = ScrollWindowEx(hWnd, 20, 0, NULL, NULL, NULL, NULL, 0); + TEST(Result == SIMPLEREGION); + TEST(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION); + + Result = ScrollWindowEx(hWnd, 20, 0, NULL, NULL, NULL, NULL, SW_INVALIDATE); + TEST(Result == SIMPLEREGION); + TEST(GetUpdateRgn(hWnd, hrgn, FALSE) == SIMPLEREGION); + UpdateWindow(hWnd); + + // test invalid update region + DeleteObject(hrgn); + Result = ScrollWindowEx(hWnd, 20, 0, NULL, NULL, hrgn, NULL, SW_INVALIDATE); + TEST(Result == ERROR); + hrgn = CreateRectRgn(0,0,0,0); + UpdateWindow(hWnd); + + // Test invalid updaterect pointer + Result = ScrollWindowEx(hWnd, 20, 0, NULL, NULL, NULL, (LPRECT)1, SW_INVALIDATE); + TEST(Result == ERROR); + TEST(GetUpdateRgn(hWnd, hrgn, FALSE) == SIMPLEREGION); + +// test for alignment of rects + + DeleteObject(hrgn); + DestroyWindow(hWnd); + + return APISTATUS_NORMAL; +} diff --git a/rostests/apitests/user32api/user32api.c b/rostests/apitests/user32api/user32api.c new file mode 100644 index 00000000000..7b51b0fe185 --- /dev/null +++ b/rostests/apitests/user32api/user32api.c @@ -0,0 +1,18 @@ +#include "user32api.h" + +HINSTANCE g_hInstance; + +BOOL +IsFunctionPresent(LPWSTR lpszFunction) +{ + return TRUE; +} + +int APIENTRY WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow) +{ + g_hInstance = hInstance; + return TestMain(L"user32api", L"user32.dll"); +} diff --git a/rostests/apitests/user32api/user32api.h b/rostests/apitests/user32api/user32api.h new file mode 100644 index 00000000000..1af1dbf9676 --- /dev/null +++ b/rostests/apitests/user32api/user32api.h @@ -0,0 +1,10 @@ +#ifndef _USER32TEST_H +#define _USER32TEST_H + +#include "../apitest.h" + +extern HINSTANCE g_hInstance; + +#endif /* _USER32TEST_H */ + +/* EOF */ diff --git a/rostests/apitests/user32api/user32api.rbuild b/rostests/apitests/user32api/user32api.rbuild new file mode 100644 index 00000000000..dd97018bc2b --- /dev/null +++ b/rostests/apitests/user32api/user32api.rbuild @@ -0,0 +1,12 @@ + + . + + 0x0501 + apitest + kernel32 + user32 + gdi32 + shell32 + user32api.c + testlist.c + diff --git a/rostests/apitests/w32kdll/w32kdll.def b/rostests/apitests/w32kdll/w32kdll.def index f665ca116a6..93717621e81 100644 --- a/rostests/apitests/w32kdll/w32kdll.def +++ b/rostests/apitests/w32kdll/w32kdll.def @@ -306,7 +306,7 @@ NtGdiStretchBlt@48 NtGdiStrokeAndFillPath@4 NtGdiStrokePath@4 NtGdiSwapBuffers@4 -;NtGdiTransformPoints@20 +NtGdiTransformPoints@20 NtGdiTransparentBlt@44 ;NtGdiUnloadPrinterDriver@8 ;NtGdiUMPDEngFreeUserMem@4 diff --git a/rostests/apitests/w32knapi/ntdd/NtGdiDdCreateDirectDrawObject.c b/rostests/apitests/w32knapi/ntdd/NtGdiDdCreateDirectDrawObject.c index c1a5bde2762..8ed753836c3 100644 --- a/rostests/apitests/w32knapi/ntdd/NtGdiDdCreateDirectDrawObject.c +++ b/rostests/apitests/w32knapi/ntdd/NtGdiDdCreateDirectDrawObject.c @@ -13,13 +13,14 @@ NtGdiDdCreateDirectDrawObject( INT Test_NtGdiDdCreateDirectDrawObject(PTESTINFO pti) { - HDC hdc=CreateDCW(L"Display",NULL,NULL,NULL); + HDC hdc = CreateDCW(L"Display",NULL,NULL,NULL); + ASSERT1(hdc != NULL); - RTEST(NtGdiDdCreateDirectDrawObject(NULL) == NULL); + RTEST(NtGdiDdCreateDirectDrawObject(NULL) == NULL); - TEST(NtGdiDdCreateDirectDrawObject(hdc) != NULL); + TEST(NtGdiDdCreateDirectDrawObject(hdc) != NULL); - DeleteDC(hdc); + DeleteDC(hdc); - return APISTATUS_NORMAL; + return APISTATUS_NORMAL; } diff --git a/rostests/apitests/w32knapi/ntdd/NtGdiDdDeleteDirectDrawObject.c b/rostests/apitests/w32knapi/ntdd/NtGdiDdDeleteDirectDrawObject.c index 5d8ebbd9593..50429dbf24a 100644 --- a/rostests/apitests/w32knapi/ntdd/NtGdiDdDeleteDirectDrawObject.c +++ b/rostests/apitests/w32knapi/ntdd/NtGdiDdDeleteDirectDrawObject.c @@ -13,7 +13,7 @@ NtGdiDdDeleteDirectDrawObject( INT Test_NtGdiDdDeleteDirectDrawObject(PTESTINFO pti) { - TEST(NtGdiDdDeleteDirectDrawObject(NULL) == 0); + TEST(NtGdiDdDeleteDirectDrawObject(NULL) == 0); - return APISTATUS_NORMAL; + return APISTATUS_NORMAL; } diff --git a/rostests/apitests/w32knapi/ntdd/NtGdiDdQueryDirectDrawObject.c b/rostests/apitests/w32knapi/ntdd/NtGdiDdQueryDirectDrawObject.c index c073c0ec96a..658a3cb3658 100644 --- a/rostests/apitests/w32knapi/ntdd/NtGdiDdQueryDirectDrawObject.c +++ b/rostests/apitests/w32knapi/ntdd/NtGdiDdQueryDirectDrawObject.c @@ -1,5 +1,5 @@ #include "../w32knapi.h" -#if 0 + W32KAPI BOOL STDCALL NtGdiDdQueryDirectDrawObject( @@ -16,9 +16,9 @@ NtGdiDdQueryDirectDrawObject( DWORD *puFourCC ) { - return (HANDLE)Syscall("NtGdiDdQueryDirectDrawObject", 11, &hDirectDrawLocal); + return (BOOL)Syscall(L"NtGdiDdQueryDirectDrawObject", 11, &hDirectDrawLocal); } -#endif + INT Test_NtGdiDdQueryDirectDrawObject(PTESTINFO pti) { diff --git a/rostests/apitests/w32knapi/w32knapi.rbuild b/rostests/apitests/w32knapi/w32knapi.rbuild index f997b9d1ff3..8f4524bc9e8 100644 --- a/rostests/apitests/w32knapi/w32knapi.rbuild +++ b/rostests/apitests/w32knapi/w32knapi.rbuild @@ -2,6 +2,7 @@ . 0x0501 + apitest kernel32 user32 gdi32 @@ -9,5 +10,4 @@ w32knapi.c testlist.c xp-2600.c - ..\apitest.c