ReactOS  0.4.14-dev-815-ge410a12
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)
 
 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 740 of file path.c.

741 {
742  POINT **pt = (POINT**)lparam;
743  ok((*pt)->x == x && (*pt)->y == y, "point mismatch expect(%d,%d) got(%d,%d)\n",
744  (*pt)->x, (*pt)->y, x, y);
745 
746  (*pt)++;
747  return;
748 }
#define pt(x, y)
Definition: drawing.c:79
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
#define ok(value,...)
Definition: atltest.h:57
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 %d\n", size, GetLastError());
414  if (size <= 0) return;
415 
416  pnt = HeapAlloc(GetProcessHeap(), 0, size*sizeof(POINT));
417  assert(pnt != 0);
418  types = HeapAlloc(GetProcessHeap(), 0, size*sizeof(BYTE));
419  assert(types != 0);
420  size = GetPath(hdc, pnt, types, size);
421  assert(size > 0);
422 
424  ok( size == expected_size, "%s: Path size %d does not match expected size %d\n",
425  path_name, size, expected_size);
426 
427  for (idx = 0; idx < min( size, expected_size ); idx++)
428  {
429  /* We allow a few pixels fudge in matching X and Y coordinates to account for imprecision in
430  * floating point to integer conversion */
431  static const int fudge = 2;
432 
434  ok( types[idx] == expected[idx].type, "%s: Expected #%d: %s (%d,%d) but got %s (%d,%d)\n",
435  path_name, idx, type_string[expected[idx].type], expected[idx].x, expected[idx].y,
436  type_string[types[idx]], pnt[idx].x, pnt[idx].y);
437 
438  if (types[idx] == expected[idx].type)
440  ok( (pnt[idx].x >= expected[idx].x - fudge && pnt[idx].x <= expected[idx].x + fudge) &&
441  (pnt[idx].y >= expected[idx].y - fudge && pnt[idx].y <= expected[idx].y + fudge),
442  "%s: Expected #%d: %s position (%d,%d) but got (%d,%d)\n", path_name, idx,
443  type_string[expected[idx].type], expected[idx].x, expected[idx].y, pnt[idx].x, pnt[idx].y);
444  }
445 
446  if (winetest_debug > 2)
447  {
448  printf("static const path_test_t %s[] =\n{\n", path_name);
449  for (idx = 0; idx < size; idx++)
450  printf(" {%d, %d, %s}, /* %d */\n", pnt[idx].x, pnt[idx].y, type_string[types[idx]], idx);
451  printf("};\n" );
452  }
453 
455  HeapFree(GetProcessHeap(), 0, pnt);
456 }
GLsizei GLenum GLenum * types
Definition: glext.h:7753
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define assert(x)
Definition: debug.h:53
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
int winetest_debug
unsigned int idx
Definition: utils.c:41
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
Definition: cmds.c:130
INT WINAPI GetPath(HDC hdc, LPPOINT pptlBuf, LPBYTE pjTypes, INT cptBuf)
Definition: path.c:95
static char * path_name(DOS_FILE *file)
Definition: check.c:208
HDC hdc
Definition: main.c:9
unsigned char BYTE
Definition: mem.h:68
#define ros_skip_flaky
Definition: test.h:166
#define ok(value,...)
Definition: atltest.h:57
#define min(a, b)
Definition: monoChain.cc:55
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define HeapFree(x, y, z)
Definition: compat.h:402
BOOL expected
Definition: store.c:2063
#define printf
Definition: config.h:203

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 1900 of file path.c.

1901 {
1902  test_path_state();
1903  test_widenpath();
1904  test_arcto();
1905  test_anglearc();
1906  test_polydraw();
1907  test_closefigure();
1908  test_linedda();
1909  test_rectangle();
1910  test_roundrect();
1911  test_ellipse();
1913 }
static void test_polydraw(void)
Definition: path.c:608
static void test_widenpath(void)
Definition: path.c:311
static void test_ellipse(void)
Definition: path.c:1666
static void test_closefigure(void)
Definition: path.c:694
static void test_rectangle(void)
Definition: path.c:925
static void test_linedda(void)
Definition: path.c:750
static void test_roundrect(void)
Definition: path.c:1292
static void test_all_functions(void)
Definition: path.c:1862
static void test_anglearc(void)
Definition: path.c:531
static void test_arcto(void)
Definition: path.c:483
static void test_path_state(void)
Definition: path.c:36

◆ test_all_functions()

static void test_all_functions ( void  )
static

Definition at line 1862 of file path.c.

1863 {
1864  POINT pts[9] = {{10, 10}, {20, 10}, {10, 20}, {20, 20}, {30, 30}, {40, 20},
1865  {20, 30}, {30, 40}, {10, 50}};
1866  DWORD counts[5] = {4, 5, 0, 1, 2};
1869  HDC hdc = GetDC( 0 );
1870 
1871  BeginPath( hdc );
1872  LineTo( hdc, 50, 150 );
1873  MoveToEx( hdc, 50, 50, NULL );
1874  LineTo( hdc, 150, 150 );
1875  LineTo( hdc, 150, 50 );
1876  LineTo( hdc, 50, 50 );
1877  AngleArc( hdc, 37, 36, 23, 90, 180 );
1878  Polyline( hdc, pts, 4 );
1879  Arc( hdc, 21, 21, 39, 29, 39, 29, 21, 21 );
1880  PolylineTo( hdc, pts, 4 );
1881  ArcTo( hdc, 23, 23, 37, 27, 37, 27, 23, 23 );
1882  PolyPolyline( hdc, pts, counts, 2 );
1883  Chord( hdc, 42, 43, 57, 66, 39, 29, 21, 21 );
1884  PolyDraw( hdc, pts, types, 9 );
1885  Pie( hdc, 52, 54, 65, 68, 39, 29, 21, 21 );
1886  Polygon( hdc, pts, 9 );
1887  Ellipse( hdc, 22, 33, 44, 66 );
1888  Rectangle( hdc, 60, 70, 80, 90 );
1889  RoundRect( hdc, 100, 100, 200, 200, 35, 45 );
1890  PolyBezier( hdc, pts, 7 );
1891  PolyPolygon( hdc, pts, (int *)counts, 2 );
1892  PolyBezierTo( hdc, pts, 9 );
1893  LineTo( hdc, 150, 150 );
1894  /* FIXME: ExtTextOut */
1895  EndPath( hdc );
1896  ok_path( hdc, "all_funcs_path", all_funcs_path, sizeof(all_funcs_path)/sizeof(path_test_t) );
1897  ReleaseDC( 0, hdc );
1898 }
BOOL WINAPI PolyDraw(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_reads_(cpt) const BYTE *aj, _In_ int cpt)
BOOL Polygon(CONST PPOINT UnsafePoints, int Count, int polyFillMode)
Definition: polytest.cpp:730
static const path_test_t all_funcs_path[]
Definition: path.c:1716
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
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 LineTo(_In_ HDC, _In_ int, _In_ int)
BOOL WINAPI PolylineTo(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_ DWORD cpt)
Definition: painting.c:354
static void ok_path(HDC hdc, const char *path_name, const path_test_t *expected, int expected_size)
Definition: path.c:401
BOOL WINAPI BeginPath(HDC hdc)
Definition: path.c:31
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
BOOL WINAPI PolyBezierTo(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_ DWORD cpt)
Definition: painting.c:281
BOOL WINAPI RoundRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI Arc(_In_ HDC hdc, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom, _In_ INT xStartArc, _In_ INT yStartArc, _In_ INT xEndArc, _In_ INT yEndArc)
Definition: arc.c:5
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI PolyPolygon(_In_ HDC hdc, _In_ const POINT *apt, _In_reads_(csz) const INT *asz, _In_ int csz)
Definition: cmds.c:130
BOOL WINAPI Pie(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
HDC hdc
Definition: main.c:9
unsigned char BYTE
Definition: mem.h:68
BOOL WINAPI PolyPolyline(_In_ HDC hdc, _In_ const POINT *apt, _In_reads_(csz) const DWORD *asz, _In_ DWORD csz)
BOOL WINAPI EndPath(HDC hdc)
Definition: path.c:56
BOOL WINAPI Ellipse(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI PolyBezier(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_ DWORD cpt)
Definition: painting.c:263
#define PT_CLOSEFIGURE
Definition: wingdi.h:886
#define PT_LINETO
Definition: wingdi.h:884
BOOL WINAPI Polyline(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_ int cpt)
#define PT_MOVETO
Definition: wingdi.h:883
#define PT_BEZIERTO
Definition: wingdi.h:885
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 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

Referenced by START_TEST().

◆ test_anglearc()

static void test_anglearc ( void  )
static

Definition at line 531 of file path.c.

532 {
533  HDC hdc = GetDC(0);
534  BeginPath(hdc);
535  if (!AngleArc(hdc, 300, 300, 100, 45.0, 135.0) &&
537  {
538  /* AngleArc is only available on Win2k and later */
539  win_skip("AngleArc is not available\n");
540  goto done;
541  }
542  AngleArc(hdc, 300, 300, 80, 150.0, -180.0);
543  CloseFigure(hdc);
544  EndPath(hdc);
545 
546  ok_path(hdc, "anglearc_path", anglearc_path, sizeof(anglearc_path)/sizeof(path_test_t));
547 done:
548  ReleaseDC(0, hdc);
549 }
static const path_test_t anglearc_path[]
Definition: path.c:506
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
BOOL WINAPI CloseFigure(HDC hdc)
Definition: path.c:43
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static void ok_path(HDC hdc, const char *path_name, const path_test_t *expected, int expected_size)
Definition: path.c:401
BOOL WINAPI BeginPath(HDC hdc)
Definition: path.c:31
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC hdc
Definition: main.c:9
BOOL WINAPI EndPath(HDC hdc)
Definition: path.c:56
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define win_skip
Definition: test.h:149
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

Referenced by START_TEST().

◆ test_arcto()

static void test_arcto ( void  )
static

Definition at line 483 of file path.c.

484 {
485  HDC hdc = GetDC(0);
486 
487  BeginPath(hdc);
489  if (!ArcTo(hdc, 200, 200, 400, 300, 200, 200, 400, 300) &&
491  {
492  /* ArcTo is only available on Win2k and later */
493  win_skip("ArcTo is not available\n");
494  goto done;
495  }
497  ArcTo(hdc, 210, 210, 390, 290, 390, 290, 210, 210);
498  CloseFigure(hdc);
499  EndPath(hdc);
500 
501  ok_path(hdc, "arcto_path", arcto_path, sizeof(arcto_path)/sizeof(path_test_t));
502 done:
503  ReleaseDC(0, hdc);
504 }
HDC WINAPI GetDC(_In_opt_ HWND)
static const path_test_t arcto_path[]
Definition: path.c:458
static HDC
Definition: imagelist.c:92
BOOL WINAPI CloseFigure(HDC hdc)
Definition: path.c:43
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
static void ok_path(HDC hdc, const char *path_name, const path_test_t *expected, int expected_size)
Definition: path.c:401
#define AD_COUNTERCLOCKWISE
Definition: wingdi.h:666
BOOL WINAPI BeginPath(HDC hdc)
Definition: path.c:31
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define AD_CLOCKWISE
Definition: wingdi.h:667
int WINAPI SetArcDirection(_In_ HDC, _In_ int)
HDC hdc
Definition: main.c:9
BOOL WINAPI EndPath(HDC hdc)
Definition: path.c:56
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define win_skip
Definition: test.h:149
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

Referenced by START_TEST().

◆ test_closefigure()

static void test_closefigure ( void  )
static

Definition at line 694 of file path.c.

694  {
695  int nSize, nSizeWitness;
696  POINT pos;
697  HDC hdc = GetDC(0);
698 
699  MoveToEx( hdc, 100, 100, NULL );
701  ok( pos.x == 100 && pos.y == 100, "wrong pos %d,%d\n", pos.x, pos.y );
702 
703  BeginPath(hdc);
705  ok( pos.x == 100 && pos.y == 100, "wrong pos %d,%d\n", pos.x, pos.y );
706  MoveToEx(hdc, 95, 95, NULL);
708  ok( pos.x == 95 && pos.y == 95, "wrong pos %d,%d\n", pos.x, pos.y );
709  LineTo(hdc, 95, 0);
711  ok( pos.x == 95 && pos.y == 0, "wrong pos %d,%d\n", pos.x, pos.y );
712  LineTo(hdc, 0, 95);
714  ok( pos.x == 0 && pos.y == 95, "wrong pos %d,%d\n", pos.x, pos.y );
715 
716  CloseFigure(hdc);
718  ok( pos.x == 0 && pos.y == 95, "wrong pos %d,%d\n", pos.x, pos.y );
719  EndPath(hdc);
721  ok( pos.x == 0 && pos.y == 95, "wrong pos %d,%d\n", pos.x, pos.y );
722  nSize = GetPath(hdc, NULL, NULL, 0);
723 
724  AbortPath(hdc);
725 
726  BeginPath(hdc);
727  MoveToEx(hdc, 95, 95, NULL);
728  LineTo(hdc, 95, 0);
729  LineTo(hdc, 0, 95);
730 
731  EndPath(hdc);
732  nSizeWitness = GetPath(hdc, NULL, NULL, 0);
733 
734  /* This test shows CloseFigure does not have to add a point at the end of the path */
735  ok(nSize == nSizeWitness, "Wrong number of points, no point should be added by CloseFigure\n");
736 
737  ReleaseDC(0, hdc);
738 }
BOOL WINAPI GetCurrentPositionEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:241
HDC WINAPI GetDC(_In_opt_ HWND)
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2031
static HDC
Definition: imagelist.c:92
BOOL WINAPI CloseFigure(HDC hdc)
Definition: path.c:43
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
BOOL WINAPI BeginPath(HDC hdc)
Definition: path.c:31
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
INT WINAPI GetPath(HDC hdc, LPPOINT pptlBuf, LPBYTE pjTypes, INT cptBuf)
Definition: path.c:95
HDC hdc
Definition: main.c:9
BOOL WINAPI EndPath(HDC hdc)
Definition: path.c:56
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI AbortPath(HDC hdc)
Definition: path.c:18

Referenced by START_TEST().

◆ test_ellipse()

static void test_ellipse ( void  )
static

Definition at line 1666 of file path.c.

1667 {
1668  HDC hdc = GetDC( 0 );
1669 
1670  BeginPath( hdc );
1671  Ellipse( hdc, 20, 20, 40, 40 );
1672  Ellipse( hdc, 30, 50, 55, 35 );
1673  Ellipse( hdc, 60, 60, 35, 45 );
1674  Ellipse( hdc, 70, 70, 50, 70 );
1675  Ellipse( hdc, 75, 75, 75, 85 );
1676  Ellipse( hdc, 80, 80, 81, 81 );
1678  Ellipse( hdc, 20, 20, 40, 40 );
1679  Ellipse( hdc, 30, 50, 55, 35 );
1680  Ellipse( hdc, 60, 60, 35, 45 );
1681  Ellipse( hdc, 70, 70, 50, 70 );
1682  Ellipse( hdc, 75, 75, 75, 85 );
1683  Ellipse( hdc, 80, 80, 81, 81 );
1686  SetViewportExtEx( hdc, -2, 2, NULL );
1687  Ellipse( hdc, 20, 20, 40, 40 );
1688  Ellipse( hdc, 30, 50, 55, 35 );
1689  SetViewportExtEx( hdc, 3, -3, NULL );
1690  Ellipse( hdc, 20, 20, 40, 40 );
1691  Ellipse( hdc, 30, 50, 55, 35 );
1692  SetWindowExtEx( hdc, -20, 20, NULL );
1693  Ellipse( hdc, 20, 20, 40, 40 );
1694  Ellipse( hdc, 24, 22, 21, 20 );
1695  SetMapMode( hdc, MM_TEXT );
1697  Ellipse( hdc, 20, 20, 40, 40 );
1698  Ellipse( hdc, 30, 50, 55, 35 );
1699  Ellipse( hdc, 60, 60, 35, 45 );
1700  Ellipse( hdc, 70, 70, 50, 70 );
1701  Ellipse( hdc, 75, 75, 75, 85 );
1702  Ellipse( hdc, 80, 80, 81, 81 );
1704  Ellipse( hdc, 20, 20, 40, 40 );
1705  Ellipse( hdc, 30, 50, 55, 35 );
1706  Ellipse( hdc, 60, 60, 35, 45 );
1707  Ellipse( hdc, 70, 70, 50, 70 );
1708  Ellipse( hdc, 75, 75, 75, 85 );
1709  Ellipse( hdc, 80, 80, 81, 81 );
1711  EndPath( hdc );
1712  SetMapMode( hdc, MM_TEXT );
1713  ok_path( hdc, "ellipse_path", ellipse_path, sizeof(ellipse_path)/sizeof(path_test_t) );
1714 }
BOOL WINAPI SetWindowExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
static const path_test_t ellipse_path[]
Definition: path.c:1337
static void ok_path(HDC hdc, const char *path_name, const path_test_t *expected, int expected_size)
Definition: path.c:401
#define AD_COUNTERCLOCKWISE
Definition: wingdi.h:666
BOOL WINAPI BeginPath(HDC hdc)
Definition: path.c:31
int WINAPI SetMapMode(_In_ HDC, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
#define AD_CLOCKWISE
Definition: wingdi.h:667
int WINAPI SetArcDirection(_In_ HDC, _In_ int)
HDC hdc
Definition: main.c:9
#define MM_ANISOTROPIC
Definition: wingdi.h:866
BOOL WINAPI EndPath(HDC hdc)
Definition: path.c:56
BOOL WINAPI Ellipse(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define MM_TEXT
Definition: wingdi.h:872
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:465
int WINAPI SetGraphicsMode(_In_ HDC, _In_ int)
Definition: dc.c:1202
#define GM_ADVANCED
Definition: wingdi.h:864

Referenced by START_TEST().

◆ test_linedda()

static void test_linedda ( void  )
static

Definition at line 750 of file path.c.

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

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)];
39  BITMAPINFO *bi = (BITMAPINFO *)buffer;
40  HDC hdc;
41  HRGN rgn;
42  HBITMAP orig, dib;
43  void *bits;
44  BOOL ret;
45 
46  hdc = CreateCompatibleDC( 0 );
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, (void**)&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 %u\n", GetLastError() );
73  ret = WidenPath( hdc );
74  ok( ret, "WidenPath failed error %u\n", GetLastError() );
75 
76  SelectObject( hdc, orig );
77  ret = WidenPath( hdc );
78  ok( ret, "WidenPath failed error %u\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 %u\n", GetLastError() );
88  ret = WidenPath( hdc );
89  ok( ret, "WidenPath failed error %u\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 %u\n", GetLastError() );
97 
98  SaveDC( hdc );
99  BeginPath( hdc );
100  RestoreDC( hdc, -1 );
101  ret = WidenPath( hdc );
102  ok( ret, "WidenPath failed error %u\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 %u\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 %u\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 %u\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 %u\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 %u\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 %u\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 %u\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 %u\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 %u\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 %u\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 %u\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 %u\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 %u\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 %u\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 %u\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 %u\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 %u\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 %u\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 %u\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 %u\n", GetLastError() );
306 
307  DeleteDC( hdc );
308  DeleteObject( dib );
309 }
BOOL WINAPI SelectClipPath(HDC hdc, int iMode)
Definition: path.c:191
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1475
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI StrokeAndFillPath(HDC hdc)
Definition: path.c:153
static HDC
Definition: imagelist.c:92
BOOL WINAPI CloseFigure(HDC hdc)
Definition: path.c:43
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
GLuint buffer
Definition: glext.h:5915
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
DWORD ret
Definition: path.c:47
BOOL WINAPI BeginPath(HDC hdc)
Definition: path.c:31
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ERROR_CAN_NOT_COMPLETE
Definition: winerror.h:582
DWORD biCompression
Definition: amvideo.idl:35
smooth NULL
Definition: ftsmooth.c:416
#define RGN_OR
Definition: wingdi.h:358
BOOL WINAPI WidenPath(HDC hdc)
Definition: path.c:179
INT WINAPI GetPath(HDC hdc, LPPOINT pptlBuf, LPBYTE pjTypes, INT cptBuf)
Definition: path.c:95
HRGN WINAPI PathToRegion(HDC hdc)
Definition: path.c:120
BOOL WINAPI FillPath(HDC hdc)
Definition: path.c:69
#define SetLastError(x)
Definition: compat.h:417
BOOL WINAPI StrokePath(HDC hdc)
Definition: path.c:166
HDC hdc
Definition: main.c:9
unsigned char BYTE
Definition: mem.h:68
#define broken(x)
Definition: _sntprintf.h:21
BOOL WINAPI EndPath(HDC hdc)
Definition: path.c:56
BOOL WINAPI DeleteDC(_In_ HDC)
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
#define ok(value,...)
Definition: atltest.h:57
int WINAPI SaveDC(_In_ HDC)
static const BYTE dib[]
Definition: ole2.c:201
BOOL WINAPI FlattenPath(HDC hdc)
Definition: path.c:82
static HBITMAP
Definition: button.c:44
#define DIB_RGB_COLORS
Definition: wingdi.h:366
#define memset(x, y, z)
Definition: compat.h:39
BOOL WINAPI RestoreDC(_In_ HDC, _In_ int)
#define BI_RGB
Definition: precomp.h:41
BOOL WINAPI AbortPath(HDC hdc)
Definition: path.c:18
struct tagBITMAPINFO BITMAPINFO

Referenced by START_TEST().

◆ test_polydraw()

static void test_polydraw ( void  )
static

Definition at line 608 of file path.c.

609 {
610  BOOL retb;
611  POINT pos;
612  HDC hdc = GetDC(0);
613 
614  MoveToEx( hdc, -20, -20, NULL );
615 
616  BeginPath(hdc);
618  ok( pos.x == -20 && pos.y == -20, "wrong pos %d,%d\n", pos.x, pos.y );
619 
620  /* closefigure with no previous moveto */
621  if (!(retb = PolyDraw(hdc, polydraw_pts, polydraw_tps, 2)) &&
623  {
624  /* PolyDraw is only available on Win2k and later */
625  win_skip("PolyDraw is not available\n");
626  goto done;
627  }
628  expect(TRUE, retb);
630  ok( pos.x == 10 && pos.y == 15, "wrong pos %d,%d\n", pos.x, pos.y );
631  LineTo(hdc, -10, -10);
633  ok( pos.x == -10 && pos.y == -10, "wrong pos %d,%d\n", pos.x, pos.y );
634 
635  MoveToEx(hdc, 100, 100, NULL);
637  ok( pos.x == 100 && pos.y == 100, "wrong pos %d,%d\n", pos.x, pos.y );
638  LineTo(hdc, 95, 95);
640  ok( pos.x == 95 && pos.y == 95, "wrong pos %d,%d\n", pos.x, pos.y );
641  /* closefigure with previous moveto */
642  retb = PolyDraw(hdc, polydraw_pts, polydraw_tps, 2);
643  expect(TRUE, retb);
645  ok( pos.x == 10 && pos.y == 15, "wrong pos %d,%d\n", pos.x, pos.y );
646  /* bad bezier points */
647  retb = PolyDraw(hdc, &(polydraw_pts[2]), &(polydraw_tps[2]), 4);
648  expect(FALSE, retb);
650  ok( pos.x == 10 && pos.y == 15, "wrong pos %d,%d\n", pos.x, pos.y );
651  retb = PolyDraw(hdc, &(polydraw_pts[6]), &(polydraw_tps[6]), 4);
652  expect(FALSE, retb);
654  ok( pos.x == 10 && pos.y == 15, "wrong pos %d,%d\n", pos.x, pos.y );
655  /* good bezier points */
656  retb = PolyDraw(hdc, &(polydraw_pts[8]), &(polydraw_tps[8]), 4);
657  expect(TRUE, retb);
659  ok( pos.x == 35 && pos.y == 40, "wrong pos %d,%d\n", pos.x, pos.y );
660  /* does lineto or bezierto take precedence? */
661  retb = PolyDraw(hdc, &(polydraw_pts[12]), &(polydraw_tps[12]), 4);
662  expect(FALSE, retb);
664  ok( pos.x == 35 && pos.y == 40, "wrong pos %d,%d\n", pos.x, pos.y );
665  /* bad point type, has already moved cursor position */
666  retb = PolyDraw(hdc, &(polydraw_pts[15]), &(polydraw_tps[15]), 4);
667  expect(FALSE, retb);
669  ok( pos.x == 35 && pos.y == 40, "wrong pos %d,%d\n", pos.x, pos.y );
670  /* bad point type, cursor position is moved, but back to its original spot */
671  retb = PolyDraw(hdc, &(polydraw_pts[17]), &(polydraw_tps[17]), 4);
672  expect(FALSE, retb);
674  ok( pos.x == 35 && pos.y == 40, "wrong pos %d,%d\n", pos.x, pos.y );
675  /* does lineto or moveto take precedence? */
676  retb = PolyDraw(hdc, &(polydraw_pts[20]), &(polydraw_tps[20]), 3);
677  expect(TRUE, retb);
679  ok( pos.x == 65 && pos.y == 65, "wrong pos %d,%d\n", pos.x, pos.y );
680  /* consecutive movetos */
681  retb = PolyDraw(hdc, &(polydraw_pts[23]), &(polydraw_tps[23]), 4);
682  expect(TRUE, retb);
684  ok( pos.x == 80 && pos.y == 80, "wrong pos %d,%d\n", pos.x, pos.y );
685 
686  EndPath(hdc);
687  ok_path(hdc, "polydraw_path", polydraw_path, sizeof(polydraw_path)/sizeof(path_test_t));
689  ok( pos.x == 80 && pos.y == 80, "wrong pos %d,%d\n", pos.x, pos.y );
690 done:
691  ReleaseDC(0, hdc);
692 }
BOOL WINAPI PolyDraw(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_reads_(cpt) const BYTE *aj, _In_ int cpt)
BOOL WINAPI GetCurrentPositionEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:241
#define TRUE
Definition: types.h:120
HDC WINAPI GetDC(_In_opt_ HWND)
static const path_test_t polydraw_path[]
Definition: path.c:551
static HDC
Definition: imagelist.c:92
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
#define expect(expected, got)
Definition: path.c:34
static void ok_path(HDC hdc, const char *path_name, const path_test_t *expected, int expected_size)
Definition: path.c:401
BOOL WINAPI BeginPath(HDC hdc)
Definition: path.c:31
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
static BYTE polydraw_tps[]
Definition: path.c:597
unsigned int BOOL
Definition: ntddk_ex.h:94
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
HDC hdc
Definition: main.c:9
BOOL WINAPI EndPath(HDC hdc)
Definition: path.c:56
static POINT polydraw_pts[]
Definition: path.c:586
#define ok(value,...)
Definition: atltest.h:57
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define win_skip
Definition: test.h:149

Referenced by START_TEST().

◆ test_rectangle()

static void test_rectangle ( void  )
static

Definition at line 925 of file path.c.

926 {
927  HDC hdc = GetDC( 0 );
928 
929  BeginPath( hdc );
930  Rectangle( hdc, 20, 20, 40, 40 );
931  Rectangle( hdc, 30, 50, 55, 35 );
932  Rectangle( hdc, 60, 60, 35, 45 );
933  Rectangle( hdc, 70, 70, 50, 70 );
934  Rectangle( hdc, 75, 75, 75, 85 );
935  Rectangle( hdc, 80, 80, 81, 81 );
937  Rectangle( hdc, 20, 20, 40, 40 );
938  Rectangle( hdc, 30, 50, 55, 35 );
939  Rectangle( hdc, 60, 60, 35, 45 );
940  Rectangle( hdc, 70, 70, 50, 70 );
941  Rectangle( hdc, 75, 75, 75, 85 );
942  Rectangle( hdc, 80, 80, 81, 81 );
945  SetViewportExtEx( hdc, -2, 2, NULL );
946  Rectangle( hdc, 20, 20, 40, 40 );
947  Rectangle( hdc, 30, 50, 55, 35 );
948  SetViewportExtEx( hdc, 3, -3, NULL );
949  Rectangle( hdc, 20, 20, 40, 40 );
950  Rectangle( hdc, 30, 50, 55, 35 );
951  SetWindowExtEx( hdc, -20, 20, NULL );
952  Rectangle( hdc, 20, 20, 40, 40 );
953  Rectangle( hdc, 24, 22, 21, 20 );
954  SetMapMode( hdc, MM_TEXT );
956  Rectangle( hdc, 20, 20, 40, 40 );
957  Rectangle( hdc, 30, 50, 55, 35 );
958  Rectangle( hdc, 60, 60, 35, 45 );
959  Rectangle( hdc, 70, 70, 50, 70 );
960  Rectangle( hdc, 75, 75, 75, 85 );
961  Rectangle( hdc, 80, 80, 81, 81 );
963  Rectangle( hdc, 20, 20, 40, 40 );
964  Rectangle( hdc, 30, 50, 55, 35 );
965  Rectangle( hdc, 60, 60, 35, 45 );
966  Rectangle( hdc, 70, 70, 50, 70 );
967  Rectangle( hdc, 75, 75, 75, 85 );
968  Rectangle( hdc, 80, 80, 81, 81 );
970  EndPath( hdc );
971  SetMapMode( hdc, MM_TEXT );
972  ok_path( hdc, "rectangle_path", rectangle_path, sizeof(rectangle_path)/sizeof(path_test_t) );
973  ReleaseDC( 0, hdc );
974 }
BOOL WINAPI SetWindowExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
static void ok_path(HDC hdc, const char *path_name, const path_test_t *expected, int expected_size)
Definition: path.c:401
#define AD_COUNTERCLOCKWISE
Definition: wingdi.h:666
BOOL WINAPI BeginPath(HDC hdc)
Definition: path.c:31
int WINAPI SetMapMode(_In_ HDC, _In_ int)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
#define AD_CLOCKWISE
Definition: wingdi.h:667
int WINAPI SetArcDirection(_In_ HDC, _In_ int)
HDC hdc
Definition: main.c:9
#define MM_ANISOTROPIC
Definition: wingdi.h:866
BOOL WINAPI EndPath(HDC hdc)
Definition: path.c:56
#define MM_TEXT
Definition: wingdi.h:872
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:465
int WINAPI SetGraphicsMode(_In_ HDC, _In_ int)
Definition: dc.c:1202
static const path_test_t rectangle_path[]
Definition: path.c:821
#define GM_ADVANCED
Definition: wingdi.h:864

Referenced by START_TEST().

◆ test_roundrect()

static void test_roundrect ( void  )
static

Definition at line 1292 of file path.c.

1293 {
1294  HDC hdc = GetDC( 0 );
1295 
1296  BeginPath( hdc );
1297  RoundRect( hdc, 20, 20, 40, 40, 10, 10 );
1298  RoundRect( hdc, 30, 50, 55, 35, -30, -30 );
1299  RoundRect( hdc, 60, 60, 35, 45, 5, 2 );
1300  RoundRect( hdc, 70, 70, 50, 70, 3, 5 );
1301  RoundRect( hdc, 75, 75, 75, 85, 6, 4 );
1302  RoundRect( hdc, 80, 80, 81, 81, 8, 9 );
1303  RoundRect( hdc, 90, 90, 95, 85, 0, 7 );
1305  RoundRect( hdc, 20, 20, 40, 40, 10, 10 );
1306  RoundRect( hdc, 30, 50, 55, 35, -30, -30 );
1309  SetViewportExtEx( hdc, -2, 2, NULL );
1310  RoundRect( hdc, 20, 20, 40, 40, 15, 12 );
1311  RoundRect( hdc, 30, 50, 55, 35, 7, 9 );
1312  SetViewportExtEx( hdc, 3, -3, NULL );
1313  RoundRect( hdc, 20, 20, 40, 40, 15, 12 );
1314  RoundRect( hdc, 30, 50, 55, 35, 3, 4 );
1315  SetWindowExtEx( hdc, -20, 20, NULL );
1316  RoundRect( hdc, 20, 20, 40, 40, 2, 1 );
1317  RoundRect( hdc, 24, 22, 21, 20, 4, 4 );
1318  SetMapMode( hdc, MM_TEXT );
1320  RoundRect( hdc, 20, 20, 40, 40, 10, 10 );
1321  RoundRect( hdc, 30, 50, 55, 35, -30, -30 );
1322  RoundRect( hdc, 60, 60, 35, 45, 5, 2 );
1323  RoundRect( hdc, 70, 70, 50, 70, 3, 5 );
1324  RoundRect( hdc, 75, 75, 75, 85, 6, 4 );
1325  RoundRect( hdc, 80, 80, 81, 81, 8, 9 );
1326  RoundRect( hdc, 90, 90, 95, 85, 0, 7 );
1328  RoundRect( hdc, 20, 20, 40, 40, 10, 10 );
1329  RoundRect( hdc, 30, 50, 55, 35, -30, -30 );
1331  EndPath( hdc );
1332  SetMapMode( hdc, MM_TEXT );
1333  ok_path( hdc, "roundrect_path", roundrect_path, sizeof(roundrect_path)/sizeof(path_test_t) );
1334  ReleaseDC( 0, hdc );
1335 }
BOOL WINAPI SetWindowExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
static void ok_path(HDC hdc, const char *path_name, const path_test_t *expected, int expected_size)
Definition: path.c:401
#define AD_COUNTERCLOCKWISE
Definition: wingdi.h:666
BOOL WINAPI BeginPath(HDC hdc)
Definition: path.c:31
static const path_test_t roundrect_path[]
Definition: path.c:976
BOOL WINAPI RoundRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI SetMapMode(_In_ HDC, _In_ int)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
#define AD_CLOCKWISE
Definition: wingdi.h:667
int WINAPI SetArcDirection(_In_ HDC, _In_ int)
HDC hdc
Definition: main.c:9
#define MM_ANISOTROPIC
Definition: wingdi.h:866
BOOL WINAPI EndPath(HDC hdc)
Definition: path.c:56
#define MM_TEXT
Definition: wingdi.h:872
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:465
int WINAPI SetGraphicsMode(_In_ HDC, _In_ int)
Definition: dc.c:1202
#define GM_ADVANCED
Definition: wingdi.h:864

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 %u\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: %d\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 }
#define TRUE
Definition: types.h:120
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
HDC WINAPI GetDC(_In_opt_ HWND)
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2031
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
int32_t INT
Definition: typedefs.h:56
DWORD ret
Definition: path.c:47
BOOL WINAPI BeginPath(HDC hdc)
Definition: path.c:31
#define PS_SOLID
Definition: wingdi.h:585
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ERROR_CAN_NOT_COMPLETE
Definition: winerror.h:582
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI WidenPath(HDC hdc)
Definition: path.c:179
INT WINAPI GetPath(HDC hdc, LPPOINT pptlBuf, LPBYTE pjTypes, INT cptBuf)
Definition: path.c:95
#define RGB(r, g, b)
Definition: wingdi.h:2939
#define SetLastError(x)
Definition: compat.h:417
HDC hdc
Definition: main.c:9
BOOL WINAPI EndPath(HDC hdc)
Definition: path.c:56
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI Polyline(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_ int cpt)
BOOL WINAPI AbortPath(HDC hdc)
Definition: path.c:18

Referenced by START_TEST().

Variable Documentation

◆ all_funcs_path

const path_test_t all_funcs_path[]
static

Definition at line 1716 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},
}
#define PT_CLOSEFIGURE
Definition: wingdi.h:886
#define PT_LINETO
Definition: wingdi.h:884
#define PT_MOVETO
Definition: wingdi.h:883
#define PT_BEZIERTO
Definition: wingdi.h:885

Definition at line 506 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},
}
#define PT_CLOSEFIGURE
Definition: wingdi.h:886
#define PT_LINETO
Definition: wingdi.h:884
#define PT_MOVETO
Definition: wingdi.h:883
#define PT_BEZIERTO
Definition: wingdi.h:885

Definition at line 458 of file path.c.

Referenced by test_arcto().

◆ ellipse_path

const path_test_t ellipse_path[]
static

Definition at line 1337 of file path.c.

Referenced by test_ellipse().

◆ polydraw_path

const path_test_t polydraw_path[]
static

Definition at line 551 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 586 of file path.c.

Referenced by test_polydraw().

◆ polydraw_tps

◆ rectangle_path

const path_test_t rectangle_path[]
static

Definition at line 821 of file path.c.

Referenced by test_rectangle().

◆ roundrect_path

const path_test_t roundrect_path[]
static

Definition at line 976 of file path.c.

Referenced by test_roundrect().