Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594/* * Unit test suite for pathiterator * * Copyright (C) 2008 Nikolay Sivov * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
#include "objbase.h"#include "gdiplus.h"#include "wine/test.h"
#define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
static void test_constructor_destructor(void){ GpPath *path; GpPathIterator *iter; GpStatus stat;
GdipCreatePath(FillModeAlternate, &path); GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0);
/* NULL args */ stat = GdipCreatePathIter(NULL, NULL); expect(InvalidParameter, stat); iter = NULL; stat = GdipCreatePathIter(&iter, NULL); expect(Ok, stat); ok(iter != NULL, "Expected iterator to be created\n"); GdipDeletePathIter(iter); stat = GdipCreatePathIter(NULL, path); expect(InvalidParameter, stat); stat = GdipDeletePathIter(NULL); expect(InvalidParameter, stat);
/* valid args */ stat = GdipCreatePathIter(&iter, path); expect(Ok, stat);
GdipDeletePathIter(iter); GdipDeletePath(path);}
static void test_hascurve(void){ GpPath *path; GpPathIterator *iter; GpStatus stat; BOOL hasCurve;
GdipCreatePath(FillModeAlternate, &path); GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0);
stat = GdipCreatePathIter(&iter, path); expect(Ok, stat);
/* NULL args BOOL out argument is local in wrapper class method, so it always has not-NULL address */ stat = GdipPathIterHasCurve(NULL, &hasCurve); expect(InvalidParameter, stat);
/* valid args */ stat = GdipPathIterHasCurve(iter, &hasCurve); expect(Ok, stat); expect(FALSE, hasCurve);
GdipDeletePathIter(iter);
stat = GdipAddPathEllipse(path, 0.0, 0.0, 35.0, 70.0); expect(Ok, stat);
stat = GdipCreatePathIter(&iter, path); expect(Ok, stat);
stat = GdipPathIterHasCurve(iter, &hasCurve); expect(Ok, stat); expect(TRUE, hasCurve);
GdipDeletePathIter(iter); GdipDeletePath(path);}
static void test_nextmarker(void){ GpPath *path; GpPathIterator *iter; GpStatus stat; INT start, end; INT result;
/* NULL args BOOL out argument is local in wrapper class method, so it always has not-NULL address */ stat = GdipPathIterNextMarker(NULL, &result, NULL, NULL); expect(InvalidParameter, stat); stat = GdipPathIterNextMarker(NULL, &result, &start, NULL); expect(InvalidParameter, stat); stat = GdipPathIterNextMarker(NULL, &result, NULL, &end); expect(InvalidParameter, stat);
GdipCreatePath(FillModeAlternate, &path); GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0);
/* no markers */ GdipCreatePathIter(&iter, path); start = end = result = (INT)0xdeadbeef; stat = GdipPathIterNextMarker(iter, &result, &start, &end); expect(Ok, stat); expect(0, start); expect(3, end); expect(4, result); start = end = result = (INT)0xdeadbeef; stat = GdipPathIterNextMarker(iter, &result, &start, &end); expect(Ok, stat); /* start/end remain unchanged */ expect((INT)0xdeadbeef, start); expect((INT)0xdeadbeef, end); expect(0, result); GdipDeletePathIter(iter);
/* one marker */ GdipSetPathMarker(path); GdipCreatePathIter(&iter, path); start = end = result = (INT)0xdeadbeef; stat = GdipPathIterNextMarker(iter, &result, &start, &end); expect(Ok, stat); expect(0, start); expect(3, end); expect(4, result); start = end = result = (INT)0xdeadbeef; stat = GdipPathIterNextMarker(iter, &result, &start, &end); expect(Ok, stat); expect((INT)0xdeadbeef, start); expect((INT)0xdeadbeef, end); expect(0, result); GdipDeletePathIter(iter);
/* two markers */ GdipAddPathLine(path, 0.0, 0.0, 10.0, 30.0); GdipSetPathMarker(path); GdipCreatePathIter(&iter, path); start = end = result = (INT)0xdeadbeef; stat = GdipPathIterNextMarker(iter, &result, &start, &end); expect(Ok, stat); expect(0, start); expect(3, end); expect(4, result); start = end = result = (INT)0xdeadbeef; stat = GdipPathIterNextMarker(iter, &result, &start, &end); expect(Ok, stat); expect(4, start); expect(5, end); expect(2, result); start = end = result = (INT)0xdeadbeef; stat = GdipPathIterNextMarker(iter, &result, &start, &end); expect(Ok, stat); expect((INT)0xdeadbeef, start); expect((INT)0xdeadbeef, end); expect(0, result); GdipDeletePathIter(iter);
GdipDeletePath(path);}
static void test_nextmarkerpath(void){ GpPath *path, *retpath; GpPathIterator *iter; GpStatus stat; INT result, count;
GdipCreatePath(FillModeAlternate, &path);
/* NULL */ stat = GdipPathIterNextMarkerPath(NULL, NULL, NULL); expect(InvalidParameter, stat); stat = GdipPathIterNextMarkerPath(NULL, &result, NULL); expect(InvalidParameter, stat); stat = GdipPathIterNextMarkerPath(NULL, &result, path); expect(InvalidParameter, stat);
GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0);
/* no markers */ GdipCreatePath(FillModeAlternate, &retpath); GdipCreatePathIter(&iter, path); result = -1; stat = GdipPathIterNextMarkerPath(iter, &result, retpath); expect(Ok, stat); expect(4, result); count = -1; GdipGetPointCount(retpath, &count); expect(4, count); result = -1; stat = GdipPathIterNextMarkerPath(iter, &result, retpath); expect(Ok, stat); expect(0, result); count = -1; GdipGetPointCount(retpath, &count); expect(4, count); GdipDeletePathIter(iter); GdipDeletePath(retpath);
/* one marker */ GdipSetPathMarker(path); GdipCreatePath(FillModeAlternate, &retpath); GdipCreatePathIter(&iter, path); result = -1; stat = GdipPathIterNextMarkerPath(iter, &result, retpath); expect(Ok, stat); expect(4, result); count = -1; GdipGetPointCount(retpath, &count); expect(4, count); result = -1; stat = GdipPathIterNextMarkerPath(iter, &result, retpath); expect(Ok, stat); expect(0, result); count = -1; GdipGetPointCount(retpath, &count); expect(4, count); GdipDeletePathIter(iter); GdipDeletePath(retpath);
/* two markers */ GdipAddPathLine(path, 0.0, 0.0, 10.0, 30.0); GdipSetPathMarker(path); GdipCreatePath(FillModeAlternate, &retpath); GdipCreatePathIter(&iter, path); result = -1; stat = GdipPathIterNextMarkerPath(iter, &result, retpath); expect(Ok, stat); expect(4, result); result = -1; stat = GdipPathIterNextMarkerPath(iter, &result, retpath); expect(Ok, stat); expect(2, result); result = -1; stat = GdipPathIterNextMarkerPath(iter, &result, retpath); expect(Ok, stat); expect(0, result); GdipDeletePathIter(iter); GdipDeletePath(retpath);
GdipDeletePath(path);}
static void test_getsubpathcount(void){ GpPath *path; GpPathIterator *iter; GpStatus stat; INT count;
/* NULL args */ stat = GdipPathIterGetSubpathCount(NULL, NULL); expect(InvalidParameter, stat); stat = GdipPathIterGetSubpathCount(NULL, &count); expect(InvalidParameter, stat);
GdipCreatePath(FillModeAlternate, &path);
/* empty path */ GdipCreatePathIter(&iter, path); stat = GdipPathIterGetSubpathCount(iter, &count); expect(Ok, stat); expect(0, count); GdipDeletePathIter(iter);
GdipAddPathLine(path, 5.0, 5.0, 100.0, 50.0);
/* open figure */ GdipCreatePathIter(&iter, path); stat = GdipPathIterGetSubpathCount(iter, &count); expect(Ok, stat); expect(1, count); GdipDeletePathIter(iter);
/* manually start new figure */ GdipStartPathFigure(path); GdipAddPathLine(path, 50.0, 50.0, 110.0, 40.0); GdipCreatePathIter(&iter, path); stat = GdipPathIterGetSubpathCount(iter, &count); expect(Ok, stat); expect(2, count); GdipDeletePathIter(iter);
GdipDeletePath(path);}
static void test_isvalid(void){ GpPath *path; GpPathIterator *iter; GpStatus stat; BOOL isvalid; INT start, end, result;
GdipCreatePath(FillModeAlternate, &path);
/* NULL args */ GdipCreatePathIter(&iter, path); stat = GdipPathIterIsValid(NULL, NULL); expect(InvalidParameter, stat); stat = GdipPathIterIsValid(iter, NULL); expect(InvalidParameter, stat); stat = GdipPathIterIsValid(NULL, &isvalid); expect(InvalidParameter, stat); GdipDeletePathIter(iter);
/* on empty path */ GdipCreatePathIter(&iter, path); isvalid = FALSE; stat = GdipPathIterIsValid(iter, &isvalid); expect(Ok, stat); expect(TRUE, isvalid); GdipDeletePathIter(iter);
/* no markers */ stat = GdipAddPathLine(path, 50.0, 50.0, 110.0, 40.0); expect(Ok, stat); stat = GdipCreatePathIter(&iter, path); expect(Ok, stat); stat = GdipPathIterNextMarker(iter, &result, &start, &end); expect(Ok, stat); isvalid = FALSE; stat = GdipPathIterIsValid(iter, &isvalid); expect(Ok, stat); expect(TRUE, isvalid); GdipDeletePathIter(iter);
GdipDeletePath(path);}
static void test_nextsubpathpath(void){ GpPath *path, *retpath; GpPathIterator *iter; GpStatus stat; BOOL closed; INT count, result;
GdipCreatePath(FillModeAlternate, &path);
/* NULL args */ GdipCreatePath(FillModeAlternate, &retpath); GdipCreatePathIter(&iter, path); stat = GdipPathIterNextSubpathPath(NULL, NULL, NULL, NULL); expect(InvalidParameter, stat); stat = GdipPathIterNextSubpathPath(iter, NULL, NULL, NULL); expect(InvalidParameter, stat); stat = GdipPathIterNextSubpathPath(NULL, &result, NULL, NULL); expect(InvalidParameter, stat); stat = GdipPathIterNextSubpathPath(iter, &result, NULL, &closed); expect(Ok, stat); stat = GdipPathIterNextSubpathPath(iter, NULL, NULL, &closed); expect(InvalidParameter, stat); stat = GdipPathIterNextSubpathPath(iter, NULL, retpath, NULL); expect(InvalidParameter, stat); stat = GdipPathIterNextSubpathPath(iter, &result, retpath, NULL); expect(InvalidParameter, stat); GdipDeletePathIter(iter); GdipDeletePath(retpath);
/* empty path */ GdipCreatePath(FillModeAlternate, &retpath); GdipCreatePathIter(&iter, path); result = -2; closed = TRUE; stat = GdipPathIterNextSubpathPath(iter, &result, retpath, &closed); expect(Ok, stat); expect(0, result); expect(TRUE, closed); count = -1; GdipGetPointCount(retpath, &count); expect(0, count); GdipDeletePathIter(iter); GdipDeletePath(retpath);
/* open figure */ GdipAddPathLine(path, 5.0, 5.0, 100.0, 50.0);
GdipCreatePath(FillModeAlternate, &retpath); GdipCreatePathIter(&iter, path); result = -2; closed = TRUE; stat = GdipPathIterNextSubpathPath(iter, &result, retpath, &closed); expect(Ok, stat); expect(2, result); expect(FALSE, closed); count = -1; GdipGetPointCount(retpath, &count); expect(2, count); /* subsequent call */ result = -2; closed = TRUE; stat = GdipPathIterNextSubpathPath(iter, &result, retpath, &closed); expect(Ok, stat); expect(0, result); expect(TRUE, closed); count = -1; GdipGetPointCount(retpath, &count); expect(2, count); GdipDeletePathIter(iter);
/* closed figure, check does it extend retpath or reset it */ GdipAddPathLine(retpath, 50.0, 55.0, 200.0, 150.0);
GdipClosePathFigure(path); GdipAddPathLine(path, 50.0, 55.0, 200.0, 150.0); GdipClosePathFigure(path);
GdipCreatePathIter(&iter, path); result = -2; closed = FALSE; stat = GdipPathIterNextSubpathPath(iter, &result, retpath, &closed); expect(Ok, stat); expect(2, result); expect(TRUE, closed); count = -1; GdipGetPointCount(retpath, &count); expect(2, count); /* subsequent call */ result = -2; closed = FALSE; stat = GdipPathIterNextSubpathPath(iter, &result, retpath, &closed); expect(Ok, stat); expect(2, result); expect(TRUE, closed); count = -1; GdipGetPointCount(retpath, &count); expect(2, count); result = -2; closed = FALSE; stat = GdipPathIterNextSubpathPath(iter, &result, retpath, &closed); expect(Ok, stat); expect(0, result); expect(TRUE, closed); count = -1; GdipGetPointCount(retpath, &count); expect(2, count); GdipDeletePathIter(iter);
GdipDeletePath(retpath); GdipDeletePath(path);}
static void test_nextsubpath(void){ GpPath *path; GpPathIterator *iter; GpStatus stat; INT start, end, result; BOOL closed;
/* empty path */ GdipCreatePath(FillModeAlternate, &path); GdipCreatePathIter(&iter, path);
result = -2; closed = TRUE; stat = GdipPathIterNextSubpath(iter, &result, &start, &end, &closed); expect(Ok, stat); expect(0, result); expect(TRUE, closed);
GdipDeletePathIter(iter); GdipDeletePath(path);}
static void test_nextpathtype(void){ GpPath *path; GpPathIterator *iter; GpStatus stat; INT start, end, result; BYTE type;
GdipCreatePath(FillModeAlternate, &path); GdipCreatePathIter(&iter, path);
/* NULL arguments */ stat = GdipPathIterNextPathType(NULL, NULL, NULL, NULL, NULL); expect(InvalidParameter, stat); stat = GdipPathIterNextPathType(iter, NULL, NULL, NULL, NULL); expect(InvalidParameter, stat); stat = GdipPathIterNextPathType(iter, &result, NULL, NULL, NULL); expect(InvalidParameter, stat); stat = GdipPathIterNextPathType(iter, NULL, &type, NULL, NULL); expect(InvalidParameter, stat); stat = GdipPathIterNextPathType(iter, NULL, NULL, &start, &end); expect(InvalidParameter, stat); stat = GdipPathIterNextPathType(iter, NULL, &type, &start, &end); expect(InvalidParameter, stat); stat = GdipPathIterNextPathType(iter, &result, &type, NULL, NULL); expect(InvalidParameter, stat);
/* empty path */ start = end = result = (INT)0xdeadbeef; stat = GdipPathIterNextPathType(iter, &result, &type, &start, &end); todo_wine expect(Ok, stat); expect((INT)0xdeadbeef, start); expect((INT)0xdeadbeef, end); todo_wine expect(0, result); GdipDeletePathIter(iter);
/* single figure */ GdipAddPathLine(path, 0.0, 0.0, 10.0, 30.0); GdipCreatePathIter(&iter, path); start = end = result = (INT)0xdeadbeef; type = 255; /* out of range */ stat = GdipPathIterNextPathType(iter, &result, &type, &start, &end); todo_wine expect(Ok, stat); expect((INT)0xdeadbeef, start); expect((INT)0xdeadbeef, end); expect(255, type); todo_wine expect(0, result); GdipDeletePathIter(iter);
stat = GdipAddPathEllipse(path, 0.0, 0.0, 35.0, 70.0); expect(Ok, stat); GdipCreatePathIter(&iter, path); start = end = result = (INT)0xdeadbeef; type = 255; /* out of range */ stat = GdipPathIterNextPathType(iter, &result, &type, &start, &end); todo_wine expect(Ok, stat); expect((INT)0xdeadbeef, start); expect((INT)0xdeadbeef, end); expect(255, type); todo_wine expect(0, result); GdipDeletePathIter(iter);
/* closed */ GdipClosePathFigure(path); GdipCreatePathIter(&iter, path); start = end = result = (INT)0xdeadbeef; type = 255; /* out of range */ stat = GdipPathIterNextPathType(iter, &result, &type, &start, &end); todo_wine expect(Ok, stat); expect((INT)0xdeadbeef, start); expect((INT)0xdeadbeef, end); expect(255, type); todo_wine expect(0, result); GdipDeletePathIter(iter);
GdipDeletePath(path);}
START_TEST(pathiterator){ struct GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; HMODULE hmsvcrt; int (CDECL * _controlfp_s)(unsigned int *cur, unsigned int newval, unsigned int mask);
/* Enable all FP exceptions except _EM_INEXACT, which gdi32 can trigger */ hmsvcrt = LoadLibraryA("msvcrt"); _controlfp_s = (void*)GetProcAddress(hmsvcrt, "_controlfp_s"); if (_controlfp_s) _controlfp_s(0, 0, 0x0008001e);
gdiplusStartupInput.GdiplusVersion = 1; gdiplusStartupInput.DebugEventCallback = NULL; gdiplusStartupInput.SuppressBackgroundThread = 0; gdiplusStartupInput.SuppressExternalCodecs = 0;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
test_constructor_destructor(); test_hascurve(); test_nextmarker(); test_nextmarkerpath(); test_getsubpathcount(); test_isvalid(); test_nextsubpathpath(); test_nextsubpath(); test_nextpathtype();
GdiplusShutdown(gdiplusToken);}