gdiplus/tests: Add another set of clipping region tests.

This commit is contained in:
Dmitry Timoshkov 2013-07-12 17:14:20 +09:00 committed by Alexandre Julliard
parent bbb7358d1c
commit ffd207850c
1 changed files with 231 additions and 52 deletions

View File

@ -4556,10 +4556,8 @@ static void test_clipping(void)
status = GdipGetClipBounds(graphics, &rect);
expect(Ok, status);
expectf(100.0, rect.X);
expectf(100.0, rect.Y);
expectf(100.0, rect.Width);
expectf(100.0, rect.Height);
ok(rect.X == 100.0 && rect.Y == 100.0 && rect.Width == 100.0 && rect.Height == 100.0,
"expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
status = GdipSetEmpty(region);
expect(Ok, status);
@ -4567,10 +4565,8 @@ static void test_clipping(void)
expect(Ok, status);
status = GdipGetRegionBounds(region, graphics, &rect);
expect(Ok, status);
expectf(100.0, rect.X);
expectf(100.0, rect.Y);
expectf(100.0, rect.Width);
expectf(100.0, rect.Height);
ok(rect.X == 100.0 && rect.Y == 100.0 && rect.Width == 100.0 && rect.Height == 100.0,
"expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
status = GdipCreateMatrix(&matrix);
expect(Ok, status);
@ -4584,13 +4580,8 @@ static void test_clipping(void)
status = GdipGetClipBounds(graphics, &rect);
expect(Ok, status);
todo_wine
expectf(45.0, rect.X);
todo_wine
expectf(20.0, rect.Y);
todo_wine
expectf(50.0, rect.Width);
todo_wine
expectf(25.0, rect.Height);
ok(rect.X == 45.0 && rect.Y == 20.0 && rect.Width == 50.0 && rect.Height == 25.0,
"expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
status = GdipSetEmpty(region);
expect(Ok, status);
@ -4599,20 +4590,13 @@ todo_wine
status = GdipGetRegionBounds(region, graphics, &rect);
expect(Ok, status);
todo_wine
expectf(45.0, rect.X);
todo_wine
expectf(20.0, rect.Y);
todo_wine
expectf(50.0, rect.Width);
todo_wine
expectf(25.0, rect.Height);
ok(rect.X == 45.0 && rect.Y == 20.0 && rect.Width == 50.0 && rect.Height == 25.0,
"expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
status = GdipGetRegionBounds(region100x100, graphics, &rect);
expect(Ok, status);
expectf(100.0, rect.X);
expectf(100.0, rect.Y);
expectf(100.0, rect.Width);
expectf(100.0, rect.Height);
ok(rect.X == 100.0 && rect.Y == 100.0 && rect.Width == 100.0 && rect.Height == 100.0,
"expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
status = GdipGetRegionHRgn(region, NULL, &hrgn);
expect(Ok, status);
@ -4654,13 +4638,8 @@ todo_wine
status = GdipGetClipBounds(graphics, &rect);
expect(Ok, status);
todo_wine
expectf(45.0, rect.X);
todo_wine
expectf(20.0, rect.Y);
todo_wine
expectf(50.0, rect.Width);
todo_wine
expectf(25.0, rect.Height);
ok(rect.X == 45.0 && rect.Y == 20.0 && rect.Width == 50.0 && rect.Height == 25.0,
"expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
status = GdipSetEmpty(region);
expect(Ok, status);
@ -4669,20 +4648,13 @@ todo_wine
status = GdipGetRegionBounds(region, graphics, &rect);
expect(Ok, status);
todo_wine
expectf(45.0, rect.X);
todo_wine
expectf(20.0, rect.Y);
todo_wine
expectf(50.0, rect.Width);
todo_wine
expectf(25.0, rect.Height);
ok(rect.X == 45.0 && rect.Y == 20.0 && rect.Width == 50.0 && rect.Height == 25.0,
"expected 45.0,20.0-50.0,25.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
status = GdipGetRegionBounds(region100x100, graphics, &rect);
expect(Ok, status);
expectf(100.0, rect.X);
expectf(100.0, rect.Y);
expectf(100.0, rect.Width);
expectf(100.0, rect.Height);
ok(rect.X == 100.0 && rect.Y == 100.0 && rect.Width == 100.0 && rect.Height == 100.0,
"expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
status = GdipGetRegionHRgn(region, NULL, &hrgn);
expect(Ok, status);
@ -4741,10 +4713,8 @@ todo_wine
status = GdipGetRegionBounds(region100x100, graphics, &rect);
expect(Ok, status);
expectf(100.0, rect.X);
expectf(100.0, rect.Y);
expectf(100.0, rect.Width);
expectf(100.0, rect.Height);
ok(rect.X == 100.0 && rect.Y == 100.0 && rect.Width == 100.0 && rect.Height == 100.0,
"expected 100.0,100.0-100.0,100.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
status = GdipGetRegionHRgn(region, NULL, &hrgn);
expect(Ok, status);
@ -4789,10 +4759,8 @@ todo_wine
status = GdipGetRegionBounds(region100x100, graphics, &rect);
expect(Ok, status);
expectf(210.0, rect.X);
expectf(420.0, rect.Y);
expectf(200.0, rect.Width);
expectf(400.0, rect.Height);
ok(rect.X == 210.0 && rect.Y == 420.0 && rect.Width == 200.0 && rect.Height == 400.0,
"expected 210.0,420.0-200.0,400.0, got %.2f,%.2f-%.2f,%.2f\n", rect.X, rect.Y, rect.Width, rect.Height);
status = GdipGetRegionHRgn(region100x100, NULL, &hrgn);
expect(Ok, status);
@ -4819,6 +4787,216 @@ todo_wine
DeleteDC(hdc);
}
static void test_clipping_2(void)
{
HDC hdc;
GpStatus status;
GpGraphics *graphics;
GpRegion *region;
GpMatrix *matrix;
GpRectF rect;
HRGN hrgn;
int ret;
RECT rc;
hdc = CreateCompatibleDC(0);
status = GdipCreateFromHDC(hdc, &graphics);
expect(Ok, status);
GdipSetPageUnit(graphics, UnitInch);
status = GdipCreateRegion(&region);
expect(Ok, status);
status = GdipSetEmpty(region);
expect(Ok, status);
rect.X = rect.Y = 100.0;
rect.Width = rect.Height = 100.0;
status = GdipCombineRegionRect(region, &rect, CombineModeUnion);
expect(Ok, status);
status = GdipSetClipRegion(graphics, region, CombineModeReplace);
expect(Ok, status);
status = GdipGetClip(graphics, region);
expect(Ok, status);
status = GdipGetRegionHRgn(region, NULL, &hrgn);
expect(Ok, status);
ret = GetRgnBox(hrgn, &rc);
ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
"expected 100,100-200,200, got %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom);
DeleteObject(hrgn);
status = GdipGetRegionHRgn(region, graphics, &hrgn);
expect(Ok, status);
ret = GetRgnBox(hrgn, &rc);
ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
ok(rc.left == 9600 && rc.top == 9600 && rc.right == 19200 && rc.bottom == 19200,
"expected 9600,9600-19200,19200, got %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom);
DeleteObject(hrgn);
GdipSetPageUnit(graphics, UnitPoint);
status = GdipGetClip(graphics, region);
expect(Ok, status);
status = GdipGetRegionHRgn(region, NULL, &hrgn);
expect(Ok, status);
ret = GetRgnBox(hrgn, &rc);
ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
todo_wine
ok((rc.left == 7200 && rc.top == 7200 && rc.right == 14400 && rc.bottom == 14400) ||
broken(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200) /* before Win7 */,
"expected 7200,7200-14400,14400, got %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom);
DeleteObject(hrgn);
status = GdipGetRegionHRgn(region, graphics, &hrgn);
expect(Ok, status);
ret = GetRgnBox(hrgn, &rc);
ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
todo_wine
ok((rc.left == 9600 && rc.top == 9600 && rc.right == 19200 && rc.bottom == 19200) ||
broken(rc.left == 134 && rc.top == 134 && rc.right == 267 && rc.bottom == 267) /* before Win7 */,
"expected 9600,9600-19200,19200, got %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom);
DeleteObject(hrgn);
GdipDeleteRegion(region);
GdipSetPageUnit(graphics, UnitPixel);
status = GdipCreateRegion(&region);
expect(Ok, status);
status = GdipSetEmpty(region);
expect(Ok, status);
rect.X = rect.Y = 100.0;
rect.Width = rect.Height = 100.0;
status = GdipCombineRegionRect(region, &rect, CombineModeUnion);
expect(Ok, status);
status = GdipSetClipRegion(graphics, region, CombineModeReplace);
expect(Ok, status);
status = GdipGetClip(graphics, region);
expect(Ok, status);
status = GdipGetRegionHRgn(region, NULL, &hrgn);
expect(Ok, status);
ret = GetRgnBox(hrgn, &rc);
ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
ok((rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200) ||
broken(rc.left == 2 && rc.top == 2 && rc.right == 3 && rc.bottom == 3) /* before Win7 */,
"expected 100,100-200,200, got %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom);
DeleteObject(hrgn);
status = GdipGetRegionHRgn(region, graphics, &hrgn);
expect(Ok, status);
ret = GetRgnBox(hrgn, &rc);
ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
ok((rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200) ||
broken(rc.left == 2 && rc.top == 2 && rc.right == 3 && rc.bottom == 3) /* before Win7 */,
"expected 100,100-200,200, got %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom);
DeleteObject(hrgn);
GdipSetPageUnit(graphics, UnitPoint);
status = GdipGetClip(graphics, region);
expect(Ok, status);
status = GdipGetRegionHRgn(region, NULL, &hrgn);
expect(Ok, status);
ret = GetRgnBox(hrgn, &rc);
ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
todo_wine
ok((rc.left == 75 && rc.top == 75 && rc.right == 150 && rc.bottom == 150) ||
broken(rc.left == 2 && rc.top == 2 && rc.right == 3 && rc.bottom == 3) /* before Win7 */,
"expected 75,75-150,150, got %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom);
DeleteObject(hrgn);
status = GdipGetRegionHRgn(region, graphics, &hrgn);
expect(Ok, status);
ret = GetRgnBox(hrgn, &rc);
ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
todo_wine
ok((rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200) ||
broken(rc.left == 2 && rc.top == 2 && rc.right == 3 && rc.bottom == 3) /* before Win7 */,
"expected 100,100-200,200, got %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom);
DeleteObject(hrgn);
status = GdipCreateMatrix(&matrix);
expect(Ok, status);
status = GdipTranslateMatrix(matrix, 10.0, 10.0, MatrixOrderAppend);
expect(Ok, status);
status = GdipSetWorldTransform(graphics, matrix);
expect(Ok, status);
GdipDeleteMatrix(matrix);
status = GdipGetClip(graphics, region);
expect(Ok, status);
status = GdipGetRegionHRgn(region, NULL, &hrgn);
expect(Ok, status);
ret = GetRgnBox(hrgn, &rc);
ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
todo_wine
ok(rc.left == 65 && rc.top == 65 && rc.right == 140 && rc.bottom == 140,
"expected 65,65-140,140, got %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom);
DeleteObject(hrgn);
status = GdipGetRegionHRgn(region, graphics, &hrgn);
expect(Ok, status);
ret = GetRgnBox(hrgn, &rc);
ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
todo_wine
ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
"expected 100,100-200,200, got %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom);
DeleteObject(hrgn);
status = GdipCreateMatrix(&matrix);
expect(Ok, status);
status = GdipScaleMatrix(matrix, 0.25, 0.5, MatrixOrderAppend);
expect(Ok, status);
status = GdipSetWorldTransform(graphics, matrix);
expect(Ok, status);
GdipDeleteMatrix(matrix);
status = GdipGetClip(graphics, region);
expect(Ok, status);
status = GdipGetRegionHRgn(region, NULL, &hrgn);
expect(Ok, status);
ret = GetRgnBox(hrgn, &rc);
ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
todo_wine
ok(rc.left == 300 && rc.top == 150 && rc.right == 600 && rc.bottom == 300,
"expected 300,150-600,300, got %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom);
DeleteObject(hrgn);
status = GdipGetRegionHRgn(region, graphics, &hrgn);
expect(Ok, status);
ret = GetRgnBox(hrgn, &rc);
ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
todo_wine
ok(rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200,
"expected 100,100-200,200, got %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom);
DeleteObject(hrgn);
status = GdipSetPageScale(graphics, 2.0);
expect(Ok, status);
status = GdipGetClip(graphics, region);
expect(Ok, status);
status = GdipGetRegionHRgn(region, NULL, &hrgn);
expect(Ok, status);
ret = GetRgnBox(hrgn, &rc);
ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
todo_wine
ok((rc.left == 150 && rc.top == 75 && rc.right == 300 && rc.bottom == 150) ||
broken(rc.left == 300 && rc.top == 150 && rc.right == 600 && rc.bottom == 300) /* before Win7 */,
"expected 150,75-300,150, got %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom);
DeleteObject(hrgn);
status = GdipGetRegionHRgn(region, graphics, &hrgn);
expect(Ok, status);
ret = GetRgnBox(hrgn, &rc);
ok(ret == SIMPLEREGION, "expected SIMPLEREGION, got %d\n", ret);
todo_wine
ok((rc.left == 100 && rc.top == 100 && rc.right == 200 && rc.bottom == 200) ||
broken(rc.left == 200 && rc.top == 200 && rc.right == 400 && rc.bottom == 400) /* before Win7 */,
"expected 100,100-200,200, got %d,%d-%d,%d\n", rc.left, rc.top, rc.right, rc.bottom);
DeleteObject(hrgn);
GdipDeleteRegion(region);
GdipDeleteGraphics(graphics);
DeleteDC(hdc);
}
START_TEST(graphics)
{
struct GdiplusStartupInput gdiplusStartupInput;
@ -4846,6 +5024,7 @@ START_TEST(graphics)
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
test_clipping();
test_clipping_2();
test_measured_extra_space();
test_measure_string();
test_font_height_scaling();