1 /* Unit test suite for user interface functions
3 * Copyright 2009 Nikolay Sivov
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.
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.
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
20 #include "wine/test.h"
25 static void test_FillRect(void)
29 HBITMAP hbmp
, oldhbmp
;
34 /* fill bitmap data with white */
35 memset(bits
, 0xff, sizeof(bits
));
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
);
50 /* select black brush */
51 old_brush
= SelectObject(hdcmem
, GetStockObject(BLACK_BRUSH
));
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
);
60 SelectObject(hdcmem
, oldhbmp
);
66 static void test_SubtractRect(void)
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 "
80 "(dest rect={%d, %d, %d, %d})\n", rectr
.left
, rectr
.top
, rectr
.right
, rectr
.bottom
);
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 "
89 "(dest rect={%d, %d, %d, %d})\n", rectr
.left
, rectr
.top
, rectr
.right
, rectr
.bottom
);
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 "
98 "(dest rect={%d, %d, %d, %d})\n", rectr
.left
, rectr
.top
, rectr
.right
, rectr
.bottom
);
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 "
105 "(dest rect={%d, %d, %d, %d})\n", rectr
.left
, rectr
.top
, rectr
.right
, rectr
.bottom
);
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 "
112 "(dest rect={%d, %d, %d, %d})\n", rect2
.left
, rect2
.top
, rect2
.right
, rect2
.bottom
);