ReactOS 0.4.15-dev-7924-g5949c20
SetMapMode.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for SetMapMode
5 * PROGRAMMERS: Timo Kreuzer
6 * Katayama Hirofumi MZ
7 */
8
9#include "precomp.h"
10
12{
13 HDC hDC;
14 SIZE WindowExt, ViewportExt;
15 ULONG ulMapMode;
16 POINT pt;
17
19 ok(hDC != 0, "CreateCompatibleDC failed, skipping tests.\n");
20 if (!hDC) return;
21
22 GetWindowExtEx(hDC, &WindowExt);
23 GetViewportExtEx(hDC, &ViewportExt);
24
25 ulMapMode = SetMapMode(hDC, MM_ISOTROPIC);
26 ok_long(ulMapMode, MM_TEXT);
27 ok_long(WindowExt.cx, 1);
28 ok_long(WindowExt.cy, 1);
29 ok_long(ViewportExt.cx, 1);
30 ok_long(ViewportExt.cy, 1);
31
32 SetLastError(0);
33 ulMapMode = SetMapMode(hDC, 0);
34 ok_err(0);
35 ok_long(ulMapMode, 0);
36
37 /* Go through all valid values */
38 ulMapMode = SetMapMode(hDC, 1);
39 ok_long(ulMapMode, MM_ISOTROPIC);
40 ulMapMode = SetMapMode(hDC, 2);
41 ok_long(ulMapMode, 1);
42 ulMapMode = SetMapMode(hDC, 3);
43 ok_long(ulMapMode, 2);
44 ulMapMode = SetMapMode(hDC, 4);
45 ok_long(ulMapMode, 3);
46 ulMapMode = SetMapMode(hDC, 5);
47 ok_long(ulMapMode, 4);
48 ulMapMode = SetMapMode(hDC, 6);
49 ok_long(ulMapMode, 5);
50 ulMapMode = SetMapMode(hDC, 7);
51 ok_long(ulMapMode, 6);
52 ulMapMode = SetMapMode(hDC, 8);
53 ok_long(ulMapMode, 7);
54
55 /* Test invalid value */
56 ulMapMode = SetMapMode(hDC, 9);
57 ok_long(ulMapMode, 0);
58 ulMapMode = SetMapMode(hDC, 10);
59 ok_long(ulMapMode, 0);
60
61 ok_err(0);
62
63 /* Test NULL DC */
64 ulMapMode = SetMapMode((HDC)0, 2);
65 ok_long(ulMapMode, 0);
67
68 /* Test NULL DC and invalid mode */
69 ulMapMode = SetMapMode((HDC)0, 10);
70 ok_long(ulMapMode, 0);
72
73 /* Test invalid DC */
74 ulMapMode = SetMapMode((HDC)0x12345, 2);
75 ok_long(ulMapMode, 0);
77
78 /* Test invalid DC and invalid mode */
79 ulMapMode = SetMapMode((HDC)0x12345, 10);
80 ok_long(ulMapMode, 0);
82
84
85 /* Test a deleted DC */
86 ulMapMode = SetMapMode(hDC, 2);
87 ok_long(ulMapMode, 0);
89
90 /* Test MM_TEXT */
93 GetWindowExtEx(hDC, &WindowExt);
94 GetViewportExtEx(hDC, &ViewportExt);
95 ok_long(WindowExt.cx, 1);
96 ok_long(WindowExt.cy, 1);
97 ok_long(ViewportExt.cx, 1);
98 ok_long(ViewportExt.cy, 1);
100
101 /* Test MM_ISOTROPIC */
104 GetWindowExtEx(hDC, &WindowExt);
105 GetViewportExtEx(hDC, &ViewportExt);
106 //ok_long(WindowExt.cx, 3600);
107 //ok_long(WindowExt.cy, 2700);
108 //ok_long(ViewportExt.cx, GetDeviceCaps(GetDC(0), HORZRES) - 4);
109 ok_long(ViewportExt.cy, -GetDeviceCaps(GetDC(0), VERTRES));
110 DeleteDC(hDC);
111
112 /* Test MM_ANISOTROPIC */
115 GetWindowExtEx(hDC, &WindowExt);
116 GetViewportExtEx(hDC, &ViewportExt);
117 ok_long(WindowExt.cx, 1);
118 ok_long(WindowExt.cy, 1);
119 ok_long(ViewportExt.cx, 1);
120 ok_long(ViewportExt.cy, 1);
121
122 /* set MM_ISOTROPIC first, the values will be kept */
125 GetWindowExtEx(hDC, &WindowExt);
126 GetViewportExtEx(hDC, &ViewportExt);
127 //ok_long(WindowExt.cx, 3600);
128 //ok_long(WindowExt.cy, 2700);
129 ok_long(ViewportExt.cx, GetDeviceCaps(GetDC(0), HORZRES));
130 ok_long(ViewportExt.cy, -GetDeviceCaps(GetDC(0), VERTRES));
131 DeleteDC(hDC);
132
133 /* Test MM_LOMETRIC */
136 GetWindowExtEx(hDC, &WindowExt);
137 GetViewportExtEx(hDC, &ViewportExt);
138 //ok_long(WindowExt.cx, 3600);
139 //ok_long(WindowExt.cy, 2700);
140 ok_long(ViewportExt.cx, GetDeviceCaps(GetDC(0), HORZRES));
141 ok_long(ViewportExt.cy, -GetDeviceCaps(GetDC(0), VERTRES));
142 DeleteDC(hDC);
143
144 /* Test MM_HIMETRIC */
147 GetWindowExtEx(hDC, &WindowExt);
148 GetViewportExtEx(hDC, &ViewportExt);
149 //ok_long(WindowExt.cx, 36000);
150 //ok_long(WindowExt.cy, 27000);
151 ok_long(ViewportExt.cx, GetDeviceCaps(GetDC(0), HORZRES));
152 ok_long(ViewportExt.cy, -GetDeviceCaps(GetDC(0), VERTRES));
153 DeleteDC(hDC);
154
155 /* Test MM_LOENGLISH */
158 GetWindowExtEx(hDC, &WindowExt);
159 GetViewportExtEx(hDC, &ViewportExt);
160 //ok_long(WindowExt.cx, 1417);
161 //ok_long(WindowExt.cy, 1063);
162 ok_long(ViewportExt.cx, GetDeviceCaps(GetDC(0), HORZRES));
163 ok_long(ViewportExt.cy, -GetDeviceCaps(GetDC(0), VERTRES));
164 DeleteDC(hDC);
165
166 /* Test MM_HIENGLISH */
169 GetWindowExtEx(hDC, &WindowExt);
170 GetViewportExtEx(hDC, &ViewportExt);
171 //ok_long(WindowExt.cx, 14173);
172 //ok_long(WindowExt.cy, 10630);
173 ok_long(ViewportExt.cx, GetDeviceCaps(GetDC(0), HORZRES));
174 ok_long(ViewportExt.cy, -GetDeviceCaps(GetDC(0), VERTRES));
175 DeleteDC(hDC);
176
177 /* Test MM_TWIPS */
180 GetWindowExtEx(hDC, &WindowExt);
181 GetViewportExtEx(hDC, &ViewportExt);
182 //ok_long(WindowExt.cx, 20409);
183 //ok_long(WindowExt.cy, 15307);
184 ok_long(ViewportExt.cx, GetDeviceCaps(GetDC(0), HORZRES));
185 ok_long(ViewportExt.cy, -GetDeviceCaps(GetDC(0), VERTRES));
186 DeleteDC(hDC);
187
188 //
189 // Test mode and extents
190 //
192 GetViewportExtEx(hDC, &ViewportExt);
193 GetWindowExtEx(hDC, &WindowExt);
194 ok_long(ViewportExt.cx, 1);
195 ok_long(ViewportExt.cy, 1);
196 ok_long(WindowExt.cx, 1);
197 ok_long(WindowExt.cy, 1);
198
200 GetViewportExtEx(hDC, &ViewportExt);
201 GetWindowExtEx(hDC, &WindowExt);
202 ok_long(ViewportExt.cx, 1);
203 ok_long(ViewportExt.cy, 1);
204 ok_long(WindowExt.cx, 1);
205 ok_long(WindowExt.cy, 1);
206 SetWindowExtEx(hDC, 200, 200, NULL);
207 SetViewportExtEx(hDC, 100, 100, NULL);
208
210 GetViewportExtEx(hDC, &ViewportExt);
211 GetWindowExtEx(hDC, &WindowExt);
212 ok_long(ViewportExt.cx, 100);
213 ok_long(ViewportExt.cy, 100);
214 ok_long(WindowExt.cx, 200);
215 ok_long(WindowExt.cy, 200);
216
218 GetViewportExtEx(hDC, &ViewportExt);
219 ok_long(ViewportExt.cx, 100);
220 ok_long(ViewportExt.cy, 100);
221 ok_long(WindowExt.cx, 200);
222 ok_long(WindowExt.cy, 200);
223
225 GetViewportExtEx(hDC, &ViewportExt);
226 //ok_long(ViewportExt.cx, GetDeviceCaps(GetDC(0), HORZRES) - 4);
227 ok_long(ViewportExt.cy, -GetDeviceCaps(GetDC(0), VERTRES));
228 SetWindowExtEx(hDC, 100, 100, NULL);
229 SetViewportExtEx(hDC, 100, 100, NULL);
230
232 GetViewportExtEx(hDC, &ViewportExt);
233 ok_long(ViewportExt.cx, 100);
234 ok_long(ViewportExt.cy, 100);
235
237 GetViewportExtEx(hDC, &ViewportExt);
238 ok_long(ViewportExt.cx, 100);
239 ok_long(ViewportExt.cy, 100);
240
242 GetViewportExtEx(hDC, &ViewportExt);
243 ok_long(ViewportExt.cx, 1);
244 ok_long(ViewportExt.cy, 1);
245
247 GetViewportExtEx(hDC, &ViewportExt);
248 ok_long(ViewportExt.cx, 1);
249 ok_long(ViewportExt.cy, 1);
250
252 GetViewportExtEx(hDC, &ViewportExt);
253 //ok_long(ViewportExt.cx, GetDeviceCaps(GetDC(0), HORZRES) - 4);
254 ok_long(ViewportExt.cy, -GetDeviceCaps(GetDC(0), VERTRES));
255
257 GetViewportExtEx(hDC, &ViewportExt);
258 GetWindowExtEx(hDC, &WindowExt);
259 ok_long(ViewportExt.cx, 1);
260 ok_long(ViewportExt.cy, 1);
261 ok_long(WindowExt.cx, 1);
262 ok_long(WindowExt.cy, 1);
263 DeleteDC(hDC);
264
265 //
266 // Test mode and GetCurrentPositionEx
267 //
269 MoveToEx(hDC, 100, 100, NULL);
272 ok_long(pt.x, 100);
273 ok_long(pt.y, 100);
276 ok_long(pt.x, 100);
277 ok_long(pt.y, 100);
280 ok_long(pt.x, 100);
281 ok_long(pt.y, 100);
282 DeleteDC(hDC);
283}
284
286{
288}
static HDC hDC
Definition: 3dtext.c:33
void Test_SetMapMode()
Definition: SetMapMode.c:11
#define ok_long(expression, result)
Definition: atltest.h:133
#define ok(value,...)
Definition: atltest.h:57
#define ok_err(error)
Definition: atltest.h:124
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define pt(x, y)
Definition: drawing.c:79
static HDC
Definition: imagelist.c:92
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
uint32_t ULONG
Definition: typedefs.h:59
int WINAPI SetMapMode(_In_ HDC, _In_ int)
#define HORZRES
Definition: wingdi.h:716
#define MM_HIENGLISH
Definition: wingdi.h:868
#define MM_LOENGLISH
Definition: wingdi.h:871
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define MM_HIMETRIC
Definition: wingdi.h:869
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:465
BOOL WINAPI GetCurrentPositionEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:241
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
#define MM_ANISOTROPIC
Definition: wingdi.h:867
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI SetWindowExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
#define VERTRES
Definition: wingdi.h:717
#define MM_TWIPS
Definition: wingdi.h:874
#define MM_LOMETRIC
Definition: wingdi.h:872
#define MM_ISOTROPIC
Definition: wingdi.h:870
BOOL WINAPI GetWindowExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:411
#define MM_TEXT
Definition: wingdi.h:873
BOOL WINAPI DeleteDC(_In_ HDC)
BOOL WINAPI GetViewportExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:351
HDC WINAPI GetDC(_In_opt_ HWND)