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 HBITMAP ghbmpTarget; 11 PULONG gpulTargetBits; 12 HDC hdcTarget; 13 14 void Test_PatBlt_Params() 15 { 16 BOOL ret; 17 ULONG i, rop; 18 HDC hdc; 19 20 /* Test a rop that contains only the operation index */ 21 ret = PatBlt(hdcTarget, 0, 0, 1, 1, PATCOPY & 0x00FF0000); 22 ok_long(ret, 1); 23 24 /* Test a rop that contains arbitrary values outside the operation index */ 25 ret = PatBlt(hdcTarget, 0, 0, 1, 1, (PATCOPY & 0x00FF0000) | 0xab00cdef); 26 ok_long(ret, 1); 27 28 /* Test an invalid rop */ 29 SetLastError(0); 30 ok_long(PatBlt(hdcTarget, 0, 0, 1, 1, SRCCOPY) , 0); 31 ok_err(0); 32 33 /* Test all rops */ 34 for (i = 0; i < 256; i++) 35 { 36 rop = i << 16; 37 ret = PatBlt(hdcTarget, 0, 0, 1, 1, rop); 38 39 /* Only these should succeed (they use no source) */ 40 if ((i == 0) || (i == 5) || (i == 10) || (i == 15) || (i == 80) || 41 (i == 85) || (i == 90) || (i == 95) || (i == 160) || (i == 165) || 42 (i == 170) || (i == 175) || (i == 240) || (i == 245) || 43 (i == 250) || (i == 255)) 44 { 45 ok(ret == 1, "index %ld failed, but should succeed\n", i); 46 } 47 else 48 { 49 ok(ret == 0, "index %ld succeeded, but should fail\n", i); 50 } 51 } 52 53 /* Test quaternary rop, the background part is simply ignored */ 54 ret = PatBlt(hdcTarget, 0, 0, 1, 1, MAKEROP4(PATCOPY, PATINVERT)); 55 ok_long(ret, 1); 56 ret = PatBlt(hdcTarget, 0, 0, 1, 1, MAKEROP4(PATCOPY, SRCCOPY)); 57 ok_long(ret, 1); 58 ret = PatBlt(hdcTarget, 0, 0, 1, 1, MAKEROP4(SRCCOPY, PATCOPY)); 59 ok_long(ret, 0); 60 61 /* Test an info DC */ 62 hdc = CreateICA("DISPLAY", NULL, NULL, NULL); 63 ok(hdc != 0, "\n"); 64 SetLastError(0); 65 ok_long(PatBlt(hdc, 0, 0, 1, 1, PATCOPY), 1); 66 ok_err(0); 67 DeleteDC(hdc); 68 69 /* Test a mem DC without selecting a bitmap */ 70 hdc = CreateCompatibleDC(NULL); 71 ok(hdc != 0, "\n"); 72 ok_long(PatBlt(hdc, 0, 0, 1, 1, PATCOPY), 1); 73 ok_err(0); 74 DeleteDC(hdc); 75 76 77 78 } 79 80 void Test_BrushOrigin() 81 { 82 ULONG aulBits[2] = {0x5555AAAA, 0}; 83 HBITMAP hbmp; 84 HBRUSH hbr; 85 BOOL ret; 86 87 hbmp = CreateBitmap(2, 2, 1, 1, aulBits); 88 if (!hbmp) 89 { 90 printf("Couln not create a bitmap\n"); 91 return; 92 } 93 94 hbr = CreatePatternBrush(hbmp); 95 if (!hbr) 96 { 97 printf("Couln not create a bitmap\n"); 98 return; 99 } 100 101 if (!SelectObject(hdcTarget, hbr)) 102 { 103 printf("failed to select pattern brush\n"); 104 return; 105 } 106 107 ret = PatBlt(hdcTarget, 0, 0, 2, 2, PATCOPY); 108 ok_long(ret, 1); 109 ok_long(gpulTargetBits[0], 0xffffff); 110 ok_long(gpulTargetBits[1], 0); 111 ok_long(gpulTargetBits[16], 0); 112 ok_long(gpulTargetBits[17], 0xffffff); 113 //printf("0x%lx, 0x%lx\n", gpulTargetBits[0], gpulTargetBits[1]); 114 115 ret = PatBlt(hdcTarget, 1, 0, 2, 2, PATCOPY); 116 ok_long(ret, 1); 117 ok_long(gpulTargetBits[0], 0xffffff); 118 ok_long(gpulTargetBits[1], 0); 119 ok_long(gpulTargetBits[2], 0xffffff); 120 ok_long(gpulTargetBits[16], 0); 121 ok_long(gpulTargetBits[17], 0xffffff); 122 ok_long(gpulTargetBits[18], 0); 123 124 } 125 126 START_TEST(PatBlt) 127 { 128 BITMAPINFO bmi; 129 130 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 131 bmi.bmiHeader.biWidth = 16; 132 bmi.bmiHeader.biHeight = -16; 133 bmi.bmiHeader.biPlanes = 1; 134 bmi.bmiHeader.biBitCount = 32; 135 bmi.bmiHeader.biCompression = BI_RGB; 136 bmi.bmiHeader.biSizeImage = 0; 137 bmi.bmiHeader.biXPelsPerMeter = 1; 138 bmi.bmiHeader.biYPelsPerMeter = 1; 139 bmi.bmiHeader.biClrUsed = 0; 140 bmi.bmiHeader.biClrImportant = 0; 141 ghbmpTarget = CreateDIBSection(NULL, 142 &bmi, 143 DIB_RGB_COLORS, 144 (PVOID*)&gpulTargetBits, 145 NULL, 146 0); 147 if (!ghbmpTarget) 148 { 149 printf("Couln not create target bitmap\n"); 150 return; 151 } 152 153 hdcTarget = CreateCompatibleDC(0); 154 if (!hdcTarget) 155 { 156 printf("Couln not create target dc\n"); 157 return; 158 } 159 160 161 if (!SelectObject(hdcTarget, ghbmpTarget)) 162 { 163 printf("Failed to select bitmap\n"); 164 return; 165 } 166 167 Test_PatBlt_Params(); 168 169 Test_BrushOrigin(); 170 171 172 } 173 174