1 /* 2 * PROJECT: ReactOS api tests 3 * LICENSE: GPL - See COPYING in the top level directory 4 * PURPOSE: Test for FrameRgn 5 * PROGRAMMERS: Timo Kreuzer 6 */ 7 8 #include "precomp.h" 9 10 #include "init.h" 11 12 #if 0 13 BOOL 14 MyFrameRgn( 15 HDC hdc, 16 HRGN hrgn, 17 HBRUSH hbr, 18 INT cx, 19 INT cy) 20 { 21 HRGN hrgnTemp; 22 23 hrgnTemp = CreateRectRgn(0, 0, 0, 0); 24 if (hrgnTemp == NULL) 25 { 26 return FALSE; 27 } 28 29 if (CombineRgn(hrgnTemp, hrgn, NULL, RGN_COPY) == ERROR) 30 goto Failure; 31 32 if (OffsetRgn(hrgn, cx, cy) == ERROR) 33 goto Failure; 34 35 if (CombineRgn(hrgnTemp, hrgnTemp, hrgn, RGN_AND) == ERROR) 36 goto Failure; 37 38 if (OffsetRgn(hrgn, -2 * cx, 0) == ERROR) 39 goto Failure; 40 41 if (CombineRgn(hrgnTemp, hrgnTemp, hrgn, RGN_AND) == ERROR) 42 goto Failure; 43 44 if (OffsetRgn(hrgn, 0, -2 * cy) == ERROR) 45 goto Failure; 46 47 if (CombineRgn(hrgnTemp, hrgnTemp, hrgn, RGN_AND) == ERROR) 48 goto Failure; 49 50 if (OffsetRgn(hrgn, 2 * cx, 0) == ERROR) 51 goto Failure; 52 53 if (CombineRgn(hrgnTemp, hrgnTemp, hrgn, RGN_AND) == ERROR) 54 goto Failure; 55 56 if (OffsetRgn(hrgn, -cx, cy) == ERROR) 57 goto Failure; 58 59 if (CombineRgn(hrgnTemp, hrgn, hrgnTemp, RGN_DIFF) == ERROR) 60 goto Failure; 61 62 if (!FillRgn(hdc, hrgnTemp, hbr)) 63 goto Failure; 64 65 DeleteObject(hrgnTemp); 66 return TRUE; 67 68 Failure: 69 DeleteObject(hrgnTemp); 70 return FALSE; 71 } 72 #endif // 0 73 74 static 75 void 76 CheckBitmapBitsWithLine( 77 ULONG Line, 78 HDC hdc, 79 UINT cx, 80 UINT cy, 81 PUCHAR pjBits, 82 COLORREF *pcrColors) 83 { 84 UINT x, y, i; 85 86 for (y = 0; y < cy; y++) 87 { 88 for (x = 0; x < cy; x++) 89 { 90 i = y * cx + x; 91 ok(GetPixel(hdc, x, y) == pcrColors[pjBits[i]], 92 "Wrong pixel at (%u,%u): expected 0x%08lx, got 0x%08lx\n", 93 x, y, pcrColors[pjBits[i]], GetPixel(hdc, x, y)); 94 } 95 } 96 } 97 98 #define CheckBitmapBits(hdc,cx,cy,pj,pcr) \ 99 CheckBitmapBitsWithLine(__LINE__, hdc,cx,cy,pj,pcr) 100 101 void Test_FrameRgn() 102 { 103 RECT rc = {0, 0, 8, 8 }; 104 HRGN hrgn1, hrgn2; 105 BOOL bRet; 106 UCHAR ajBits[64] = { 107 0, 0, 0, 0, 0, 0, 0, 0, // 0000000 108 0, 1, 1, 1, 1, 0, 0, 0, // 0****00 109 0, 1, 2, 2, 1, 0, 0, 0, // 0*xx**0 110 0, 1, 2, 2, 1, 1, 1, 0, // 0*xxx*0 111 0, 1, 1, 1, 2, 2, 1, 0, // 0**xx*0 112 0, 0, 0, 1, 2, 2, 1, 0, // 00****0 113 0, 0, 0, 1, 1, 1, 1, 0, // 0000000 114 0, 0, 0, 0, 0, 0, 0, 0 // 0000000 115 }; 116 COLORREF acrColors[16] = {RGB(0,0,0), RGB(255,255,255), RGB(128,128,128), 0}; 117 118 FillRect(ghdcDIB32, &rc, GetStockObject(BLACK_BRUSH)); 119 120 hrgn1 = CreateRectRgn(1, 1, 5, 5); 121 ok(hrgn1 != NULL, "failed to create region\n"); 122 123 hrgn2 = CreateRectRgn(3, 3, 7, 7); 124 ok(hrgn1 != NULL, "failed to create region\n"); 125 126 CombineRgn(hrgn1, hrgn1, hrgn2, RGN_OR); 127 128 bRet = FillRgn(ghdcDIB32, hrgn1, GetStockObject(GRAY_BRUSH)); 129 ok(bRet != 0, "FrameRgn failed\n"); 130 131 bRet = FrameRgn(ghdcDIB32, hrgn1, GetStockObject(WHITE_BRUSH), 1, 1); 132 ok(bRet != 0, "FrameRgn failed\n"); 133 134 CheckBitmapBits(ghdcDIB32, 8, 8, ajBits, acrColors); 135 136 } 137 138 139 140 START_TEST(FrameRgn) 141 { 142 InitStuff(); 143 Test_FrameRgn(); 144 } 145 146