[winetests]
[reactos.git] / rostests / winetests / user32 / uitools.c
1 /* Unit test suite for user interface functions
2 *
3 * Copyright 2009 Nikolay Sivov
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20 #include "wine/test.h"
21 #include "winbase.h"
22 #include "wingdi.h"
23 #include "winuser.h"
24
25 static void test_FillRect(void)
26 {
27 HDC hdc, hdcmem;
28 DWORD bits[64];
29 HBITMAP hbmp, oldhbmp;
30 COLORREF col;
31 HBRUSH old_brush;
32 RECT r;
33
34 /* fill bitmap data with white */
35 memset(bits, 0xff, sizeof(bits));
36
37 hdc = GetDC(0);
38 ok( hdc != NULL, "CreateDC rets %p\n", hdc);
39 /* create a memory dc */
40 hdcmem = CreateCompatibleDC(hdc);
41 ok(hdcmem != NULL, "CreateCompatibleDC rets %p\n", hdcmem);
42 /* test monochrome bitmap: should always work */
43 hbmp = CreateBitmap(32, 32, 1, 1, bits);
44 ok(hbmp != NULL, "CreateBitmap returns %p\n", hbmp);
45 oldhbmp = SelectObject(hdcmem, hbmp);
46 ok(oldhbmp != NULL, "SelectObject returned NULL\n"); /* a memdc always has a bitmap selected */
47 col = GetPixel(hdcmem, 0, 0);
48 ok( col == 0xffffff, "GetPixel returned %08x, expected 0xffffff\n", col);
49
50 /* select black brush */
51 old_brush = SelectObject(hdcmem, GetStockObject(BLACK_BRUSH));
52 r.left = r.top = 0;
53 r.right = r.bottom = 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);
61 DeleteObject(hbmp);
62 DeleteDC(hdcmem);
63 ReleaseDC(0, hdc);
64 }
65
66 START_TEST(uitools)
67 {
68 test_FillRect();
69 }