[GDI32_APITEST]

- Test Rectangle function.
Don't laugh, ROS fails those tests and fixing this breaks the GUI.

svn path=/trunk/; revision=51018
This commit is contained in:
Jérôme Gardou 2011-03-11 15:32:54 +00:00
parent b6ee921ee6
commit 1f0f4f62b0
5 changed files with 120 additions and 1 deletions

View file

@ -39,6 +39,7 @@ list(APPEND SOURCE
GetTextExtentExPoint.c
GetTextFace.c
MaskBlt.c
Rectangle.c
SelectObject.c
SetDCPenColor.c
SetDIBits.c

View file

@ -1,7 +1,7 @@
/*
* PROJECT: ReactOS api tests
* LICENSE: GPL - See COPYING in the top level directory
* PURPOSE: Test for SetDIBits
* PURPOSE: Test for GetPixel
* PROGRAMMERS: Jérôme Gardou
*/

View file

@ -0,0 +1,115 @@
/*
* PROJECT: ReactOS api tests
* LICENSE: GPL - See COPYING in the top level directory
* PURPOSE: Test for Rectangle
* PROGRAMMERS: Jérôme Gardou
*/
#include <stdio.h>
#include <wine/test.h>
#include <windows.h>
void Test_Rectangle(void)
{
HDC hdc;
HBITMAP hBmp;
BOOL ret;
HBRUSH hBrush;
COLORREF color;
hdc = CreateCompatibleDC(NULL);
ok(hdc != NULL, "Failed to create the DC!\n");
hBmp = CreateCompatibleBitmap(hdc, 4, 4);
ok(hBmp != NULL, "Failed to create the Bitmap!\n");
hBmp = SelectObject(hdc, hBmp);
ok(hBmp != NULL, "Failed to select the Bitmap!\n");
hBrush = CreateSolidBrush(RGB(0, 0, 0));
ok(hBrush != NULL, "Failed to create a solid brush!\n");
hBrush = SelectObject(hdc, hBrush);
ok(hBrush != NULL, "Failed to select the brush!\n");
/* Blank the bitmap */
ret = BitBlt(hdc, 0, 0, 4, 4, NULL, 0, 0, WHITENESS);
ok(ret, "BitBlt failed to blank the bitmap!\n");
/* Try inverted rectangle coordinates */
ret = Rectangle(hdc, 0, 2, 2, 0);
ok(ret, "Rectangle failed!");
color = GetPixel(hdc, 0, 0);
ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
color = GetPixel(hdc, 2, 2);
ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT)color);
color = GetPixel(hdc, 0, 2);
ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT)color);
color = GetPixel(hdc, 2, 0);
ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT)color);
color = GetPixel(hdc, 1, 1);
ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
ret = BitBlt(hdc, 0, 0, 4, 4, NULL, 0, 0, WHITENESS);
ok(ret, "BitBlt failed to blank the bitmap!\n");
/* Try well ordered rectangle coordinates */
ret = Rectangle(hdc, 0, 0, 2, 2);
ok(ret, "Rectangle failed!");
color = GetPixel(hdc, 0, 0);
ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
color = GetPixel(hdc, 2, 2);
ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT)color);
color = GetPixel(hdc, 0, 2);
ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT)color);
color = GetPixel(hdc, 2, 0);
ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT)color);
color = GetPixel(hdc, 1, 1);
ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
/* Same tests with GM_ADVANCED */
ok(SetGraphicsMode(hdc, GM_ADVANCED) == GM_COMPATIBLE, "Default mode for the DC is not GM_COMPATIBLE.\n");
/* Blank the bitmap */
ret = BitBlt(hdc, 0, 0, 4, 4, NULL, 0, 0, WHITENESS);
ok(ret, "BitBlt failed to blank the bitmap!\n");
/* Try inverted rectangle coordinates */
ret = Rectangle(hdc, 0, 2, 2, 0);
ok(ret, "Rectangle failed!");
color = GetPixel(hdc, 0, 0);
ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
color = GetPixel(hdc, 2, 2);
ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
color = GetPixel(hdc, 0, 2);
ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
color = GetPixel(hdc, 2, 0);
ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
color = GetPixel(hdc, 1, 1);
ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
ret = BitBlt(hdc, 0, 0, 4, 4, NULL, 0, 0, WHITENESS);
ok(ret, "BitBlt failed to blank the bitmap!\n");
/* Try well ordered rectangle coordinates */
ret = Rectangle(hdc, 0, 0, 2, 2);
ok(ret, "Rectangle failed!");
color = GetPixel(hdc, 0, 0);
ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
color = GetPixel(hdc, 2, 2);
ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
color = GetPixel(hdc, 0, 2);
ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
color = GetPixel(hdc, 2, 0);
ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
color = GetPixel(hdc, 1, 1);
ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
hBmp = SelectObject(hdc, hBmp);
hBrush = SelectObject(hdc, hBrush);
DeleteObject(hBmp);
DeleteObject(hBrush);
DeleteDC(hdc);
}
START_TEST(Rectangle)
{
Test_Rectangle();
}

View file

@ -46,6 +46,7 @@
<file>GetTextExtentExPoint.c</file>
<file>GetTextFace.c</file>
<file>MaskBlt.c</file>
<file>Rectangle.c</file>
<file>SelectObject.c</file>
<file>SetDCPenColor.c</file>
<file>SetDIBits.c</file>

View file

@ -42,6 +42,7 @@ extern void func_GetStockObject(void);
extern void func_GetTextExtentExPoint(void);
extern void func_GetTextFace(void);
extern void func_MaskBlt(void);
extern void func_Rectangle(void);
extern void func_SelectObject(void);
extern void func_SetDCPenColor(void);
extern void func_SetDIBits(void);
@ -89,6 +90,7 @@ const struct test winetest_testlist[] =
{ "GetTextExtentExPoint", func_GetTextExtentExPoint },
{ "GetTextFace", func_GetTextFace },
{ "MaskBlt", func_MaskBlt },
{ "Rectangle", func_Rectangle },
{ "SelectObject", func_SelectObject },
{ "SetDCPenColor", func_SetDCPenColor },
{ "SetDIBits", func_SetDIBits },