2011-03-11 15:32:54 +00:00
|
|
|
|
/*
|
|
|
|
|
* PROJECT: ReactOS api tests
|
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
|
* PURPOSE: Test for Rectangle
|
|
|
|
|
* PROGRAMMERS: J<EFBFBD>r<EFBFBD>me Gardou
|
|
|
|
|
*/
|
|
|
|
|
|
2017-12-02 20:00:06 +00:00
|
|
|
|
#include "precomp.h"
|
2011-03-11 15:32:54 +00:00
|
|
|
|
|
|
|
|
|
void Test_Rectangle(void)
|
|
|
|
|
{
|
|
|
|
|
HDC hdc;
|
|
|
|
|
HBITMAP hBmp;
|
|
|
|
|
BOOL ret;
|
|
|
|
|
HBRUSH hBrush;
|
2011-06-01 18:20:51 +00:00
|
|
|
|
HPEN hPen;
|
2011-03-11 15:32:54 +00:00
|
|
|
|
COLORREF color;
|
2021-09-13 01:33:14 +00:00
|
|
|
|
|
2011-03-11 15:32:54 +00:00
|
|
|
|
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");
|
2021-09-13 01:33:14 +00:00
|
|
|
|
|
2011-03-11 15:32:54 +00:00
|
|
|
|
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");
|
2021-09-13 01:33:14 +00:00
|
|
|
|
|
2011-03-11 15:32:54 +00:00
|
|
|
|
/* Blank the bitmap */
|
|
|
|
|
ret = BitBlt(hdc, 0, 0, 4, 4, NULL, 0, 0, WHITENESS);
|
|
|
|
|
ok(ret, "BitBlt failed to blank the bitmap!\n");
|
2021-09-13 01:33:14 +00:00
|
|
|
|
|
2011-03-11 15:32:54 +00:00
|
|
|
|
/* 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);
|
2011-06-01 18:20:51 +00:00
|
|
|
|
ok(ret, "BitBlt failed to blank the bitmap!\n");
|
2011-03-11 15:32:54 +00:00
|
|
|
|
/* 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);
|
2021-09-13 01:33:14 +00:00
|
|
|
|
|
2011-06-01 18:20:51 +00:00
|
|
|
|
/* tests with NULL pen */
|
|
|
|
|
hPen = SelectObject(hdc, GetStockObject(NULL_PEN));
|
2021-09-13 01:33:14 +00:00
|
|
|
|
|
2011-06-01 18:20:51 +00:00
|
|
|
|
/* Blank the bitmap */
|
|
|
|
|
ret = BitBlt(hdc, 0, 0, 4, 4, NULL, 0, 0, WHITENESS);
|
|
|
|
|
ok(ret, "BitBlt failed to blank the bitmap!\n");
|
2021-09-13 01:33:14 +00:00
|
|
|
|
|
2011-06-01 18:20:51 +00:00
|
|
|
|
ret = Rectangle(hdc, 0, 0, 3, 3);
|
|
|
|
|
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);
|
2021-09-13 01:33:14 +00:00
|
|
|
|
|
2011-06-01 18:20:51 +00:00
|
|
|
|
SelectObject(hdc, hPen);
|
2021-09-13 01:33:14 +00:00
|
|
|
|
|
2011-03-11 15:32:54 +00:00
|
|
|
|
/* Same tests with GM_ADVANCED */
|
|
|
|
|
ok(SetGraphicsMode(hdc, GM_ADVANCED) == GM_COMPATIBLE, "Default mode for the DC is not GM_COMPATIBLE.\n");
|
2021-09-13 01:33:14 +00:00
|
|
|
|
|
2011-03-11 15:32:54 +00:00
|
|
|
|
/* Blank the bitmap */
|
|
|
|
|
ret = BitBlt(hdc, 0, 0, 4, 4, NULL, 0, 0, WHITENESS);
|
|
|
|
|
ok(ret, "BitBlt failed to blank the bitmap!\n");
|
2021-09-13 01:33:14 +00:00
|
|
|
|
|
2011-03-11 15:32:54 +00:00
|
|
|
|
/* 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);
|
2021-09-13 01:33:14 +00:00
|
|
|
|
ok(ret, "BitBlt failed to blank the bitmap!\n");
|
2011-03-11 15:32:54 +00:00
|
|
|
|
/* 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);
|
2021-09-13 01:33:14 +00:00
|
|
|
|
|
|
|
|
|
|
2011-03-11 15:32:54 +00:00
|
|
|
|
hBmp = SelectObject(hdc, hBmp);
|
|
|
|
|
hBrush = SelectObject(hdc, hBrush);
|
|
|
|
|
DeleteObject(hBmp);
|
|
|
|
|
DeleteObject(hBrush);
|
|
|
|
|
DeleteDC(hdc);
|
|
|
|
|
}
|
2021-09-13 01:33:14 +00:00
|
|
|
|
|
2011-03-11 15:32:54 +00:00
|
|
|
|
|
|
|
|
|
START_TEST(Rectangle)
|
|
|
|
|
{
|
|
|
|
|
Test_Rectangle();
|
|
|
|
|
}
|