Dmitry Timoshkov : gdiplus: Add some GdipTransformPoints tests for a device with different x/ y resolutions.
Alexandre Julliard
julliard at winehq.org
Thu Jul 26 15:34:57 CDT 2012
Module: wine
Branch: master
Commit: e6c69e9685d355a7c2aff55b46b1accfd08f1f7f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e6c69e9685d355a7c2aff55b46b1accfd08f1f7f
Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date: Wed Jul 25 14:52:46 2012 +0900
gdiplus: Add some GdipTransformPoints tests for a device with different x/y resolutions.
---
dlls/gdiplus/tests/graphics.c | 101 ++++++++++++++++++++++++++++++++++++++++-
1 files changed, 100 insertions(+), 1 deletions(-)
diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c
index 7c53ced..e6b6513 100644
--- a/dlls/gdiplus/tests/graphics.c
+++ b/dlls/gdiplus/tests/graphics.c
@@ -26,7 +26,7 @@
#define expect(expected, got) ok((got) == (expected), "Expected %d, got %d\n", (INT)(expected), (INT)(got))
#define expectf_(expected, got, precision) ok(fabs((expected) - (got)) < (precision), "Expected %f, got %f\n", (expected), (got))
-#define expectf(expected, got) expectf_((expected), (got), 0.0001)
+#define expectf(expected, got) expectf_((expected), (got), 0.001)
#define TABLE_LEN (23)
static HWND hwnd;
@@ -3398,6 +3398,104 @@ static void test_GdipMeasureString(void)
DeleteDC(hdc);
}
+static GpGraphics *create_graphics(REAL res_x, REAL res_y, GpUnit unit, REAL scale)
+{
+ GpStatus status;
+ union
+ {
+ GpBitmap *bitmap;
+ GpImage *image;
+ } u;
+ GpGraphics *graphics = NULL;
+ REAL res;
+
+ status = GdipCreateBitmapFromScan0(1, 1, 4, PixelFormat24bppRGB, NULL, &u.bitmap);
+ expect(Ok, status);
+
+ status = GdipBitmapSetResolution(u.bitmap, res_x, res_y);
+ expect(Ok, status);
+ status = GdipGetImageHorizontalResolution(u.image, &res);
+ expect(Ok, status);
+ expectf(res_x, res);
+ status = GdipGetImageVerticalResolution(u.image, &res);
+ expect(Ok, status);
+ expectf(res_y, res);
+
+ status = GdipGetImageGraphicsContext(u.image, &graphics);
+ expect(Ok, status);
+ status = GdipDisposeImage(u.image);
+ expect(Ok, status);
+
+ status = GdipGetDpiX(graphics, &res);
+ expect(Ok, status);
+ expectf(res_x, res);
+ status = GdipGetDpiY(graphics, &res);
+ expect(Ok, status);
+ expectf(res_y, res);
+
+ status = GdipSetPageUnit(graphics, unit);
+ expect(Ok, status);
+ status = GdipSetPageScale(graphics, scale);
+ expect(Ok, status);
+
+ return graphics;
+}
+
+static void test_transform(void)
+{
+ static const struct test_data
+ {
+ REAL res_x, res_y, scale;
+ GpUnit unit;
+ GpPointF in[2], out[2];
+ } td[] =
+ {
+ { 96.0, 96.0, 1.0, UnitPixel,
+ { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
+ { 96.0, 96.0, 1.0, UnitDisplay,
+ { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
+ { 96.0, 96.0, 1.0, UnitInch,
+ { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 9600.0, 0.0 }, { 0.0, 9600.0 } } },
+ { 123.0, 456.0, 1.0, UnitPoint,
+ { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 170.833313, 0.0 }, { 0.0, 633.333252 } } },
+ { 123.0, 456.0, 1.0, UnitDocument,
+ { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 40.999996, 0.0 }, { 0.0, 151.999985 } } },
+ { 123.0, 456.0, 2.0, UnitMillimeter,
+ { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 968.503845, 0.0 }, { 0.0, 3590.550781 } } },
+ { 196.0, 296.0, 1.0, UnitDisplay,
+ { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
+ { 196.0, 296.0, 1.0, UnitPixel,
+ { { 100.0, 0.0 }, { 0.0, 100.0 } }, { { 100.0, 0.0 }, { 0.0, 100.0 } } },
+ };
+ GpStatus status;
+ GpGraphics *graphics;
+ GpPointF ptf[2];
+ UINT i;
+
+ for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
+ {
+ graphics = create_graphics(td[i].res_x, td[i].res_y, td[i].unit, td[i].scale);
+ ptf[0].X = td[i].in[0].X;
+ ptf[0].Y = td[i].in[0].Y;
+ ptf[1].X = td[i].in[1].X;
+ ptf[1].Y = td[i].in[1].Y;
+ status = GdipTransformPoints(graphics, CoordinateSpaceDevice, CoordinateSpaceWorld, ptf, 2);
+ expect(Ok, status);
+ expectf(td[i].out[0].X, ptf[0].X);
+ expectf(td[i].out[0].Y, ptf[0].Y);
+ expectf(td[i].out[1].X, ptf[1].X);
+ expectf(td[i].out[1].Y, ptf[1].Y);
+ status = GdipTransformPoints(graphics, CoordinateSpaceWorld, CoordinateSpaceDevice, ptf, 2);
+ expect(Ok, status);
+ expectf(td[i].in[0].X, ptf[0].X);
+ expectf(td[i].in[0].Y, ptf[0].Y);
+ expectf(td[i].in[1].X, ptf[1].X);
+ expectf(td[i].in[1].Y, ptf[1].Y);
+ status = GdipDeleteGraphics(graphics);
+ expect(Ok, status);
+ }
+}
+
START_TEST(graphics)
{
struct GdiplusStartupInput gdiplusStartupInput;
@@ -3424,6 +3522,7 @@ START_TEST(graphics)
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
+ test_transform();
test_GdipMeasureString();
test_constructor_destructor();
test_save_restore();
More information about the wine-cvs
mailing list