Author: tkreuzer
Date: Sat Feb 14 13:19:02 2015
New Revision: 66259
URL:
http://svn.reactos.org/svn/reactos?rev=66259&view=rev
Log:
[GDI32_APITEST]
Add tests for OffsetRgn, PaintRgn and FrameRgn, fix 1BPP DIB creation in InitStuff()
Added:
trunk/rostests/apitests/gdi32/FrameRgn.c (with props)
trunk/rostests/apitests/gdi32/OffsetRgn.c (with props)
trunk/rostests/apitests/gdi32/PaintRgn.c (with props)
Modified:
trunk/rostests/apitests/gdi32/CMakeLists.txt
trunk/rostests/apitests/gdi32/init.c
trunk/rostests/apitests/gdi32/init.h
trunk/rostests/apitests/gdi32/testlist.c
Modified: trunk/rostests/apitests/gdi32/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/CMakeLists…
==============================================================================
--- trunk/rostests/apitests/gdi32/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/CMakeLists.txt [iso-8859-1] Sat Feb 14 13:19:02 2015
@@ -26,6 +26,7 @@
ExcludeClipRect.c
ExtCreatePen.c
ExtCreateRegion.c
+ FrameRgn.c
GdiConvertBitmap.c
GdiConvertBrush.c
GdiConvertDC.c
@@ -51,6 +52,8 @@
GetTextFace.c
MaskBlt.c
OffsetClipRgn.c
+ OffsetRgn.c
+ PaintRgn.c
PatBlt.c
Rectangle.c
RealizePalette.c
Added: trunk/rostests/apitests/gdi32/FrameRgn.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/FrameRgn.c…
==============================================================================
--- trunk/rostests/apitests/gdi32/FrameRgn.c (added)
+++ trunk/rostests/apitests/gdi32/FrameRgn.c [iso-8859-1] Sat Feb 14 13:19:02 2015
@@ -0,0 +1,146 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: GPL - See COPYING in the top level directory
+ * PURPOSE: Test for FrameRgn
+ * PROGRAMMERS: Timo Kreuzer
+ */
+
+#include <apitest.h>
+#include <windows.h>
+#include <stdio.h>
+#include "init.h"
+
+#if 0
+BOOL
+MyFrameRgn(
+ HDC hdc,
+ HRGN hrgn,
+ HBRUSH hbr,
+ INT cx,
+ INT cy)
+{
+ HRGN hrgnTemp;
+
+ hrgnTemp = CreateRectRgn(0, 0, 0, 0);
+ if (hrgnTemp == NULL)
+ {
+ return FALSE;
+ }
+
+ if (CombineRgn(hrgnTemp, hrgn, NULL, RGN_COPY) == ERROR)
+ goto Failure;
+
+ if (OffsetRgn(hrgn, cx, cy) == ERROR)
+ goto Failure;
+
+ if (CombineRgn(hrgnTemp, hrgnTemp, hrgn, RGN_AND) == ERROR)
+ goto Failure;
+
+ if (OffsetRgn(hrgn, -2 * cx, 0) == ERROR)
+ goto Failure;
+
+ if (CombineRgn(hrgnTemp, hrgnTemp, hrgn, RGN_AND) == ERROR)
+ goto Failure;
+
+ if (OffsetRgn(hrgn, 0, -2 * cy) == ERROR)
+ goto Failure;
+
+ if (CombineRgn(hrgnTemp, hrgnTemp, hrgn, RGN_AND) == ERROR)
+ goto Failure;
+
+ if (OffsetRgn(hrgn, 2 * cx, 0) == ERROR)
+ goto Failure;
+
+ if (CombineRgn(hrgnTemp, hrgnTemp, hrgn, RGN_AND) == ERROR)
+ goto Failure;
+
+ if (OffsetRgn(hrgn, -cx, cy) == ERROR)
+ goto Failure;
+
+ if (CombineRgn(hrgnTemp, hrgn, hrgnTemp, RGN_DIFF) == ERROR)
+ goto Failure;
+
+ if (!FillRgn(hdc, hrgnTemp, hbr))
+ goto Failure;
+
+ DeleteObject(hrgnTemp);
+ return TRUE;
+
+Failure:
+ DeleteObject(hrgnTemp);
+ return FALSE;
+}
+#endif // 0
+
+static
+void
+CheckBitmapBitsWithLine(
+ ULONG Line,
+ HDC hdc,
+ UINT cx,
+ UINT cy,
+ PUCHAR pjBits,
+ COLORREF *pcrColors)
+{
+ UINT x, y, i;
+
+ for (y = 0; y < cy; y++)
+ {
+ for (x = 0; x < cy; x++)
+ {
+ i = y * cx + x;
+ ok(GetPixel(hdc, x, y) == pcrColors[pjBits[i]],
+ "Wrong pixel at (%u,%u): expected 0x%08x, got 0x%08x\n",
+ x, y, pcrColors[pjBits[i]], GetPixel(hdc, x, y));
+ }
+ }
+}
+
+#define CheckBitmapBits(hdc,cx,cy,pj,pcr) \
+ CheckBitmapBitsWithLine(__LINE__, hdc,cx,cy,pj,pcr)
+
+void Test_FrameRgn()
+{
+ RECT rc = {0, 0, 8, 8 };
+ HRGN hrgn1, hrgn2;
+ BOOL bRet;
+ UCHAR ajBits[64] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, // 0000000
+ 0, 1, 1, 1, 1, 0, 0, 0, // 0****00
+ 0, 1, 2, 2, 1, 0, 0, 0, // 0*xx**0
+ 0, 1, 2, 2, 1, 1, 1, 0, // 0*xxx*0
+ 0, 1, 1, 1, 2, 2, 1, 0, // 0**xx*0
+ 0, 0, 0, 1, 2, 2, 1, 0, // 00****0
+ 0, 0, 0, 1, 1, 1, 1, 0, // 0000000
+ 0, 0, 0, 0, 0, 0, 0, 0 // 0000000
+ };
+ COLORREF acrColors[16] = {RGB(0,0,0), RGB(255,255,255), RGB(128,128,128), 0};
+
+ FillRect(ghdcDIB32, &rc, GetStockObject(BLACK_BRUSH));
+
+ hrgn1 = CreateRectRgn(1, 1, 5, 5);
+ ok(hrgn1 != NULL, "failed to create region\n");
+
+ hrgn2 = CreateRectRgn(3, 3, 7, 7);
+ ok(hrgn1 != NULL, "failed to create region\n");
+
+ CombineRgn(hrgn1, hrgn1, hrgn2, RGN_OR);
+
+ bRet = FillRgn(ghdcDIB32, hrgn1, GetStockObject(GRAY_BRUSH));
+ ok(bRet != 0, "FrameRgn failed\n");
+
+ bRet = FrameRgn(ghdcDIB32, hrgn1, GetStockObject(WHITE_BRUSH), 1, 1);
+ ok(bRet != 0, "FrameRgn failed\n");
+
+ CheckBitmapBits(ghdcDIB32, 8, 8, ajBits, acrColors);
+
+}
+
+
+
+START_TEST(FrameRgn)
+{
+ InitStuff();
+ Test_FrameRgn();
+}
+
Propchange: trunk/rostests/apitests/gdi32/FrameRgn.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/apitests/gdi32/OffsetRgn.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/OffsetRgn.…
==============================================================================
--- trunk/rostests/apitests/gdi32/OffsetRgn.c (added)
+++ trunk/rostests/apitests/gdi32/OffsetRgn.c [iso-8859-1] Sat Feb 14 13:19:02 2015
@@ -0,0 +1,58 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: GPL - See COPYING in the top level directory
+ * PURPOSE: Test for FrameRgn
+ * PROGRAMMERS: Timo Kreuzer
+ */
+
+#include <apitest.h>
+#include <windows.h>
+#include <stdio.h>
+#include "init.h"
+
+void Test_OffsetRgn()
+{
+ HRGN hrgn1, hrgn2;
+ HDC hdc;
+
+ hrgn1 = CreateRectRgn(0, 0, 0, 0);
+ ok(hrgn1 != NULL, "CreateRectRgn failed\n");
+ ok_int(OffsetRgn(hrgn1, INT_MIN + 10, 10), NULLREGION);
+ ok_int(OffsetRgn(hrgn1, 0xF000000, 0xF000000), NULLREGION);
+ DeleteObject(hrgn1);
+
+ hrgn1 = CreateRectRgn(0, 0, 100, 100);
+ ok(hrgn1 != NULL, "CreateRectRgn failed\n");
+ ok_int(OffsetRgn(hrgn1, 10, 10), SIMPLEREGION);
+ ok_int(OffsetRgn(hrgn1, 0x8000000 - 110, 10), ERROR);
+ ok_int(OffsetRgn(hrgn1, 0x8000000 - 111, 10), SIMPLEREGION);
+ DeleteObject(hrgn1);
+
+ hrgn1 = CreateRectRgn(0, 0, 100, 100);
+ ok(hrgn1 != NULL, "CreateRectRgn failed\n");
+ ok_int(OffsetRgn(hrgn1, -10, 10), SIMPLEREGION);
+ ok_int(OffsetRgn(hrgn1, -(0x8000000 - 9), 10), ERROR);
+ ok_int(OffsetRgn(hrgn1, -(0x8000000 - 10), 10), SIMPLEREGION);
+ DeleteObject(hrgn1);
+
+ hrgn1 = CreateRectRgn(0, 0, 10, 10);
+ hrgn2 = CreateRectRgn(1000, 20, 1010, 30);
+ ok_int(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_OR), COMPLEXREGION);
+ ok_int(OffsetRgn(hrgn1, 0x8000000 - 100, 10), ERROR);
+ ok_int(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_XOR), SIMPLEREGION);
+ DeleteObject(hrgn2);
+ hrgn2 = CreateRectRgn(0, 0, 10, 10);
+ ok_int(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_XOR), NULLREGION);
+
+ hrgn1 = CreateRectRgn(0, 0, 0, 0);
+ hdc = CreateCompatibleDC(NULL);
+ ok_int(GetClipRgn(hdc, hrgn1), 0);
+ ok_int(OffsetRgn(hrgn1, 10, 10), NULLREGION);
+
+}
+
+START_TEST(OffsetRgn)
+{
+ Test_OffsetRgn();
+}
+
Propchange: trunk/rostests/apitests/gdi32/OffsetRgn.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/apitests/gdi32/PaintRgn.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/PaintRgn.c…
==============================================================================
--- trunk/rostests/apitests/gdi32/PaintRgn.c (added)
+++ trunk/rostests/apitests/gdi32/PaintRgn.c [iso-8859-1] Sat Feb 14 13:19:02 2015
@@ -0,0 +1,63 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: GPL - See COPYING in the top level directory
+ * PURPOSE: Test for FrameRgn
+ * PROGRAMMERS: Timo Kreuzer
+ */
+
+#include <apitest.h>
+#include <windows.h>
+#include <stdio.h>
+#include "init.h"
+
+
+void Test_PaintRgn()
+{
+ RECT rc = { 0, 0, 100, 100 };
+ HRGN hrgn1, hrgn2;
+ BOOL bRet;
+ XFORM xform;
+ PULONG pulDIB = gpvDIB1;
+
+ FillRect(ghdcDIB1, &rc, GetStockObject(BLACK_BRUSH));
+
+ hrgn1 = CreateRectRgn(0, 0, 8, 3);
+ ok(hrgn1 != NULL, "failed to create region\n");
+
+ hrgn2 = CreateRectRgn(2, 3, 5, 8);
+ ok(hrgn1 != NULL, "failed to create region\n");
+
+ CombineRgn(hrgn1, hrgn1, hrgn2, RGN_OR);
+
+ xform.eM11 = 1.0;
+ xform.eM12 = 0.5f;
+ xform.eM21 = 0.0;
+ xform.eM22 = 1.0;
+ xform.eDx = 0.0;
+ xform.eDy = 0.0;
+
+ SetGraphicsMode(ghdcDIB1, GM_ADVANCED);
+ ok(SetWorldTransform(ghdcDIB1, &xform) == TRUE, "SetWorldTransform
failed\n");
+
+ SelectObject(ghdcDIB1, GetStockObject(WHITE_BRUSH));
+
+ bRet = PaintRgn(ghdcDIB1, hrgn1);
+ ok(bRet == TRUE, "PaintRgn failed\n");
+
+ ok_long(pulDIB[0], 0x00000000); // 000000000
+ ok_long(pulDIB[1], 0x000000C0); // 110000000
+ ok_long(pulDIB[2], 0x000000F0); // 111110000
+ ok_long(pulDIB[3], 0x000000FC); // 111111000
+ ok_long(pulDIB[4], 0x0000003F); // 001111110
+ ok_long(pulDIB[5], 0x0000003F); // 001111110
+ ok_long(pulDIB[6], 0x0000003B); // 001110110
+ ok_long(pulDIB[7], 0x00000038); // 001110000
+ ok_long(pulDIB[8], 0x00000038); // 001110000
+}
+
+START_TEST(PaintRgn)
+{
+ InitStuff();
+ Test_PaintRgn();
+}
+
Propchange: trunk/rostests/apitests/gdi32/PaintRgn.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/rostests/apitests/gdi32/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/init.c?rev…
==============================================================================
--- trunk/rostests/apitests/gdi32/init.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/init.c [iso-8859-1] Sat Feb 14 13:19:02 2015
@@ -9,7 +9,6 @@
HDC ghdcDIB1, ghdcDIB4, ghdcDIB8, ghdcDIB16, ghdcDIB24, ghdcDIB32;
PVOID gpvDIB1, gpvDIB4, gpvDIB8, gpvDIB16, gpvDIB24, gpvDIB32;
ULONG (*gpDIB32)[8][8];
-PULONG pulDIB4Bits;
HPALETTE ghpal;
MYPAL gpal =
@@ -40,7 +39,7 @@
struct
{
BITMAPINFOHEADER bmiHeader;
- RGBQUAD bmiColors[256];
+ ULONG bmiColors[256];
} bmiBuffer;
LPBITMAPINFO pbmi = (LPBITMAPINFO)&bmiBuffer;
@@ -65,6 +64,13 @@
pbmi->bmiHeader.biYPelsPerMeter = 0;
pbmi->bmiHeader.biClrUsed = 0;
pbmi->bmiHeader.biClrImportant = 0;
+
+ if (cBitsPerPixel == 1)
+ {
+ bmiBuffer.bmiColors[0] = 0;
+ bmiBuffer.bmiColors[1] = 0xFFFFFF;
+ pbmi->bmiHeader.biClrUsed = 2;
+ }
/* Create a compatible DC for the DIB */
*phdcDIB = CreateCompatibleDC(0);
@@ -110,7 +116,6 @@
}
gpDIB32 = gpvDIB32;
- pulDIB4Bits = gpvDIB4;
return TRUE;
}
Modified: trunk/rostests/apitests/gdi32/init.h
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/init.h?rev…
==============================================================================
--- trunk/rostests/apitests/gdi32/init.h [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/init.h [iso-8859-1] Sat Feb 14 13:19:02 2015
@@ -2,7 +2,7 @@
extern HBITMAP ghbmp1, ghbmp4, ghbmp8, ghbmp16, ghbmp24, ghbmp32;
extern HBITMAP ghbmpDIB1, ghbmpDIB4, ghbmpDIB8, ghbmpDIB16, ghbmpDIB24, ghbmpDIB32;
extern HDC ghdcDIB1, ghdcDIB4, ghdcDIB8, ghdcDIB16, ghdcDIB24, ghdcDIB32;
-extern PVOID pvBits1Bpp, pvBits4Bpp, pvBits8Bpp, pvBits16Bpp, pvBits24Bpp, pvBits32Bpp;
+extern PVOID gpvDIB1, gpvDIB4, gpvDIB8, gpvDIB16, gpvDIB24, gpvDIB32;
extern HBITMAP ghbmpDIB32;
//extern PULONG pulDIB32Bits;
Modified: trunk/rostests/apitests/gdi32/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/testlist.c…
==============================================================================
--- trunk/rostests/apitests/gdi32/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/gdi32/testlist.c [iso-8859-1] Sat Feb 14 13:19:02 2015
@@ -27,6 +27,7 @@
extern void func_ExcludeClipRect(void);
extern void func_ExtCreatePen(void);
extern void func_ExtCreateRegion(void);
+extern void func_FrameRgn(void);
extern void func_GdiConvertBitmap(void);
extern void func_GdiConvertBrush(void);
extern void func_GdiConvertDC(void);
@@ -52,6 +53,8 @@
extern void func_GetTextFace(void);
extern void func_MaskBlt(void);
extern void func_OffsetClipRgn(void);
+extern void func_OffsetRgn(void);
+extern void func_PaintRgn(void);
extern void func_PatBlt(void);
extern void func_Rectangle(void);
extern void func_RealizePalette(void);
@@ -92,6 +95,7 @@
{ "ExcludeClipRect", func_ExcludeClipRect },
{ "ExtCreatePen", func_ExtCreatePen },
{ "ExtCreateRegion", func_ExtCreateRegion },
+ { "FrameRgn", func_FrameRgn },
{ "GdiConvertBitmap", func_GdiConvertBitmap },
{ "GdiConvertBrush", func_GdiConvertBrush },
{ "GdiConvertDC", func_GdiConvertDC },
@@ -117,6 +121,8 @@
{ "GetTextFace", func_GetTextFace },
{ "MaskBlt", func_MaskBlt },
{ "OffsetClipRgn", func_OffsetClipRgn },
+ { "OffsetRgn", func_OffsetRgn },
+ { "PaintRgn", func_PaintRgn },
{ "PatBlt", func_PatBlt },
{ "Rectangle", func_Rectangle },
{ "RealizePalette", func_RealizePalette },