mirror of
https://github.com/reactos/wine.git
synced 2025-02-07 20:57:39 +00:00
user32/uitools: Fix FillRect behaviour for invalid brush passed.
This commit is contained in:
parent
385b8dcb95
commit
ff12594a15
@ -26,6 +26,7 @@ CTESTS = \
|
|||||||
static.c \
|
static.c \
|
||||||
sysparams.c \
|
sysparams.c \
|
||||||
text.c \
|
text.c \
|
||||||
|
uitools.c \
|
||||||
win.c \
|
win.c \
|
||||||
winstation.c \
|
winstation.c \
|
||||||
wsprintf.c
|
wsprintf.c
|
||||||
|
69
dlls/user32/tests/uitools.c
Normal file
69
dlls/user32/tests/uitools.c
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/* Unit test suite for user interface functions
|
||||||
|
*
|
||||||
|
* Copyright 2009 Nikolay Sivov
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "wine/test.h"
|
||||||
|
#include "winbase.h"
|
||||||
|
#include "wingdi.h"
|
||||||
|
#include "winuser.h"
|
||||||
|
|
||||||
|
static void test_FillRect(void)
|
||||||
|
{
|
||||||
|
HDC hdc, hdcmem;
|
||||||
|
DWORD bits[64];
|
||||||
|
HBITMAP hbmp, oldhbmp;
|
||||||
|
COLORREF col;
|
||||||
|
HBRUSH old_brush;
|
||||||
|
RECT r;
|
||||||
|
|
||||||
|
/* fill bitmap data with white */
|
||||||
|
memset(bits, 0xff, sizeof(bits));
|
||||||
|
|
||||||
|
hdc = GetDC(0);
|
||||||
|
ok( hdc != NULL, "CreateDC rets %p\n", hdc);
|
||||||
|
/* create a memory dc */
|
||||||
|
hdcmem = CreateCompatibleDC(hdc);
|
||||||
|
ok(hdcmem != NULL, "CreateCompatibleDC rets %p\n", hdcmem);
|
||||||
|
/* test monochrome bitmap: should always work */
|
||||||
|
hbmp = CreateBitmap(32, 32, 1, 1, bits);
|
||||||
|
ok(hbmp != NULL, "CreateBitmap returns %p\n", hbmp);
|
||||||
|
oldhbmp = SelectObject(hdcmem, hbmp);
|
||||||
|
ok(oldhbmp != NULL, "SelectObject returned NULL\n"); /* a memdc always has a bitmap selected */
|
||||||
|
col = GetPixel(hdcmem, 0, 0);
|
||||||
|
ok( col == 0xffffff, "GetPixel returned %08x, expected 0xffffff\n", col);
|
||||||
|
|
||||||
|
/* select black brush */
|
||||||
|
old_brush = SelectObject(hdcmem, GetStockObject(BLACK_BRUSH));
|
||||||
|
r.left = r.top = 0;
|
||||||
|
r.right = r.bottom = 5;
|
||||||
|
FillRect(hdcmem, &r, 0);
|
||||||
|
SelectObject(hdcmem, old_brush);
|
||||||
|
/* bitmap filled with last selected brush */
|
||||||
|
col = GetPixel(hdcmem, 0, 0);
|
||||||
|
ok(col == 0, "GetPixel returned %08x, expected 0\n", col);
|
||||||
|
|
||||||
|
SelectObject(hdcmem, oldhbmp);
|
||||||
|
DeleteObject(hbmp);
|
||||||
|
DeleteDC(hdcmem);
|
||||||
|
ReleaseDC(0, hdc);
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(uitools)
|
||||||
|
{
|
||||||
|
test_FillRect();
|
||||||
|
}
|
@ -1425,14 +1425,14 @@ BOOL WINAPI SubtractRect( LPRECT dest, const RECT *src1, const RECT *src2 )
|
|||||||
*/
|
*/
|
||||||
INT WINAPI FillRect( HDC hdc, const RECT *rect, HBRUSH hbrush )
|
INT WINAPI FillRect( HDC hdc, const RECT *rect, HBRUSH hbrush )
|
||||||
{
|
{
|
||||||
HBRUSH prevBrush;
|
HBRUSH prev_brush;
|
||||||
|
|
||||||
if (hbrush <= (HBRUSH) (COLOR_MAX + 1)) hbrush = GetSysColorBrush( HandleToULong(hbrush) - 1 );
|
if (hbrush <= (HBRUSH) (COLOR_MAX + 1)) hbrush = GetSysColorBrush( HandleToULong(hbrush) - 1 );
|
||||||
|
|
||||||
if (!(prevBrush = SelectObject( hdc, hbrush ))) return 0;
|
prev_brush = SelectObject( hdc, hbrush );
|
||||||
PatBlt( hdc, rect->left, rect->top,
|
PatBlt( hdc, rect->left, rect->top,
|
||||||
rect->right - rect->left, rect->bottom - rect->top, PATCOPY );
|
rect->right - rect->left, rect->bottom - rect->top, PATCOPY );
|
||||||
SelectObject( hdc, prevBrush );
|
if (prev_brush) SelectObject( hdc, prev_brush );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user