Merging r37048, r37051, r37052, r37055 from the-real-msvc branch
[reactos.git] / rostests / winetests / gdiplus / pathiterator.c
1 /*
2 * Unit test suite for pathiterator
3 *
4 * Copyright (C) 2008 Nikolay Sivov
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #include "windows.h"
22 #include "gdiplus.h"
23 #include "wine/test.h"
24
25 #define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
26
27 static void test_constructor_destructor(void)
28 {
29 GpPath *path;
30 GpPathIterator *iter;
31 GpStatus stat;
32
33 GdipCreatePath(FillModeAlternate, &path);
34 GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0);
35
36 /* NULL args */
37 stat = GdipCreatePathIter(NULL, NULL);
38 expect(InvalidParameter, stat);
39 stat = GdipCreatePathIter(&iter, NULL);
40 expect(InvalidParameter, stat);
41 stat = GdipCreatePathIter(NULL, path);
42 expect(InvalidParameter, stat);
43 stat = GdipDeletePathIter(NULL);
44 expect(InvalidParameter, stat);
45
46 /* valid args */
47 stat = GdipCreatePathIter(&iter, path);
48 expect(Ok, stat);
49
50 GdipDeletePathIter(iter);
51 GdipDeletePath(path);
52 }
53
54 static void test_hascurve(void)
55 {
56 GpPath *path;
57 GpPathIterator *iter;
58 GpStatus stat;
59 BOOL hasCurve;
60
61 GdipCreatePath(FillModeAlternate, &path);
62 GdipAddPathRectangle(path, 5.0, 5.0, 100.0, 50.0);
63
64 stat = GdipCreatePathIter(&iter, path);
65 expect(Ok, stat);
66
67 /* NULL args
68 BOOL out argument is local in wrapper class method,
69 so it always has not-NULL address */
70 stat = GdipPathIterHasCurve(NULL, &hasCurve);
71 expect(InvalidParameter, stat);
72
73 /* valid args */
74 stat = GdipPathIterHasCurve(iter, &hasCurve);
75 expect(Ok, stat);
76 expect(FALSE, hasCurve);
77
78 GdipDeletePathIter(iter);
79
80 GdipAddPathEllipse(path, 0.0, 0.0, 35.0, 70.0);
81
82 stat = GdipCreatePathIter(&iter, path);
83 expect(Ok, stat);
84
85 stat = GdipPathIterHasCurve(iter, &hasCurve);
86 expect(Ok, stat);
87 expect(TRUE, hasCurve);
88
89 GdipDeletePathIter(iter);
90 GdipDeletePath(path);
91 }
92
93 START_TEST(pathiterator)
94 {
95 struct GdiplusStartupInput gdiplusStartupInput;
96 ULONG_PTR gdiplusToken;
97
98 gdiplusStartupInput.GdiplusVersion = 1;
99 gdiplusStartupInput.DebugEventCallback = NULL;
100 gdiplusStartupInput.SuppressBackgroundThread = 0;
101 gdiplusStartupInput.SuppressExternalCodecs = 0;
102
103 GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
104
105 test_constructor_destructor();
106 test_hascurve();
107
108 GdiplusShutdown(gdiplusToken);
109 }