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