New version of my test for bug 4543

Charles Davis cdavis at mymail.mines.edu
Thu Nov 19 18:11:08 CST 2009


Ricardo Filipe wrote:
> 2009/11/19 Charles Davis <cdavis at mymail.mines.edu>:
>> Hi,
>>
>> This is a new version of my test for bug 4543. This time, I followed
>> Dmitry's suggestion of using the existing functions for comparing the
>> contents of EMFs. I can't build tests for Windows both due to bug 20763
>> and due to the fact that I don't have any Windows boxes, so once again I
>> need people to run this test on Windows to make sure it's an accurate
>> representation of Windows' behavior. The test currently succeeds on Wine.
>>
>> Thanks in advance.
>>
>> Chip
>>
>> From 574bb4f7b2b90a209b1693b7f8048a2eb271ada8 Mon Sep 17 00:00:00 2001
>> From: Charles Davis <cdavis at mymail.mines.edu>
>> Date: Tue, 17 Nov 2009 11:10:50 -0700
>> Subject: [PATCH] gdi32/tests: Test BitBlt() to an enhanced metafile.
>> To: wine-patches <wine-patches at winehq.org>
>> Reply-To: wine-devel <wine-devel at winehq.org>
>>
>> ---
>>  dlls/gdi32/tests/metafile.c |  125 +++++++++++++++++++++++++++++++++++++++++++
>>  1 files changed, 125 insertions(+), 0 deletions(-)
>>
>> diff --git a/dlls/gdi32/tests/metafile.c b/dlls/gdi32/tests/metafile.c
>> index b559901..3bd413b 100644
>> --- a/dlls/gdi32/tests/metafile.c
>> +++ b/dlls/gdi32/tests/metafile.c
>> @@ -1030,6 +1030,63 @@ static const unsigned char EMF_LINETO_MM_TEXT_BITS[] = {
>>     0x14, 0x00, 0x00, 0x00
>>  };
>>
>> +static const unsigned char EMF_BITBLT[] =
>> +{
>> +    0x01, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x94, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00,
>> +    0x20, 0x45, 0x4d, 0x46, 0x00, 0x00, 0x01, 0x00,
>> +    0xa0, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
>> +    0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x00, 0x04, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
>> +    0xfc, 0x01, 0x00, 0x00, 0x38, 0x01, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x60, 0xc0, 0x07, 0x00,
>> +    0xc0, 0xc2, 0x04, 0x00, 0x4c, 0x00, 0x00, 0x00,
>> +    0xbc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
>> +    0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
>> +    0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0xcc, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f,
>> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x64, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
>> +    0x8c, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
>> +    0x28, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
>> +    0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
>> +    0xc4, 0x0e, 0x00, 0x00, 0xc4, 0x0e, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x4c, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
>> +    0x62, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f,
>> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00,
>> +    0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
>> +    0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
>> +    0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00
>> +};
>> +
>> +
>>  /* For debugging or dumping the raw metafiles produced by
>>  * new test functions.
>>  */
>> @@ -1382,6 +1439,73 @@ static int compare_emf_bits(const HENHMETAFILE mf, const unsigned char *bits,
>>     return 0;
>>  }
>>
>> +
>> +/* tests blitting to an EMF */
>> +static void test_emf_BitBlt(void)
>> +{
>> +    HDC hdcDisplay, hdcMetafile, hdcBitmap;
>> +    HBITMAP hBitmap, hOldBitmap;
>> +    HENHMETAFILE hMetafile;
>> +#define BMP_DIM 4
>> +    BITMAPINFOHEADER bmih =
>> +    {
>> +        sizeof(BITMAPINFOHEADER),
>> +        BMP_DIM,/* biWidth */
>> +        BMP_DIM,/* biHeight */
>> +        1,      /* biPlanes */
>> +        24,     /* biBitCount */
>> +        BI_RGB, /* biCompression */
>> +        0,      /* biXPelsPerMeter */
>> +        0,      /* biYPelsPerMeter */
>> +        0,      /* biClrUsed */
>> +        0,      /* biClrImportant */
>> +    };
>> +    void *bits;
>> +    BOOL ret;
>> +
>> +    hdcDisplay = CreateDCA("DISPLAY", NULL, NULL, NULL);
>> +    ok( hdcDisplay != 0, "CreateDCA error %d\n", GetLastError() );
>> +
>> +    hdcBitmap = CreateCompatibleDC(hdcDisplay);
>> +    ok( hdcBitmap != 0, "CreateCompatibleDC failed\n" );
>> +    bmih.biXPelsPerMeter = MulDiv(GetDeviceCaps(hdcDisplay, LOGPIXELSX), 100, 3937);
>> +    bmih.biYPelsPerMeter = MulDiv(GetDeviceCaps(hdcDisplay, LOGPIXELSY), 100, 3937);
>> +    hBitmap = CreateDIBSection(hdcDisplay, (const BITMAPINFO *)&bmih,
>> +                               DIB_RGB_COLORS, &bits, NULL, 0);
>> +    hOldBitmap = SelectObject(hdcBitmap, hBitmap);
>> +
>> +    hdcMetafile = CreateEnhMetaFileA(hdcBitmap, NULL, NULL, NULL);
>> +    ok( hdcMetafile != 0, "CreateEnhMetaFileA failed\n" );
>> +
>> +    /* First fill the bitmap DC with something recognizable, like BLACKNESS */
>> +    ret = BitBlt(hdcBitmap, 0, 0, BMP_DIM, BMP_DIM, 0, 0, 0, BLACKNESS);
>> +    ok( ret, "BitBlt(BLACKNESS) failed\n" );
>> +
>> +    ret = BitBlt(hdcMetafile, 0, 0, BMP_DIM, BMP_DIM, hdcBitmap, 0, 0, SRCCOPY);
>> +    ok( ret, "BitBlt(SRCCOPY) failed\n" );
>> +    if(0) /* Crashes on wine */
>> +    {
>> +        ret = BitBlt(hdcMetafile, 0, 0, BMP_DIM, BMP_DIM, 0, 0, 0, WHITENESS);
>> +        ok( ret, "BitBlt(WHITENESS) failed\n" );
>> +    }
>> +
>> +    hMetafile = CloseEnhMetaFile(hdcMetafile);
>> +    ok( hMetafile != 0, "CloseEnhMetaFile failed\n" );
>> +
>> +    if(1 || compare_emf_bits(hMetafile, EMF_BITBLT, sizeof(EMF_BITBLT),
>> +        "emf_BitBlt", FALSE) != 0)
>> +    {
>> +        dump_emf_bits(hMetafile, "emf_BitBlt");
>> +        dump_emf_records(hMetafile, "emf_BitBlt");
>> +    }
>> +
>> +    SelectObject(hdcBitmap, hOldBitmap);
>> +    DeleteObject(hBitmap);
>> +    DeleteDC(hdcBitmap);
>> +    DeleteDC(hdcDisplay);
>> +#undef BMP_DIM
>> +}
>> +
>>  /* Test a blank metafile.  May be used as a template for new tests. */
>>
>>  static void test_mf_Blank(void)
>> @@ -2628,6 +2752,7 @@ START_TEST(metafile)
>>     /* For enhanced metafiles (enhmfdrv) */
>>     test_ExtTextOut();
>>     test_SaveDC();
>> +    test_emf_BitBlt();
>>
>>     /* For win-format metafiles (mfdrv) */
>>     test_mf_SaveDC();
>> --
>> 1.6.5.2
>>
>>
>>
>>
>>
> it would really help you get some more tests if you just cross
> compiled the dll, hosted it somewhere and gave the link on the email
> ;) not all of us are on linux when we read the mail or have a compiler
> ready on windows :)
I told you, I can't cross-compile for Windows right now. See bug 20763.

Chip



More information about the wine-devel mailing list