Alexandre Julliard : gdi32/tests: Add tests for path open/closed states.
Alexandre Julliard
julliard at winehq.org
Wed Oct 26 12:35:47 CDT 2011
Module: wine
Branch: master
Commit: f44c1e653317ffaed2c752d1345df56153360eff
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f44c1e653317ffaed2c752d1345df56153360eff
Author: Alexandre Julliard <julliard at winehq.org>
Date: Mon Oct 24 15:06:05 2011 +0200
gdi32/tests: Add tests for path open/closed states.
---
dlls/gdi32/path.c | 4 +-
dlls/gdi32/tests/path.c | 233 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 235 insertions(+), 2 deletions(-)
diff --git a/dlls/gdi32/path.c b/dlls/gdi32/path.c
index 277d167..2fc998e 100644
--- a/dlls/gdi32/path.c
+++ b/dlls/gdi32/path.c
@@ -2240,7 +2240,7 @@ BOOL nulldrv_FlattenPath( PHYSDEV dev )
{
DC *dc = get_nulldrv_dc( dev );
- if (dc->path.state == PATH_Closed)
+ if (dc->path.state != PATH_Closed)
{
SetLastError( ERROR_CAN_NOT_COMPLETE );
return FALSE;
@@ -2252,7 +2252,7 @@ BOOL nulldrv_WidenPath( PHYSDEV dev )
{
DC *dc = get_nulldrv_dc( dev );
- if (dc->path.state == PATH_Open)
+ if (dc->path.state != PATH_Closed)
{
SetLastError( ERROR_CAN_NOT_COMPLETE );
return FALSE;
diff --git a/dlls/gdi32/tests/path.c b/dlls/gdi32/tests/path.c
index 18dffa3..8399b19 100644
--- a/dlls/gdi32/tests/path.c
+++ b/dlls/gdi32/tests/path.c
@@ -33,6 +33,238 @@
#define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
+static void test_path_state(void)
+{
+ BYTE buffer[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
+ BITMAPINFO *bi = (BITMAPINFO *)buffer;
+ HDC hdc;
+ HBITMAP orig, dib;
+ void *bits;
+ BOOL ret;
+
+ hdc = CreateCompatibleDC( 0 );
+ memset( buffer, 0, sizeof(buffer) );
+ bi->bmiHeader.biSize = sizeof(bi->bmiHeader);
+ bi->bmiHeader.biHeight = 256;
+ bi->bmiHeader.biWidth = 256;
+ bi->bmiHeader.biBitCount = 32;
+ bi->bmiHeader.biPlanes = 1;
+ bi->bmiHeader.biCompression = BI_RGB;
+ dib = CreateDIBSection( 0, bi, DIB_RGB_COLORS, (void**)&bits, NULL, 0 );
+ orig = SelectObject( hdc, dib );
+
+ BeginPath( hdc );
+ LineTo( hdc, 100, 100 );
+ ret = WidenPath( hdc );
+ ok( !ret, "WidenPath succeeded\n" );
+
+ /* selecting another bitmap doesn't affect the path */
+ SelectObject( hdc, orig );
+ ret = WidenPath( hdc );
+ ok( !ret, "WidenPath succeeded\n" );
+
+ SelectObject( hdc, dib );
+ ret = WidenPath( hdc );
+ ok( !ret, "WidenPath succeeded\n" );
+
+ ret = EndPath( hdc );
+ ok( ret, "EndPath failed error %u\n", GetLastError() );
+ ret = WidenPath( hdc );
+ ok( ret, "WidenPath failed error %u\n", GetLastError() );
+
+ SelectObject( hdc, orig );
+ ret = WidenPath( hdc );
+ ok( ret, "WidenPath failed error %u\n", GetLastError() );
+
+ BeginPath( hdc );
+ LineTo( hdc, 100, 100 );
+ ret = WidenPath( hdc );
+ ok( !ret, "WidenPath succeeded\n" );
+ SaveDC( hdc );
+ SelectObject( hdc, dib );
+ ret = EndPath( hdc );
+ ok( ret, "EndPath failed error %u\n", GetLastError() );
+ ret = WidenPath( hdc );
+ ok( ret, "WidenPath failed error %u\n", GetLastError() );
+
+ /* path should be open again after RestoreDC */
+ RestoreDC( hdc, -1 );
+ ret = WidenPath( hdc );
+ ok( !ret, "WidenPath succeeded\n" );
+ ret = EndPath( hdc );
+ ok( ret, "EndPath failed error %u\n", GetLastError() );
+
+ SaveDC( hdc );
+ BeginPath( hdc );
+ RestoreDC( hdc, -1 );
+ ret = WidenPath( hdc );
+ ok( ret, "WidenPath failed error %u\n", GetLastError() );
+
+ /* test all functions with no path at all */
+ AbortPath( hdc );
+ SetLastError( 0xdeadbeef );
+ ret = WidenPath( hdc );
+ ok( !ret, "WidenPath succeeded\n" );
+ ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
+ "wrong error %u\n", GetLastError() );
+
+ SetLastError( 0xdeadbeef );
+ ret = FlattenPath( hdc );
+ ok( !ret, "FlattenPath succeeded\n" );
+ ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
+ "wrong error %u\n", GetLastError() );
+
+ SetLastError( 0xdeadbeef );
+ ret = StrokePath( hdc );
+ ok( !ret, "StrokePath succeeded\n" );
+ ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
+ "wrong error %u\n", GetLastError() );
+
+ SetLastError( 0xdeadbeef );
+ ret = FillPath( hdc );
+ ok( !ret, "FillPath succeeded\n" );
+ ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
+ "wrong error %u\n", GetLastError() );
+
+ SetLastError( 0xdeadbeef );
+ ret = StrokeAndFillPath( hdc );
+ ok( !ret, "StrokeAndFillPath succeeded\n" );
+ ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
+ "wrong error %u\n", GetLastError() );
+
+ SetLastError( 0xdeadbeef );
+ ret = SelectClipPath( hdc, RGN_OR );
+ ok( !ret, "SelectClipPath succeeded\n" );
+ ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
+ "wrong error %u\n", GetLastError() );
+
+ SetLastError( 0xdeadbeef );
+ ret = EndPath( hdc );
+ ok( !ret, "SelectClipPath succeeded\n" );
+ ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
+ "wrong error %u\n", GetLastError() );
+
+ SetLastError( 0xdeadbeef );
+ ret = CloseFigure( hdc );
+ ok( !ret, "CloseFigure succeeded\n" );
+ ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
+ "wrong error %u\n", GetLastError() );
+
+ /* test all functions with an open path */
+ AbortPath( hdc );
+ BeginPath( hdc );
+ SetLastError( 0xdeadbeef );
+ ret = WidenPath( hdc );
+ ok( !ret, "WidenPath succeeded\n" );
+ ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
+ "wrong error %u\n", GetLastError() );
+
+ AbortPath( hdc );
+ BeginPath( hdc );
+ SetLastError( 0xdeadbeef );
+ ret = FlattenPath( hdc );
+ ok( !ret, "FlattenPath succeeded\n" );
+ ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
+ "wrong error %u\n", GetLastError() );
+
+ AbortPath( hdc );
+ BeginPath( hdc );
+ SetLastError( 0xdeadbeef );
+ ret = StrokePath( hdc );
+ ok( !ret, "StrokePath succeeded\n" );
+ ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
+ "wrong error %u\n", GetLastError() );
+
+ AbortPath( hdc );
+ BeginPath( hdc );
+ SetLastError( 0xdeadbeef );
+ ret = FillPath( hdc );
+ ok( !ret, "FillPath succeeded\n" );
+ ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
+ "wrong error %u\n", GetLastError() );
+
+ AbortPath( hdc );
+ BeginPath( hdc );
+ SetLastError( 0xdeadbeef );
+ ret = StrokeAndFillPath( hdc );
+ ok( !ret, "StrokeAndFillPath succeeded\n" );
+ ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
+ "wrong error %u\n", GetLastError() );
+
+ AbortPath( hdc );
+ BeginPath( hdc );
+ Rectangle( hdc, 1, 1, 10, 10 ); /* region needs some contents */
+ SetLastError( 0xdeadbeef );
+ ret = SelectClipPath( hdc, RGN_OR );
+ ok( !ret, "SelectClipPath succeeded\n" );
+ ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
+ "wrong error %u\n", GetLastError() );
+
+ AbortPath( hdc );
+ BeginPath( hdc );
+ ret = CloseFigure( hdc );
+ ok( ret, "CloseFigure failed\n" );
+
+ /* test all functions with a closed path */
+ AbortPath( hdc );
+ BeginPath( hdc );
+ EndPath( hdc );
+ ret = WidenPath( hdc );
+ ok( ret, "WidenPath failed\n" );
+
+ AbortPath( hdc );
+ BeginPath( hdc );
+ EndPath( hdc );
+ ret = FlattenPath( hdc );
+ ok( ret, "FlattenPath failed\n" );
+
+ AbortPath( hdc );
+ BeginPath( hdc );
+ EndPath( hdc );
+ ret = StrokePath( hdc );
+ ok( ret, "StrokePath failed\n" );
+
+ AbortPath( hdc );
+ BeginPath( hdc );
+ EndPath( hdc );
+ ret = FillPath( hdc );
+ ok( ret, "FillPath failed\n" );
+
+ AbortPath( hdc );
+ BeginPath( hdc );
+ EndPath( hdc );
+ ret = StrokeAndFillPath( hdc );
+ ok( ret, "StrokeAndFillPath failed\n" );
+
+ AbortPath( hdc );
+ BeginPath( hdc );
+ Rectangle( hdc, 1, 1, 10, 10 ); /* region needs some contents */
+ EndPath( hdc );
+ ret = SelectClipPath( hdc, RGN_OR );
+ ok( ret, "SelectClipPath failed\n" );
+
+ AbortPath( hdc );
+ BeginPath( hdc );
+ EndPath( hdc );
+ SetLastError( 0xdeadbeef );
+ ret = CloseFigure( hdc );
+ ok( !ret, "CloseFigure succeeded\n" );
+ ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
+ "wrong error %u\n", GetLastError() );
+
+ AbortPath( hdc );
+ BeginPath( hdc );
+ EndPath( hdc );
+ SetLastError( 0xdeadbeef );
+ ret = EndPath( hdc );
+ ok( !ret, "SelectClipPath succeeded\n" );
+ ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
+ "wrong error %u\n", GetLastError() );
+
+ DeleteDC( hdc );
+ DeleteObject( dib );
+}
+
static void test_widenpath(void)
{
HDC hdc = GetDC(0);
@@ -504,6 +736,7 @@ static void test_linedda(void)
START_TEST(path)
{
+ test_path_state();
test_widenpath();
test_arcto();
test_anglearc();
More information about the wine-cvs
mailing list