Re: [PATCH] gdi32/tests: Check values returned from GetPath
On Wed, Feb 17, 2016 at 02:01:25PM +1100, Alistair Leslie-Hughes wrote:
diff --git a/dlls/gdi32/tests/metafile.c b/dlls/gdi32/tests/metafile.c index 6804a96..b3f164d 100644 --- a/dlls/gdi32/tests/metafile.c +++ b/dlls/gdi32/tests/metafile.c @@ -3361,12 +3361,46 @@ static void test_emf_polybezier(void) DeleteEnhMetaFile(hemf); }
+static const unsigned char EMF_PATH_BITS[] = +{ + 0x01, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xdd, 0xff, 0xff, 0xff, 0xdd, 0xff, 0xff, 0xff, + 0x20, 0x45, 0x4d, 0x46, 0x00, 0x00, 0x01, 0x00, + 0xe0, 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, + 0xc4, 0x01, 0x00, 0x00, 0x69, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xe3, 0xe3, 0x06, 0x00, + 0x1c, 0x83, 0x05, 0x00, 0x3b, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, + 0x96, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, + 0x96, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00 +}; + static void test_emf_GetPath(void) { HDC hdcMetafile; HENHMETAFILE hemf; BOOL ret; int size; + POINT *points; + BYTE *types;
SetLastError(0xdeadbeef); hdcMetafile = CreateEnhMetaFileA(GetDC(0), NULL, NULL, NULL); @@ -3387,10 +3421,37 @@ static void test_emf_GetPath(void)
size = GetPath(hdcMetafile, NULL, NULL, 0); todo_wine ok( size == 5, "GetPath returned %d.\n", size); + if(size == 5) + { + points = HeapAlloc(GetProcessHeap(), 0, size * sizeof(POINT)); + types = HeapAlloc(GetProcessHeap(), 0, size ); + + GetPath(hdcMetafile, points, types, size); + + ok(types[0] == PT_MOVETO, "unexpected value %d\n", types[0]); + ok(points[0].x == 50 && points[0].y == 50, "unexpected point (%d,%d)\n", points[0].x, points[0].y); + ok(types[1] == PT_LINETO, "unexpected value %d\n", types[1]); + ok(points[1].x == 50 && points[1].y == 150, "unexpected point (%d,%d)\n", points[1].x, points[1].y); + ok(types[2] == PT_LINETO, "unexpected value %d\n", types[2]); + ok(points[2].x == 150 && points[2].y == 150, "unexpected point (%d,%d)\n", points[2].x, points[2].y); + ok(types[3] == PT_LINETO, "unexpected value %d\n", types[3]); + ok(points[3].x == 150 && points[3].y == 50, "unexpected point (%d,%d)\n", points[3].x, points[3].y); + ok(types[4] == PT_LINETO, "unexpected value %d\n", types[4]); + ok(points[4].x == 50 && points[4].y == 50, "unexpected point (%d,%d)\n", points[4].x, points[4].y); + + HeapFree(GetProcessHeap(), 0, points); + HeapFree(GetProcessHeap(), 0, types); + }
hemf = CloseEnhMetaFile(hdcMetafile); ok(hemf != 0, "CloseEnhMetaFile error %d\n", GetLastError());
+ if (compare_emf_bits(hemf, EMF_PATH_BITS, sizeof(EMF_PATH_BITS), "test_emf_GetPath", FALSE) != 0) + { + dump_emf_bits(hemf, "test_emf_GetPath"); + dump_emf_records(hemf, "test_emf_GetPath"); + } + DeleteEnhMetaFile(hemf); }
Please add a Rectangle() call to the path building code. This will show that the metafile doesn't just consist of path elements. Also, as discussed yesterday, please add a similar test for wmfs (this could be a separate patch). Thanks, Huw.
participants (1)
-
Huw Davies