GDI: test the capabilities and properties of a metafile DC
Mike McCormack
mike at codeweavers.com
Tue Nov 16 03:28:14 CST 2004
ChangeLog:
* test the capabilities and properties of a metafile DC
* fix two problems that makes this test crash
-------------- next part --------------
? dlls/gdi/x
? dlls/gdi/tests/gdi32_test.exe-kE1iag.spec.c
Index: dlls/gdi/dc.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/dc.c,v
retrieving revision 1.2
diff -u -r1.2 dc.c
--- dlls/gdi/dc.c 13 Sep 2004 18:03:44 -0000 1.2
+++ dlls/gdi/dc.c 16 Nov 2004 09:07:14 -0000
@@ -698,6 +698,11 @@
else
{
static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
+
+ /* should fail on a metafile DC */
+ if (OBJ_METADC == GetObjectType(hdc))
+ return 0;
+
funcs = DRIVER_load_driver( displayW );
physDev = NULL;
}
Index: dlls/gdi/mfdrv/bitblt.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/mfdrv/bitblt.c,v
retrieving revision 1.6
diff -u -r1.6 bitblt.c
--- dlls/gdi/mfdrv/bitblt.c 4 Mar 2004 20:41:13 -0000 1.6
+++ dlls/gdi/mfdrv/bitblt.c 16 Nov 2004 09:07:14 -0000
@@ -70,7 +70,8 @@
LPBITMAPINFOHEADER lpBMI;
WORD nBPP;
#endif
- GetObjectA(dcSrc->hBitmap, sizeof(BITMAP), &BM);
+ if(0 == GetObjectA(dcSrc->hBitmap, sizeof(BITMAP), &BM))
+ return FALSE;
#ifdef STRETCH_VIA_DIB
nBPP = BM.bmPlanes * BM.bmBitsPixel;
if(nBPP > 8) nBPP = 24; /* FIXME Can't get 16bpp to work for some reason */
Index: dlls/gdi/tests/metafile.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/tests/metafile.c,v
retrieving revision 1.1
diff -u -r1.1 metafile.c
--- dlls/gdi/tests/metafile.c 9 Mar 2004 19:19:53 -0000 1.1
+++ dlls/gdi/tests/metafile.c 16 Nov 2004 09:07:14 -0000
@@ -188,7 +188,86 @@
ok(ReleaseDC(hwnd, hdcDisplay), "ReleaseDC error %ld\n", GetLastError());
}
+void test_metafile_dc_compat(void)
+{
+ HMETAFILE hmf;
+ HDC hmemdc;
+ HBITMAP hAndBits, hXorBits;
+ UINT height = 32, width = 32;
+ HDC hmfdc;
+ unsigned char data[32*32*4];
+ HICON hIcon;
+ unsigned char bAndBits[32*32*1];
+ unsigned char bXorBits[32*32*1];
+
+ /* create an enhanced metafile DC */
+ hmfdc = CreateEnhMetaFile(NULL,NULL,NULL,NULL);
+ ok( hmfdc != NULL, "CreateMetaFile failed\n");
+ ok( GetObjectType(hmfdc) == OBJ_ENHMETADC, "not a enhmeta dc\n" );
+ hmemdc = CreateCompatibleDC(hmfdc);
+ ok( hmemdc != NULL, "CreateCompatibleDC failed\n" );
+ ok( DeleteDC(hmemdc),"DeleteDC failed\n");
+ ok( DeleteDC(hmfdc),"DeleteDC failed\n");
+
+ /* see how a metafile dc differs */
+ hmfdc = CreateMetaFile(NULL);
+ ok( hmfdc != NULL, "CreateMetaFile failed\n");
+ ok( GetObjectType(hmfdc) == OBJ_METADC, "not a meta dc\n" );
+
+ memset( bAndBits, 0, sizeof bAndBits );
+ memset( bXorBits, 0, sizeof bXorBits );
+ hIcon = CreateIcon(NULL, width, height, 1, 8, bAndBits, bXorBits );
+ ok( hIcon != NULL, "failed to create icon\n");
+
+ hmemdc = CreateCompatibleDC(hmfdc);
+ ok( !hmemdc, "CreateCompatibleDC succeeded\n" );
+
+ todo_wine {
+ ok( DrawIcon(hmfdc, 0, 0, hIcon),"failed to draw icon\n");
+ }
+
+ hmemdc = CreateCompatibleDC(NULL);
+ ok( hmemdc != NULL, "CreateCompatibleDC failed\n" );
+ ok( GetObjectType(hmemdc) == OBJ_MEMDC, "not a memory dc\n" );
+
+ hAndBits = CreateBitmap( width, height, 1, 1, data );
+ ok( hAndBits != NULL, "CreateBitmaps hAndBits failed\n" );
+
+ hXorBits = CreateCompatibleBitmap( hmemdc, width, height);
+ ok( hXorBits != NULL, "CreateBitmaps hXorBits failed\n" );
+
+ if(hAndBits && hXorBits)
+ {
+ HBITMAP hBitTemp;
+ BOOL r;
+
+ hBitTemp = SelectObject( hmemdc, hAndBits );
+ ok(hBitTemp != NULL,"SelectObject failed\n");
+
+ todo_wine {
+ r = BitBlt( hmfdc, 0, 0, 32, 32, hmemdc, 0, 0, SRCAND );
+ ok(r, "BitBlt SRCAND failed\n");
+ }
+
+ ok( NULL != SelectObject( hmemdc, hXorBits ), "SelectObject on hXorBits failed\n");
+
+ todo_wine {
+ r = BitBlt( hmfdc, 0, 0, 32, 32, hmemdc, 0, 0, SRCINVERT );
+ ok(r, "BitBlt SRCINVERT failed\n");
+ }
+ }
+ DeleteDC( hmemdc );
+ if(hXorBits)
+ DeleteObject(hXorBits);
+ if(hAndBits)
+ DeleteObject(hAndBits);
+ hmf = CloseMetaFile(hmfdc);
+
+ DeleteObject(hmf);
+}
+
START_TEST(metafile)
{
test_ExtTextOut();
+ test_metafile_dc_compat();
}
More information about the wine-patches
mailing list