From 1f0f4f62b080dfe5ab4647853b3d2f69ff1ffc64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Fri, 11 Mar 2011 15:32:54 +0000 Subject: [PATCH] [GDI32_APITEST] - Test Rectangle function. Don't laugh, ROS fails those tests and fixing this breaks the GUI. svn path=/trunk/; revision=51018 --- rostests/apitests/gdi32/CMakeLists.txt | 1 + rostests/apitests/gdi32/GetPixel.c | 2 +- rostests/apitests/gdi32/Rectangle.c | 115 +++++++++++++++++++ rostests/apitests/gdi32/gdi32_apitest.rbuild | 1 + rostests/apitests/gdi32/testlist.c | 2 + 5 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 rostests/apitests/gdi32/Rectangle.c diff --git a/rostests/apitests/gdi32/CMakeLists.txt b/rostests/apitests/gdi32/CMakeLists.txt index 2418976b336..e7d18f55eb8 100644 --- a/rostests/apitests/gdi32/CMakeLists.txt +++ b/rostests/apitests/gdi32/CMakeLists.txt @@ -39,6 +39,7 @@ list(APPEND SOURCE GetTextExtentExPoint.c GetTextFace.c MaskBlt.c + Rectangle.c SelectObject.c SetDCPenColor.c SetDIBits.c diff --git a/rostests/apitests/gdi32/GetPixel.c b/rostests/apitests/gdi32/GetPixel.c index f7dac23d666..739be912d3a 100644 --- a/rostests/apitests/gdi32/GetPixel.c +++ b/rostests/apitests/gdi32/GetPixel.c @@ -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 */ diff --git a/rostests/apitests/gdi32/Rectangle.c b/rostests/apitests/gdi32/Rectangle.c new file mode 100644 index 00000000000..2dde92536d3 --- /dev/null +++ b/rostests/apitests/gdi32/Rectangle.c @@ -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 +#include +#include + +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(); +} diff --git a/rostests/apitests/gdi32/gdi32_apitest.rbuild b/rostests/apitests/gdi32/gdi32_apitest.rbuild index 18327f64d12..fe56b0dde1c 100644 --- a/rostests/apitests/gdi32/gdi32_apitest.rbuild +++ b/rostests/apitests/gdi32/gdi32_apitest.rbuild @@ -46,6 +46,7 @@ GetTextExtentExPoint.c GetTextFace.c MaskBlt.c + Rectangle.c SelectObject.c SetDCPenColor.c SetDIBits.c diff --git a/rostests/apitests/gdi32/testlist.c b/rostests/apitests/gdi32/testlist.c index fc99d87d0e7..dfcb82ce054 100644 --- a/rostests/apitests/gdi32/testlist.c +++ b/rostests/apitests/gdi32/testlist.c @@ -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 },