ReactOS 0.4.15-dev-7924-g5949c20
uitools.c File Reference
#include "wine/test.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
Include dependency graph for uitools.c:

Go to the source code of this file.

Macros

#define WINE_NO_INLINE_RECT
 

Functions

static void test_FillRect (void)
 
static void test_SubtractRect (void)
 
static void test_EqualRect (void)
 
static void test_IsRectEmpty (void)
 
static void test_SetRect (void)
 
 START_TEST (uitools)
 

Macro Definition Documentation

◆ WINE_NO_INLINE_RECT

#define WINE_NO_INLINE_RECT

Definition at line 20 of file uitools.c.

Function Documentation

◆ START_TEST()

START_TEST ( uitools  )

Definition at line 204 of file uitools.c.

205{
210 test_SetRect();
211}
static void test_FillRect(void)
Definition: uitools.c:26
static void test_SetRect(void)
Definition: uitools.c:185
static void test_EqualRect(void)
Definition: uitools.c:115
static void test_SubtractRect(void)
Definition: uitools.c:66
static void test_IsRectEmpty(void)
Definition: uitools.c:149

◆ test_EqualRect()

static void test_EqualRect ( void  )
static

Definition at line 115 of file uitools.c.

116{
117 RECT rect1, rect2;
118 BOOL ret;
119
120 SetRect(&rect1, 0, 0, 0, 0);
121 SetRect(&rect2, 1, 1, 1, 1);
122
124 ok(!ret, "got %d\n", ret);
125
126 ret = EqualRect(&rect1, NULL);
127 ok(!ret, "got %d\n", ret);
128
129 ret = EqualRect(NULL, &rect2);
130 ok(!ret, "got %d\n", ret);
131
132 ret = EqualRect(&rect1, &rect2);
133 ok(!ret, "got %d\n", ret);
134
135 SetRect(&rect1, 0, 0, 10, 10);
136 SetRect(&rect2, 10, 10, 0, 0);
137
138 ret = EqualRect(&rect1, &rect2);
139 ok(!ret, "got %d\n", ret);
140
141 ret = EqualRect(&rect1, &rect1);
142 ok(ret, "got %d\n", ret);
143
144 rect2 = rect1;
145 ret = EqualRect(&rect1, &rect2);
146 ok(ret, "got %d\n", ret);
147}
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
RECT rect2
Definition: edittest.c:51
unsigned int BOOL
Definition: ntddk_ex.h:94
int ret
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by START_TEST().

◆ test_FillRect()

static void test_FillRect ( void  )
static

Definition at line 26 of file uitools.c.

27{
28 HDC hdc, hdcmem;
29 DWORD bits[64];
30 HBITMAP hbmp, oldhbmp;
31 COLORREF col;
32 HBRUSH old_brush;
33 RECT r;
34
35 /* fill bitmap data with white */
36 memset(bits, 0xff, sizeof(bits));
37
38 hdc = GetDC(0);
39 ok( hdc != NULL, "CreateDC rets %p\n", hdc);
40 /* create a memory dc */
41 hdcmem = CreateCompatibleDC(hdc);
42 ok(hdcmem != NULL, "CreateCompatibleDC rets %p\n", hdcmem);
43 /* test monochrome bitmap: should always work */
44 hbmp = CreateBitmap(32, 32, 1, 1, bits);
45 ok(hbmp != NULL, "CreateBitmap returns %p\n", hbmp);
46 oldhbmp = SelectObject(hdcmem, hbmp);
47 ok(oldhbmp != NULL, "SelectObject returned NULL\n"); /* a memdc always has a bitmap selected */
48 col = GetPixel(hdcmem, 0, 0);
49 ok( col == 0xffffff, "GetPixel returned %08x, expected 0xffffff\n", col);
50
51 /* select black brush */
52 old_brush = SelectObject(hdcmem, GetStockObject(BLACK_BRUSH));
53 SetRect(&r, 0, 0, 5, 5);
54 FillRect(hdcmem, &r, 0);
55 SelectObject(hdcmem, old_brush);
56 /* bitmap filled with last selected brush */
57 col = GetPixel(hdcmem, 0, 0);
58 ok(col == 0, "GetPixel returned %08x, expected 0\n", col);
59
60 SelectObject(hdcmem, oldhbmp);
62 DeleteDC(hdcmem);
63 ReleaseDC(0, hdc);
64}
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
HBITMAP hbmp
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
#define memset(x, y, z)
Definition: compat.h:39
DWORD COLORREF
Definition: windef.h:300
HGDIOBJ WINAPI GetStockObject(_In_ int)
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define BLACK_BRUSH
Definition: wingdi.h:896
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
BOOL WINAPI DeleteDC(_In_ HDC)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by START_TEST().

◆ test_IsRectEmpty()

static void test_IsRectEmpty ( void  )
static

Definition at line 149 of file uitools.c.

150{
151 BOOL ret;
152 unsigned int i;
153 static const struct {
154 RECT rect;
155 BOOL ret;
156 } rtest[] = {
157 {{0, 0, 0, 0}, TRUE},
158 {{127, 131, 127, 131}, TRUE},
160 {{-1, -1, -1, -1}, TRUE},
161 {{-2011, -2017, -2011, -2017}, TRUE},
163 /* Only width or height are 0 */
164 {{31, 37, 31, 41}, TRUE},
165 {{881, 883, 887, 883}, TRUE},
166 {{-1721, 1723, -1721, 7213}, TRUE},
167 /* Negative width and/or height */
168 {{11, 13, 5, 7}, TRUE},
169 {{-11, -13, -19, -23}, TRUE},
170 {{11, 13, -17, 19}, TRUE},
171 {{11, 13, 17, 11}, TRUE},
172 /* Non empty rects */
173 {{101, 103, 107, 109}, FALSE},
174 {{1, -9, 7, 3}, FALSE},
175 {{-109, -107, -103, -101}, FALSE},
176 };
177
178 for (i = 0; i < ARRAY_SIZE(rtest); i++) {
179 ret = IsRectEmpty(&rtest[i].rect);
180 ok(ret == rtest[i].ret, "Test %d: IsRectEmpty returned %s for %s\n", i,
181 ret ? "TRUE" : "FALSE", wine_dbgstr_rect(&rtest[i].rect));
182 }
183}
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define ARRAY_SIZE(A)
Definition: main.h:33
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
& rect
Definition: startmenu.cpp:1413
#define MAXLONG
Definition: umtypes.h:116
#define MINLONG
Definition: umtypes.h:115
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)

Referenced by START_TEST().

◆ test_SetRect()

static void test_SetRect ( void  )
static

Definition at line 185 of file uitools.c.

186{
187 RECT rect;
188 BOOL ret;
189
190 ret = SetRect(NULL, 0, 0, 0, 0);
191 ok(!ret, "got %d\n", ret);
192
193 ret = SetRect(&rect, 1, 2, 3, 4);
194 ok(ret, "got %d\n", ret);
195 ok(rect.left == 1 && rect.top == 2 && rect.right == 3 && rect.bottom == 4,
196 "got wrong rectangle\n");
197
198 ret = SetRect(&rect, 10, 10, 5, 5);
199 ok(ret, "got %d\n", ret);
200 ok(rect.left == 10 && rect.top == 10 && rect.right == 5 && rect.bottom == 5,
201 "got wrong rectangle\n");
202}

Referenced by START_TEST().

◆ test_SubtractRect()

static void test_SubtractRect ( void  )
static

Definition at line 66 of file uitools.c.

67{
68 RECT rect1;
69 RECT rect2;
70 RECT rectr;
72
73 /* source rectangles don't intersect */
74 SetRect(&rect1, 50, 50, 150, 100);
75 SetRect(&rect2, 250, 200, 1500, 1000);
76 result = SubtractRect(&rectr, &rect1, &rect2);
77 ok(result, "SubtractRect returned FALSE but subtraction should not be empty\n");
78 ok(result && rectr.left == 50 && rectr.top == 50 && rectr.right ==150
79 && rectr.bottom == 100, "wrong rect subtraction of SubtractRect (dest rect=%s)\n",
80 wine_dbgstr_rect(&rectr));
81
82 /* source rect 2 partially overlaps rect 1 */
83 SetRect(&rect1, 2431, 626, 3427, 1608);
84 SetRect(&rect2, 2499, 626, 3427, 1608);
85 result = SubtractRect(&rectr, &rect1, &rect2);
86 ok(result, "SubtractRect returned FALSE but subtraction should not be empty\n");
87 ok(result && rectr.left == 2431 && rectr.top == 626 && rectr.right == 2499
88 && rectr.bottom == 1608, "wrong rect subtraction of SubtractRect (dest rect=%s)\n",
89 wine_dbgstr_rect(&rectr));
90
91 /* source rect 2 partially overlaps rect 1 - dest is src rect 2 */
92 SetRect(&rect1, 2431, 626, 3427, 1608);
93 SetRect(&rect2, 2499, 626, 3427, 1608);
94 result = SubtractRect(&rect2, &rect1, &rect2);
95 ok(result, "SubtractRect returned FALSE but subtraction should not be empty\n");
96 ok(result && rectr.left == 2431 && rectr.top == 626 && rectr.right == 2499
97 && rectr.bottom == 1608, "wrong rect subtraction of SubtractRect (dest rect=%s)\n",
98 wine_dbgstr_rect(&rectr));
99
100 /* source rect 2 completely overlaps rect 1 */
101 SetRect(&rect1, 250, 250, 400, 500);
102 SetRect(&rect2, 50, 50, 1500, 1000);
103 result = SubtractRect(&rectr, &rect1, &rect2);
104 ok(!result, "SubtractRect returned TRUE but subtraction should be empty (dest rect=%s)\n",
105 wine_dbgstr_rect(&rectr));
106
107 /* source rect 2 completely overlaps rect 1 - dest is src rect 2 */
108 SetRect(&rect1, 250, 250, 400, 500);
109 SetRect(&rect2, 50, 50, 1500, 1000);
110 result = SubtractRect(&rect2, &rect1, &rect2);
111 ok(!result, "SubtractRect returned TRUE but subtraction should be empty (dest rect=%s)\n",
113}
GLuint64EXT * result
Definition: glext.h:11304
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
BOOL WINAPI SubtractRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)

Referenced by START_TEST().