static void test_getblend(void) { GpStatus status; GpPathGradient *brush; REAL blends[4]; REAL pos[4]; status = GdipCreatePathGradient(getblend_ptf, 2, WrapModeClamp, &brush); expect(Ok, status); /* check some invalid parameters combinations */ status = GdipGetPathGradientBlend(NULL, NULL, NULL, -1); expect(InvalidParameter, status); status = GdipGetPathGradientBlend(brush,NULL, NULL, -1); expect(InvalidParameter, status); status = GdipGetPathGradientBlend(NULL, blends,NULL, -1); expect(InvalidParameter, status); status = GdipGetPathGradientBlend(NULL, NULL, pos, -1); expect(InvalidParameter, status); status = GdipGetPathGradientBlend(NULL, NULL, NULL, 1); expect(InvalidParameter, status); blends[0] = (REAL)0xdeadbeef; pos[0] = (REAL)0xdeadbeef; status = GdipGetPathGradientBlend(brush, blends, pos, 1); expect(Ok, status); expectf(1.0, blends[0]); expectf((REAL)0xdeadbeef, pos[0]); GdipDeleteBrush((GpBrush*) brush); }
static void test_getbounds(void) { GpStatus status; GpPathGradient *brush; GpRectF bounds; status = GdipCreatePathGradient(getbounds_ptf, 4, WrapModeClamp, &brush); expect(Ok, status); status = GdipGetPathGradientRect(NULL, NULL); expect(InvalidParameter, status); status = GdipGetPathGradientRect(brush, NULL); expect(InvalidParameter, status); status = GdipGetPathGradientRect(NULL, &bounds); expect(InvalidParameter, status); status = GdipGetPathGradientRect(brush, &bounds); expect(Ok, status); expectf(0.0, bounds.X); expectf(20.0, bounds.Y); expectf(50.0, bounds.Width); expectf(30.0, bounds.Height); GdipDeleteBrush((GpBrush*) brush); }
main () { expectd (negd (zerod), nzerod); expectf (negf (zerof), nzerof); expectd (negd (nzerod), zerod); expectf (negf (nzerof), zerof); exit (0); }
static void func_ptr_call(void) { expectf(4, ptrtest3(2)); int (*p1)(void) = ptrtest1; expect(55, p1()); int (*p2)(int) = ptrtest2; expect(110, p2(55)); float (*p3)(float) = ptrtest3; expectf(4, p3(2)); int (*p4)(void) = &ptrtest1; expect(55, (**p4)()); }
static void test_inset(void) { GpCustomLineCap *custom; GpPath *path; REAL inset; GpStatus stat; stat = GdipCreatePath(FillModeAlternate, &path); expect(Ok, stat); stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0); expect(Ok, stat); stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &custom); expect(Ok, stat); /* NULL args */ stat = GdipGetCustomLineCapBaseInset(NULL, NULL); expect(InvalidParameter, stat); stat = GdipGetCustomLineCapBaseInset(NULL, &inset); expect(InvalidParameter, stat); stat = GdipGetCustomLineCapBaseInset(custom, NULL); expect(InvalidParameter, stat); /* valid args */ inset = (REAL)0xdeadbeef; stat = GdipGetCustomLineCapBaseInset(custom, &inset); expect(Ok, stat); expectf(0.0, inset); GdipDeleteCustomLineCap(custom); GdipDeletePath(path); }
static void test_scale(void) { GpCustomLineCap *custom; GpPath *path; REAL scale; GpStatus stat; stat = GdipCreatePath(FillModeAlternate, &path); expect(Ok, stat); stat = GdipAddPathRectangle(path, 5.0, 5.0, 10.0, 10.0); expect(Ok, stat); stat = GdipCreateCustomLineCap(NULL, path, LineCapFlat, 0.0, &custom); expect(Ok, stat); /* NULL args */ stat = GdipGetCustomLineCapWidthScale(NULL, NULL); expect(InvalidParameter, stat); stat = GdipGetCustomLineCapWidthScale(NULL, &scale); expect(InvalidParameter, stat); stat = GdipGetCustomLineCapWidthScale(custom, NULL); expect(InvalidParameter, stat); /* valid args */ scale = (REAL)0xdeadbeef; stat = GdipGetCustomLineCapWidthScale(custom, &scale); expect(Ok, stat); expectf(1.0, scale); GdipDeleteCustomLineCap(custom); GdipDeletePath(path); }
static void test_pathgradientcenterpoint(void) { static const GpPointF path_points[] = {{0,0}, {3,0}, {0,4}}; GpStatus status; GpPathGradient *grad; GpPointF point; status = GdipCreatePathGradient(path_points+1, 2, WrapModeClamp, &grad); expect(Ok, status); status = GdipGetPathGradientCenterPoint(NULL, &point); expect(InvalidParameter, status); status = GdipGetPathGradientCenterPoint(grad, NULL); expect(InvalidParameter, status); status = GdipGetPathGradientCenterPoint(grad, &point); expect(Ok, status); expectf(1.5, point.X); expectf(2.0, point.Y); status = GdipSetPathGradientCenterPoint(NULL, &point); expect(InvalidParameter, status); status = GdipSetPathGradientCenterPoint(grad, NULL); expect(InvalidParameter, status); point.X = 10.0; point.Y = 15.0; status = GdipSetPathGradientCenterPoint(grad, &point); expect(Ok, status); point.X = point.Y = -1; status = GdipGetPathGradientCenterPoint(grad, &point); expect(Ok, status); expectf(10.0, point.X); expectf(15.0, point.Y); status = GdipDeleteBrush((GpBrush*)grad); expect(Ok, status); status = GdipCreatePathGradient(path_points, 3, WrapModeClamp, &grad); expect(Ok, status); status = GdipGetPathGradientCenterPoint(grad, &point); expect(Ok, status); todo_wine expectf(1.0, point.X); todo_wine expectf(4.0/3.0, point.Y); status = GdipDeleteBrush((GpBrush*)grad); expect(Ok, status); }
static void test_dasharray(void) { GpPen *pen; GpDashStyle style; GpStatus status; REAL dashes[12]; GdipCreatePen1(0xdeadbeef, 10.0, UnitWorld, &pen); dashes[0] = 10.0; dashes[1] = 11.0; dashes[2] = 12.0; dashes[3] = 13.0; dashes[4] = 14.0; dashes[5] = -100.0; dashes[6] = -100.0; dashes[7] = dashes[8] = dashes[9] = dashes[10] = dashes[11] = 0.0; /* setting the array sets the type to custom */ GdipGetPenDashStyle(pen, &style); expect(DashStyleSolid, style); status = GdipSetPenDashArray(pen, dashes, 2); expect(Ok, status); GdipGetPenDashStyle(pen, &style); expect(DashStyleCustom, style); /* Getting the array on a non-custom pen returns invalid parameter (unless * you are getting 0 elements).*/ GdipSetPenDashStyle(pen, DashStyleSolid); status = GdipGetPenDashArray(pen, &dashes[5], 2); expect(InvalidParameter, status); status = GdipGetPenDashArray(pen, &dashes[5], 0); expect(Ok, status); /* What does setting DashStyleCustom do to the array length? */ GdipSetPenDashArray(pen, dashes, 2); GdipSetPenDashStyle(pen, DashStyleCustom); status = GdipGetPenDashArray(pen, &dashes[5], 2); expect(Ok, status); expectf(10.0, dashes[5]); expectf(11.0, dashes[6]); /* Set the array, then get with different sized buffers. */ status = GdipSetPenDashArray(pen, dashes, 5); expect(Ok, status); dashes[5] = -100.0; dashes[6] = -100.0; status = GdipGetPenDashArray(pen, &dashes[5], 1); expect(Ok, status); /* not InsufficientBuffer! */ expectf(10.0, dashes[5]); expectf(-100.0, dashes[6]); dashes[5] = -100.0; status = GdipGetPenDashArray(pen, &dashes[5], 6); expect(InvalidParameter, status); /* not Ok! */ expectf(-100.0, dashes[5]); expectf(-100.0, dashes[6]); /* Some invalid array values. */ status = GdipSetPenDashArray(pen, &dashes[7], 5); expect(InvalidParameter, status); dashes[9] = -1.0; status = GdipSetPenDashArray(pen, &dashes[7], 5); expect(InvalidParameter, status); /* Try to set with count = 0. */ GdipSetPenDashStyle(pen, DashStyleDot); if (0) /* corrupts stack on 64-bit Vista */ { status = GdipSetPenDashArray(pen, dashes, 0); ok(status == OutOfMemory || status == InvalidParameter, "Expected OutOfMemory or InvalidParameter, got %.8x\n", status); } status = GdipSetPenDashArray(pen, dashes, -1); ok(status == OutOfMemory || status == InvalidParameter, "Expected OutOfMemory or InvalidParameter, got %.8x\n", status); GdipGetPenDashStyle(pen, &style); expect(DashStyleDot, style); 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); todo_wine 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); todo_wine expect(Ok, status); GdipDeleteMatrix(matrix2); status = GdipGetPenTransform(pen, matrix); todo_wine expect(Ok, status); status = GdipGetMatrixElements(matrix, values); expect(Ok, status); todo_wine { 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); todo_wine expect(Ok, status); status = GdipGetPenTransform(pen, matrix); todo_wine 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); }
static void test_font_transform(void) { static const WCHAR string[] = { 'A',0 }; GpStatus status; HDC hdc; LOGFONTA lf; GpFont *font; GpGraphics *graphics; GpMatrix *matrix; GpStringFormat *format, *typographic; PointF pos[1] = { { 0,0 } }; REAL height, margin_y; RectF bounds, rect; hdc = CreateCompatibleDC(0); status = GdipCreateFromHDC(hdc, &graphics); expect(Ok, status); status = GdipSetPageUnit(graphics, UnitPixel); expect(Ok, status); status = GdipCreateStringFormat(0, LANG_NEUTRAL, &format); expect(Ok, status); status = GdipStringFormatGetGenericTypographic(&typographic); expect(Ok, status); memset(&lf, 0, sizeof(lf)); lstrcpyA(lf.lfFaceName, "Tahoma"); lf.lfHeight = -100; lf.lfWidth = 100; status = GdipCreateFontFromLogfontA(hdc, &lf, &font); expect(Ok, status); margin_y = 100.0 / 8.0; /* identity matrix */ status = GdipCreateMatrix(&matrix); expect(Ok, status); status = GdipSetWorldTransform(graphics, matrix); expect(Ok, status); status = GdipGetLogFontA(font, graphics, &lf); expect(Ok, status); expect(-100, lf.lfHeight); expect(0, lf.lfWidth); expect(0, lf.lfEscapement); expect(0, lf.lfOrientation); status = GdipGetFontHeight(font, graphics, &height); expect(Ok, status); expectf(120.703125, height); set_rect_empty(&rect); set_rect_empty(&bounds); status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL); expect(Ok, status); expectf(0.0, bounds.X); expectf(0.0, bounds.Y); todo_wine expectf(height + margin_y, bounds.Height); set_rect_empty(&rect); set_rect_empty(&bounds); status = GdipMeasureString(graphics, string, -1, font, &rect, typographic, &bounds, NULL, NULL); expect(Ok, status); expectf(0.0, bounds.X); expectf(0.0, bounds.Y); expectf_(height, bounds.Height, 1.0); set_rect_empty(&bounds); status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos, DriverStringOptionsCmapLookup, NULL, &bounds); expect(Ok, status); expectf(0.0, bounds.X); expectf_(-100.0, bounds.Y, 0.05); expectf_(height, bounds.Height, 0.5); set_rect_empty(&bounds); status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos, DriverStringOptionsCmapLookup, matrix, &bounds); expect(Ok, status); expectf(0.0, bounds.X); expectf_(-100.0, bounds.Y, 0.05); expectf_(height, bounds.Height, 0.5); /* scale matrix */ status = GdipScaleMatrix(matrix, 2.0, 3.0, MatrixOrderAppend); expect(Ok, status); status = GdipSetWorldTransform(graphics, matrix); expect(Ok, status); status = GdipGetLogFontA(font, graphics, &lf); expect(Ok, status); expect(-300, lf.lfHeight); expect(0, lf.lfWidth); expect(0, lf.lfEscapement); expect(0, lf.lfOrientation); status = GdipGetFontHeight(font, graphics, &height); expect(Ok, status); expectf(120.703125, height); set_rect_empty(&rect); set_rect_empty(&bounds); status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL); expect(Ok, status); expectf(0.0, bounds.X); expectf(0.0, bounds.Y); todo_wine expectf(height + margin_y, bounds.Height); set_rect_empty(&rect); set_rect_empty(&bounds); status = GdipMeasureString(graphics, string, -1, font, &rect, typographic, &bounds, NULL, NULL); expect(Ok, status); expectf(0.0, bounds.X); expectf(0.0, bounds.Y); expectf_(height, bounds.Height, 0.05); set_rect_empty(&bounds); status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos, DriverStringOptionsCmapLookup, NULL, &bounds); expect(Ok, status); expectf(0.0, bounds.X); expectf_(-100.0, bounds.Y, 0.05); expectf_(height, bounds.Height, 0.2); set_rect_empty(&bounds); status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos, DriverStringOptionsCmapLookup, matrix, &bounds); expect(Ok, status); expectf(0.0, bounds.X); todo_wine expectf_(-300.0, bounds.Y, 0.15); todo_wine expectf(height * 3.0, bounds.Height); /* scale + ratate matrix */ status = GdipRotateMatrix(matrix, 45.0, MatrixOrderAppend); expect(Ok, status); status = GdipSetWorldTransform(graphics, matrix); expect(Ok, status); status = GdipGetLogFontA(font, graphics, &lf); expect(Ok, status); expect(-300, lf.lfHeight); expect(0, lf.lfWidth); expect_(3151, lf.lfEscapement, 1); expect_(3151, lf.lfOrientation, 1); status = GdipGetFontHeight(font, graphics, &height); expect(Ok, status); expectf(120.703125, height); set_rect_empty(&rect); set_rect_empty(&bounds); status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL); expect(Ok, status); expectf(0.0, bounds.X); expectf(0.0, bounds.Y); todo_wine expectf(height + margin_y, bounds.Height); set_rect_empty(&rect); set_rect_empty(&bounds); status = GdipMeasureString(graphics, string, -1, font, &rect, typographic, &bounds, NULL, NULL); expect(Ok, status); expectf(0.0, bounds.X); expectf(0.0, bounds.Y); expectf_(height, bounds.Height, 0.05); set_rect_empty(&bounds); status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos, DriverStringOptionsCmapLookup, NULL, &bounds); expect(Ok, status); expectf(0.0, bounds.X); expectf_(-100.0, bounds.Y, 0.05); expectf_(height, bounds.Height, 0.2); set_rect_empty(&bounds); status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos, DriverStringOptionsCmapLookup, matrix, &bounds); expect(Ok, status); todo_wine expectf_(-43.814377, bounds.X, 0.05); todo_wine expectf_(-212.235611, bounds.Y, 0.05); todo_wine expectf_(340.847534, bounds.Height, 0.05); /* scale + ratate + shear matrix */ status = GdipShearMatrix(matrix, 4.0, 5.0, MatrixOrderAppend); expect(Ok, status); status = GdipSetWorldTransform(graphics, matrix); expect(Ok, status); status = GdipGetLogFontA(font, graphics, &lf); expect(Ok, status); todo_wine expect(1032, lf.lfHeight); expect(0, lf.lfWidth); expect_(3099, lf.lfEscapement, 1); expect_(3099, lf.lfOrientation, 1); status = GdipGetFontHeight(font, graphics, &height); expect(Ok, status); expectf(120.703125, height); set_rect_empty(&rect); set_rect_empty(&bounds); status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL); expect(Ok, status); expectf(0.0, bounds.X); expectf(0.0, bounds.Y); todo_wine expectf(height + margin_y, bounds.Height); set_rect_empty(&rect); set_rect_empty(&bounds); status = GdipMeasureString(graphics, string, -1, font, &rect, typographic, &bounds, NULL, NULL); expect(Ok, status); expectf(0.0, bounds.X); expectf(0.0, bounds.Y); expectf_(height, bounds.Height, 0.2); set_rect_empty(&bounds); status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos, DriverStringOptionsCmapLookup, NULL, &bounds); expect(Ok, status); expectf(0.0, bounds.X); expectf_(-100.0, bounds.Y, 0.2); expectf_(height, bounds.Height, 0.2); set_rect_empty(&bounds); status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos, DriverStringOptionsCmapLookup, matrix, &bounds); expect(Ok, status); todo_wine expectf_(-636.706848, bounds.X, 0.05); todo_wine expectf_(-175.257523, bounds.Y, 0.05); todo_wine expectf_(1532.984985, bounds.Height, 0.05); /* scale + ratate + shear + translate matrix */ status = GdipTranslateMatrix(matrix, 10.0, 20.0, MatrixOrderAppend); expect(Ok, status); status = GdipSetWorldTransform(graphics, matrix); expect(Ok, status); status = GdipGetLogFontA(font, graphics, &lf); expect(Ok, status); todo_wine expect(1032, lf.lfHeight); expect(0, lf.lfWidth); expect_(3099, lf.lfEscapement, 1); expect_(3099, lf.lfOrientation, 1); status = GdipGetFontHeight(font, graphics, &height); expect(Ok, status); expectf(120.703125, height); set_rect_empty(&rect); set_rect_empty(&bounds); status = GdipMeasureString(graphics, string, -1, font, &rect, format, &bounds, NULL, NULL); expect(Ok, status); expectf(0.0, bounds.X); expectf(0.0, bounds.Y); todo_wine expectf(height + margin_y, bounds.Height); set_rect_empty(&rect); set_rect_empty(&bounds); status = GdipMeasureString(graphics, string, -1, font, &rect, typographic, &bounds, NULL, NULL); expect(Ok, status); expectf(0.0, bounds.X); expectf(0.0, bounds.Y); expectf_(height, bounds.Height, 0.1); set_rect_empty(&bounds); status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos, DriverStringOptionsCmapLookup, NULL, &bounds); expect(Ok, status); expectf(0.0, bounds.X); expectf_(-100.0, bounds.Y, 0.2); expectf_(height, bounds.Height, 0.2); set_rect_empty(&bounds); status = GdipMeasureDriverString(graphics, (const UINT16 *)string, -1, font, pos, DriverStringOptionsCmapLookup, matrix, &bounds); expect(Ok, status); todo_wine expectf_(-626.706848, bounds.X, 0.05); todo_wine expectf_(-155.257523, bounds.Y, 0.05); todo_wine expectf_(1532.984985, bounds.Height, 0.05); GdipDeleteMatrix(matrix); GdipDeleteFont(font); GdipDeleteGraphics(graphics); GdipDeleteStringFormat(typographic); GdipDeleteStringFormat(format); DeleteDC(hdc); }
static void test_logfont(void) { LOGFONTA lfa, lfa2; GpFont *font; GpFontFamily *family; GpStatus stat; GpGraphics *graphics; HDC hdc = GetDC(0); INT style; REAL rval; UINT16 em_height, line_spacing; Unit unit; GdipCreateFromHDC(hdc, &graphics); memset(&lfa, 0, sizeof(LOGFONTA)); memset(&lfa2, 0xff, sizeof(LOGFONTA)); lstrcpyA(lfa.lfFaceName, "Tahoma"); stat = GdipCreateFontFromLogfontA(hdc, &lfa, &font); expect(Ok, stat); stat = GdipGetLogFontA(font, graphics, &lfa2); expect(Ok, stat); ok(lfa2.lfHeight < 0, "Expected negative height\n"); expect(0, lfa2.lfWidth); expect(0, lfa2.lfEscapement); expect(0, lfa2.lfOrientation); ok((lfa2.lfWeight >= 100) && (lfa2.lfWeight <= 900), "Expected weight to be set\n"); expect(0, lfa2.lfItalic); expect(0, lfa2.lfUnderline); expect(0, lfa2.lfStrikeOut); ok(lfa2.lfCharSet == GetTextCharset(hdc) || lfa2.lfCharSet == ANSI_CHARSET, "Expected %x or %x, got %x\n", GetTextCharset(hdc), ANSI_CHARSET, lfa2.lfCharSet); expect(0, lfa2.lfOutPrecision); expect(0, lfa2.lfClipPrecision); expect(0, lfa2.lfQuality); expect(0, lfa2.lfPitchAndFamily); GdipDeleteFont(font); memset(&lfa, 0, sizeof(LOGFONTA)); lfa.lfHeight = 25; lfa.lfWidth = 25; lfa.lfEscapement = lfa.lfOrientation = 50; lfa.lfItalic = lfa.lfUnderline = lfa.lfStrikeOut = TRUE; memset(&lfa2, 0xff, sizeof(LOGFONTA)); lstrcpyA(lfa.lfFaceName, "Tahoma"); stat = GdipCreateFontFromLogfontA(hdc, &lfa, &font); expect(Ok, stat); stat = GdipGetLogFontA(font, graphics, &lfa2); expect(Ok, stat); ok(lfa2.lfHeight < 0, "Expected negative height\n"); expect(0, lfa2.lfWidth); expect(0, lfa2.lfEscapement); expect(0, lfa2.lfOrientation); ok((lfa2.lfWeight >= 100) && (lfa2.lfWeight <= 900), "Expected weight to be set\n"); expect(TRUE, lfa2.lfItalic); expect(TRUE, lfa2.lfUnderline); expect(TRUE, lfa2.lfStrikeOut); ok(lfa2.lfCharSet == GetTextCharset(hdc) || lfa2.lfCharSet == ANSI_CHARSET, "Expected %x or %x, got %x\n", GetTextCharset(hdc), ANSI_CHARSET, lfa2.lfCharSet); expect(0, lfa2.lfOutPrecision); expect(0, lfa2.lfClipPrecision); expect(0, lfa2.lfQuality); expect(0, lfa2.lfPitchAndFamily); stat = GdipGetFontStyle(font, &style); expect(Ok, stat); ok (style == (FontStyleItalic | FontStyleUnderline | FontStyleStrikeout), "Expected , got %d\n", style); stat = GdipGetFontUnit(font, &unit); expect(Ok, stat); expect(UnitWorld, unit); stat = GdipGetFontHeight(font, graphics, &rval); expect(Ok, stat); expectf(25.347656, rval); stat = GdipGetFontSize(font, &rval); expect(Ok, stat); expectf(21.0, rval); stat = GdipGetFamily(font, &family); expect(Ok, stat); stat = GdipGetEmHeight(family, FontStyleRegular, &em_height); expect(Ok, stat); expect(2048, em_height); stat = GdipGetLineSpacing(family, FontStyleRegular, &line_spacing); expect(Ok, stat); expect(2472, line_spacing); GdipDeleteFontFamily(family); GdipDeleteFont(font); memset(&lfa, 0, sizeof(lfa)); lfa.lfHeight = -25; lstrcpyA(lfa.lfFaceName, "Tahoma"); stat = GdipCreateFontFromLogfontA(hdc, &lfa, &font); expect(Ok, stat); memset(&lfa2, 0xff, sizeof(lfa2)); stat = GdipGetLogFontA(font, graphics, &lfa2); expect(Ok, stat); expect(lfa.lfHeight, lfa2.lfHeight); stat = GdipGetFontUnit(font, &unit); expect(Ok, stat); expect(UnitWorld, unit); stat = GdipGetFontHeight(font, graphics, &rval); expect(Ok, stat); expectf(30.175781, rval); stat = GdipGetFontSize(font, &rval); expect(Ok, stat); expectf(25.0, rval); stat = GdipGetFamily(font, &family); expect(Ok, stat); stat = GdipGetEmHeight(family, FontStyleRegular, &em_height); expect(Ok, stat); expect(2048, em_height); stat = GdipGetLineSpacing(family, FontStyleRegular, &line_spacing); expect(Ok, stat); expect(2472, line_spacing); GdipDeleteFontFamily(family); GdipDeleteFont(font); GdipDeleteGraphics(graphics); ReleaseDC(0, hdc); }
static void test_worldbounds(void) { GpStatus status; GpPath *path; GpPen *pen; GpMatrix *matrix; GpRectF bounds; GpPointF line2_points[10]; int i; for(i = 0; i < 10; i ++){ line2_points[i].X = 200.0 + i * 50.0 * (i % 2); line2_points[i].Y = 200.0 + i * 50.0 * !(i % 2); } GdipCreatePen1((ARGB)0xdeadbeef, 20.0, UnitWorld, &pen); GdipSetPenEndCap(pen, LineCapSquareAnchor); GdipCreateMatrix2(1.5, 0.0, 1.0, 1.2, 10.4, 10.2, &matrix); GdipCreatePath(FillModeAlternate, &path); GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0); GdipAddPathLine2(path, &(line2_points[0]), 10); status = GdipGetPathWorldBounds(path, &bounds, NULL, NULL); expect(Ok, status); GdipDeletePath(path); expectf(200.0, bounds.X); expectf(200.0, bounds.Y); expectf(450.0, bounds.Width); expectf(600.0, bounds.Height); GdipCreatePath(FillModeAlternate, &path); GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0); GdipAddPathLine2(path, &(line2_points[0]), 10); status = GdipGetPathWorldBounds(path, &bounds, matrix, NULL); expect(Ok, status); GdipDeletePath(path); expectf(510.4, bounds.X); expectf(250.2, bounds.Y); expectf(1275.0, bounds.Width); expectf(720.0, bounds.Height); GdipCreatePath(FillModeAlternate, &path); GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0); GdipAddPathLine2(path, &(line2_points[0]), 10); status = GdipGetPathWorldBounds(path, &bounds, NULL, pen); expect(Ok, status); GdipDeletePath(path); expectf(100.0, bounds.X); expectf(100.0, bounds.Y); expectf(650.0, bounds.Width); expectf(800.0, bounds.Height); GdipCreatePath(FillModeAlternate, &path); GdipAddPathLine2(path, &(line2_points[0]), 2); status = GdipGetPathWorldBounds(path, &bounds, NULL, pen); expect(Ok, status); GdipDeletePath(path); expectf(156.0, bounds.X); expectf(156.0, bounds.Y); expectf(138.0, bounds.Width); expectf(88.0, bounds.Height); line2_points[2].X = 2 * line2_points[1].X - line2_points[0].X; line2_points[2].Y = 2 * line2_points[1].Y - line2_points[0].Y; GdipCreatePath(FillModeAlternate, &path); GdipAddPathLine2(path, &(line2_points[0]), 3); status = GdipGetPathWorldBounds(path, &bounds, NULL, pen); expect(Ok, status); GdipDeletePath(path); expectf(100.0, bounds.X); expectf(100.0, bounds.Y); expectf(300.0, bounds.Width); expectf(200.0, bounds.Height); GdipCreatePath(FillModeAlternate, &path); GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 45.0, 20.0); status = GdipGetPathWorldBounds(path, &bounds, NULL, pen); expect(Ok, status); GdipDeletePath(path); expectf(386.7, bounds.X); expectf(553.4, bounds.Y); expectf(266.8, bounds.Width); expectf(289.6, bounds.Height); GdipCreatePath(FillModeAlternate, &path); status = GdipGetPathWorldBounds(path, &bounds, matrix, pen); expect(Ok, status); GdipDeletePath(path); expectf(0.0, bounds.X); expectf(0.0, bounds.Y); expectf(0.0, bounds.Width); expectf(0.0, bounds.Height); GdipCreatePath(FillModeAlternate, &path); GdipAddPathLine2(path, &(line2_points[0]), 2); status = GdipGetPathWorldBounds(path, &bounds, matrix, pen); expect(Ok, status); GdipDeletePath(path); todo_wine{ expectf(427.9, bounds.X); expectf(167.7, bounds.Y); expectf(239.9, bounds.Width); expectf(164.9, bounds.Height); } GdipDeleteMatrix(matrix); GdipCreateMatrix2(0.9, -0.5, -0.5, -1.2, 10.4, 10.2, &matrix); GdipCreatePath(FillModeAlternate, &path); GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0); GdipAddPathLine2(path, &(line2_points[0]), 10); status = GdipGetPathWorldBounds(path, &bounds, matrix, NULL); expect(Ok, status); GdipDeletePath(path); GdipDeleteMatrix(matrix); expectf(-209.6, bounds.X); expectf(-1274.8, bounds.Y); expectf(705.0, bounds.Width); expectf(945.0, bounds.Height); GdipDeletePen(pen); }
static void test_heightgivendpi(void) { GpStatus stat; GpFont* font = NULL; GpFontFamily* fontfamily = NULL; REAL height; Unit unit; stat = GdipCreateFontFamilyFromName(Tahoma, NULL, &fontfamily); expect(Ok, stat); stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitPixel, &font); expect(Ok, stat); stat = GdipGetFontHeightGivenDPI(NULL, 96, &height); expect(InvalidParameter, stat); stat = GdipGetFontHeightGivenDPI(font, 96, NULL); expect(InvalidParameter, stat); stat = GdipGetFontHeightGivenDPI(font, 96, &height); expect(Ok, stat); expectf(36.210938, height); GdipDeleteFont(font); height = 12345; stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitWorld, &font); expect(Ok, stat); stat = GdipGetFontUnit(font, &unit); expect(Ok, stat); expect(UnitWorld, unit); stat = GdipGetFontHeightGivenDPI(font, 96, &height); expect(Ok, stat); expectf(36.210938, height); GdipDeleteFont(font); height = 12345; stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitPoint, &font); expect(Ok, stat); stat = GdipGetFontHeightGivenDPI(font, 96, &height); expect(Ok, stat); expectf(48.281250, height); GdipDeleteFont(font); height = 12345; stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitInch, &font); expect(Ok, stat); stat = GdipGetFontUnit(font, &unit); expect(Ok, stat); expect(UnitInch, unit); stat = GdipGetFontHeightGivenDPI(font, 96, &height); expect(Ok, stat); expectf(3476.250000, height); GdipDeleteFont(font); height = 12345; stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitDocument, &font); expect(Ok, stat); stat = GdipGetFontUnit(font, &unit); expect(Ok, stat); expect(UnitDocument, unit); stat = GdipGetFontHeightGivenDPI(font, 96, &height); expect(Ok, stat); expectf(11.587500, height); GdipDeleteFont(font); height = 12345; stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitMillimeter, &font); expect(Ok, stat); stat = GdipGetFontUnit(font, &unit); expect(Ok, stat); expect(UnitMillimeter, unit); stat = GdipGetFontHeightGivenDPI(font, 96, &height); expect(Ok, stat); expectf(136.860245, height); GdipDeleteFont(font); GdipDeleteFontFamily(fontfamily); }
static void test_tabstops(void) { GpStringFormat *format; GpStatus stat; INT count; REAL tabs[3]; REAL firsttab; stat = GdipCreateStringFormat(0, LANG_NEUTRAL, &format); expect(Ok, stat); /* NULL */ stat = GdipGetStringFormatTabStopCount(NULL, NULL); expect(InvalidParameter, stat); stat = GdipGetStringFormatTabStopCount(NULL, &count); expect(InvalidParameter, stat); stat = GdipGetStringFormatTabStopCount(format, NULL); expect(InvalidParameter, stat); stat = GdipSetStringFormatTabStops(NULL, 0.0, 0, NULL); expect(InvalidParameter, stat); stat = GdipSetStringFormatTabStops(format, 0.0, 0, NULL); expect(InvalidParameter, stat); stat = GdipSetStringFormatTabStops(NULL, 0.0, 0, tabstops); expect(InvalidParameter, stat); stat = GdipGetStringFormatTabStops(NULL, 0, NULL, NULL); expect(InvalidParameter, stat); stat = GdipGetStringFormatTabStops(format, 0, NULL, NULL); expect(InvalidParameter, stat); stat = GdipGetStringFormatTabStops(NULL, 0, &firsttab, NULL); expect(InvalidParameter, stat); stat = GdipGetStringFormatTabStops(NULL, 0, NULL, tabs); expect(InvalidParameter, stat); stat = GdipGetStringFormatTabStops(format, 0, &firsttab, NULL); expect(InvalidParameter, stat); stat = GdipGetStringFormatTabStops(format, 0, NULL, tabs); expect(InvalidParameter, stat); /* not NULL */ stat = GdipGetStringFormatTabStopCount(format, &count); expect(Ok, stat); expect(0, count); /* negative tabcount */ stat = GdipSetStringFormatTabStops(format, 0.0, -1, tabstops); expect(Ok, stat); count = -1; stat = GdipGetStringFormatTabStopCount(format, &count); expect(Ok, stat); expect(0, count); stat = GdipSetStringFormatTabStops(format, -10.0, 0, tabstops); expect(Ok, stat); stat = GdipSetStringFormatTabStops(format, -10.0, 1, tabstops); expect(NotImplemented, stat); firsttab = -1.0; tabs[0] = tabs[1] = tabs[2] = -1.0; stat = GdipGetStringFormatTabStops(format, 0, &firsttab, tabs); expect(Ok, stat); expectf(-1.0, tabs[0]); expectf(-1.0, tabs[1]); expectf(-1.0, tabs[2]); expectf(0.0, firsttab); stat = GdipSetStringFormatTabStops(format, +0.0, 3, tabstops); expect(Ok, stat); count = 0; stat = GdipGetStringFormatTabStopCount(format, &count); expect(Ok, stat); expect(3, count); firsttab = -1.0; tabs[0] = tabs[1] = tabs[2] = -1.0; stat = GdipGetStringFormatTabStops(format, 3, &firsttab, tabs); expect(Ok, stat); expectf(0.0, tabs[0]); expectf(10.0, tabs[1]); expectf(2.0, tabs[2]); expectf(0.0, firsttab); stat = GdipSetStringFormatTabStops(format, 10.0, 3, tabstops); expect(Ok, stat); firsttab = -1.0; tabs[0] = tabs[1] = tabs[2] = -1.0; stat = GdipGetStringFormatTabStops(format, 0, &firsttab, tabs); expect(Ok, stat); expectf(-1.0, tabs[0]); expectf(-1.0, tabs[1]); expectf(-1.0, tabs[2]); expectf(10.0, firsttab); /* zero tabcount, after valid setting to 3 */ stat = GdipSetStringFormatTabStops(format, 0.0, 0, tabstops); expect(Ok, stat); count = 0; stat = GdipGetStringFormatTabStopCount(format, &count); expect(Ok, stat); expect(3, count); stat = GdipDeleteStringFormat(format); expect(Ok, stat); }
static void test_comma(void) { expect(3, (1, 3)); expectf(7.0, (1, 3, 5, 7.0)); }
static void test_pathgradientpresetblend(void) { static const GpPointF path_points[] = {{0,0}, {3,0}, {0,4}}; GpStatus status; GpPathGradient *grad; INT count; int i; const REAL positions[5] = {0.0f, 0.2f, 0.5f, 0.8f, 1.0f}; const REAL two_positions[2] = {0.0f, 1.0f}; const ARGB colors[5] = {0xff0000ff, 0xff00ff00, 0xff00ffff, 0xffff0000, 0xffffffff}; REAL res_positions[6] = {0.3f, 0.0f, 0.0f, 0.0f, 0.0f}; ARGB res_colors[6] = {0xdeadbeef, 0, 0, 0, 0}; status = GdipCreatePathGradient(path_points+1, 2, WrapModeClamp, &grad); expect(Ok, status); status = GdipGetPathGradientPresetBlendCount(NULL, &count); expect(InvalidParameter, status); status = GdipGetPathGradientPresetBlendCount(grad, NULL); expect(InvalidParameter, status); status = GdipGetPathGradientPresetBlendCount(grad, &count); expect(Ok, status); expect(0, count); status = GdipGetPathGradientPresetBlend(NULL, res_colors, res_positions, 1); expect(InvalidParameter, status); status = GdipGetPathGradientPresetBlend(grad, NULL, res_positions, 1); expect(InvalidParameter, status); status = GdipGetPathGradientPresetBlend(grad, res_colors, NULL, 1); expect(InvalidParameter, status); status = GdipGetPathGradientPresetBlend(grad, res_colors, res_positions, 0); expect(InvalidParameter, status); status = GdipGetPathGradientPresetBlend(grad, res_colors, res_positions, -1); expect(OutOfMemory, status); status = GdipGetPathGradientPresetBlend(grad, res_colors, res_positions, 1); expect(InvalidParameter, status); status = GdipGetPathGradientPresetBlend(grad, res_colors, res_positions, 2); expect(GenericError, status); status = GdipSetPathGradientPresetBlend(NULL, colors, positions, 5); expect(InvalidParameter, status); status = GdipSetPathGradientPresetBlend(grad, NULL, positions, 5); expect(InvalidParameter, status); if (0) { /* crashes on windows xp */ status = GdipSetPathGradientPresetBlend(grad, colors, NULL, 5); expect(InvalidParameter, status); } status = GdipSetPathGradientPresetBlend(grad, colors, positions, 0); expect(InvalidParameter, status); status = GdipSetPathGradientPresetBlend(grad, colors, positions, -1); expect(InvalidParameter, status); status = GdipSetPathGradientPresetBlend(grad, colors, positions, 1); expect(InvalidParameter, status); /* leave off the 0.0 position */ status = GdipSetPathGradientPresetBlend(grad, &colors[1], &positions[1], 4); expect(InvalidParameter, status); /* leave off the 1.0 position */ status = GdipSetPathGradientPresetBlend(grad, colors, positions, 4); expect(InvalidParameter, status); status = GdipSetPathGradientPresetBlend(grad, colors, positions, 5); expect(Ok, status); status = GdipGetPathGradientPresetBlendCount(grad, &count); expect(Ok, status); expect(5, count); if (0) { /* Native GdipGetPathGradientPresetBlend seems to copy starting from * the end of each array and do no bounds checking. This is so braindead * I'm not going to copy it. */ res_colors[0] = 0xdeadbeef; res_positions[0] = 0.3; status = GdipGetPathGradientPresetBlend(grad, &res_colors[1], &res_positions[1], 4); expect(Ok, status); expect(0xdeadbeef, res_colors[0]); expectf(0.3, res_positions[0]); for (i=1; i<5; i++) { expect(colors[i], res_colors[i]); expectf(positions[i], res_positions[i]); } status = GdipGetPathGradientPresetBlend(grad, res_colors, res_positions, 6); expect(Ok, status); for (i=0; i<5; i++) { expect(colors[i], res_colors[i+1]); expectf(positions[i], res_positions[i+1]); } } status = GdipGetPathGradientPresetBlend(grad, res_colors, res_positions, 5); expect(Ok, status); for (i=0; i<5; i++) { expect(colors[i], res_colors[i]); expectf(positions[i], res_positions[i]); } status = GdipGetPathGradientPresetBlend(grad, res_colors, res_positions, 0); expect(InvalidParameter, status); status = GdipGetPathGradientPresetBlend(grad, res_colors, res_positions, -1); expect(OutOfMemory, status); status = GdipGetPathGradientPresetBlend(grad, res_colors, res_positions, 1); expect(InvalidParameter, status); status = GdipSetPathGradientPresetBlend(grad, colors, two_positions, 2); expect(Ok, status); status = GdipDeleteBrush((GpBrush*)grad); expect(Ok, status); }
static void test_gradientgetrect(void) { GpLineGradient *brush; GpRectF rectf; GpStatus status; GpPointF pt1, pt2; pt1.X = pt1.Y = 1.0; pt2.X = pt2.Y = 100.0; status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush); expect(Ok, status); memset(&rectf, 0, sizeof(GpRectF)); status = GdipGetLineRect(brush, &rectf); expect(Ok, status); expectf(1.0, rectf.X); expectf(1.0, rectf.Y); expectf(99.0, rectf.Width); expectf(99.0, rectf.Height); status = GdipDeleteBrush((GpBrush*)brush); /* vertical gradient */ pt1.X = pt1.Y = pt2.X = 0.0; pt2.Y = 10.0; status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush); expect(Ok, status); memset(&rectf, 0, sizeof(GpRectF)); status = GdipGetLineRect(brush, &rectf); expect(Ok, status); expectf(-5.0, rectf.X); expectf(0.0, rectf.Y); expectf(10.0, rectf.Width); expectf(10.0, rectf.Height); status = GdipDeleteBrush((GpBrush*)brush); /* horizontal gradient */ pt1.X = pt1.Y = pt2.Y = 0.0; pt2.X = 10.0; status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush); expect(Ok, status); memset(&rectf, 0, sizeof(GpRectF)); status = GdipGetLineRect(brush, &rectf); expect(Ok, status); expectf(0.0, rectf.X); expectf(-5.0, rectf.Y); expectf(10.0, rectf.Width); expectf(10.0, rectf.Height); status = GdipDeleteBrush((GpBrush*)brush); /* slope = -1 */ pt1.X = pt1.Y = 0.0; pt2.X = 20.0; pt2.Y = -20.0; status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush); expect(Ok, status); memset(&rectf, 0, sizeof(GpRectF)); status = GdipGetLineRect(brush, &rectf); expect(Ok, status); expectf(0.0, rectf.X); expectf(-20.0, rectf.Y); expectf(20.0, rectf.Width); expectf(20.0, rectf.Height); status = GdipDeleteBrush((GpBrush*)brush); /* slope = 1/100 */ pt1.X = pt1.Y = 0.0; pt2.X = 100.0; pt2.Y = 1.0; status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush); expect(Ok, status); memset(&rectf, 0, sizeof(GpRectF)); status = GdipGetLineRect(brush, &rectf); expect(Ok, status); expectf(0.0, rectf.X); expectf(0.0, rectf.Y); expectf(100.0, rectf.Width); expectf(1.0, rectf.Height); status = GdipDeleteBrush((GpBrush*)brush); /* from rect with LinearGradientModeHorizontal */ rectf.X = rectf.Y = 10.0; rectf.Width = rectf.Height = 100.0; status = GdipCreateLineBrushFromRect(&rectf, 0, 0, LinearGradientModeHorizontal, WrapModeTile, &brush); expect(Ok, status); memset(&rectf, 0, sizeof(GpRectF)); status = GdipGetLineRect(brush, &rectf); expect(Ok, status); expectf(10.0, rectf.X); expectf(10.0, rectf.Y); expectf(100.0, rectf.Width); expectf(100.0, rectf.Height); status = GdipDeleteBrush((GpBrush*)brush); /* passing negative Width/Height to LinearGradientModeHorizontal */ rectf.X = rectf.Y = 10.0; rectf.Width = rectf.Height = -100.0; status = GdipCreateLineBrushFromRect(&rectf, 0, 0, LinearGradientModeHorizontal, WrapModeTile, &brush); expect(Ok, status); memset(&rectf, 0, sizeof(GpRectF)); status = GdipGetLineRect(brush, &rectf); expect(Ok, status); expectf(10.0, rectf.X); expectf(10.0, rectf.Y); expectf(-100.0, rectf.Width); expectf(-100.0, rectf.Height); status = GdipDeleteBrush((GpBrush*)brush); }
static void test_heightgivendpi(void) { GpStatus stat; GpFont* font = NULL; GpFontFamily* fontfamily = NULL; REAL height; stat = GdipCreateFontFamilyFromName(arial, NULL, &fontfamily); if(stat == FontFamilyNotFound) { skip("Arial not installed\n"); return; } expect(Ok, stat); stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitPixel, &font); expect(Ok, stat); stat = GdipGetFontHeightGivenDPI(NULL, 96, &height); expect(InvalidParameter, stat); stat = GdipGetFontHeightGivenDPI(font, 96, NULL); expect(InvalidParameter, stat); stat = GdipGetFontHeightGivenDPI(font, 96, &height); expect(Ok, stat); expectf((REAL)34.497070, height); GdipDeleteFont(font); height = 12345; stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitWorld, &font); expect(Ok, stat); stat = GdipGetFontHeightGivenDPI(font, 96, &height); expect(Ok, stat); expectf((REAL)34.497070, height); GdipDeleteFont(font); height = 12345; stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitPoint, &font); expect(Ok, stat); stat = GdipGetFontHeightGivenDPI(font, 96, &height); expect(Ok, stat); expectf((REAL)45.996094, height); GdipDeleteFont(font); height = 12345; stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitInch, &font); expect(Ok, stat); stat = GdipGetFontHeightGivenDPI(font, 96, &height); expect(Ok, stat); expectf((REAL)3311.718750, height); GdipDeleteFont(font); height = 12345; stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitDocument, &font); expect(Ok, stat); stat = GdipGetFontHeightGivenDPI(font, 96, &height); expect(Ok, stat); expectf((REAL)11.039062, height); GdipDeleteFont(font); height = 12345; stat = GdipCreateFont(fontfamily, 30, FontStyleRegular, UnitMillimeter, &font); expect(Ok, stat); stat = GdipGetFontHeightGivenDPI(font, 96, &height); expect(Ok, stat); expectf((REAL)130.382614, height); GdipDeleteFont(font); GdipDeleteFontFamily(fontfamily); }
static void test_pathgradientblend(void) { static const GpPointF path_points[] = {{0,0}, {3,0}, {0,4}}; GpPathGradient *brush; GpStatus status; INT count, i; const REAL factors[5] = {0.0f, 0.1f, 0.5f, 0.9f, 1.0f}; const REAL positions[5] = {0.0f, 0.2f, 0.5f, 0.8f, 1.0f}; REAL res_factors[6] = {0.3f, 0.0f, 0.0f, 0.0f, 0.0f}; REAL res_positions[6] = {0.3f, 0.0f, 0.0f, 0.0f, 0.0f}; status = GdipCreatePathGradient(path_points, 3, WrapModeClamp, &brush); expect(Ok, status); status = GdipGetPathGradientBlendCount(NULL, &count); expect(InvalidParameter, status); status = GdipGetPathGradientBlendCount(brush, NULL); expect(InvalidParameter, status); status = GdipGetPathGradientBlendCount(brush, &count); expect(Ok, status); expect(1, count); status = GdipGetPathGradientBlend(NULL, res_factors, res_positions, 1); expect(InvalidParameter, status); status = GdipGetPathGradientBlend(brush, NULL, res_positions, 1); expect(InvalidParameter, status); status = GdipGetPathGradientBlend(brush, res_factors, NULL, 1); expect(InvalidParameter, status); status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 0); expect(InvalidParameter, status); status = GdipGetPathGradientBlend(brush, res_factors, res_positions, -1); expect(InvalidParameter, status); status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 1); expect(Ok, status); status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 2); expect(Ok, status); status = GdipSetPathGradientBlend(NULL, factors, positions, 5); expect(InvalidParameter, status); status = GdipSetPathGradientBlend(brush, NULL, positions, 5); expect(InvalidParameter, status); status = GdipSetPathGradientBlend(brush, factors, NULL, 5); expect(InvalidParameter, status); status = GdipSetPathGradientBlend(brush, factors, positions, 0); expect(InvalidParameter, status); status = GdipSetPathGradientBlend(brush, factors, positions, -1); expect(InvalidParameter, status); /* leave off the 0.0 position */ status = GdipSetPathGradientBlend(brush, &factors[1], &positions[1], 4); expect(InvalidParameter, status); /* leave off the 1.0 position */ status = GdipSetPathGradientBlend(brush, factors, positions, 4); expect(InvalidParameter, status); status = GdipSetPathGradientBlend(brush, factors, positions, 5); expect(Ok, status); status = GdipGetPathGradientBlendCount(brush, &count); expect(Ok, status); expect(5, count); status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 4); expect(InsufficientBuffer, status); status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 5); expect(Ok, status); for (i=0; i<5; i++) { expectf(factors[i], res_factors[i]); expectf(positions[i], res_positions[i]); } status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 6); expect(Ok, status); status = GdipSetPathGradientBlend(brush, factors, positions, 1); expect(Ok, status); status = GdipGetPathGradientBlendCount(brush, &count); expect(Ok, status); expect(1, count); status = GdipGetPathGradientBlend(brush, res_factors, res_positions, 1); expect(Ok, status); status = GdipDeleteBrush((GpBrush*)brush); expect(Ok, status); }
static void test_linelinearblend(void) { GpLineGradient *brush; GpStatus status; GpPointF pt1, pt2; INT count=10; REAL res_factors[3] = {0.3f}; REAL res_positions[3] = {0.3f}; status = GdipSetLineLinearBlend(NULL, 0.6, 0.8); expect(InvalidParameter, status); pt1.X = pt1.Y = 1.0; pt2.X = pt2.Y = 100.0; status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush); expect(Ok, status); status = GdipSetLineLinearBlend(brush, 0.6, 0.8); expect(Ok, status); status = GdipGetLineBlendCount(brush, &count); expect(Ok, status); expect(3, count); status = GdipGetLineBlend(brush, res_factors, res_positions, 3); expect(Ok, status); expectf(0.0, res_factors[0]); expectf(0.0, res_positions[0]); expectf(0.8, res_factors[1]); expectf(0.6, res_positions[1]); expectf(0.0, res_factors[2]); expectf(1.0, res_positions[2]); status = GdipSetLineLinearBlend(brush, 0.0, 0.8); expect(Ok, status); status = GdipGetLineBlendCount(brush, &count); expect(Ok, status); expect(2, count); status = GdipGetLineBlend(brush, res_factors, res_positions, 3); expect(Ok, status); expectf(0.8, res_factors[0]); expectf(0.0, res_positions[0]); expectf(0.0, res_factors[1]); expectf(1.0, res_positions[1]); status = GdipSetLineLinearBlend(brush, 1.0, 0.8); expect(Ok, status); status = GdipGetLineBlendCount(brush, &count); expect(Ok, status); expect(2, count); status = GdipGetLineBlend(brush, res_factors, res_positions, 3); expect(Ok, status); expectf(0.0, res_factors[0]); expectf(0.0, res_positions[0]); expectf(0.8, res_factors[1]); expectf(1.0, res_positions[1]); status = GdipDeleteBrush((GpBrush*)brush); expect(Ok, status); }
static void test_lineblend(void) { GpLineGradient *brush; GpStatus status; GpPointF pt1, pt2; INT count=10; int i; const REAL factors[5] = {0.0f, 0.1f, 0.5f, 0.9f, 1.0f}; const REAL positions[5] = {0.0f, 0.2f, 0.5f, 0.8f, 1.0f}; const REAL two_positions[2] = {0.0f, 1.0f}; const ARGB colors[5] = {0xff0000ff, 0xff00ff00, 0xff00ffff, 0xffff0000, 0xffffffff}; REAL res_factors[6] = {0.3f, 0.0f, 0.0f, 0.0f, 0.0f}; REAL res_positions[6] = {0.3f, 0.0f, 0.0f, 0.0f, 0.0f}; ARGB res_colors[6] = {0xdeadbeef, 0, 0, 0, 0}; pt1.X = pt1.Y = pt2.Y = pt2.X = 1.0; status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush); expect(OutOfMemory, status); pt1.X = pt1.Y = 1.0; pt2.X = pt2.Y = 100.0; status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush); expect(Ok, status); status = GdipGetLineBlendCount(NULL, &count); expect(InvalidParameter, status); status = GdipGetLineBlendCount(brush, NULL); expect(InvalidParameter, status); status = GdipGetLineBlendCount(brush, &count); expect(Ok, status); expect(1, count); status = GdipGetLineBlend(NULL, res_factors, res_positions, 1); expect(InvalidParameter, status); status = GdipGetLineBlend(brush, NULL, res_positions, 1); expect(InvalidParameter, status); status = GdipGetLineBlend(brush, res_factors, NULL, 1); expect(InvalidParameter, status); status = GdipGetLineBlend(brush, res_factors, res_positions, 0); expect(InvalidParameter, status); status = GdipGetLineBlend(brush, res_factors, res_positions, -1); expect(InvalidParameter, status); status = GdipGetLineBlend(brush, res_factors, res_positions, 1); expect(Ok, status); status = GdipGetLineBlend(brush, res_factors, res_positions, 2); expect(Ok, status); status = GdipSetLineBlend(NULL, factors, positions, 5); expect(InvalidParameter, status); status = GdipSetLineBlend(brush, NULL, positions, 5); expect(InvalidParameter, status); status = GdipSetLineBlend(brush, factors, NULL, 5); expect(InvalidParameter, status); status = GdipSetLineBlend(brush, factors, positions, 0); expect(InvalidParameter, status); status = GdipSetLineBlend(brush, factors, positions, -1); expect(InvalidParameter, status); /* leave off the 0.0 position */ status = GdipSetLineBlend(brush, &factors[1], &positions[1], 4); expect(InvalidParameter, status); /* leave off the 1.0 position */ status = GdipSetLineBlend(brush, factors, positions, 4); expect(InvalidParameter, status); status = GdipSetLineBlend(brush, factors, positions, 5); expect(Ok, status); status = GdipGetLineBlendCount(brush, &count); expect(Ok, status); expect(5, count); status = GdipGetLineBlend(brush, res_factors, res_positions, 4); expect(InsufficientBuffer, status); status = GdipGetLineBlend(brush, res_factors, res_positions, 5); expect(Ok, status); for (i=0; i<5; i++) { expectf(factors[i], res_factors[i]); expectf(positions[i], res_positions[i]); } status = GdipGetLineBlend(brush, res_factors, res_positions, 6); expect(Ok, status); status = GdipSetLineBlend(brush, factors, positions, 1); expect(Ok, status); status = GdipGetLineBlendCount(brush, &count); expect(Ok, status); expect(1, count); status = GdipGetLineBlend(brush, res_factors, res_positions, 1); expect(Ok, status); status = GdipGetLinePresetBlendCount(NULL, &count); expect(InvalidParameter, status); status = GdipGetLinePresetBlendCount(brush, NULL); expect(InvalidParameter, status); status = GdipGetLinePresetBlendCount(brush, &count); expect(Ok, status); expect(0, count); status = GdipGetLinePresetBlend(NULL, res_colors, res_positions, 1); expect(InvalidParameter, status); status = GdipGetLinePresetBlend(brush, NULL, res_positions, 1); expect(InvalidParameter, status); status = GdipGetLinePresetBlend(brush, res_colors, NULL, 1); expect(InvalidParameter, status); status = GdipGetLinePresetBlend(brush, res_colors, res_positions, 0); expect(InvalidParameter, status); status = GdipGetLinePresetBlend(brush, res_colors, res_positions, -1); expect(InvalidParameter, status); status = GdipGetLinePresetBlend(brush, res_colors, res_positions, 1); expect(InvalidParameter, status); status = GdipGetLinePresetBlend(brush, res_colors, res_positions, 2); expect(GenericError, status); status = GdipSetLinePresetBlend(NULL, colors, positions, 5); expect(InvalidParameter, status); status = GdipSetLinePresetBlend(brush, NULL, positions, 5); expect(InvalidParameter, status); status = GdipSetLinePresetBlend(brush, colors, NULL, 5); expect(InvalidParameter, status); status = GdipSetLinePresetBlend(brush, colors, positions, 0); expect(InvalidParameter, status); status = GdipSetLinePresetBlend(brush, colors, positions, -1); expect(InvalidParameter, status); status = GdipSetLinePresetBlend(brush, colors, positions, 1); expect(InvalidParameter, status); /* leave off the 0.0 position */ status = GdipSetLinePresetBlend(brush, &colors[1], &positions[1], 4); expect(InvalidParameter, status); /* leave off the 1.0 position */ status = GdipSetLinePresetBlend(brush, colors, positions, 4); expect(InvalidParameter, status); status = GdipSetLinePresetBlend(brush, colors, positions, 5); expect(Ok, status); status = GdipGetLinePresetBlendCount(brush, &count); expect(Ok, status); expect(5, count); status = GdipGetLinePresetBlend(brush, res_colors, res_positions, 4); expect(InsufficientBuffer, status); status = GdipGetLinePresetBlend(brush, res_colors, res_positions, 5); expect(Ok, status); for (i=0; i<5; i++) { expect(colors[i], res_colors[i]); expectf(positions[i], res_positions[i]); } status = GdipGetLinePresetBlend(brush, res_colors, res_positions, 6); expect(Ok, status); status = GdipSetLinePresetBlend(brush, colors, two_positions, 2); expect(Ok, status); status = GdipDeleteBrush((GpBrush*)brush); expect(Ok, status); }
static void test_gradientgetrect(void) { GpLineGradient *brush; GpMatrix *transform; REAL elements[6]; GpRectF rectf; GpStatus status; GpPointF pt1, pt2; status = GdipCreateMatrix(&transform); expect(Ok, status); pt1.X = pt1.Y = 1.0; pt2.X = pt2.Y = 100.0; status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush); expect(Ok, status); memset(&rectf, 0, sizeof(GpRectF)); status = GdipGetLineRect(brush, &rectf); expect(Ok, status); expectf(1.0, rectf.X); expectf(1.0, rectf.Y); expectf(99.0, rectf.Width); expectf(99.0, rectf.Height); status = GdipGetLineTransform(brush, transform); todo_wine expect(Ok, status); if (status == Ok) { status = GdipGetMatrixElements(transform, elements); expect(Ok, status); expectf(1.0, elements[0]); expectf(1.0, elements[1]); expectf(-1.0, elements[2]); expectf(1.0, elements[3]); expectf(50.50, elements[4]); expectf(-50.50, elements[5]); } status = GdipDeleteBrush((GpBrush*)brush); expect(Ok, status); /* vertical gradient */ pt1.X = pt1.Y = pt2.X = 0.0; pt2.Y = 10.0; status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush); expect(Ok, status); memset(&rectf, 0, sizeof(GpRectF)); status = GdipGetLineRect(brush, &rectf); expect(Ok, status); expectf(-5.0, rectf.X); expectf(0.0, rectf.Y); expectf(10.0, rectf.Width); expectf(10.0, rectf.Height); status = GdipGetLineTransform(brush, transform); todo_wine expect(Ok, status); if (status == Ok) { status = GdipGetMatrixElements(transform, elements); expect(Ok, status); expectf(0.0, elements[0]); expectf(1.0, elements[1]); expectf(-1.0, elements[2]); expectf(0.0, elements[3]); expectf(5.0, elements[4]); expectf(5.0, elements[5]); } status = GdipDeleteBrush((GpBrush*)brush); expect(Ok, status); /* horizontal gradient */ pt1.X = pt1.Y = pt2.Y = 0.0; pt2.X = 10.0; status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush); expect(Ok, status); memset(&rectf, 0, sizeof(GpRectF)); status = GdipGetLineRect(brush, &rectf); expect(Ok, status); expectf(0.0, rectf.X); expectf(-5.0, rectf.Y); expectf(10.0, rectf.Width); expectf(10.0, rectf.Height); status = GdipGetLineTransform(brush, transform); todo_wine expect(Ok, status); if (status == Ok) { status = GdipGetMatrixElements(transform, elements); expect(Ok, status); expectf(1.0, elements[0]); expectf(0.0, elements[1]); expectf(0.0, elements[2]); expectf(1.0, elements[3]); expectf(0.0, elements[4]); expectf(0.0, elements[5]); } status = GdipDeleteBrush((GpBrush*)brush); expect(Ok, status); /* slope = -1 */ pt1.X = pt1.Y = 0.0; pt2.X = 20.0; pt2.Y = -20.0; status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush); expect(Ok, status); memset(&rectf, 0, sizeof(GpRectF)); status = GdipGetLineRect(brush, &rectf); expect(Ok, status); expectf(0.0, rectf.X); expectf(-20.0, rectf.Y); expectf(20.0, rectf.Width); expectf(20.0, rectf.Height); status = GdipGetLineTransform(brush, transform); todo_wine expect(Ok, status); if (status == Ok) { status = GdipGetMatrixElements(transform, elements); expect(Ok, status); expectf(1.0, elements[0]); expectf(-1.0, elements[1]); expectf(1.0, elements[2]); expectf(1.0, elements[3]); expectf(10.0, elements[4]); expectf(10.0, elements[5]); } status = GdipDeleteBrush((GpBrush*)brush); expect(Ok, status); /* slope = 1/100 */ pt1.X = pt1.Y = 0.0; pt2.X = 100.0; pt2.Y = 1.0; status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush); expect(Ok, status); memset(&rectf, 0, sizeof(GpRectF)); status = GdipGetLineRect(brush, &rectf); expect(Ok, status); expectf(0.0, rectf.X); expectf(0.0, rectf.Y); expectf(100.0, rectf.Width); expectf(1.0, rectf.Height); status = GdipGetLineTransform(brush, transform); todo_wine expect(Ok, status); if (status == Ok) { status = GdipGetMatrixElements(transform, elements); expect(Ok,status); expectf(1.0, elements[0]); expectf(0.01, elements[1]); expectf(-0.02, elements[2]); /* expectf(2.0, elements[3]); */ expectf(0.01, elements[4]); /* expectf(-1.0, elements[5]); */ } status = GdipDeleteBrush((GpBrush*)brush); expect(Ok,status); /* zero height rect */ rectf.X = rectf.Y = 10.0; rectf.Width = 100.0; rectf.Height = 0.0; status = GdipCreateLineBrushFromRect(&rectf, 0, 0, LinearGradientModeVertical, WrapModeTile, &brush); expect(OutOfMemory, status); /* zero width rect */ rectf.X = rectf.Y = 10.0; rectf.Width = 0.0; rectf.Height = 100.0; status = GdipCreateLineBrushFromRect(&rectf, 0, 0, LinearGradientModeHorizontal, WrapModeTile, &brush); expect(OutOfMemory, status); /* from rect with LinearGradientModeHorizontal */ rectf.X = rectf.Y = 10.0; rectf.Width = rectf.Height = 100.0; status = GdipCreateLineBrushFromRect(&rectf, 0, 0, LinearGradientModeHorizontal, WrapModeTile, &brush); expect(Ok, status); memset(&rectf, 0, sizeof(GpRectF)); status = GdipGetLineRect(brush, &rectf); expect(Ok, status); expectf(10.0, rectf.X); expectf(10.0, rectf.Y); expectf(100.0, rectf.Width); expectf(100.0, rectf.Height); status = GdipGetLineTransform(brush, transform); todo_wine expect(Ok, status); if (status == Ok) { status = GdipGetMatrixElements(transform, elements); expect(Ok,status); expectf(1.0, elements[0]); expectf(0.0, elements[1]); expectf(0.0, elements[2]); expectf(1.0, elements[3]); expectf(0.0, elements[4]); expectf(0.0, elements[5]); } status = GdipDeleteBrush((GpBrush*)brush); expect(Ok,status); /* passing negative Width/Height to LinearGradientModeHorizontal */ rectf.X = rectf.Y = 10.0; rectf.Width = rectf.Height = -100.0; status = GdipCreateLineBrushFromRect(&rectf, 0, 0, LinearGradientModeHorizontal, WrapModeTile, &brush); expect(Ok, status); memset(&rectf, 0, sizeof(GpRectF)); status = GdipGetLineRect(brush, &rectf); expect(Ok, status); expectf(10.0, rectf.X); expectf(10.0, rectf.Y); expectf(-100.0, rectf.Width); expectf(-100.0, rectf.Height); status = GdipGetLineTransform(brush, transform); todo_wine expect(Ok, status); if (status == Ok) { status = GdipGetMatrixElements(transform, elements); expect(Ok,status); expectf(1.0, elements[0]); expectf(0.0, elements[1]); expectf(0.0, elements[2]); expectf(1.0, elements[3]); expectf(0.0, elements[4]); expectf(0.0, elements[5]); } status = GdipDeleteBrush((GpBrush*)brush); expect(Ok,status); GdipDeleteMatrix(transform); }