1c2c66affSColin Finck /*
2c2c66affSColin Finck  * PROJECT:         ReactOS api tests
3c2c66affSColin Finck  * LICENSE:         GPL - See COPYING in the top level directory
4c2c66affSColin Finck  * PURPOSE:         Test for ...
5c2c66affSColin Finck  * PROGRAMMERS:     Timo Kreuzer
6c2c66affSColin Finck  */
7c2c66affSColin Finck 
8*aee83c35SAmine Khaldi #include "precomp.h"
9c2c66affSColin Finck 
10c2c66affSColin Finck typedef struct _RECT_TEST
11c2c66affSColin Finck {
12c2c66affSColin Finck     RECT rcSrc1;
13c2c66affSColin Finck     RECT rcSrc2;
14c2c66affSColin Finck     struct
15c2c66affSColin Finck     {
16c2c66affSColin Finck         INT iComplexity;
17c2c66affSColin Finck         RECT rcDstBounds;
18c2c66affSColin Finck     } res[4];
19c2c66affSColin Finck } RECT_TEST, *PRECT_TEST;
20c2c66affSColin Finck 
21c2c66affSColin Finck #define SetRectRgnIndirect(hrgn, prect) \
22c2c66affSColin Finck     SetRectRgn(hrgn, (prect)->left, (prect)->top, (prect)->right, (prect)->bottom)
23c2c66affSColin Finck 
24c2c66affSColin Finck PSTR apszRgnOp[6] = { "invalid", "RGN_AND", "RGN_OR", "RGN_XOR", "RGN_DIFF", "RGN_COPY" };
25c2c66affSColin Finck 
Test_RectRegions()26c2c66affSColin Finck void Test_RectRegions()
27c2c66affSColin Finck {
28c2c66affSColin Finck     RECT_TEST aRectTests[] = {
29c2c66affSColin Finck 
30c2c66affSColin Finck     /* rcSrc1    rcSrc2           RGN_AND                 RGN_OR                 RGN_XOR                    RGN_DIFF  */
31c2c66affSColin Finck     {{0,0,0,0},{0,0,0,0}, {{NULLREGION,   {0,0,0,0}}, {NULLREGION,   {0,0,0,0}}, {NULLREGION,   {0,0,0,0}}, {NULLREGION,   {0,0,0,0}}}},
32c2c66affSColin Finck     {{0,0,1,1},{0,0,0,0}, {{NULLREGION,   {0,0,0,0}}, {SIMPLEREGION, {0,0,1,1}}, {SIMPLEREGION, {0,0,1,1}}, {SIMPLEREGION, {0,0,1,1}}}},
33c2c66affSColin Finck     {{0,0,0,0},{0,0,1,1}, {{NULLREGION,   {0,0,0,0}}, {SIMPLEREGION, {0,0,1,1}}, {SIMPLEREGION, {0,0,1,1}}, {NULLREGION,   {0,0,0,0}}}},
34c2c66affSColin Finck 
35c2c66affSColin Finck     /* Equal rgn */
36c2c66affSColin Finck     {{0,0,4,4},{0,0,4,4}, {{SIMPLEREGION, {0,0,4,4}}, {SIMPLEREGION, {0,0,4,4}}, {NULLREGION,   {0,0,0,0}}, {NULLREGION,   {0,0,0,0}}}},
37c2c66affSColin Finck 
38c2c66affSColin Finck     /* rgn 2 is within rgn 1 */
39c2c66affSColin Finck     {{0,0,4,4},{0,0,2,4}, {{SIMPLEREGION, {0,0,2,4}}, {SIMPLEREGION, {0,0,4,4}}, {SIMPLEREGION ,{2,0,4,4}}, {SIMPLEREGION, {2,0,4,4}}}}, // left
40c2c66affSColin Finck     {{0,0,4,4},{0,0,4,2}, {{SIMPLEREGION, {0,0,4,2}}, {SIMPLEREGION, {0,0,4,4}}, {SIMPLEREGION ,{0,2,4,4}}, {SIMPLEREGION, {0,2,4,4}}}}, // top
41c2c66affSColin Finck     {{0,0,4,4},{2,0,4,4}, {{SIMPLEREGION, {2,0,4,4}}, {SIMPLEREGION, {0,0,4,4}}, {SIMPLEREGION ,{0,0,2,4}}, {SIMPLEREGION, {0,0,2,4}}}}, // right
42c2c66affSColin Finck     {{0,0,4,4},{0,2,4,4}, {{SIMPLEREGION, {0,2,4,4}}, {SIMPLEREGION, {0,0,4,4}}, {SIMPLEREGION ,{0,0,4,2}}, {SIMPLEREGION, {0,0,4,2}}}}, // bottom
43c2c66affSColin Finck     {{0,0,4,4},{0,0,2,2}, {{SIMPLEREGION, {0,0,2,2}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}}}, // top-left
44c2c66affSColin Finck     {{0,0,4,4},{2,0,4,2}, {{SIMPLEREGION, {2,0,4,2}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}}}, // top-right
45c2c66affSColin Finck     {{0,0,4,4},{0,2,2,4}, {{SIMPLEREGION, {0,2,2,4}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}}}, // bottom-left
46c2c66affSColin Finck     {{0,0,4,4},{2,2,4,4}, {{SIMPLEREGION, {2,2,4,4}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}}}, // bottom-right
47c2c66affSColin Finck     {{0,0,4,4},{0,1,2,3}, {{SIMPLEREGION, {0,1,2,3}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}}}, // center-left
48c2c66affSColin Finck     {{0,0,4,4},{1,0,3,2}, {{SIMPLEREGION, {1,0,3,2}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}}}, // center-top
49c2c66affSColin Finck     {{0,0,4,4},{2,1,4,3}, {{SIMPLEREGION, {2,1,4,3}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}}}, // center-right
50c2c66affSColin Finck     {{0,0,4,4},{1,2,3,4}, {{SIMPLEREGION, {1,2,3,4}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}}}, // center-bottom
51c2c66affSColin Finck     {{0,0,4,4},{1,1,3,4}, {{SIMPLEREGION, {1,1,3,4}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}}}, // center
52c2c66affSColin Finck 
53c2c66affSColin Finck     /* rgn 1 is within rgn 2 */
54c2c66affSColin Finck     {{0,0,2,4},{0,0,4,4}, {{SIMPLEREGION, {0,0,2,4}}, {SIMPLEREGION, {0,0,4,4}}, {SIMPLEREGION ,{2,0,4,4}}, {NULLREGION,   {0,0,0,0}}}}, // left
55c2c66affSColin Finck     {{0,0,4,2},{0,0,4,4}, {{SIMPLEREGION, {0,0,4,2}}, {SIMPLEREGION, {0,0,4,4}}, {SIMPLEREGION ,{0,2,4,4}}, {NULLREGION,   {0,0,0,0}}}}, // top
56c2c66affSColin Finck     {{2,0,4,4},{0,0,4,4}, {{SIMPLEREGION, {2,0,4,4}}, {SIMPLEREGION, {0,0,4,4}}, {SIMPLEREGION ,{0,0,2,4}}, {NULLREGION,   {0,0,0,0}}}}, // right
57c2c66affSColin Finck     {{0,2,4,4},{0,0,4,4}, {{SIMPLEREGION, {0,2,4,4}}, {SIMPLEREGION, {0,0,4,4}}, {SIMPLEREGION ,{0,0,4,2}}, {NULLREGION,   {0,0,0,0}}}}, // bottom
58c2c66affSColin Finck     {{0,0,2,2},{0,0,4,4}, {{SIMPLEREGION, {0,0,2,2}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {NULLREGION,   {0,0,0,0}}}}, // top-left
59c2c66affSColin Finck     {{2,0,4,2},{0,0,4,4}, {{SIMPLEREGION, {2,0,4,2}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {NULLREGION,   {0,0,0,0}}}}, // top-right
60c2c66affSColin Finck     {{0,2,2,4},{0,0,4,4}, {{SIMPLEREGION, {0,2,2,4}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {NULLREGION,   {0,0,0,0}}}}, // bottom-left
61c2c66affSColin Finck     {{2,2,4,4},{0,0,4,4}, {{SIMPLEREGION, {2,2,4,4}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {NULLREGION,   {0,0,0,0}}}}, // bottom-right
62c2c66affSColin Finck     {{0,1,2,3},{0,0,4,4}, {{SIMPLEREGION, {0,1,2,3}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {NULLREGION,   {0,0,0,0}}}}, // center-left
63c2c66affSColin Finck     {{1,0,3,2},{0,0,4,4}, {{SIMPLEREGION, {1,0,3,2}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {NULLREGION,   {0,0,0,0}}}}, // center-top
64c2c66affSColin Finck     {{2,1,4,3},{0,0,4,4}, {{SIMPLEREGION, {2,1,4,3}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {NULLREGION,   {0,0,0,0}}}}, // center-right
65c2c66affSColin Finck     {{1,2,3,4},{0,0,4,4}, {{SIMPLEREGION, {1,2,3,4}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {NULLREGION,   {0,0,0,0}}}}, // center-bottom
66c2c66affSColin Finck     {{1,1,3,4},{0,0,4,4}, {{SIMPLEREGION, {1,1,3,4}}, {SIMPLEREGION, {0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {NULLREGION,   {0,0,0,0}}}}, // center
67c2c66affSColin Finck 
68c2c66affSColin Finck     /* rgn 2 is adjacent to rgn 1 */
69c2c66affSColin Finck     {{2,2,4,4},{0,2,2,4}, {{NULLREGION,   {0,0,0,0}}, {SIMPLEREGION, {0,2,4,4}}, {SIMPLEREGION, {0,2,4,4}}, {SIMPLEREGION, {2,2,4,4}}}}, // left-fit
70c2c66affSColin Finck     {{2,2,4,4},{0,1,2,5}, {{NULLREGION,   {0,0,0,0}}, {COMPLEXREGION,{0,1,4,5}}, {COMPLEXREGION,{0,1,4,5}}, {SIMPLEREGION, {2,2,4,4}}}}, // left-larger
71c2c66affSColin Finck     {{2,2,4,4},{0,3,2,4}, {{NULLREGION,   {0,0,0,0}}, {COMPLEXREGION,{0,2,4,4}}, {COMPLEXREGION,{0,2,4,4}}, {SIMPLEREGION, {2,2,4,4}}}}, // left-smaller
72c2c66affSColin Finck     {{2,2,4,4},{2,0,4,2}, {{NULLREGION,   {0,0,0,0}}, {SIMPLEREGION, {2,0,4,4}}, {SIMPLEREGION, {2,0,4,4}}, {SIMPLEREGION, {2,2,4,4}}}}, // top-fit
73c2c66affSColin Finck     {{2,2,4,4},{1,0,5,2}, {{NULLREGION,   {0,0,0,0}}, {COMPLEXREGION,{1,0,5,4}}, {COMPLEXREGION,{1,0,5,4}}, {SIMPLEREGION, {2,2,4,4}}}}, // top-larger
74c2c66affSColin Finck     {{2,2,4,4},{3,0,4,2}, {{NULLREGION,   {0,0,0,0}}, {COMPLEXREGION,{2,0,4,4}}, {COMPLEXREGION,{2,0,4,4}}, {SIMPLEREGION, {2,2,4,4}}}}, // top-smaller
75c2c66affSColin Finck     {{2,2,4,4},{4,2,6,4}, {{NULLREGION,   {0,0,0,0}}, {SIMPLEREGION, {2,2,6,4}}, {SIMPLEREGION, {2,2,6,4}}, {SIMPLEREGION, {2,2,4,4}}}}, // right-fit
76c2c66affSColin Finck     {{2,2,4,4},{4,1,6,5}, {{NULLREGION,   {0,0,0,0}}, {COMPLEXREGION,{2,1,6,5}}, {COMPLEXREGION,{2,1,6,5}}, {SIMPLEREGION, {2,2,4,4}}}}, // right-larger
77c2c66affSColin Finck     {{2,2,4,4},{4,3,6,4}, {{NULLREGION,   {0,0,0,0}}, {COMPLEXREGION,{2,2,6,4}}, {COMPLEXREGION,{2,2,6,4}}, {SIMPLEREGION, {2,2,4,4}}}}, // right-smaller
78c2c66affSColin Finck     {{2,2,4,4},{2,4,4,6}, {{NULLREGION,   {0,0,0,0}}, {SIMPLEREGION, {2,2,4,6}}, {SIMPLEREGION, {2,2,4,6}}, {SIMPLEREGION, {2,2,4,4}}}}, // bottom-fit
79c2c66affSColin Finck     {{2,2,4,4},{1,4,5,6}, {{NULLREGION,   {0,0,0,0}}, {COMPLEXREGION,{1,2,5,6}}, {COMPLEXREGION,{1,2,5,6}}, {SIMPLEREGION, {2,2,4,4}}}}, // bottom-larger
80c2c66affSColin Finck     {{2,2,4,4},{3,4,4,6}, {{NULLREGION,   {0,0,0,0}}, {COMPLEXREGION,{2,2,4,6}}, {COMPLEXREGION,{2,2,4,6}}, {SIMPLEREGION, {2,2,4,4}}}}, // bottom-smaller
81c2c66affSColin Finck 
82c2c66affSColin Finck     /* rgn 2 overlaps rgn 1 */
83c2c66affSColin Finck     {{2,2,4,4},{0,2,3,4}, {{SIMPLEREGION, {2,2,3,4}}, {SIMPLEREGION, {0,2,4,4}}, {COMPLEXREGION,{0,2,4,4}}, {SIMPLEREGION, {3,2,4,4}}}}, // left-fit
84c2c66affSColin Finck     {{2,2,4,4},{0,1,3,5}, {{SIMPLEREGION, {2,2,3,4}}, {COMPLEXREGION,{0,1,4,5}}, {COMPLEXREGION,{0,1,4,5}}, {SIMPLEREGION, {3,2,4,4}}}}, // left-larger
85c2c66affSColin Finck     {{2,2,4,4},{0,3,3,4}, {{SIMPLEREGION, {2,3,3,4}}, {COMPLEXREGION,{0,2,4,4}}, {COMPLEXREGION,{0,2,4,4}}, {COMPLEXREGION,{2,2,4,4}}}}, // left-smaller
86c2c66affSColin Finck     {{2,2,4,4},{2,0,4,3}, {{SIMPLEREGION, {2,2,4,3}}, {SIMPLEREGION, {2,0,4,4}}, {COMPLEXREGION,{2,0,4,4}}, {SIMPLEREGION, {2,3,4,4}}}}, // top-fit
87c2c66affSColin Finck     {{2,2,4,4},{1,0,5,3}, {{SIMPLEREGION, {2,2,4,3}}, {COMPLEXREGION,{1,0,5,4}}, {COMPLEXREGION,{1,0,5,4}}, {SIMPLEREGION, {2,3,4,4}}}}, // top-larger
88c2c66affSColin Finck     {{2,2,4,4},{3,0,4,3}, {{SIMPLEREGION, {3,2,4,3}}, {COMPLEXREGION,{2,0,4,4}}, {COMPLEXREGION,{2,0,4,4}}, {COMPLEXREGION,{2,2,4,4}}}}, // top-smaller
89c2c66affSColin Finck     {{2,2,4,4},{3,2,6,4}, {{SIMPLEREGION, {3,2,4,4}}, {SIMPLEREGION, {2,2,6,4}}, {COMPLEXREGION,{2,2,6,4}}, {SIMPLEREGION, {2,2,3,4}}}}, // right-fit
90c2c66affSColin Finck     {{2,2,4,4},{3,1,6,5}, {{SIMPLEREGION, {3,2,4,4}}, {COMPLEXREGION,{2,1,6,5}}, {COMPLEXREGION,{2,1,6,5}}, {SIMPLEREGION, {2,2,3,4}}}}, // right-larger
91c2c66affSColin Finck     {{2,2,4,4},{3,3,6,4}, {{SIMPLEREGION, {3,3,4,4}}, {COMPLEXREGION,{2,2,6,4}}, {COMPLEXREGION,{2,2,6,4}}, {COMPLEXREGION,{2,2,4,4}}}}, // right-smaller
92c2c66affSColin Finck     {{2,2,4,4},{2,3,4,6}, {{SIMPLEREGION, {2,3,4,4}}, {SIMPLEREGION, {2,2,4,6}}, {COMPLEXREGION,{2,2,4,6}}, {SIMPLEREGION, {2,2,4,3}}}}, // bottom-fit
93c2c66affSColin Finck     {{2,2,4,4},{1,3,5,6}, {{SIMPLEREGION, {2,3,4,4}}, {COMPLEXREGION,{1,2,5,6}}, {COMPLEXREGION,{1,2,5,6}}, {SIMPLEREGION, {2,2,4,3}}}}, // bottom-larger
94c2c66affSColin Finck     {{2,2,4,4},{3,3,4,6}, {{SIMPLEREGION, {3,3,4,4}}, {COMPLEXREGION,{2,2,4,6}}, {COMPLEXREGION,{2,2,4,6}}, {COMPLEXREGION,{2,2,4,4}}}}, // bottom-smaller
95c2c66affSColin Finck     {{2,2,4,4},{0,0,3,3}, {{SIMPLEREGION, {2,2,3,3}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{0,0,4,4}}, {COMPLEXREGION,{2,2,4,4}}}}, // top-left
96c2c66affSColin Finck     {{2,2,4,4},{3,0,6,3}, {{SIMPLEREGION, {3,2,4,3}}, {COMPLEXREGION,{2,0,6,4}}, {COMPLEXREGION,{2,0,6,4}}, {COMPLEXREGION,{2,2,4,4}}}}, // top-right
97c2c66affSColin Finck     {{2,2,4,4},{0,3,3,6}, {{SIMPLEREGION, {2,3,3,4}}, {COMPLEXREGION,{0,2,4,6}}, {COMPLEXREGION,{0,2,4,6}}, {COMPLEXREGION,{2,2,4,4}}}}, // bottom-left
98c2c66affSColin Finck     {{2,2,4,4},{3,3,6,6}, {{SIMPLEREGION, {3,3,4,4}}, {COMPLEXREGION,{2,2,6,6}}, {COMPLEXREGION,{2,2,6,6}}, {COMPLEXREGION,{2,2,4,4}}}}, // bottom-right
99c2c66affSColin Finck 
100c2c66affSColin Finck     };
101c2c66affSColin Finck 
102c2c66affSColin Finck     HRGN hrgn1, hrgn2, hrgn3, hrgnRes;
103c2c66affSColin Finck     RECT rc;
104c2c66affSColin Finck     INT iComplexity;
105c2c66affSColin Finck     UINT i;
106c2c66affSColin Finck 
107c2c66affSColin Finck     hrgn1 =  CreateRectRgn(0, 0, 0, 0);
108c2c66affSColin Finck     hrgn2 =  CreateRectRgn(0, 0, 0, 0);
109c2c66affSColin Finck     hrgn3 =  CreateRectRgn(0, 0, 0, 0);
110c2c66affSColin Finck     hrgnRes = CreateRectRgn(0, 0, 0, 0);
111c2c66affSColin Finck 
112c2c66affSColin Finck     for (i = 0; i < sizeof(aRectTests) / sizeof(aRectTests[0]); i++)
113c2c66affSColin Finck     {
114c2c66affSColin Finck         INT iCombine;
115c2c66affSColin Finck 
116c2c66affSColin Finck         SetRectRgnIndirect(hrgn1, &aRectTests[i].rcSrc1);
117c2c66affSColin Finck         SetRectRgnIndirect(hrgn2, &aRectTests[i].rcSrc2);
118c2c66affSColin Finck 
119c2c66affSColin Finck         for (iCombine = RGN_AND; iCombine <= RGN_DIFF; iCombine++)
120c2c66affSColin Finck         {
121c2c66affSColin Finck             iComplexity = CombineRgn(hrgnRes, hrgn1, hrgn2, iCombine);
122c2c66affSColin Finck             ok(iComplexity == aRectTests[i].res[iCombine-1].iComplexity,
123c2c66affSColin Finck                "#%u (%s), iComplexity does not match: expected %u, got %u\n",
124c2c66affSColin Finck                i, apszRgnOp[iCombine], aRectTests[i].res[iCombine-1].iComplexity, iComplexity);
125c2c66affSColin Finck 
126c2c66affSColin Finck             ok(GetRgnBox(hrgnRes, &rc), "GetRgnBox failed!\n");
127c2c66affSColin Finck             ok(EqualRect(&rc, &aRectTests[i].res[iCombine-1].rcDstBounds),
128c2c66affSColin Finck                "#%u (%s), Bounding box does not match: expected {%ld,%ld,%ld,%ld} got {%ld,%ld,%ld,%ld}\n",
129c2c66affSColin Finck                i, apszRgnOp[iCombine],
130c2c66affSColin Finck                aRectTests[i].res[iCombine-1].rcDstBounds.left, aRectTests[i].res[iCombine-1].rcDstBounds.top,
131c2c66affSColin Finck                aRectTests[i].res[iCombine-1].rcDstBounds.right, aRectTests[i].res[iCombine-1].rcDstBounds.bottom,
132c2c66affSColin Finck                rc.left, rc.top, rc.right, rc.bottom);
133c2c66affSColin Finck 
134c2c66affSColin Finck             if (aRectTests[i].res[iCombine-1].iComplexity == SIMPLEREGION)
135c2c66affSColin Finck             {
136c2c66affSColin Finck                 SetRectRgnIndirect(hrgn3, &aRectTests[i].res[iCombine-1].rcDstBounds);
137c2c66affSColin Finck                 ok(EqualRgn(hrgnRes, hrgn3), "#%u (%s), regions are not equal\n",
138c2c66affSColin Finck                    i, apszRgnOp[iCombine]);
139c2c66affSColin Finck             }
140c2c66affSColin Finck         }
141c2c66affSColin Finck     }
142c2c66affSColin Finck 
143c2c66affSColin Finck     DeleteObject(hrgn1);
144c2c66affSColin Finck     DeleteObject(hrgn2);
145c2c66affSColin Finck     DeleteObject(hrgn3);
146c2c66affSColin Finck     DeleteObject(hrgnRes);
147c2c66affSColin Finck }
148c2c66affSColin Finck 
149c2c66affSColin Finck 
Test_CombineRgn_Params()150c2c66affSColin Finck void Test_CombineRgn_Params()
151c2c66affSColin Finck {
152c2c66affSColin Finck     HRGN hrgn1, hrgn2, hrgn3;
153c2c66affSColin Finck 
154c2c66affSColin Finck     hrgn1 = CreateRectRgn(0, 0, 0, 0);
155c2c66affSColin Finck     hrgn2 = CreateRectRgn(0, 0, 10, 10);
156c2c66affSColin Finck     hrgn3 = CreateRectRgn(5, 5, 20, 20);
157c2c66affSColin Finck 
158c2c66affSColin Finck     SetLastError(0xbadbabe);
159c2c66affSColin Finck     ok_long(CombineRgn(NULL, NULL, NULL, 0), ERROR);
160c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, 0), ERROR);
161c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, 6), ERROR);
162c2c66affSColin Finck     ok((GetLastError() == 0xbadbabe) || (GetLastError() == ERROR_INVALID_PARAMETER), "wrong error: %ld\n", GetLastError());
163c2c66affSColin Finck 
164c2c66affSColin Finck }
165c2c66affSColin Finck 
Test_CombineRgn_COPY()166c2c66affSColin Finck void Test_CombineRgn_COPY()
167c2c66affSColin Finck {
168c2c66affSColin Finck     HRGN hrgn1, hrgn2, hrgn3;
169c2c66affSColin Finck 
170c2c66affSColin Finck     hrgn1 = CreateRectRgn(0, 0, 0, 0);
171c2c66affSColin Finck     hrgn2 = CreateRectRgn(0, 0, 10, 10);
172c2c66affSColin Finck     hrgn3 = CreateRectRgn(5, 5, 20, 20);
173c2c66affSColin Finck 
174c2c66affSColin Finck     SetLastError(0xbadbabe);
175c2c66affSColin Finck     ok_long(CombineRgn(NULL, NULL, NULL, RGN_COPY), ERROR);
176c2c66affSColin Finck     ok_long(CombineRgn(NULL, hrgn1, NULL, RGN_COPY), ERROR);
177c2c66affSColin Finck     ok_long(CombineRgn(NULL, NULL, hrgn1, RGN_COPY), ERROR);
178c2c66affSColin Finck     ok_long(CombineRgn(NULL, hrgn1, hrgn2, RGN_COPY), ERROR);
179c2c66affSColin Finck     ok((GetLastError() == 0xbadbabe) || (GetLastError() == ERROR_INVALID_HANDLE), "wrong error: %ld\n", GetLastError());
180c2c66affSColin Finck 
181c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_COPY), SIMPLEREGION);
182c2c66affSColin Finck     ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
183c2c66affSColin Finck 
184c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn1, NULL, RGN_COPY), SIMPLEREGION);
185c2c66affSColin Finck     ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
186c2c66affSColin Finck 
187c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn3, GetStockObject(BLACK_PEN), RGN_COPY), SIMPLEREGION);
188c2c66affSColin Finck     ok(EqualRgn(hrgn1, hrgn3), "Region is not correct\n");
189c2c66affSColin Finck 
190c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, GetStockObject(BLACK_PEN), hrgn2, RGN_COPY), ERROR);
191c2c66affSColin Finck     ok(EqualRgn(hrgn1, hrgn3), "Region is not correct\n");
192c2c66affSColin Finck 
193c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, NULL, hrgn2, RGN_COPY), ERROR);
194c2c66affSColin Finck     ok(EqualRgn(hrgn1, hrgn3), "Region is not correct\n");
195c2c66affSColin Finck 
196c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, NULL, NULL, RGN_COPY), ERROR);
197c2c66affSColin Finck     ok(EqualRgn(hrgn1, hrgn3), "Region is not correct\n");
198c2c66affSColin Finck 
199c2c66affSColin Finck     ok((GetLastError() == 0xbadbabe) || (GetLastError() == ERROR_INVALID_HANDLE), "wrong error: %ld\n", GetLastError());
200c2c66affSColin Finck 
201c2c66affSColin Finck }
202c2c66affSColin Finck 
Test_CombineRgn_AND()203c2c66affSColin Finck void Test_CombineRgn_AND()
204c2c66affSColin Finck {
205c2c66affSColin Finck     HRGN hrgn1, hrgn2, hrgn3;
206c2c66affSColin Finck 
207c2c66affSColin Finck     hrgn1 = CreateRectRgn(0, 0, 0, 0);
208c2c66affSColin Finck     hrgn2 = CreateRectRgn(0, 0, 10, 10);
209c2c66affSColin Finck     hrgn3 = CreateRectRgn(5, 5, 20, 20);
210c2c66affSColin Finck 
211c2c66affSColin Finck     SetLastError(0xbadbabe);
212c2c66affSColin Finck     ok_long(CombineRgn(NULL, NULL, NULL, RGN_AND), ERROR);
213c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, NULL, NULL, RGN_AND), ERROR);
214c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn2, NULL, RGN_AND), ERROR);
215c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, NULL, hrgn2, RGN_AND), ERROR);
216c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, GetStockObject(BLACK_PEN), hrgn2, RGN_AND), ERROR);
217c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn2, GetStockObject(BLACK_PEN), RGN_AND), ERROR);
218c2c66affSColin Finck     ok((GetLastError() == 0xbadbabe) || (GetLastError() == ERROR_INVALID_HANDLE), "wrong error: %ld\n", GetLastError());
219c2c66affSColin Finck 
220c2c66affSColin Finck 
221c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_AND), SIMPLEREGION);
222c2c66affSColin Finck     SetRectRgn(hrgn2, 5, 5, 10, 10);
223c2c66affSColin Finck     ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
224c2c66affSColin Finck 
225c2c66affSColin Finck     SetRectRgn(hrgn2, 0, 0, 5, 5);
226c2c66affSColin Finck     SetRectRgn(hrgn3, 5, 0, 10, 5);
227c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_AND), NULLREGION);
228c2c66affSColin Finck     SetRectRgn(hrgn2, 0, 0, 0, 0);
229c2c66affSColin Finck     ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
230c2c66affSColin Finck 
231c2c66affSColin Finck     SetRectRgn(hrgn2, 0, 0, 20, 20);
232c2c66affSColin Finck     SetRectRgn(hrgn3, 5, 5, 10, 10);
233c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_AND), SIMPLEREGION);
234c2c66affSColin Finck     SetRectRgn(hrgn2, 5, 5, 10, 10);
235c2c66affSColin Finck     ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
236c2c66affSColin Finck 
237c2c66affSColin Finck 
238c2c66affSColin Finck     SetRectRgn(hrgn2, 0, 0, 30, 10);
239c2c66affSColin Finck     SetRectRgn(hrgn3, 10, 10, 20, 30);
240c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_OR), COMPLEXREGION);
241c2c66affSColin Finck     SetRectRgn(hrgn2, 10, 0, 30, 30);
242c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_AND), COMPLEXREGION);
243c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn1, hrgn1, RGN_AND), COMPLEXREGION);
244c2c66affSColin Finck     SetRectRgn(hrgn2, 10, 10, 30, 30);
245c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_AND), SIMPLEREGION);
246c2c66affSColin Finck     SetRectRgn(hrgn2, 0, 0, 10, 10);
247c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_AND), NULLREGION);
248c2c66affSColin Finck 
249c2c66affSColin Finck     SetRectRgn(hrgn1, 0, 0, 30, 10);
250c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn1, hrgn1, RGN_AND), SIMPLEREGION);
251c2c66affSColin Finck 
252c2c66affSColin Finck }
253c2c66affSColin Finck 
Test_CombineRgn_OR()254c2c66affSColin Finck void Test_CombineRgn_OR()
255c2c66affSColin Finck {
256c2c66affSColin Finck     HRGN hrgn1, hrgn2, hrgn3;
257c2c66affSColin Finck 
258c2c66affSColin Finck     hrgn1 = CreateRectRgn(0, 0, 0, 0);
259c2c66affSColin Finck     hrgn2 = CreateRectRgn(0, 0, 5, 5);
260c2c66affSColin Finck     hrgn3 = CreateRectRgn(5, 0, 10, 5);
261c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_OR), SIMPLEREGION);
262c2c66affSColin Finck     SetRectRgn(hrgn2, 0, 0, 10, 5);
263c2c66affSColin Finck     ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
264c2c66affSColin Finck 
265c2c66affSColin Finck     SetRectRgn(hrgn2, 0, 0, 10, 10);
266c2c66affSColin Finck     SetRectRgn(hrgn3, 10, 10, 20, 20);
267c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_OR), COMPLEXREGION);
268c2c66affSColin Finck     SetRectRgn(hrgn2, 10, 0, 20, 10);
269c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_OR), COMPLEXREGION);
270c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn1, hrgn1, RGN_OR), COMPLEXREGION);
271c2c66affSColin Finck     SetRectRgn(hrgn2, 0, 10, 10, 20);
272c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_OR), SIMPLEREGION);
273c2c66affSColin Finck     SetRectRgn(hrgn2, 0, 0, 20, 20);
274c2c66affSColin Finck     ok(EqualRgn(hrgn1, hrgn2), "Region is not correct\n");
275c2c66affSColin Finck 
276c2c66affSColin Finck }
277c2c66affSColin Finck 
Test_CombineRgn_DIFF()278c2c66affSColin Finck void Test_CombineRgn_DIFF()
279c2c66affSColin Finck {
280c2c66affSColin Finck     HRGN hrgn1, hrgn2, hrgn3;
281c2c66affSColin Finck 
282c2c66affSColin Finck     hrgn1 = CreateRectRgn(0, 0, 0, 0);
283c2c66affSColin Finck     hrgn2 = CreateRectRgn(0, 0, 10, 10);
284c2c66affSColin Finck     hrgn3 = CreateRectRgn(5, 0, 10, 5);
285c2c66affSColin Finck 
286c2c66affSColin Finck     SetLastError(0xbadbabe);
287c2c66affSColin Finck     ok_long(CombineRgn(NULL, NULL, NULL, RGN_DIFF), ERROR);
288c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, NULL, NULL, RGN_DIFF), ERROR);
289c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn2, NULL, RGN_DIFF), ERROR);
290c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, NULL, hrgn2, RGN_DIFF), ERROR);
291c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, GetStockObject(BLACK_PEN), hrgn2, RGN_DIFF), ERROR);
292c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn2, GetStockObject(BLACK_PEN), RGN_DIFF), ERROR);
293c2c66affSColin Finck     ok((GetLastError() == 0xbadbabe) || (GetLastError() == ERROR_INVALID_HANDLE), "wrong error: %ld\n", GetLastError());
294c2c66affSColin Finck 
295c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn1, hrgn1, RGN_DIFF), NULLREGION);
296c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn2, hrgn2, RGN_DIFF), NULLREGION);
297c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_DIFF), NULLREGION);
298c2c66affSColin Finck 
299c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn2, hrgn1, RGN_DIFF), SIMPLEREGION);
300c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_DIFF), COMPLEXREGION);
301c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn1, hrgn3, RGN_DIFF), COMPLEXREGION);
302c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_DIFF), NULLREGION);
303c2c66affSColin Finck 
304c2c66affSColin Finck 
305c2c66affSColin Finck }
306c2c66affSColin Finck 
Test_CombineRgn_XOR()307c2c66affSColin Finck void Test_CombineRgn_XOR()
308c2c66affSColin Finck {
309c2c66affSColin Finck     HRGN hrgn1, hrgn2, hrgn3, hrgn4;
310c2c66affSColin Finck 
311c2c66affSColin Finck     hrgn1 = CreateRectRgn(0, 0, 0, 0);
312c2c66affSColin Finck     hrgn2 = CreateRectRgn(0, 0, 5, 5);
313c2c66affSColin Finck     hrgn3 = CreateRectRgn(5, 5, 10, 10);
314c2c66affSColin Finck     hrgn4 = CreateRectRgn(0, 0, 0, 0);
315c2c66affSColin Finck 
316c2c66affSColin Finck     SetLastError(0xbadbabe);
317c2c66affSColin Finck     ok_long(CombineRgn(NULL, NULL, NULL, RGN_XOR), ERROR);
318c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, NULL, NULL, RGN_XOR), ERROR);
319c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn2, NULL, RGN_XOR), ERROR);
320c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, NULL, hrgn2, RGN_XOR), ERROR);
321c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, GetStockObject(BLACK_PEN), hrgn2, RGN_XOR), ERROR);
322c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn2, GetStockObject(BLACK_PEN), RGN_XOR), ERROR);
323c2c66affSColin Finck     ok((GetLastError() == 0xbadbabe) || (GetLastError() == ERROR_INVALID_HANDLE), "wrong error: %ld\n", GetLastError());
324c2c66affSColin Finck 
325c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn2, hrgn3, RGN_XOR), COMPLEXREGION);
326c2c66affSColin Finck     ok_long(CombineRgn(hrgn4, hrgn2, hrgn3, RGN_OR), COMPLEXREGION);
327c2c66affSColin Finck     ok(EqualRgn(hrgn1, hrgn4), "Region is not correct\n");
328c2c66affSColin Finck 
329c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn1, hrgn2, RGN_XOR), SIMPLEREGION);
330c2c66affSColin Finck     ok(EqualRgn(hrgn1, hrgn3), "Region is not correct\n");
331c2c66affSColin Finck     ok_long(CombineRgn(hrgn1, hrgn1, hrgn3, RGN_XOR), NULLREGION);
332c2c66affSColin Finck 
333c2c66affSColin Finck 
334c2c66affSColin Finck }
335c2c66affSColin Finck 
START_TEST(CombineRgn)336c2c66affSColin Finck START_TEST(CombineRgn)
337c2c66affSColin Finck {
338c2c66affSColin Finck     Test_CombineRgn_Params();
339c2c66affSColin Finck     Test_CombineRgn_COPY();
340c2c66affSColin Finck     Test_CombineRgn_AND();
341c2c66affSColin Finck     Test_CombineRgn_OR();
342c2c66affSColin Finck     Test_CombineRgn_DIFF();
343c2c66affSColin Finck     Test_CombineRgn_XOR();
344c2c66affSColin Finck     Test_RectRegions();
345c2c66affSColin Finck }
346c2c66affSColin Finck 
347