fd795835c58abd2baf803e13464eb55e2b578091
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for SetMapMode
5 * PROGRAMMERS: Timo Kreuzer
12 #define TEST(x) ok(x, #x"\n")
13 #define RTEST(x) ok(x, #x"\n")
15 void Test_SetMapMode()
18 SIZE WindowExt
, ViewportExt
;
21 hDC
= CreateCompatibleDC(NULL
);
22 ok(hDC
!= 0, "CreateCompatibleDC failed, skipping tests.\n");
25 GetWindowExtEx(hDC
, &WindowExt
);
26 GetViewportExtEx(hDC
, &ViewportExt
);
28 ulMapMode
= SetMapMode(hDC
, MM_ISOTROPIC
);
29 TEST(ulMapMode
== MM_TEXT
);
30 TEST(WindowExt
.cx
== 1);
31 TEST(WindowExt
.cy
== 1);
32 TEST(ViewportExt
.cx
== 1);
33 TEST(ViewportExt
.cy
== 1);
36 ulMapMode
= SetMapMode(hDC
, 0);
37 TEST(GetLastError() == 0);
40 /* Go through all valid values */
41 ulMapMode
= SetMapMode(hDC
, 1);
42 TEST(ulMapMode
== MM_ISOTROPIC
);
43 ulMapMode
= SetMapMode(hDC
, 2);
45 ulMapMode
= SetMapMode(hDC
, 3);
47 ulMapMode
= SetMapMode(hDC
, 4);
49 ulMapMode
= SetMapMode(hDC
, 5);
51 ulMapMode
= SetMapMode(hDC
, 6);
53 ulMapMode
= SetMapMode(hDC
, 7);
55 ulMapMode
= SetMapMode(hDC
, 8);
58 /* Test invalid value */
59 ulMapMode
= SetMapMode(hDC
, 9);
61 ulMapMode
= SetMapMode(hDC
, 10);
64 TEST(GetLastError() == 0);
67 ulMapMode
= SetMapMode((HDC
)0, 2);
69 TEST(GetLastError() == ERROR_INVALID_PARAMETER
);
71 /* Test NULL DC and invalid mode */
72 ulMapMode
= SetMapMode((HDC
)0, 10);
74 TEST(GetLastError() == ERROR_INVALID_PARAMETER
);
77 ulMapMode
= SetMapMode((HDC
)0x12345, 2);
79 TEST(GetLastError() == ERROR_INVALID_PARAMETER
);
81 /* Test invalid DC and invalid mode */
82 ulMapMode
= SetMapMode((HDC
)0x12345, 10);
84 TEST(GetLastError() == ERROR_INVALID_PARAMETER
);
88 /* Test a deleted DC */
89 ulMapMode
= SetMapMode(hDC
, 2);
91 TEST(GetLastError() == ERROR_INVALID_PARAMETER
);
94 hDC
= CreateCompatibleDC(NULL
);
95 SetMapMode(hDC
, MM_TEXT
);
96 GetWindowExtEx(hDC
, &WindowExt
);
97 GetViewportExtEx(hDC
, &ViewportExt
);
98 TEST(WindowExt
.cx
== 1);
99 TEST(WindowExt
.cy
== 1);
100 TEST(ViewportExt
.cx
== 1);
101 TEST(ViewportExt
.cy
== 1);
104 /* Test MM_ISOTROPIC */
105 hDC
= CreateCompatibleDC(NULL
);
106 SetMapMode(hDC
, MM_ISOTROPIC
);
107 GetWindowExtEx(hDC
, &WindowExt
);
108 GetViewportExtEx(hDC
, &ViewportExt
);
109 //TEST(WindowExt.cx == 3600);
110 //TEST(WindowExt.cy == 2700);
111 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
112 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
115 /* Test MM_ANISOTROPIC */
116 hDC
= CreateCompatibleDC(NULL
);
117 SetMapMode(hDC
, MM_ANISOTROPIC
);
118 GetWindowExtEx(hDC
, &WindowExt
);
119 GetViewportExtEx(hDC
, &ViewportExt
);
120 TEST(WindowExt
.cx
== 1);
121 TEST(WindowExt
.cy
== 1);
122 TEST(ViewportExt
.cx
== 1);
123 TEST(ViewportExt
.cy
== 1);
125 /* set MM_ISOTROPIC first, the values will be kept */
126 SetMapMode(hDC
, MM_ISOTROPIC
);
127 SetMapMode(hDC
, MM_ANISOTROPIC
);
128 GetWindowExtEx(hDC
, &WindowExt
);
129 GetViewportExtEx(hDC
, &ViewportExt
);
130 //TEST(WindowExt.cx == 3600);
131 //TEST(WindowExt.cy == 2700);
132 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
133 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
136 /* Test MM_LOMETRIC */
137 hDC
= CreateCompatibleDC(NULL
);
138 SetMapMode(hDC
, MM_LOMETRIC
);
139 GetWindowExtEx(hDC
, &WindowExt
);
140 GetViewportExtEx(hDC
, &ViewportExt
);
141 //TEST(WindowExt.cx == 3600);
142 //TEST(WindowExt.cy == 2700);
143 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
144 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
147 /* Test MM_HIMETRIC */
148 hDC
= CreateCompatibleDC(NULL
);
149 SetMapMode(hDC
, MM_HIMETRIC
);
150 GetWindowExtEx(hDC
, &WindowExt
);
151 GetViewportExtEx(hDC
, &ViewportExt
);
152 //TEST(WindowExt.cx == 36000);
153 //TEST(WindowExt.cy == 27000);
154 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
155 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
158 /* Test MM_LOENGLISH */
159 hDC
= CreateCompatibleDC(NULL
);
160 SetMapMode(hDC
, MM_LOENGLISH
);
161 GetWindowExtEx(hDC
, &WindowExt
);
162 GetViewportExtEx(hDC
, &ViewportExt
);
163 //TEST(WindowExt.cx == 1417);
164 //TEST(WindowExt.cy == 1063);
165 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
166 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
169 /* Test MM_HIENGLISH */
170 hDC
= CreateCompatibleDC(NULL
);
171 SetMapMode(hDC
, MM_HIENGLISH
);
172 GetWindowExtEx(hDC
, &WindowExt
);
173 GetViewportExtEx(hDC
, &ViewportExt
);
174 //TEST(WindowExt.cx == 14173);
175 //TEST(WindowExt.cy == 10630);
176 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
177 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
181 hDC
= CreateCompatibleDC(NULL
);
182 SetMapMode(hDC
, MM_TWIPS
);
183 GetWindowExtEx(hDC
, &WindowExt
);
184 GetViewportExtEx(hDC
, &ViewportExt
);
185 //TEST(WindowExt.cx == 20409);
186 //TEST(WindowExt.cy == 15307);
187 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
188 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
192 START_TEST(SetMapMode
)