Author: tkreuzer
Date: Sat Dec 15 07:22:19 2007
New Revision: 31225
URL:
http://svn.reactos.org/svn/reactos?rev=31225&view=rev
Log:
- use own version of GdiQueryTable() instead of relying on gdi32.dll
- CrateFont -> CreateFontA
- A bunch of tests for SelectObject
Modified:
trunk/rostests/apitests/gdi32api/gdi.h
trunk/rostests/apitests/gdi32api/gdi32api.c
trunk/rostests/apitests/gdi32api/gdi32api.h
trunk/rostests/apitests/gdi32api/tests/GetObject.c
trunk/rostests/apitests/gdi32api/tests/SelectObject.c
Modified: trunk/rostests/apitests/gdi32api/gdi.h
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32api/gdi.h?r…
==============================================================================
--- trunk/rostests/apitests/gdi32api/gdi.h (original)
+++ trunk/rostests/apitests/gdi32api/gdi.h Sat Dec 15 07:22:19 2007
@@ -128,7 +128,11 @@
ULONG ulForegroundClr;
#if (_WIN32_WINNT >= 0x0500)
- unsigned unk020_00000000[4]; // 020
+ COLORREF crBrushClr; // 020
+ ULONG ulBrushClr;
+ COLORREF crPenClr;
+ ULONG ulPenClr;
+
#endif
int iCS_CP; // 030
int iGraphicsMode;
@@ -149,10 +153,10 @@
long lIcmMode;
unsigned hcmXform; // 060
HCOLORSPACE hColorSpace;
- unsigned unk068_00000000;
+ FLONG flIcmFlags;
unsigned IcmBrushColor;
unsigned IcmPenColor; // 070
- unsigned unk074_00000000;
+ PVOID pvLIcm;
#endif
long flTextAlign; // 078
@@ -167,7 +171,10 @@
MATRIX mxDeviceToWorld; // 0D0
MATRIX mxWorldToPage; // 10C
- unsigned unk048_00000000[8]; // 148
+ EFLOAT_S efM11PtoD;
+ EFLOAT_S efM22PtoD;
+ EFLOAT_S efDxPtoD;
+ EFLOAT_S efDyPtoD;
int iMapMode; // 168
@@ -186,8 +193,11 @@
POINT ptlBrushOrigin; // 1a8
unsigned unk1b0_00000000[2]; // 1b0
- unsigned RectRegionFlag; // 1b4
- RECT VisRectRegion; // 1b8
+ RGNATTR VisRectRegion;
+
+// unsigned unk1b0_00000000[2]; // 1b0
+// unsigned RectRegionFlag; // 1b4
+// RECT VisRectRegion; // 1b8
} DC_ATTR, *PDC_ATTR;
Modified: trunk/rostests/apitests/gdi32api/gdi32api.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32api/gdi32ap…
==============================================================================
--- trunk/rostests/apitests/gdi32api/gdi32api.c (original)
+++ trunk/rostests/apitests/gdi32api/gdi32api.c Sat Dec 15 07:22:19 2007
@@ -9,22 +9,24 @@
return TRUE;
}
+static
+PGDI_TABLE_ENTRY
+MyGdiQueryTable()
+{
+ PTEB pTeb = NtCurrentTeb();
+ PPEB pPeb = pTeb->ProcessEnvironmentBlock;
+ return pPeb->GdiSharedHandleTable;
+}
+
int APIENTRY
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
- GDIQUERYPROC GdiQueryTable;
-
g_hInstance = hInstance;
- GdiQueryTable = (GDIQUERYPROC)GetProcAddress(GetModuleHandleW(L"GDI32.DLL"),
"GdiQueryTable");
- if(!GdiQueryTable)
- {
- return -1;
- }
- GdiHandleTable = GdiQueryTable();
+ GdiHandleTable = MyGdiQueryTable();
if(!GdiHandleTable)
{
return -1;
Modified: trunk/rostests/apitests/gdi32api/gdi32api.h
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32api/gdi32ap…
==============================================================================
--- trunk/rostests/apitests/gdi32api/gdi32api.h (original)
+++ trunk/rostests/apitests/gdi32api/gdi32api.h Sat Dec 15 07:22:19 2007
@@ -1,5 +1,9 @@
#ifndef _GDITEST_H
#define _GDITEST_H
+
+#define WIN32_NO_STATUS
+#include <windows.h>
+#include <ndk/ntndk.h>
#include "../apitest.h"
#include "gdi.h"
Modified: trunk/rostests/apitests/gdi32api/tests/GetObject.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32api/tests/G…
==============================================================================
--- trunk/rostests/apitests/gdi32api/tests/GetObject.c (original)
+++ trunk/rostests/apitests/gdi32api/tests/GetObject.c Sat Dec 15 07:22:19 2007
@@ -308,7 +308,7 @@
BYTE bData[270];
FillMemory(&logfonta, sizeof(LOGFONTA), 0x77);
- hFont = CreateFont(8, 8, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
+ hFont = CreateFontA(8, 8, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS,
ANTIALIASED_QUALITY, DEFAULT_PITCH, "testfont");
TEST(hFont);
Modified: trunk/rostests/apitests/gdi32api/tests/SelectObject.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32api/tests/S…
==============================================================================
--- trunk/rostests/apitests/gdi32api/tests/SelectObject.c (original)
+++ trunk/rostests/apitests/gdi32api/tests/SelectObject.c Sat Dec 15 07:22:19 2007
@@ -1,6 +1,142 @@
INT
Test_SelectObject(PTESTINFO pti)
{
+ HGDIOBJ hOldObj, hNewObj;
+ HDC hScreenDC, hDC;
+ PGDI_TABLE_ENTRY pEntry;
+ PDC_ATTR pDc_Attr;
+ HANDLE hcmXform;
+ BYTE bmBits[4] = {0};
+
+ hScreenDC = GetDC(NULL);
+ ASSERT (hScreenDC != NULL);
+ hDC = CreateCompatibleDC(hScreenDC);
+ ASSERT (hDC != NULL);
+
+ /* Get the Dc_Attr for later testing */
+ pEntry = &GdiHandleTable[GDI_HANDLE_GET_INDEX(hDC)];
+ ASSERT(pEntry);
+ pDc_Attr = pEntry->UserData;
+ ASSERT(pDc_Attr);
+
+ /* Test incomplete dc handle doesn't work */
+ SetLastError(ERROR_SUCCESS);
+ hNewObj = GetStockObject(GRAY_BRUSH);
+ hOldObj = SelectObject((HDC)GDI_HANDLE_GET_INDEX(hDC), hNewObj);
+ TEST(GetLastError() == ERROR_INVALID_HANDLE);
+ TEST(hOldObj == NULL);
+ TEST(pDc_Attr->hbrush == GetStockObject(WHITE_BRUSH));
+ SelectObject(hDC, hOldObj);
+
+ /* Test incomplete hobj handle works */
+ hNewObj = GetStockObject(GRAY_BRUSH);
+ hOldObj = SelectObject(hDC, (HGDIOBJ)GDI_HANDLE_GET_INDEX(hNewObj));
+ TEST(hOldObj == GetStockObject(WHITE_BRUSH));
+ TEST(pDc_Attr->hbrush == hNewObj);
+ SelectObject(hDC, hOldObj);
+
+ /* Test wrong hobj handle type */
+ SetLastError(ERROR_SUCCESS);
+ hNewObj = GetStockObject(GRAY_BRUSH);
+ hNewObj = (HGDIOBJ)((UINT_PTR)hNewObj & ~GDI_HANDLE_TYPE_MASK);
+ hNewObj = (HGDIOBJ)((UINT_PTR)hNewObj | GDI_OBJECT_TYPE_PEN);
+ hOldObj = SelectObject(hDC, hNewObj);
+ TEST(GetLastError() == ERROR_SUCCESS);
+ TEST(hOldObj == NULL);
+ TEST(pDc_Attr->hbrush == GetStockObject(WHITE_BRUSH));
+
+ SetLastError(ERROR_SUCCESS);
+ hNewObj = (HGDIOBJ)0x00761234;
+ hOldObj = SelectObject(hDC, hNewObj);
+ TEST(hOldObj == NULL);
+ TEST(GetLastError() == ERROR_SUCCESS);
+ SelectObject(hDC, hOldObj);
+
+ /* Test DC */
+ SetLastError(ERROR_SUCCESS);
+ hOldObj = SelectObject(hDC, hScreenDC);
+ TEST(hOldObj == NULL);
+ TEST(GetLastError() == ERROR_SUCCESS);
+
+ /* Test REGION */
+ SetLastError(ERROR_SUCCESS);
+ hNewObj = CreateRectRgn(0,0,0,0);
+ hOldObj = SelectObject(hDC, hNewObj);
+ TEST((UINT_PTR)hOldObj == NULLREGION);
+ DeleteObject(hNewObj);
+
+ hNewObj = CreateRectRgn(0,0,10,10);
+ TEST((UINT_PTR)SelectObject(hDC, hNewObj) == SIMPLEREGION);
+ hOldObj = CreateRectRgn(5,5,20,20);
+ TEST(CombineRgn(hNewObj, hNewObj, hOldObj, RGN_OR) == COMPLEXREGION);
+ DeleteObject(hOldObj);
+ TEST((UINT_PTR)SelectObject(hDC, hNewObj) == SIMPLEREGION); // ??? Why this?
+ DeleteObject(hNewObj);
+ TEST(GetLastError() == ERROR_SUCCESS);
+
+ /* Test BITMAP */
+ hNewObj = CreateBitmap(2, 2, 1, 1, &bmBits);
+ ASSERT(hNewObj != NULL);
+ hOldObj = SelectObject(hDC, hNewObj);
+ TEST(GDI_HANDLE_GET_TYPE(hOldObj) == GDI_OBJECT_TYPE_BITMAP);
+ hOldObj = SelectObject(hDC, hOldObj);
+ TEST(hOldObj == hNewObj);
+
+ /* Test CLIOBJ */
+
+ /* Test PATH */
+
+ /* Test PALETTE */
+ SetLastError(ERROR_SUCCESS);
+ hNewObj = GetStockObject(DEFAULT_PALETTE);
+ hOldObj = SelectObject(hDC, hNewObj);
+ TEST(hOldObj == NULL);
+ TEST(GetLastError() == ERROR_INVALID_FUNCTION);
+
+ /* Test COLORSPACE */
+
+ /* Test FONT */
+
+ /* Test PFE */
+
+ /* Test BRUSH */
+ hNewObj = GetStockObject(GRAY_BRUSH);
+ hOldObj = SelectObject(hDC, hNewObj);
+ TEST(hOldObj == GetStockObject(WHITE_BRUSH));
+ TEST(pDc_Attr->hbrush == hNewObj);
+ TEST(GDI_HANDLE_GET_TYPE(hOldObj) == GDI_OBJECT_TYPE_BRUSH);
+ SelectObject(hDC, hOldObj);
+
+ /* Test DC_BRUSH */
+ hNewObj = GetStockObject(DC_BRUSH);
+ hOldObj = SelectObject(hDC, hNewObj);
+ TEST(pDc_Attr->hbrush == hNewObj);
+ SelectObject(hDC, hOldObj);
+
+ /* Test BRUSH color xform */
+ hcmXform = (HANDLE)pDc_Attr->hcmXform;
+
+
+ /* Test EMF */
+
+ /* test METAFILE */
+
+ /* Test ENHMETAFILE */
+
+ /* Test PEN */
+ hNewObj = GetStockObject(GRAY_BRUSH);
+ hOldObj = SelectObject(hDC, hNewObj);
+ TEST(hOldObj == GetStockObject(WHITE_BRUSH));
+ TEST(pDc_Attr->hbrush == hNewObj);
+ TEST(GDI_HANDLE_GET_TYPE(hOldObj) == GDI_OBJECT_TYPE_BRUSH);
+ SelectObject(hDC, hOldObj);
+
+
+ /* Test EXTPEN */
+
+ /* Test METADC */
+
+
return APISTATUS_NORMAL;
}