ReactOS 0.4.17-dev-116-ga4b6fe9
path.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "wine/test.h"
#include "winuser.h"
#include "winerror.h"
Include dependency graph for path.c:

Go to the source code of this file.

Classes

struct  path_test_t
 

Macros

#define expect(expected, got)   ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
 

Functions

static void test_path_state (void)
 
static void test_widenpath (void)
 
static void ok_path (HDC hdc, const char *path_name, const path_test_t *expected, int expected_size)
 
static void test_arcto (void)
 
static void test_anglearc (void)
 
static void test_polydraw (void)
 
static void test_closefigure (void)
 
static void WINAPI linedda_callback (INT x, INT y, LPARAM lparam)
 
static void test_linedda (void)
 
static void test_rectangle (void)
 
static void test_roundrect (void)
 
static void test_ellipse (void)
 
static void test_all_functions (void)
 
static void test_clipped_polygon_fill (void)
 
 START_TEST (path)
 

Variables

static const path_test_t arcto_path []
 
static const path_test_t anglearc_path []
 
static const path_test_t polydraw_path []
 
static POINT polydraw_pts []
 
static BYTE polydraw_tps []
 
static const path_test_t rectangle_path []
 
static const path_test_t roundrect_path []
 
static const path_test_t ellipse_path []
 
static const path_test_t all_funcs_path []
 

Macro Definition Documentation

◆ expect

#define expect (   expected,
  got 
)    ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)

Definition at line 34 of file path.c.

Function Documentation

◆ linedda_callback()

static void WINAPI linedda_callback ( INT  x,
INT  y,
LPARAM  lparam 
)
static

Definition at line 751 of file path.c.

752{
753 POINT **pt = (POINT**)lparam;
754 ok((*pt)->x == x && (*pt)->y == y, "point mismatch expect(%ld,%ld) got(%d,%d)\n",
755 (*pt)->x, (*pt)->y, x, y);
756
757 (*pt)++;
758 return;
759}
@ lparam
Definition: SystemMenu.c:31
#define ok(value,...)
Definition: atltest.h:57
#define pt(x, y)
Definition: drawing.c:79
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Referenced by test_linedda().

◆ ok_path()

static void ok_path ( HDC  hdc,
const char path_name,
const path_test_t expected,
int  expected_size 
)
static

Definition at line 401 of file path.c.

402{
403 static const char *type_string[8] = { "Unknown (0)", "PT_CLOSEFIGURE", "PT_LINETO",
404 "PT_LINETO | PT_CLOSEFIGURE", "PT_BEZIERTO",
405 "PT_BEZIERTO | PT_CLOSEFIGURE", "PT_MOVETO", "PT_MOVETO | PT_CLOSEFIGURE"};
406 POINT *pnt;
407 BYTE *types;
408 int size, idx;
409
410 /* Get the path */
411 assert(hdc != 0);
412 size = GetPath(hdc, NULL, NULL, 0);
413 ok(size > 0, "GetPath returned size %d, last error %ld\n", size, GetLastError());
414 if (size <= 0) return;
415
416 pnt = malloc(size * sizeof(POINT));
417 assert(pnt != 0);
418 types = malloc(size);
419 assert(types != 0);
420 size = GetPath(hdc, pnt, types, size);
421 assert(size > 0);
422
423 ok( size == expected_size, "%s: Path size %d does not match expected size %d\n",
424 path_name, size, expected_size);
425
426 for (idx = 0; idx < min( size, expected_size ); idx++)
427 {
428 /* We allow a few pixels fudge in matching X and Y coordinates to account for imprecision in
429 * floating point to integer conversion */
430 static const int fudge = 2;
431
432 ok( types[idx] == expected[idx].type, "%s: Expected #%d: %s (%d,%d) but got %s (%ld,%ld)\n",
433 path_name, idx, type_string[expected[idx].type], expected[idx].x, expected[idx].y,
434 type_string[types[idx]], pnt[idx].x, pnt[idx].y);
435
436 if (types[idx] == expected[idx].type)
437 ok( (pnt[idx].x >= expected[idx].x - fudge && pnt[idx].x <= expected[idx].x + fudge) &&
438 (pnt[idx].y >= expected[idx].y - fudge && pnt[idx].y <= expected[idx].y + fudge),
439 "%s: Expected #%d: %s position (%d,%d) but got (%ld,%ld)\n", path_name, idx,
440 type_string[expected[idx].type], expected[idx].x, expected[idx].y, pnt[idx].x, pnt[idx].y);
441 }
442
443 if (winetest_debug > 2)
444 {
445 printf("static const path_test_t %s[] =\n{\n", path_name);
446 for (idx = 0; idx < size; idx++)
447 printf(" {%ld, %ld, %s}, /* %d */\n", pnt[idx].x, pnt[idx].y, type_string[types[idx]], idx);
448 printf("};\n" );
449 }
450
451 free(types);
452 free(pnt);
453}
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
unsigned int idx
Definition: utils.c:41
#define assert(_expr)
Definition: assert.h:32
#define printf
Definition: freeldr.h:103
static char * path_name(DOS_FILE *file)
Definition: check.c:208
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
int winetest_debug
HDC hdc
Definition: main.c:9
BOOL expected
Definition: store.c:2000
#define min(a, b)
Definition: monoChain.cc:55
Definition: cmds.c:130
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
int WINAPI GetPath(_In_ HDC hdc, _Out_writes_opt_(cpt) LPPOINT apt, _Out_writes_opt_(cpt) LPBYTE aj, int cpt)
unsigned char BYTE
Definition: xxhash.c:193

Referenced by test_all_functions(), test_anglearc(), test_arcto(), test_ellipse(), test_polydraw(), test_rectangle(), and test_roundrect().

◆ START_TEST()

START_TEST ( path  )

Definition at line 1936 of file path.c.

1937{
1940 test_arcto();
1941 test_anglearc();
1942 test_polydraw();
1944 test_linedda();
1947 test_ellipse();
1950}
static void test_arcto(void)
Definition: path.c:480
static void test_widenpath(void)
Definition: path.c:311
static void test_all_functions(void)
Definition: path.c:1873
static void test_ellipse(void)
Definition: path.c:1677
static void test_clipped_polygon_fill(void)
Definition: path.c:1911
static void test_path_state(void)
Definition: path.c:36
static void test_rectangle(void)
Definition: path.c:936
static void test_closefigure(void)
Definition: path.c:705
static void test_roundrect(void)
Definition: path.c:1303
static void test_linedda(void)
Definition: path.c:761
static void test_polydraw(void)
Definition: path.c:605
static void test_anglearc(void)
Definition: path.c:528

◆ test_all_functions()

static void test_all_functions ( void  )
static

Definition at line 1873 of file path.c.

1874{
1875 POINT pts[9] = {{10, 10}, {20, 10}, {10, 20}, {20, 20}, {30, 30}, {40, 20},
1876 {20, 30}, {30, 40}, {10, 50}};
1877 DWORD counts[5] = {4, 5, 0, 1, 2};
1880 HDC hdc = GetDC( 0 );
1881
1882 BeginPath( hdc );
1883 LineTo( hdc, 50, 150 );
1884 MoveToEx( hdc, 50, 50, NULL );
1885 LineTo( hdc, 150, 150 );
1886 LineTo( hdc, 150, 50 );
1887 LineTo( hdc, 50, 50 );
1888 AngleArc( hdc, 37, 36, 23, 90, 180 );
1889 Polyline( hdc, pts, 4 );
1890 Arc( hdc, 21, 21, 39, 29, 39, 29, 21, 21 );
1891 PolylineTo( hdc, pts, 4 );
1892 ArcTo( hdc, 23, 23, 37, 27, 37, 27, 23, 23 );
1893 PolyPolyline( hdc, pts, counts, 2 );
1894 Chord( hdc, 42, 43, 57, 66, 39, 29, 21, 21 );
1895 PolyDraw( hdc, pts, types, 9 );
1896 Pie( hdc, 52, 54, 65, 68, 39, 29, 21, 21 );
1897 Polygon( hdc, pts, 9 );
1898 Ellipse( hdc, 22, 33, 44, 66 );
1899 Rectangle( hdc, 60, 70, 80, 90 );
1900 RoundRect( hdc, 100, 100, 200, 200, 35, 45 );
1901 PolyBezier( hdc, pts, 7 );
1902 PolyPolygon( hdc, pts, (int *)counts, 2 );
1903 PolyBezierTo( hdc, pts, 9 );
1904 LineTo( hdc, 150, 150 );
1905 /* FIXME: ExtTextOut */
1906 EndPath( hdc );
1907 ok_path( hdc, "all_funcs_path", all_funcs_path, ARRAY_SIZE(all_funcs_path) );
1908 ReleaseDC( 0, hdc );
1909}
#define ARRAY_SIZE(A)
Definition: main.h:20
Definition: arc.h:55
unsigned long DWORD
Definition: ntddk_ex.h:95
static HDC
Definition: imagelist.c:88
static const path_test_t all_funcs_path[]
Definition: path.c:1727
static void ok_path(HDC hdc, const char *path_name, const path_test_t *expected, int expected_size)
Definition: path.c:401
BOOL Polygon(CONST PPOINT UnsafePoints, int Count, int polyFillMode)
Definition: polytest.cpp:730
BOOL WINAPI ArcTo(_In_ HDC hdc, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom, _In_ INT xRadial1, _In_ INT yRadial1, _In_ INT xRadial2, _In_ INT yRadial2)
Definition: arc.c:79
BOOL WINAPI Chord(_In_ HDC hdc, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom, _In_ INT xRadial1, _In_ INT yRadial1, _In_ INT xRadial2, _In_ INT yRadial2)
Definition: arc.c:119
BOOL WINAPI PolyBezier(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_ DWORD cpt)
Definition: painting.c:263
BOOL WINAPI Polyline(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_ int cpt)
BOOL WINAPI Ellipse(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI PolylineTo(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_ DWORD cpt)
Definition: painting.c:397
BOOL WINAPI PolyBezierTo(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_ DWORD cpt)
Definition: painting.c:281
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
#define PT_LINETO
Definition: wingdi.h:885
#define PT_CLOSEFIGURE
Definition: wingdi.h:887
#define PT_MOVETO
Definition: wingdi.h:884
#define PT_BEZIERTO
Definition: wingdi.h:886
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI RoundRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI PolyDraw(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_reads_(cpt) const BYTE *aj, _In_ int cpt)
BOOL WINAPI PolyPolygon(_In_ HDC hdc, _In_ const POINT *apt, _In_reads_(csz) const INT *asz, _In_ int csz)
BOOL WINAPI EndPath(_In_ HDC)
BOOL WINAPI AngleArc(_In_ HDC hdc, _In_ INT x, _In_ INT y, _In_ DWORD dwRadius, _In_ FLOAT eStartAngle, _In_ FLOAT eSweepAngle)
Definition: arc.c:49
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
BOOL WINAPI BeginPath(_In_ HDC hdc)
BOOL WINAPI PolyPolyline(_In_ HDC hdc, _In_ const POINT *apt, _In_reads_(csz) const DWORD *asz, _In_ DWORD csz)
BOOL WINAPI Pie(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by START_TEST().

◆ test_anglearc()

static void test_anglearc ( void  )
static

Definition at line 528 of file path.c.

529{
530 HDC hdc = GetDC(0);
531 BeginPath(hdc);
532 if (!AngleArc(hdc, 300, 300, 100, 45.0, 135.0) &&
534 {
535 /* AngleArc is only available on Win2k and later */
536 win_skip("AngleArc is not available\n");
537 goto done;
538 }
539 AngleArc(hdc, 300, 300, 80, 150.0, -180.0);
541 EndPath(hdc);
542
543 ok_path(hdc, "anglearc_path", anglearc_path, ARRAY_SIZE(anglearc_path));
544done:
545 ReleaseDC(0, hdc);
546}
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define win_skip
Definition: minitest.h:67
static const path_test_t anglearc_path[]
Definition: path.c:503
BOOL WINAPI CloseFigure(_In_ HDC hdc)

Referenced by START_TEST().

◆ test_arcto()

static void test_arcto ( void  )
static

Definition at line 480 of file path.c.

481{
482 HDC hdc = GetDC(0);
483
484 BeginPath(hdc);
486 if (!ArcTo(hdc, 200, 200, 400, 300, 200, 200, 400, 300) &&
488 {
489 /* ArcTo is only available on Win2k and later */
490 win_skip("ArcTo is not available\n");
491 goto done;
492 }
494 ArcTo(hdc, 210, 210, 390, 290, 390, 290, 210, 210);
496 EndPath(hdc);
497
498 ok_path(hdc, "arcto_path", arcto_path, ARRAY_SIZE(arcto_path));
499done:
500 ReleaseDC(0, hdc);
501}
static const path_test_t arcto_path[]
Definition: path.c:455
int WINAPI SetArcDirection(_In_ HDC, _In_ int)
#define AD_COUNTERCLOCKWISE
Definition: wingdi.h:667
#define AD_CLOCKWISE
Definition: wingdi.h:668

Referenced by START_TEST().

◆ test_clipped_polygon_fill()

static void test_clipped_polygon_fill ( void  )
static

Definition at line 1911 of file path.c.

1912{
1913 const POINT pts[3] = {{-10, -10}, {10, -5}, {0, 10}};
1914 HBRUSH brush, oldbrush;
1915 HBITMAP bmp, oldbmp;
1916 HDC hdc, memdc;
1917 COLORREF col;
1918
1919 hdc = GetDC( 0 );
1920 memdc = CreateCompatibleDC( hdc );
1921 bmp = CreateCompatibleBitmap( hdc, 20, 20 );
1922 brush = CreateSolidBrush( RGB( 0x11, 0x22, 0x33 ) );
1923 oldbrush = SelectObject( memdc, brush );
1924 oldbmp = SelectObject( memdc, bmp );
1925 Polygon( memdc, pts, ARRAY_SIZE(pts) );
1926 col = GetPixel( memdc, 1, 1 );
1927 ok( col == RGB( 0x11, 0x22, 0x33 ), "got %06lx\n", col );
1928 SelectObject( memdc, oldbrush );
1929 SelectObject( memdc, oldbmp );
1930 DeleteObject( brush );
1931 DeleteObject( bmp );
1932 DeleteDC( memdc );
1933 ReleaseDC( 0, hdc );
1934}
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
#define RGB(r, g, b)
Definition: precomp.h:67
pKey DeleteObject()
BITMAP bmp
Definition: alphablend.c:62
static HBITMAP
Definition: button.c:44
DWORD COLORREF
Definition: windef.h:100
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
BOOL WINAPI DeleteDC(_In_ HDC)

Referenced by START_TEST().

◆ test_closefigure()

static void test_closefigure ( void  )
static

Definition at line 705 of file path.c.

705 {
706 int nSize, nSizeWitness;
707 POINT pos;
708 HDC hdc = GetDC(0);
709
710 MoveToEx( hdc, 100, 100, NULL );
712 ok( pos.x == 100 && pos.y == 100, "wrong pos %ld,%ld\n", pos.x, pos.y );
713
714 BeginPath(hdc);
716 ok( pos.x == 100 && pos.y == 100, "wrong pos %ld,%ld\n", pos.x, pos.y );
717 MoveToEx(hdc, 95, 95, NULL);
719 ok( pos.x == 95 && pos.y == 95, "wrong pos %ld,%ld\n", pos.x, pos.y );
720 LineTo(hdc, 95, 0);
722 ok( pos.x == 95 && pos.y == 0, "wrong pos %ld,%ld\n", pos.x, pos.y );
723 LineTo(hdc, 0, 95);
725 ok( pos.x == 0 && pos.y == 95, "wrong pos %ld,%ld\n", pos.x, pos.y );
726
729 ok( pos.x == 0 && pos.y == 95, "wrong pos %ld,%ld\n", pos.x, pos.y );
730 EndPath(hdc);
732 ok( pos.x == 0 && pos.y == 95, "wrong pos %ld,%ld\n", pos.x, pos.y );
733 nSize = GetPath(hdc, NULL, NULL, 0);
734
735 AbortPath(hdc);
736
737 BeginPath(hdc);
738 MoveToEx(hdc, 95, 95, NULL);
739 LineTo(hdc, 95, 0);
740 LineTo(hdc, 0, 95);
741
742 EndPath(hdc);
743 nSizeWitness = GetPath(hdc, NULL, NULL, 0);
744
745 /* This test shows CloseFigure does not have to add a point at the end of the path */
746 ok(nSize == nSizeWitness, "Wrong number of points, no point should be added by CloseFigure\n");
747
748 ReleaseDC(0, hdc);
749}
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:1834
BOOL WINAPI GetCurrentPositionEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:241
BOOL WINAPI AbortPath(_In_ HDC hdc)

Referenced by START_TEST().

◆ test_ellipse()

static void test_ellipse ( void  )
static

Definition at line 1677 of file path.c.

1678{
1679 HDC hdc = GetDC( 0 );
1680
1681 BeginPath( hdc );
1682 Ellipse( hdc, 20, 20, 40, 40 );
1683 Ellipse( hdc, 30, 50, 55, 35 );
1684 Ellipse( hdc, 60, 60, 35, 45 );
1685 Ellipse( hdc, 70, 70, 50, 70 );
1686 Ellipse( hdc, 75, 75, 75, 85 );
1687 Ellipse( hdc, 80, 80, 81, 81 );
1689 Ellipse( hdc, 20, 20, 40, 40 );
1690 Ellipse( hdc, 30, 50, 55, 35 );
1691 Ellipse( hdc, 60, 60, 35, 45 );
1692 Ellipse( hdc, 70, 70, 50, 70 );
1693 Ellipse( hdc, 75, 75, 75, 85 );
1694 Ellipse( hdc, 80, 80, 81, 81 );
1697 SetViewportExtEx( hdc, -2, 2, NULL );
1698 Ellipse( hdc, 20, 20, 40, 40 );
1699 Ellipse( hdc, 30, 50, 55, 35 );
1700 SetViewportExtEx( hdc, 3, -3, NULL );
1701 Ellipse( hdc, 20, 20, 40, 40 );
1702 Ellipse( hdc, 30, 50, 55, 35 );
1703 SetWindowExtEx( hdc, -20, 20, NULL );
1704 Ellipse( hdc, 20, 20, 40, 40 );
1705 Ellipse( hdc, 24, 22, 21, 20 );
1708 Ellipse( hdc, 20, 20, 40, 40 );
1709 Ellipse( hdc, 30, 50, 55, 35 );
1710 Ellipse( hdc, 60, 60, 35, 45 );
1711 Ellipse( hdc, 70, 70, 50, 70 );
1712 Ellipse( hdc, 75, 75, 75, 85 );
1713 Ellipse( hdc, 80, 80, 81, 81 );
1715 Ellipse( hdc, 20, 20, 40, 40 );
1716 Ellipse( hdc, 30, 50, 55, 35 );
1717 Ellipse( hdc, 60, 60, 35, 45 );
1718 Ellipse( hdc, 70, 70, 50, 70 );
1719 Ellipse( hdc, 75, 75, 75, 85 );
1720 Ellipse( hdc, 80, 80, 81, 81 );
1722 EndPath( hdc );
1724 ok_path( hdc, "ellipse_path", ellipse_path, ARRAY_SIZE(ellipse_path) );
1725}
static const path_test_t ellipse_path[]
Definition: path.c:1348
int WINAPI SetMapMode(_In_ HDC, _In_ int)
int WINAPI SetGraphicsMode(_In_ HDC, _In_ int)
Definition: dc.c:1233
#define GM_ADVANCED
Definition: wingdi.h:865
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:465
#define MM_ANISOTROPIC
Definition: wingdi.h:867
BOOL WINAPI SetWindowExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
#define MM_TEXT
Definition: wingdi.h:873

Referenced by START_TEST().

◆ test_linedda()

static void test_linedda ( void  )
static

Definition at line 761 of file path.c.

762{
763 const POINT *pt;
764 static const POINT array_10_20_20_40[] = {{10,20},{10,21},{11,22},{11,23},
765 {12,24},{12,25},{13,26},{13,27},
766 {14,28},{14,29},{15,30},{15,31},
767 {16,32},{16,33},{17,34},{17,35},
768 {18,36},{18,37},{19,38},{19,39},
769 {-1,-1}};
770 static const POINT array_10_20_20_43[] = {{10,20},{10,21},{11,22},{11,23},
771 {12,24},{12,25},{13,26},{13,27},
772 {13,28},{14,29},{14,30},{15,31},
773 {15,32},{16,33},{16,34},{17,35},
774 {17,36},{17,37},{18,38},{18,39},
775 {19,40},{19,41},{20,42},{-1,-1}};
776
777 static const POINT array_10_20_10_20[] = {{-1,-1}};
778 static const POINT array_10_20_11_27[] = {{10,20},{10,21},{10,22},{10,23},
779 {11,24},{11,25},{11,26},{-1,-1}};
780
781 static const POINT array_20_43_10_20[] = {{20,43},{20,42},{19,41},{19,40},
782 {18,39},{18,38},{17,37},{17,36},
783 {17,35},{16,34},{16,33},{15,32},
784 {15,31},{14,30},{14,29},{13,28},
785 {13,27},{13,26},{12,25},{12,24},
786 {11,23},{11,22},{10,21},{-1,-1}};
787
788 static const POINT array_20_20_10_43[] = {{20,20},{20,21},{19,22},{19,23},
789 {18,24},{18,25},{17,26},{17,27},
790 {17,28},{16,29},{16,30},{15,31},
791 {15,32},{14,33},{14,34},{13,35},
792 {13,36},{13,37},{12,38},{12,39},
793 {11,40},{11,41},{10,42},{-1,-1}};
794
795 static const POINT array_20_20_43_10[] = {{20,20},{21,20},{22,19},{23,19},
796 {24,18},{25,18},{26,17},{27,17},
797 {28,17},{29,16},{30,16},{31,15},
798 {32,15},{33,14},{34,14},{35,13},
799 {36,13},{37,13},{38,12},{39,12},
800 {40,11},{41,11},{42,10},{-1,-1}};
801
802
803 pt = array_10_20_20_40;
804 LineDDA(10, 20, 20, 40, linedda_callback, (LPARAM)&pt);
805 ok(pt->x == -1 && pt->y == -1, "didn't find terminator\n");
806
807 pt = array_10_20_20_43;
808 LineDDA(10, 20, 20, 43, linedda_callback, (LPARAM)&pt);
809 ok(pt->x == -1 && pt->y == -1, "didn't find terminator\n");
810
811 pt = array_10_20_10_20;
812 LineDDA(10, 20, 10, 20, linedda_callback, (LPARAM)&pt);
813 ok(pt->x == -1 && pt->y == -1, "didn't find terminator\n");
814
815 pt = array_10_20_11_27;
816 LineDDA(10, 20, 11, 27, linedda_callback, (LPARAM)&pt);
817 ok(pt->x == -1 && pt->y == -1, "didn't find terminator\n");
818
819 pt = array_20_43_10_20;
820 LineDDA(20, 43, 10, 20, linedda_callback, (LPARAM)&pt);
821 ok(pt->x == -1 && pt->y == -1, "didn't find terminator\n");
822
823 pt = array_20_20_10_43;
824 LineDDA(20, 20, 10, 43, linedda_callback, (LPARAM)&pt);
825 ok(pt->x == -1 && pt->y == -1, "didn't find terminator\n");
826
827 pt = array_20_20_43_10;
828 LineDDA(20, 20, 43, 10, linedda_callback, (LPARAM)&pt);
829 ok(pt->x == -1 && pt->y == -1, "didn't find terminator\n");
830}
LONG_PTR LPARAM
Definition: minwindef.h:175
static void WINAPI linedda_callback(INT x, INT y, LPARAM lparam)
Definition: path.c:751
BOOL WINAPI LineDDA(_In_ int, _In_ int, _In_ int, _In_ int, _In_ LINEDDAPROC, _In_opt_ LPARAM)

Referenced by START_TEST().

◆ test_path_state()

static void test_path_state ( void  )
static

Definition at line 36 of file path.c.

37{
38 BYTE buffer[sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)];
40 HDC hdc;
41 HRGN rgn;
42 HBITMAP orig, dib;
43 void *bits;
44 BOOL ret;
45
47 memset( buffer, 0, sizeof(buffer) );
48 bi->bmiHeader.biSize = sizeof(bi->bmiHeader);
49 bi->bmiHeader.biHeight = 256;
50 bi->bmiHeader.biWidth = 256;
51 bi->bmiHeader.biBitCount = 32;
52 bi->bmiHeader.biPlanes = 1;
54 dib = CreateDIBSection( 0, bi, DIB_RGB_COLORS, &bits, NULL, 0 );
55 orig = SelectObject( hdc, dib );
56
57 BeginPath( hdc );
58 LineTo( hdc, 100, 100 );
59 ret = WidenPath( hdc );
60 ok( !ret, "WidenPath succeeded\n" );
61
62 /* selecting another bitmap doesn't affect the path */
63 SelectObject( hdc, orig );
64 ret = WidenPath( hdc );
65 ok( !ret, "WidenPath succeeded\n" );
66
67 SelectObject( hdc, dib );
68 ret = WidenPath( hdc );
69 ok( !ret, "WidenPath succeeded\n" );
70
71 ret = EndPath( hdc );
72 ok( ret, "EndPath failed error %lu\n", GetLastError() );
73 ret = WidenPath( hdc );
74 ok( ret, "WidenPath failed error %lu\n", GetLastError() );
75
76 SelectObject( hdc, orig );
77 ret = WidenPath( hdc );
78 ok( ret, "WidenPath failed error %lu\n", GetLastError() );
79
80 BeginPath( hdc );
81 LineTo( hdc, 100, 100 );
82 ret = WidenPath( hdc );
83 ok( !ret, "WidenPath succeeded\n" );
84 SaveDC( hdc );
85 SelectObject( hdc, dib );
86 ret = EndPath( hdc );
87 ok( ret, "EndPath failed error %lu\n", GetLastError() );
88 ret = WidenPath( hdc );
89 ok( ret, "WidenPath failed error %lu\n", GetLastError() );
90
91 /* path should be open again after RestoreDC */
92 RestoreDC( hdc, -1 );
93 ret = WidenPath( hdc );
94 ok( !ret, "WidenPath succeeded\n" );
95 ret = EndPath( hdc );
96 ok( ret, "EndPath failed error %lu\n", GetLastError() );
97
98 SaveDC( hdc );
99 BeginPath( hdc );
100 RestoreDC( hdc, -1 );
101 ret = WidenPath( hdc );
102 ok( ret, "WidenPath failed error %lu\n", GetLastError() );
103
104 /* test all functions with no path at all */
105 AbortPath( hdc );
106 SetLastError( 0xdeadbeef );
107 ret = WidenPath( hdc );
108 ok( !ret, "WidenPath succeeded\n" );
109 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
110 "wrong error %lu\n", GetLastError() );
111
112 SetLastError( 0xdeadbeef );
113 ret = FlattenPath( hdc );
114 ok( !ret, "FlattenPath succeeded\n" );
115 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
116 "wrong error %lu\n", GetLastError() );
117
118 SetLastError( 0xdeadbeef );
119 ret = StrokePath( hdc );
120 ok( !ret, "StrokePath succeeded\n" );
121 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
122 "wrong error %lu\n", GetLastError() );
123
124 SetLastError( 0xdeadbeef );
125 ret = FillPath( hdc );
126 ok( !ret, "FillPath succeeded\n" );
127 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
128 "wrong error %lu\n", GetLastError() );
129
130 SetLastError( 0xdeadbeef );
132 ok( !ret, "StrokeAndFillPath succeeded\n" );
133 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
134 "wrong error %lu\n", GetLastError() );
135
136 SetLastError( 0xdeadbeef );
138 ok( !ret, "SelectClipPath succeeded\n" );
139 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
140 "wrong error %lu\n", GetLastError() );
141
142 SetLastError( 0xdeadbeef );
143 rgn = PathToRegion( hdc );
144 ok( !rgn, "PathToRegion succeeded\n" );
145 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
146 "wrong error %lu\n", GetLastError() );
147
148 SetLastError( 0xdeadbeef );
149 ret = EndPath( hdc );
150 ok( !ret, "SelectClipPath succeeded\n" );
151 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
152 "wrong error %lu\n", GetLastError() );
153
154 SetLastError( 0xdeadbeef );
155 ret = CloseFigure( hdc );
156 ok( !ret, "CloseFigure succeeded\n" );
157 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
158 "wrong error %lu\n", GetLastError() );
159
160 /* test all functions with an open path */
161 AbortPath( hdc );
162 BeginPath( hdc );
163 SetLastError( 0xdeadbeef );
164 ret = WidenPath( hdc );
165 ok( !ret, "WidenPath succeeded\n" );
166 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
167 "wrong error %lu\n", GetLastError() );
168
169 AbortPath( hdc );
170 BeginPath( hdc );
171 SetLastError( 0xdeadbeef );
172 ret = FlattenPath( hdc );
173 ok( !ret, "FlattenPath succeeded\n" );
174 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
175 "wrong error %lu\n", GetLastError() );
176
177 AbortPath( hdc );
178 BeginPath( hdc );
179 SetLastError( 0xdeadbeef );
180 ret = StrokePath( hdc );
181 ok( !ret, "StrokePath succeeded\n" );
182 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
183 "wrong error %lu\n", GetLastError() );
184
185 AbortPath( hdc );
186 BeginPath( hdc );
187 SetLastError( 0xdeadbeef );
188 ret = FillPath( hdc );
189 ok( !ret, "FillPath succeeded\n" );
190 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
191 "wrong error %lu\n", GetLastError() );
192
193 AbortPath( hdc );
194 BeginPath( hdc );
195 SetLastError( 0xdeadbeef );
197 ok( !ret, "StrokeAndFillPath succeeded\n" );
198 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
199 "wrong error %lu\n", GetLastError() );
200
201 AbortPath( hdc );
202 BeginPath( hdc );
203 Rectangle( hdc, 1, 1, 10, 10 ); /* region needs some contents */
204 SetLastError( 0xdeadbeef );
206 ok( !ret, "SelectClipPath succeeded\n" );
207 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
208 "wrong error %lu\n", GetLastError() );
209
210 AbortPath( hdc );
211 BeginPath( hdc );
212 Rectangle( hdc, 1, 1, 10, 10 ); /* region needs some contents */
213 SetLastError( 0xdeadbeef );
214 rgn = PathToRegion( hdc );
215 ok( !rgn, "PathToRegion succeeded\n" );
216 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
217 "wrong error %lu\n", GetLastError() );
218
219 AbortPath( hdc );
220 BeginPath( hdc );
221 ret = CloseFigure( hdc );
222 ok( ret, "CloseFigure failed\n" );
223
224 /* test all functions with a closed path */
225 AbortPath( hdc );
226 BeginPath( hdc );
227 EndPath( hdc );
228 ret = WidenPath( hdc );
229 ok( ret, "WidenPath failed\n" );
230 ok( GetPath( hdc, NULL, NULL, 0 ) != -1, "path deleted\n" );
231
232 AbortPath( hdc );
233 BeginPath( hdc );
234 EndPath( hdc );
235 ret = FlattenPath( hdc );
236 ok( ret, "FlattenPath failed\n" );
237 ok( GetPath( hdc, NULL, NULL, 0 ) != -1, "path deleted\n" );
238
239 AbortPath( hdc );
240 BeginPath( hdc );
241 EndPath( hdc );
242 ret = StrokePath( hdc );
243 ok( ret, "StrokePath failed\n" );
244 ok( GetPath( hdc, NULL, NULL, 0 ) == -1, "path not deleted\n" );
245
246 BeginPath( hdc );
247 EndPath( hdc );
248 ret = FillPath( hdc );
249 ok( ret, "FillPath failed\n" );
250 ok( GetPath( hdc, NULL, NULL, 0 ) == -1, "path not deleted\n" );
251
252 BeginPath( hdc );
253 EndPath( hdc );
255 ok( ret, "StrokeAndFillPath failed\n" );
256 ok( GetPath( hdc, NULL, NULL, 0 ) == -1, "path not deleted\n" );
257
258 BeginPath( hdc );
259 Rectangle( hdc, 1, 1, 10, 10 ); /* region needs some contents */
260 EndPath( hdc );
262 ok( ret, "SelectClipPath failed\n" );
263 ok( GetPath( hdc, NULL, NULL, 0 ) == -1, "path not deleted\n" );
264
265 BeginPath( hdc );
266 EndPath( hdc );
267 SetLastError( 0xdeadbeef );
269 ok( !ret, "SelectClipPath succeeded on empty path\n" );
270 ok( GetLastError() == 0xdeadbeef, "wrong error %lu\n", GetLastError() );
271 ok( GetPath( hdc, NULL, NULL, 0 ) == -1, "path not deleted\n" );
272
273 BeginPath( hdc );
274 Rectangle( hdc, 1, 1, 10, 10 ); /* region needs some contents */
275 EndPath( hdc );
276 rgn = PathToRegion( hdc );
277 ok( rgn != 0, "PathToRegion failed\n" );
278 DeleteObject( rgn );
279 ok( GetPath( hdc, NULL, NULL, 0 ) == -1, "path not deleted\n" );
280
281 BeginPath( hdc );
282 EndPath( hdc );
283 SetLastError( 0xdeadbeef );
284 rgn = PathToRegion( hdc );
285 ok( !rgn, "PathToRegion succeeded on empty path\n" );
286 ok( GetLastError() == 0xdeadbeef, "wrong error %lu\n", GetLastError() );
287 DeleteObject( rgn );
288 ok( GetPath( hdc, NULL, NULL, 0 ) == -1, "path not deleted\n" );
289
290 BeginPath( hdc );
291 EndPath( hdc );
292 SetLastError( 0xdeadbeef );
293 ret = CloseFigure( hdc );
294 ok( !ret, "CloseFigure succeeded\n" );
295 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
296 "wrong error %lu\n", GetLastError() );
297
298 AbortPath( hdc );
299 BeginPath( hdc );
300 EndPath( hdc );
301 SetLastError( 0xdeadbeef );
302 ret = EndPath( hdc );
303 ok( !ret, "EndPath succeeded\n" );
304 ok( GetLastError() == ERROR_CAN_NOT_COMPLETE || broken(GetLastError() == 0xdeadbeef),
305 "wrong error %lu\n", GetLastError() );
306
307 DeleteDC( hdc );
308 DeleteObject( dib );
309}
#define broken(x)
Definition: atltest.h:178
#define SetLastError(x)
Definition: compat.h:752
ULONG RGBQUAD
Definition: precomp.h:47
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint buffer
Definition: glext.h:5915
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
#define bits
Definition: infblock.c:15
#define memset(x, y, z)
Definition: compat.h:39
USHORT biBitCount
Definition: precomp.h:34
ULONG biCompression
Definition: precomp.h:35
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1922
#define BI_RGB
Definition: uefivid.c:46
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
#define ERROR_CAN_NOT_COMPLETE
Definition: winerror.h:906
#define DIB_RGB_COLORS
Definition: wingdi.h:367
BOOL WINAPI SelectClipPath(_In_ HDC, _In_ int)
BOOL WINAPI FlattenPath(_In_ HDC)
BOOL WINAPI FillPath(_In_ HDC)
BOOL WINAPI RestoreDC(_In_ HDC, _In_ int)
HRGN WINAPI PathToRegion(_In_ HDC)
BOOL WINAPI StrokePath(_In_ HDC)
#define RGN_OR
Definition: wingdi.h:359
BOOL WINAPI StrokeAndFillPath(_In_ HDC)
BOOL WINAPI WidenPath(_In_ HDC)
struct tagBITMAPINFO BITMAPINFO
int WINAPI SaveDC(_In_ HDC)

Referenced by START_TEST().

◆ test_polydraw()

static void test_polydraw ( void  )
static

Definition at line 605 of file path.c.

606{
607 BOOL retb;
608 POINT pos;
609 HDC hdc = GetDC(0);
610 HWND hwnd;
611
612 MoveToEx( hdc, -20, -20, NULL );
613
614 BeginPath(hdc);
616 ok( pos.x == -20 && pos.y == -20, "wrong pos %ld,%ld\n", pos.x, pos.y );
617
618 /* closefigure with no previous moveto */
619 if (!(retb = PolyDraw(hdc, polydraw_pts, polydraw_tps, 2)) &&
621 {
622 /* PolyDraw is only available on Win2k and later */
623 win_skip("PolyDraw is not available\n");
624 ReleaseDC(0, hdc);
625 return;
626 }
627 expect(TRUE, retb);
629 ok( pos.x == 10 && pos.y == 15, "wrong pos %ld,%ld\n", pos.x, pos.y );
630 LineTo(hdc, -10, -10);
632 ok( pos.x == -10 && pos.y == -10, "wrong pos %ld,%ld\n", pos.x, pos.y );
633
634 MoveToEx(hdc, 100, 100, NULL);
636 ok( pos.x == 100 && pos.y == 100, "wrong pos %ld,%ld\n", pos.x, pos.y );
637 LineTo(hdc, 95, 95);
639 ok( pos.x == 95 && pos.y == 95, "wrong pos %ld,%ld\n", pos.x, pos.y );
640 /* closefigure with previous moveto */
642 expect(TRUE, retb);
644 ok( pos.x == 10 && pos.y == 15, "wrong pos %ld,%ld\n", pos.x, pos.y );
645 /* bad bezier points */
646 retb = PolyDraw(hdc, &(polydraw_pts[2]), &(polydraw_tps[2]), 4);
647 expect(FALSE, retb);
649 ok( pos.x == 10 && pos.y == 15, "wrong pos %ld,%ld\n", pos.x, pos.y );
650 retb = PolyDraw(hdc, &(polydraw_pts[6]), &(polydraw_tps[6]), 4);
651 expect(FALSE, retb);
653 ok( pos.x == 10 && pos.y == 15, "wrong pos %ld,%ld\n", pos.x, pos.y );
654 /* good bezier points */
655 retb = PolyDraw(hdc, &(polydraw_pts[8]), &(polydraw_tps[8]), 4);
656 expect(TRUE, retb);
658 ok( pos.x == 35 && pos.y == 40, "wrong pos %ld,%ld\n", pos.x, pos.y );
659 /* does lineto or bezierto take precedence? */
660 retb = PolyDraw(hdc, &(polydraw_pts[12]), &(polydraw_tps[12]), 4);
661 expect(FALSE, retb);
663 ok( pos.x == 35 && pos.y == 40, "wrong pos %ld,%ld\n", pos.x, pos.y );
664 /* bad point type, has already moved cursor position */
665 retb = PolyDraw(hdc, &(polydraw_pts[15]), &(polydraw_tps[15]), 4);
666 expect(FALSE, retb);
668 ok( pos.x == 35 && pos.y == 40, "wrong pos %ld,%ld\n", pos.x, pos.y );
669 /* bad point type, cursor position is moved, but back to its original spot */
670 retb = PolyDraw(hdc, &(polydraw_pts[17]), &(polydraw_tps[17]), 4);
671 expect(FALSE, retb);
673 ok( pos.x == 35 && pos.y == 40, "wrong pos %ld,%ld\n", pos.x, pos.y );
674 /* does lineto or moveto take precedence? */
675 retb = PolyDraw(hdc, &(polydraw_pts[20]), &(polydraw_tps[20]), 3);
676 expect(TRUE, retb);
678 ok( pos.x == 65 && pos.y == 65, "wrong pos %ld,%ld\n", pos.x, pos.y );
679 /* consecutive movetos */
680 retb = PolyDraw(hdc, &(polydraw_pts[23]), &(polydraw_tps[23]), 4);
681 expect(TRUE, retb);
683 ok( pos.x == 80 && pos.y == 80, "wrong pos %ld,%ld\n", pos.x, pos.y );
684
685 EndPath(hdc);
686 ok_path(hdc, "polydraw_path", polydraw_path, ARRAY_SIZE(polydraw_path));
688 ok( pos.x == 80 && pos.y == 80, "wrong pos %ld,%ld\n", pos.x, pos.y );
689 ReleaseDC(0, hdc);
690
691 /* Test a special case that GDI path driver is created before window driver */
692 hwnd = CreateWindowA("static", NULL, 0, 0, 0, 0, 0, 0, 0, 0, NULL);
693 hdc = GetDC(hwnd);
694
695 BeginPath(hdc);
696 SetWindowPos(hwnd, 0, 0, 0, 100, 100, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW);
698 ok(retb, "PolyDraw failed, error %#lx\n", GetLastError());
699 EndPath(hdc);
700
703}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define expect(expected, got)
Definition: path.c:34
static POINT polydraw_pts[]
Definition: path.c:583
static BYTE polydraw_tps[]
Definition: path.c:594
static const path_test_t polydraw_path[]
Definition: path.c:548
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4469
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOMOVE
Definition: winuser.h:1255
#define SWP_SHOWWINDOW
Definition: winuser.h:1259
#define SWP_NOZORDER
Definition: winuser.h:1258
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by START_TEST().

◆ test_rectangle()

static void test_rectangle ( void  )
static

Definition at line 936 of file path.c.

937{
938 HDC hdc = GetDC( 0 );
939
940 BeginPath( hdc );
941 Rectangle( hdc, 20, 20, 40, 40 );
942 Rectangle( hdc, 30, 50, 55, 35 );
943 Rectangle( hdc, 60, 60, 35, 45 );
944 Rectangle( hdc, 70, 70, 50, 70 );
945 Rectangle( hdc, 75, 75, 75, 85 );
946 Rectangle( hdc, 80, 80, 81, 81 );
948 Rectangle( hdc, 20, 20, 40, 40 );
949 Rectangle( hdc, 30, 50, 55, 35 );
950 Rectangle( hdc, 60, 60, 35, 45 );
951 Rectangle( hdc, 70, 70, 50, 70 );
952 Rectangle( hdc, 75, 75, 75, 85 );
953 Rectangle( hdc, 80, 80, 81, 81 );
956 SetViewportExtEx( hdc, -2, 2, NULL );
957 Rectangle( hdc, 20, 20, 40, 40 );
958 Rectangle( hdc, 30, 50, 55, 35 );
959 SetViewportExtEx( hdc, 3, -3, NULL );
960 Rectangle( hdc, 20, 20, 40, 40 );
961 Rectangle( hdc, 30, 50, 55, 35 );
962 SetWindowExtEx( hdc, -20, 20, NULL );
963 Rectangle( hdc, 20, 20, 40, 40 );
964 Rectangle( hdc, 24, 22, 21, 20 );
967 Rectangle( hdc, 20, 20, 40, 40 );
968 Rectangle( hdc, 30, 50, 55, 35 );
969 Rectangle( hdc, 60, 60, 35, 45 );
970 Rectangle( hdc, 70, 70, 50, 70 );
971 Rectangle( hdc, 75, 75, 75, 85 );
972 Rectangle( hdc, 80, 80, 81, 81 );
974 Rectangle( hdc, 20, 20, 40, 40 );
975 Rectangle( hdc, 30, 50, 55, 35 );
976 Rectangle( hdc, 60, 60, 35, 45 );
977 Rectangle( hdc, 70, 70, 50, 70 );
978 Rectangle( hdc, 75, 75, 75, 85 );
979 Rectangle( hdc, 80, 80, 81, 81 );
981 EndPath( hdc );
983 ok_path( hdc, "rectangle_path", rectangle_path, ARRAY_SIZE(rectangle_path) );
984 ReleaseDC( 0, hdc );
985}
static const path_test_t rectangle_path[]
Definition: path.c:832

Referenced by START_TEST().

◆ test_roundrect()

static void test_roundrect ( void  )
static

Definition at line 1303 of file path.c.

1304{
1305 HDC hdc = GetDC( 0 );
1306
1307 BeginPath( hdc );
1308 RoundRect( hdc, 20, 20, 40, 40, 10, 10 );
1309 RoundRect( hdc, 30, 50, 55, 35, -30, -30 );
1310 RoundRect( hdc, 60, 60, 35, 45, 5, 2 );
1311 RoundRect( hdc, 70, 70, 50, 70, 3, 5 );
1312 RoundRect( hdc, 75, 75, 75, 85, 6, 4 );
1313 RoundRect( hdc, 80, 80, 81, 81, 8, 9 );
1314 RoundRect( hdc, 90, 90, 95, 85, 0, 7 );
1316 RoundRect( hdc, 20, 20, 40, 40, 10, 10 );
1317 RoundRect( hdc, 30, 50, 55, 35, -30, -30 );
1320 SetViewportExtEx( hdc, -2, 2, NULL );
1321 RoundRect( hdc, 20, 20, 40, 40, 15, 12 );
1322 RoundRect( hdc, 30, 50, 55, 35, 7, 9 );
1323 SetViewportExtEx( hdc, 3, -3, NULL );
1324 RoundRect( hdc, 20, 20, 40, 40, 15, 12 );
1325 RoundRect( hdc, 30, 50, 55, 35, 3, 4 );
1326 SetWindowExtEx( hdc, -20, 20, NULL );
1327 RoundRect( hdc, 20, 20, 40, 40, 2, 1 );
1328 RoundRect( hdc, 24, 22, 21, 20, 4, 4 );
1331 RoundRect( hdc, 20, 20, 40, 40, 10, 10 );
1332 RoundRect( hdc, 30, 50, 55, 35, -30, -30 );
1333 RoundRect( hdc, 60, 60, 35, 45, 5, 2 );
1334 RoundRect( hdc, 70, 70, 50, 70, 3, 5 );
1335 RoundRect( hdc, 75, 75, 75, 85, 6, 4 );
1336 RoundRect( hdc, 80, 80, 81, 81, 8, 9 );
1337 RoundRect( hdc, 90, 90, 95, 85, 0, 7 );
1339 RoundRect( hdc, 20, 20, 40, 40, 10, 10 );
1340 RoundRect( hdc, 30, 50, 55, 35, -30, -30 );
1342 EndPath( hdc );
1344 ok_path( hdc, "roundrect_path", roundrect_path, ARRAY_SIZE(roundrect_path) );
1345 ReleaseDC( 0, hdc );
1346}
static const path_test_t roundrect_path[]
Definition: path.c:987

Referenced by START_TEST().

◆ test_widenpath()

static void test_widenpath ( void  )
static

Definition at line 311 of file path.c.

312{
313 HDC hdc = GetDC(0);
314 HPEN greenPen, narrowPen;
315 POINT pnt[6];
316 INT nSize;
317 BOOL ret;
318
319 /* Create a pen to be used in WidenPath */
320 greenPen = CreatePen(PS_SOLID, 10, RGB(0,0,0));
321 SelectObject(hdc, greenPen);
322
323 /* Prepare a path */
324 pnt[0].x = 100;
325 pnt[0].y = 0;
326 pnt[1].x = 200;
327 pnt[1].y = 0;
328 pnt[2].x = 300;
329 pnt[2].y = 100;
330 pnt[3].x = 300;
331 pnt[3].y = 200;
332 pnt[4].x = 200;
333 pnt[4].y = 300;
334 pnt[5].x = 100;
335 pnt[5].y = 300;
336
337 /* Set a polyline path */
338 BeginPath(hdc);
339 Polyline(hdc, pnt, 6);
340 EndPath(hdc);
341
342 /* Widen the polyline path */
343 ok(WidenPath(hdc), "WidenPath fails while widening a poyline path.\n");
344
345 /* Test if WidenPath seems to have done his job */
346 nSize = GetPath(hdc, NULL, NULL, 0);
347 ok(nSize != -1, "GetPath fails after calling WidenPath.\n");
348 ok(nSize > 6, "Path number of points is too low. Should be more than 6 but is %d\n", nSize);
349
350 AbortPath(hdc);
351
352 /* Test WidenPath with an open path (last error only set on Win2k and later) */
353 SetLastError(0xdeadbeef);
354 BeginPath(hdc);
355 ret = WidenPath(hdc);
356 ok(ret == FALSE && (GetLastError() == ERROR_CAN_NOT_COMPLETE || GetLastError() == 0xdeadbeef),
357 "WidenPath fails while widening an open path. Return value is %d, should be %d. Error is %lu\n", ret, FALSE, GetLastError());
358
359 AbortPath(hdc);
360
361 /* Test when the pen width is equal to 1. The path should change too */
362 narrowPen = CreatePen(PS_SOLID, 1, RGB(0,0,0));
363 SelectObject(hdc, narrowPen);
364 BeginPath(hdc);
365 Polyline(hdc, pnt, 6);
366 EndPath(hdc);
367 ret = WidenPath(hdc);
368 ok(ret == TRUE, "WidenPath failed: %ld\n", GetLastError());
369 nSize = GetPath(hdc, NULL, NULL, 0);
370 ok(nSize > 6, "WidenPath should compute a widened path with a 1px wide pen. Path length is %d, should be more than 6\n", nSize);
371
372 ReleaseDC(0, hdc);
373 return;
374}
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
int32_t INT
Definition: typedefs.h:58
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
#define PS_SOLID
Definition: wingdi.h:586

Referenced by START_TEST().

Variable Documentation

◆ all_funcs_path

const path_test_t all_funcs_path[]
static

Definition at line 1727 of file path.c.

Referenced by test_all_functions().

◆ anglearc_path

const path_test_t anglearc_path[]
static
Initial value:
=
{
{0, 0, PT_MOVETO},
{371, 229, PT_LINETO},
{352, 211, PT_BEZIERTO},
{327, 200, PT_BEZIERTO},
{300, 200, PT_BEZIERTO},
{245, 200, PT_BEZIERTO},
{200, 245, PT_BEZIERTO},
{200, 300, PT_BEZIERTO},
{200, 300, PT_BEZIERTO},
{200, 300, PT_BEZIERTO},
{200, 300, PT_BEZIERTO},
{231, 260, PT_LINETO},
{245, 235, PT_BEZIERTO},
{271, 220, PT_BEZIERTO},
{300, 220, PT_BEZIERTO},
{344, 220, PT_BEZIERTO},
{380, 256, PT_BEZIERTO},
{380, 300, PT_BEZIERTO},
{380, 314, PT_BEZIERTO},
{376, 328, PT_BEZIERTO},
{369, 340, PT_BEZIERTO | PT_CLOSEFIGURE},
}

Definition at line 503 of file path.c.

Referenced by test_anglearc().

◆ arcto_path

const path_test_t arcto_path[]
static
Initial value:
=
{
{0, 0, PT_MOVETO},
{229, 215, PT_LINETO},
{248, 205, PT_BEZIERTO},
{273, 200, PT_BEZIERTO},
{300, 200, PT_BEZIERTO},
{355, 200, PT_BEZIERTO},
{399, 222, PT_BEZIERTO},
{399, 250, PT_BEZIERTO},
{399, 263, PT_BEZIERTO},
{389, 275, PT_BEZIERTO},
{370, 285, PT_BEZIERTO},
{363, 277, PT_LINETO},
{380, 270, PT_BEZIERTO},
{389, 260, PT_BEZIERTO},
{389, 250, PT_BEZIERTO},
{389, 228, PT_BEZIERTO},
{349, 210, PT_BEZIERTO},
{300, 210, PT_BEZIERTO},
{276, 210, PT_BEZIERTO},
{253, 214, PT_BEZIERTO},
{236, 222, PT_BEZIERTO | PT_CLOSEFIGURE},
}

Definition at line 455 of file path.c.

Referenced by test_arcto().

◆ ellipse_path

const path_test_t ellipse_path[]
static

Definition at line 1348 of file path.c.

Referenced by test_ellipse().

◆ polydraw_path

const path_test_t polydraw_path[]
static

Definition at line 548 of file path.c.

Referenced by test_polydraw().

◆ polydraw_pts

POINT polydraw_pts[]
static
Initial value:
= {
{10, 10}, {10, 15},
{15, 15}, {15, 20}, {20, 20}, {20, 25},
{25, 25}, {25, 30},
{30, 30}, {30, 35}, {35, 35}, {35, 40},
{40, 40}, {40, 45}, {45, 45},
{45, 50}, {50, 50},
{50, 55}, {45, 50}, {55, 60},
{60, 60}, {60, 65}, {65, 65},
{70, 70}, {75, 70}, {75, 75}, {80, 80}}

Definition at line 583 of file path.c.

Referenced by test_polydraw().

◆ polydraw_tps

◆ rectangle_path

const path_test_t rectangle_path[]
static

Definition at line 832 of file path.c.

Referenced by test_rectangle().

◆ roundrect_path

const path_test_t roundrect_path[]
static

Definition at line 987 of file path.c.

Referenced by test_roundrect().