gdi32: Add a test for WMF->EMF conversions performed by SetWinMetaFileBits.

These tests currently fail in Wine.
This commit is contained in:
Dmitry Timoshkov 2006-03-30 23:03:02 +09:00 committed by Alexandre Julliard
parent 70afa9214a
commit d53ad9c3f7
1 changed files with 179 additions and 9 deletions

View File

@ -371,7 +371,7 @@ void test_SaveDC(void)
/* with the nominal results. */
/* Maximum size of sample metafiles in bytes. */
#define MF_BUFSIZE 256
#define MF_BUFSIZE 512
/* 8x8 bitmap data for a pattern brush */
static const unsigned char SAMPLE_PATTERN_BRUSH[] = {
@ -468,13 +468,137 @@ static const unsigned char EMF_TEXTOUT_ON_PATH_BITS[] =
0x14, 0x00, 0x00, 0x00
};
static const unsigned char MF_LINETO_BITS[] = {
0x01, 0x00, 0x09, 0x00, 0x00, 0x03, 0x11, 0x00,
0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x13, 0x02,
0x0f, 0x00, 0x37, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00
};
static const unsigned char EMF_LINETO_BITS[] = {
0x01, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x37, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x61, 0x06, 0x00, 0x00, 0xb7, 0x01, 0x00, 0x00,
0x20, 0x45, 0x4d, 0x46, 0x00, 0x00, 0x01, 0x00,
0x38, 0x01, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
0x7c, 0x01, 0x00, 0x00, 0x2c, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0xcc, 0x05, 0x00,
0xe0, 0x93, 0x04, 0x00, 0x46, 0x00, 0x00, 0x00,
0x48, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00,
0x47, 0x44, 0x49, 0x43, 0x01, 0x00, 0x00, 0x80,
0x00, 0x03, 0x00, 0x00, 0x60, 0xe5, 0xf4, 0x73,
0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00,
0x01, 0x00, 0x09, 0x00, 0x00, 0x03, 0x11, 0x00,
0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x13, 0x02,
0x0f, 0x00, 0x37, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x0b, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
0x36, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x37, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
0x25, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x80, 0x25, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0x30, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x0f, 0x00, 0x00, 0x80, 0x4b, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00
};
static const unsigned char EMF_LINETO_MM_ANISOTROPIC_BITS[] = {
0x01, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x37, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x64, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00,
0x20, 0x45, 0x4d, 0x46, 0x00, 0x00, 0x01, 0x00,
0x38, 0x01, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
0x7c, 0x01, 0x00, 0x00, 0x2c, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0xcc, 0x05, 0x00,
0xe0, 0x93, 0x04, 0x00, 0x46, 0x00, 0x00, 0x00,
0x48, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00,
0x47, 0x44, 0x49, 0x43, 0x01, 0x00, 0x00, 0x80,
0x00, 0x03, 0x00, 0x00, 0xa4, 0xfe, 0xf4, 0x73,
0x00, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00,
0x01, 0x00, 0x09, 0x00, 0x00, 0x03, 0x11, 0x00,
0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x13, 0x02,
0x0f, 0x00, 0x37, 0x00, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x0b, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x36, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x37, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
0x25, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x80, 0x25, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0x30, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x0f, 0x00, 0x00, 0x80, 0x4b, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00
};
static const unsigned char EMF_LINETO_MM_TEXT_BITS[] = {
0x01, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x37, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x61, 0x06, 0x00, 0x00, 0xb7, 0x01, 0x00, 0x00,
0x20, 0x45, 0x4d, 0x46, 0x00, 0x00, 0x01, 0x00,
0xe4, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
0x7c, 0x01, 0x00, 0x00, 0x2c, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0xcc, 0x05, 0x00,
0xe0, 0x93, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
0x00, 0x04, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
0x00, 0x04, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00,
0x0f, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x80,
0x25, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0x30, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x80,
0x4b, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x05, 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.
*/
static INT CALLBACK mf_enum_proc(HDC hdc, HANDLETABLE *ht, METARECORD *mr,
INT nobj, LPARAM param)
{
trace("hdc %p, mr->rdFunction %d, mr->rdSize %lu, param %p\n",
trace("hdc %p, mr->rdFunction %04x, mr->rdSize %lu, param %p\n",
hdc, mr->rdFunction, mr->rdSize, (void *)param);
return TRUE;
}
@ -485,7 +609,7 @@ static INT CALLBACK mf_enum_proc(HDC hdc, HANDLETABLE *ht, METARECORD *mr,
static void dump_mf_bits (const HMETAFILE mf, const char *desc)
{
char buf[MF_BUFSIZE];
BYTE buf[MF_BUFSIZE];
UINT mfsize, i;
mfsize = GetMetaFileBitsEx (mf, MF_BUFSIZE, buf);
@ -494,7 +618,7 @@ static void dump_mf_bits (const HMETAFILE mf, const char *desc)
printf ("MetaFile %s has bits:\n{\n ", desc);
for (i=0; i<mfsize; i++)
{
printf ("0x%.2hhx", buf[i]);
printf ("0x%02x", buf[i]);
if (i == mfsize-1)
printf ("\n");
else if (i % 8 == 7)
@ -610,7 +734,7 @@ static void dump_emf_records(const HENHMETAFILE mf, const char *desc)
UINT mfsize, offset;
mfsize = GetEnhMetaFileBits(mf, MF_BUFSIZE, buf);
ok (mfsize > 0, "%s: GetEnhMetaFileBits failed\n", desc);
ok (mfsize > 0, "%s: GetEnhMetaFileBits error %ld\n", desc, GetLastError());
printf("EMF %s has records:\n", desc);
@ -619,7 +743,7 @@ static void dump_emf_records(const HENHMETAFILE mf, const char *desc)
while(offset < mfsize)
{
EMR *emr = (EMR *)(emf + offset);
trace("emr->iType %ld, emr->nSize %lu\n", emr->iType, emr->nSize);
printf("emr->iType %ld, emr->nSize %lu\n", emr->iType, emr->nSize);
/*trace("emr->iType 0x%04lx, emr->nSize 0x%04lx\n", emr->iType, emr->nSize);*/
offset += emr->nSize;
}
@ -639,13 +763,22 @@ static int compare_emf_bits(const HENHMETAFILE mf, const unsigned char *bits,
int diff;
mfsize = GetEnhMetaFileBits(mf, MF_BUFSIZE, buf);
ok (mfsize > 0, "%s: GetEnhMetaFileBits failed\n", desc);
ok (mfsize > 0, "%s: GetEnhMetaFileBits error %ld\n", desc, GetLastError());
if (mfsize < MF_BUFSIZE)
{
if (mfsize != bsize && todo)
{
todo_wine
ok(mfsize == bsize, "%s: mfsize=%d, bsize=%d\n", desc, mfsize, bsize);
}
else
ok(mfsize == bsize, "%s: mfsize=%d, bsize=%d\n", desc, mfsize, bsize);
}
else
ok(bsize >= MF_BUFSIZE, "%s: mfsize > bufsize (%d bytes), bsize=%d\n",
desc, mfsize, bsize);
if (mfsize != bsize)
return -1;
@ -662,7 +795,7 @@ static int compare_emf_bits(const HENHMETAFILE mf, const unsigned char *bits,
ok(diff == 0, "%s: mfsize=%d, bsize=%d, diff=%d\n",
desc, mfsize, bsize, diff);
}
return 0;
return diff;
}
else
{
@ -1027,7 +1160,10 @@ static INT CALLBACK EmfEnumProc(HDC hdc, HANDLETABLE *lpHTable, const ENHMETAREC
* until a record is played which actually outputs something */
PlayEnhMetaFileRecord(hdc, lpHTable, lpEMFR, nObj);
LPtoDP(hdc, mapping, 2);
trace("Meta record: iType = %ld, (%ld,%ld)-(%ld,%ld)\n", lpEMFR->iType, mapping[0].x, mapping[0].y, mapping[1].x, mapping[1].y);
trace("Meta record: iType %ld, nSize %ld, (%ld,%ld)-(%ld,%ld)\n",
lpEMFR->iType, lpEMFR->nSize,
mapping[0].x, mapping[0].y, mapping[1].x, mapping[1].y);
if (lpEMFR->iType == EMR_LINETO)
{
INT x0, y0, x1, y1;
@ -1069,6 +1205,13 @@ static HENHMETAFILE create_converted_emf(const METAFILEPICT *mfp)
ok(ret, "LineTo failed with error %ld\n", GetLastError());
hmf = CloseMetaFile(hdcMf);
ok(hmf != NULL, "CloseMetaFile failed with error %ld\n", GetLastError());
if (compare_mf_bits (hmf, MF_LINETO_BITS, sizeof(MF_LINETO_BITS), "mf_LineTo") != 0)
{
dump_mf_bits(hmf, "mf_LineTo");
EnumMetaFile(0, hmf, mf_enum_proc, 0);
}
size = GetMetaFileBitsEx(hmf, 0, NULL);
ok(size, "GetMetaFileBitsEx failed with error %ld\n", GetLastError());
pBits = HeapAlloc(GetProcessHeap(), 0, size);
@ -1090,7 +1233,16 @@ static void test_mf_conversions(void)
mfp.yExt = 100;
mfp.hMF = NULL;
hemf = create_converted_emf(&mfp);
if (compare_emf_bits(hemf, EMF_LINETO_MM_ANISOTROPIC_BITS, sizeof(EMF_LINETO_MM_ANISOTROPIC_BITS),
"emf_LineTo MM_ANISOTROPIC", TRUE) != 0)
{
dump_emf_bits(hemf, "emf_LineTo MM_ANISOTROPIC");
dump_emf_records(hemf, "emf_LineTo MM_ANISOTROPIC");
}
EnumEnhMetaFile(hdcOffscreen, hemf, EmfEnumProc, &mfp, &rect);
DeleteEnhMetaFile(hemf);
DeleteDC(hdcOffscreen);
}
@ -1106,7 +1258,16 @@ static void test_mf_conversions(void)
mfp.yExt = 0;
mfp.hMF = NULL;
hemf = create_converted_emf(&mfp);
if (compare_emf_bits(hemf, EMF_LINETO_MM_TEXT_BITS, sizeof(EMF_LINETO_MM_TEXT_BITS),
"emf_LineTo MM_TEXT", TRUE) != 0)
{
dump_emf_bits(hemf, "emf_LineTo MM_TEXT");
dump_emf_records(hemf, "emf_LineTo MM_TEXT");
}
EnumEnhMetaFile(hdcOffscreen, hemf, EmfEnumProc, &mfp, &rect);
DeleteEnhMetaFile(hemf);
DeleteDC(hdcOffscreen);
}
@ -1117,7 +1278,16 @@ static void test_mf_conversions(void)
HENHMETAFILE hemf;
RECT rect = { 0, 0, 100, 100 };
hemf = create_converted_emf(NULL);
if (compare_emf_bits(hemf, EMF_LINETO_BITS, sizeof(EMF_LINETO_BITS),
"emf_LineTo NULL", TRUE) != 0)
{
dump_emf_bits(hemf, "emf_LineTo NULL");
dump_emf_records(hemf, "emf_LineTo NULL");
}
EnumEnhMetaFile(hdcOffscreen, hemf, EmfEnumProc, NULL, &rect);
DeleteEnhMetaFile(hemf);
DeleteDC(hdcOffscreen);
}