ReactOS 0.4.16-dev-109-gf4cb10f
Rectangle.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for Rectangle
5 * PROGRAMMERS: Jérôme Gardou
6 */
7
8#include "precomp.h"
9
11{
12 HDC hdc;
13 HBITMAP hBmp;
14 BOOL ret;
15 HBRUSH hBrush;
16 HPEN hPen;
18
20 ok(hdc != NULL, "Failed to create the DC!\n");
21 hBmp = CreateCompatibleBitmap(hdc, 4, 4);
22 ok(hBmp != NULL, "Failed to create the Bitmap!\n");
23 hBmp = SelectObject(hdc, hBmp);
24 ok(hBmp != NULL, "Failed to select the Bitmap!\n");
25
26 hBrush = CreateSolidBrush(RGB(0, 0, 0));
27 ok(hBrush != NULL, "Failed to create a solid brush!\n");
28 hBrush = SelectObject(hdc, hBrush);
29 ok(hBrush != NULL, "Failed to select the brush!\n");
30
31 /* Blank the bitmap */
32 ret = BitBlt(hdc, 0, 0, 4, 4, NULL, 0, 0, WHITENESS);
33 ok(ret, "BitBlt failed to blank the bitmap!\n");
34
35 /* Try inverted rectangle coordinates */
36 ret = Rectangle(hdc, 0, 2, 2, 0);
37 ok(ret, "Rectangle failed!");
38 color = GetPixel(hdc, 0, 0);
39 ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
40 color = GetPixel(hdc, 2, 2);
41 ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT)color);
42 color = GetPixel(hdc, 0, 2);
43 ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT)color);
44 color = GetPixel(hdc, 2, 0);
45 ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT)color);
46 color = GetPixel(hdc, 1, 1);
47 ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
48
49 ret = BitBlt(hdc, 0, 0, 4, 4, NULL, 0, 0, WHITENESS);
50 ok(ret, "BitBlt failed to blank the bitmap!\n");
51 /* Try well ordered rectangle coordinates */
52 ret = Rectangle(hdc, 0, 0, 2, 2);
53 ok(ret, "Rectangle failed!");
54 color = GetPixel(hdc, 0, 0);
55 ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
56 color = GetPixel(hdc, 2, 2);
57 ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT)color);
58 color = GetPixel(hdc, 0, 2);
59 ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT)color);
60 color = GetPixel(hdc, 2, 0);
61 ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT)color);
62 color = GetPixel(hdc, 1, 1);
63 ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
64
65 /* tests with NULL pen */
67
68 /* Blank the bitmap */
69 ret = BitBlt(hdc, 0, 0, 4, 4, NULL, 0, 0, WHITENESS);
70 ok(ret, "BitBlt failed to blank the bitmap!\n");
71
72 ret = Rectangle(hdc, 0, 0, 3, 3);
73 ok(ret, "Rectangle failed!");
74 color = GetPixel(hdc, 0, 0);
75 ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
76 color = GetPixel(hdc, 2, 2);
77 ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT)color);
78 color = GetPixel(hdc, 0, 2);
79 ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT)color);
80 color = GetPixel(hdc, 2, 0);
81 ok( color == RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT)color);
82 color = GetPixel(hdc, 1, 1);
83 ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
84
85 SelectObject(hdc, hPen);
86
87 /* Same tests with GM_ADVANCED */
88 ok(SetGraphicsMode(hdc, GM_ADVANCED) == GM_COMPATIBLE, "Default mode for the DC is not GM_COMPATIBLE.\n");
89
90 /* Blank the bitmap */
91 ret = BitBlt(hdc, 0, 0, 4, 4, NULL, 0, 0, WHITENESS);
92 ok(ret, "BitBlt failed to blank the bitmap!\n");
93
94 /* Try inverted rectangle coordinates */
95 ret = Rectangle(hdc, 0, 2, 2, 0);
96 ok(ret, "Rectangle failed!");
97 color = GetPixel(hdc, 0, 0);
98 ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
99 color = GetPixel(hdc, 2, 2);
100 ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
101 color = GetPixel(hdc, 0, 2);
102 ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
103 color = GetPixel(hdc, 2, 0);
104 ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
105 color = GetPixel(hdc, 1, 1);
106 ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
107
108 ret = BitBlt(hdc, 0, 0, 4, 4, NULL, 0, 0, WHITENESS);
109 ok(ret, "BitBlt failed to blank the bitmap!\n");
110 /* Try well ordered rectangle coordinates */
111 ret = Rectangle(hdc, 0, 0, 2, 2);
112 ok(ret, "Rectangle failed!");
113 color = GetPixel(hdc, 0, 0);
114 ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
115 color = GetPixel(hdc, 2, 2);
116 ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
117 color = GetPixel(hdc, 0, 2);
118 ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
119 color = GetPixel(hdc, 2, 0);
120 ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
121 color = GetPixel(hdc, 1, 1);
122 ok( color == RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT)color);
123
124
125 hBmp = SelectObject(hdc, hBmp);
126 hBrush = SelectObject(hdc, hBrush);
127 DeleteObject(hBmp);
128 DeleteObject(hBrush);
129 DeleteDC(hdc);
130}
131
132
134{
136}
void Test_Rectangle(void)
Definition: Rectangle.c:10
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
#define NULL
Definition: types.h:112
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
#define RGB(r, g, b)
Definition: precomp.h:71
unsigned int BOOL
Definition: ntddk_ex.h:94
pKey DeleteObject()
GLuint color
Definition: glext.h:6243
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
unsigned int UINT
Definition: ndis.h:50
int ret
DWORD COLORREF
Definition: windef.h:300
#define GM_COMPATIBLE
Definition: wingdi.h:864
HGDIOBJ WINAPI GetStockObject(_In_ int)
int WINAPI SetGraphicsMode(_In_ HDC, _In_ int)
Definition: dc.c:1233
#define GM_ADVANCED
Definition: wingdi.h:865
#define WHITENESS
Definition: wingdi.h:337
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define NULL_PEN
Definition: wingdi.h:904
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
BOOL WINAPI DeleteDC(_In_ HDC)