From: Amine Khaldi Date: Wed, 2 Mar 2016 10:35:00 +0000 (+0000) Subject: [GDIPLUS_WINETEST] Sync with Wine Staging 1.9.4. CORE-10912 X-Git-Tag: ReactOS-0.4.1~352 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=fda1ee7c7d17928dcdc728c75195bf0766519b13 [GDIPLUS_WINETEST] Sync with Wine Staging 1.9.4. CORE-10912 svn path=/trunk/; revision=70863 --- diff --git a/rostests/winetests/gdiplus/font.c b/rostests/winetests/gdiplus/font.c index 452383c88f5..0b6fbcbd323 100644 --- a/rostests/winetests/gdiplus/font.c +++ b/rostests/winetests/gdiplus/font.c @@ -733,6 +733,7 @@ static void test_font_metrics(void) static void test_font_substitution(void) { WCHAR ms_shell_dlg[LF_FACESIZE]; + char fallback_font[LF_FACESIZE]; HDC hdc; HFONT hfont; LOGFONTA lf; @@ -779,13 +780,22 @@ static void test_font_substitution(void) status = GdipCreateFontFamilyFromName(nonexistent, NULL, &family); ok(status == FontFamilyNotFound, "expected FontFamilyNotFound, got %d\n", status); + /* nonexistent fonts fallback to Arial, or something else if it's missing */ + strcpy(lf.lfFaceName,"Arial"); + status = GdipCreateFontFromLogfontA(hdc, &lf, &font); + expect(Ok, status); + status = GdipGetLogFontA(font, graphics, &lf); + expect(Ok, status); + strcpy(fallback_font,lf.lfFaceName); + trace("fallback font %s\n", fallback_font); + lstrcpyA(lf.lfFaceName, "ThisFontShouldNotExist"); status = GdipCreateFontFromLogfontA(hdc, &lf, &font); expect(Ok, status); memset(&lf, 0xfe, sizeof(lf)); status = GdipGetLogFontA(font, graphics, &lf); expect(Ok, status); - ok(!lstrcmpA(lf.lfFaceName, "Arial"), "wrong face name %s\n", lf.lfFaceName); + ok(!lstrcmpA(lf.lfFaceName, fallback_font), "wrong face name %s / %s\n", lf.lfFaceName, fallback_font); GdipDeleteFont(font); /* empty FaceName */ @@ -795,7 +805,7 @@ static void test_font_substitution(void) memset(&lf, 0xfe, sizeof(lf)); status = GdipGetLogFontA(font, graphics, &lf); expect(Ok, status); - ok(!lstrcmpA(lf.lfFaceName, "Arial"), "wrong face name %s\n", lf.lfFaceName); + ok(!lstrcmpA(lf.lfFaceName, fallback_font), "wrong face name %s / %s\n", lf.lfFaceName, fallback_font); GdipDeleteFont(font); /* zeroing out lfWeight and lfCharSet leads to font creation failure */ diff --git a/rostests/winetests/gdiplus/graphicspath.c b/rostests/winetests/gdiplus/graphicspath.c index 1f76f57e5ce..3508de93b72 100644 --- a/rostests/winetests/gdiplus/graphicspath.c +++ b/rostests/winetests/gdiplus/graphicspath.c @@ -93,10 +93,7 @@ static void ok_path(GpPath* path, const path_test_t *expected, INT expected_size return; } - if(todo_size) todo_wine - ok(size == expected_size, "Path size %d does not match expected size %d\n", - size, expected_size); - else + todo_wine_if (todo_size) ok(size == expected_size, "Path size %d does not match expected size %d\n", size, expected_size); @@ -119,11 +116,7 @@ static void ok_path(GpPath* path, const path_test_t *expected, INT expected_size stringify_point_type(expected[eidx].type, ename); stringify_point_type(types[idx], name); - if (expected[eidx].todo || numskip) todo_wine - ok(match, "Expected #%d: %s (%.1f,%.1f) but got %s (%.1f,%.1f)\n", eidx, - ename, expected[eidx].X, expected[eidx].Y, - name, points[idx].X, points[idx].Y); - else + todo_wine_if (expected[eidx].todo || numskip) ok(match, "Expected #%d: %s (%.1f,%.1f) but got %s (%.1f,%.1f)\n", eidx, ename, expected[eidx].X, expected[eidx].Y, name, points[idx].X, points[idx].Y); @@ -1061,6 +1054,155 @@ static void test_flatten(void) GdipDeletePath(path); } +static path_test_t widenline_path[] = { + {5.0, 5.0, PathPointTypeStart, 0, 0}, /*0*/ + {50.0, 5.0, PathPointTypeLine, 0, 0}, /*1*/ + {50.0, 15.0, PathPointTypeLine, 0, 0}, /*2*/ + {5.0, 15.0, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0} /*3*/ + }; + +static path_test_t widenline_wide_path[] = { + {5.0, 0.0, PathPointTypeStart, 0, 0}, /*0*/ + {50.0, 0.0, PathPointTypeLine, 0, 0}, /*1*/ + {50.0, 20.0, PathPointTypeLine, 0, 0}, /*2*/ + {5.0, 20.0, PathPointTypeLine|PathPointTypeCloseSubpath, 0, 0} /*3*/ + }; + +static void test_widen(void) +{ + GpStatus status; + GpPath *path; + GpPen *pen; + GpMatrix *m; + + status = GdipCreatePath(FillModeAlternate, &path); + expect(Ok, status); + status = GdipCreatePen1(0xffffffff, 10.0, UnitPixel, &pen); + expect(Ok, status); + status = GdipCreateMatrix(&m); + expect(Ok, status); + + /* NULL arguments */ + status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0); + expect(Ok, status); + status = GdipWidenPath(NULL, NULL, NULL, 0.0); + expect(InvalidParameter, status); + status = GdipWidenPath(path, pen, m, 0.0); + expect(Ok, status); + status = GdipWidenPath(path, pen, NULL, 1.0); + expect(Ok, status); + status = GdipWidenPath(path, NULL, m, 1.0); + expect(InvalidParameter, status); + status = GdipWidenPath(NULL, pen, m, 1.0); + expect(InvalidParameter, status); + + /* widen empty path */ + status = GdipResetPath(path); + expect(Ok, status); + status = GdipWidenPath(path, pen, m, 1.0); + expect(OutOfMemory, status); + + /* horizontal line */ + status = GdipResetPath(path); + expect(Ok, status); + status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0); + expect(Ok, status); + + status = GdipWidenPath(path, pen, m, 1.0); + expect(Ok, status); + ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE); + + /* horizontal 2x stretch */ + status = GdipResetPath(path); + expect(Ok, status); + status = GdipAddPathLine(path, 2.5, 10.0, 25.0, 10.0); + expect(Ok, status); + + status = GdipScaleMatrix(m, 2.0, 1.0, MatrixOrderAppend); + expect(Ok, status); + + status = GdipWidenPath(path, pen, m, 1.0); + expect(Ok, status); + ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE); + + /* vertical 2x stretch */ + status = GdipResetPath(path); + expect(Ok, status); + status = GdipAddPathLine(path, 5.0, 5.0, 50.0, 5.0); + expect(Ok, status); + + status = GdipScaleMatrix(m, 0.5, 2.0, MatrixOrderAppend); + expect(Ok, status); + + status = GdipWidenPath(path, pen, m, 1.0); + expect(Ok, status); + ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE); + + status = GdipScaleMatrix(m, 1.0, 0.5, MatrixOrderAppend); + expect(Ok, status); + + /* pen width in UnitWorld */ + GdipDeletePen(pen); + status = GdipCreatePen1(0xffffffff, 10.0, UnitWorld, &pen); + expect(Ok, status); + + status = GdipResetPath(path); + expect(Ok, status); + status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0); + expect(Ok, status); + + status = GdipWidenPath(path, pen, m, 1.0); + expect(Ok, status); + ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE); + + /* horizontal 2x stretch */ + status = GdipResetPath(path); + expect(Ok, status); + status = GdipAddPathLine(path, 2.5, 10.0, 25.0, 10.0); + expect(Ok, status); + + status = GdipScaleMatrix(m, 2.0, 1.0, MatrixOrderAppend); + expect(Ok, status); + + status = GdipWidenPath(path, pen, m, 1.0); + expect(Ok, status); + ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE); + + /* vertical 2x stretch */ + status = GdipResetPath(path); + expect(Ok, status); + status = GdipAddPathLine(path, 5.0, 5.0, 50.0, 5.0); + expect(Ok, status); + + status = GdipScaleMatrix(m, 0.5, 2.0, MatrixOrderAppend); + expect(Ok, status); + + status = GdipWidenPath(path, pen, m, 1.0); + expect(Ok, status); + ok_path(path, widenline_wide_path, sizeof(widenline_wide_path)/sizeof(path_test_t), FALSE); + + status = GdipScaleMatrix(m, 1.0, 0.5, MatrixOrderAppend); + expect(Ok, status); + + /* pen width in UnitInch */ + GdipDeletePen(pen); + status = GdipCreatePen1(0xffffffff, 10.0, UnitWorld, &pen); + expect(Ok, status); + + status = GdipResetPath(path); + expect(Ok, status); + status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0); + expect(Ok, status); + + status = GdipWidenPath(path, pen, m, 1.0); + expect(Ok, status); + ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE); + + GdipDeleteMatrix(m); + GdipDeletePen(pen); + GdipDeletePath(path); +} + static void test_isvisible(void) { GpPath *path; @@ -1169,6 +1311,7 @@ START_TEST(graphicspath) test_reverse(); test_addpie(); test_flatten(); + test_widen(); test_isvisible(); test_empty_rect(); diff --git a/rostests/winetests/gdiplus/image.c b/rostests/winetests/gdiplus/image.c index 5796a873051..4f393683a76 100644 --- a/rostests/winetests/gdiplus/image.c +++ b/rostests/winetests/gdiplus/image.c @@ -75,9 +75,7 @@ static void expect_guid(REFGUID expected, REFGUID got, int line, BOOL todo) WideCharToMultiByte(CP_ACP, 0, bufferW, sizeof(bufferW)/sizeof(bufferW[0]), buffer, sizeof(buffer), NULL, NULL); StringFromGUID2(expected, bufferW, sizeof(bufferW)/sizeof(bufferW[0])); WideCharToMultiByte(CP_ACP, 0, bufferW, sizeof(bufferW)/sizeof(bufferW[0]), buffer2, sizeof(buffer2), NULL, NULL); - if(todo) - todo_wine ok_(__FILE__, line)(IsEqualGUID(expected, got), "Expected %s, got %s\n", buffer2, buffer); - else + todo_wine_if (todo) ok_(__FILE__, line)(IsEqualGUID(expected, got), "Expected %s, got %s\n", buffer2, buffer); } @@ -4318,10 +4316,8 @@ static void test_DrawImage_scale(void) expect(Ok, status); match = memcmp(dst_8x1, td[i].image, sizeof(dst_8x1)) == 0; - if (!match && td[i].todo) - todo_wine ok(match, "%d: data should match\n", i); - else - ok(match, "%d: data should match\n", i); + todo_wine_if (!match && td[i].todo) + ok(match, "%d: data should match\n", i); if (!match) { UINT i, size = sizeof(dst_8x1); @@ -4699,9 +4695,7 @@ static void test_supported_encoders(void) ok(hr == S_OK, "CreateStreamOnHGlobal error %#x\n", hr); status = GdipSaveImageToStream((GpImage *)bm, stream, &clsid, NULL); - if (td[i].todo) - todo_wine ok(status == Ok, "GdipSaveImageToStream error %d\n", status); - else + todo_wine_if (td[i].todo) ok(status == Ok, "GdipSaveImageToStream error %d\n", status); IStream_Release(stream); diff --git a/rostests/winetests/gdiplus/metafile.c b/rostests/winetests/gdiplus/metafile.c index 8f203f00ab4..e7a109de3c2 100644 --- a/rostests/winetests/gdiplus/metafile.c +++ b/rostests/winetests/gdiplus/metafile.c @@ -52,11 +52,7 @@ typedef struct emfplus_check_state static void check_record(int count, const char *desc, const struct emfplus_record *expected, const struct emfplus_record *actual) { - if (expected->todo) - todo_wine ok(expected->record_type == actual->record_type, - "%s.%i: Expected record type 0x%x, got 0x%x\n", desc, count, - expected->record_type, actual->record_type); - else + todo_wine_if (expected->todo) ok(expected->record_type == actual->record_type, "%s.%i: Expected record type 0x%x, got 0x%x\n", desc, count, expected->record_type, actual->record_type); @@ -147,9 +143,7 @@ static void check_emfplus(HENHMETAFILE hemf, const emfplus_record *expected, con EnumEnhMetaFile(0, hemf, enum_emf_proc, &state, NULL); - if (expected[state.count].todo) - todo_wine ok(expected[state.count].record_type == 0, "%s: Got %i records, expecting more\n", desc, state.count); - else + todo_wine_if (expected[state.count].todo) ok(expected[state.count].record_type == 0, "%s: Got %i records, expecting more\n", desc, state.count); } @@ -201,9 +195,7 @@ static void check_metafile(GpMetafile *metafile, const emfplus_record *expected, 3, src_rect, src_unit, enum_metafile_proc, &state, NULL); expect(Ok, stat); - if (expected[state.count].todo) - todo_wine ok(expected[state.count].record_type == 0, "%s: Got %i records, expecting more\n", desc, state.count); - else + todo_wine_if (expected[state.count].todo) ok(expected[state.count].record_type == 0, "%s: Got %i records, expecting more\n", desc, state.count); GdipDeleteGraphics(graphics); @@ -221,17 +213,13 @@ static BOOL CALLBACK play_metafile_proc(EmfPlusRecordType record_type, unsigned if (state->expected[state->count].record_type) { - if (state->expected[state->count].playback_todo) - todo_wine ok(stat == Ok, "%s.%i: GdipPlayMetafileRecord failed with stat %i\n", state->desc, state->count, stat); - else + todo_wine_if (state->expected[state->count].playback_todo) ok(stat == Ok, "%s.%i: GdipPlayMetafileRecord failed with stat %i\n", state->desc, state->count, stat); state->count++; } else { - if (state->expected[state->count].playback_todo) - todo_wine ok(0, "%s: too many records\n", state->desc); - else + todo_wine_if (state->expected[state->count].playback_todo) ok(0, "%s: too many records\n", state->desc); return FALSE; diff --git a/rostests/winetests/gdiplus/pen.c b/rostests/winetests/gdiplus/pen.c index 1f59674eacc..be9d9ac8e3b 100644 --- a/rostests/winetests/gdiplus/pen.c +++ b/rostests/winetests/gdiplus/pen.c @@ -372,6 +372,68 @@ static void test_compoundarray(void) GdipDeletePen(pen); } +static void test_transform(void) +{ + GpStatus status; + GpPen *pen; + GpMatrix *matrix, *matrix2; + REAL values[6]; + + status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen); + expect(Ok, status); + + status = GdipCreateMatrix(&matrix); + expect(Ok, status); + + status = GdipGetPenTransform(pen, matrix); + expect(Ok, status); + + status = GdipGetMatrixElements(matrix, values); + expect(Ok, status); + + expectf(1.0, values[0]); + expectf(0.0, values[1]); + expectf(0.0, values[2]); + expectf(1.0, values[3]); + expectf(0.0, values[4]); + expectf(0.0, values[5]); + + GdipCreateMatrix2(3.0, -2.0, 5.0, 2.0, 6.0, 3.0, &matrix2); + status = GdipSetPenTransform(pen, matrix2); + expect(Ok, status); + GdipDeleteMatrix(matrix2); + + status = GdipGetPenTransform(pen, matrix); + expect(Ok, status); + status = GdipGetMatrixElements(matrix, values); + expect(Ok, status); + expectf(3.0, values[0]); + expectf(-2.0, values[1]); + expectf(5.0, values[2]); + expectf(2.0, values[3]); + expectf(6.0, values[4]); + expectf(3.0, values[5]); + + status = GdipResetPenTransform(pen); + expect(Ok, status); + + status = GdipGetPenTransform(pen, matrix); + expect(Ok, status); + status = GdipGetMatrixElements(matrix, values); + expect(Ok, status); + + expectf(1.0, values[0]); + expectf(0.0, values[1]); + expectf(0.0, values[2]); + expectf(1.0, values[3]); + expectf(0.0, values[4]); + expectf(0.0, values[5]); + + GdipDeletePen(pen); + + GdipDeleteMatrix(matrix); +} + START_TEST(pen) { struct GdiplusStartupInput gdiplusStartupInput; @@ -393,6 +455,7 @@ START_TEST(pen) test_customcap(); test_penfilltype(); test_compoundarray(); + test_transform(); GdiplusShutdown(gdiplusToken); }