2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for SetMapMode
5 * PROGRAMMERS: Timo Kreuzer
13 #define TEST(x) ok(x, #x"\n")
14 #define RTEST(x) ok(x, #x"\n")
16 void Test_SetMapMode()
19 SIZE WindowExt
, ViewportExt
;
22 hDC
= CreateCompatibleDC(NULL
);
23 ok(hDC
!= 0, "CreateCompatibleDC failed, skipping tests.\n");
26 GetWindowExtEx(hDC
, &WindowExt
);
27 GetViewportExtEx(hDC
, &ViewportExt
);
29 ulMapMode
= SetMapMode(hDC
, MM_ISOTROPIC
);
30 TEST(ulMapMode
== MM_TEXT
);
31 TEST(WindowExt
.cx
== 1);
32 TEST(WindowExt
.cy
== 1);
33 TEST(ViewportExt
.cx
== 1);
34 TEST(ViewportExt
.cy
== 1);
37 ulMapMode
= SetMapMode(hDC
, 0);
38 TEST(GetLastError() == 0);
41 /* Go through all valid values */
42 ulMapMode
= SetMapMode(hDC
, 1);
43 TEST(ulMapMode
== MM_ISOTROPIC
);
44 ulMapMode
= SetMapMode(hDC
, 2);
46 ulMapMode
= SetMapMode(hDC
, 3);
48 ulMapMode
= SetMapMode(hDC
, 4);
50 ulMapMode
= SetMapMode(hDC
, 5);
52 ulMapMode
= SetMapMode(hDC
, 6);
54 ulMapMode
= SetMapMode(hDC
, 7);
56 ulMapMode
= SetMapMode(hDC
, 8);
59 /* Test invalid value */
60 ulMapMode
= SetMapMode(hDC
, 9);
62 ulMapMode
= SetMapMode(hDC
, 10);
65 TEST(GetLastError() == 0);
68 ulMapMode
= SetMapMode((HDC
)0, 2);
70 TEST(GetLastError() == ERROR_INVALID_PARAMETER
);
72 /* Test NULL DC and invalid mode */
73 ulMapMode
= SetMapMode((HDC
)0, 10);
75 TEST(GetLastError() == ERROR_INVALID_PARAMETER
);
78 ulMapMode
= SetMapMode((HDC
)0x12345, 2);
80 TEST(GetLastError() == ERROR_INVALID_PARAMETER
);
82 /* Test invalid DC and invalid mode */
83 ulMapMode
= SetMapMode((HDC
)0x12345, 10);
85 TEST(GetLastError() == ERROR_INVALID_PARAMETER
);
89 /* Test a deleted DC */
90 ulMapMode
= SetMapMode(hDC
, 2);
92 TEST(GetLastError() == ERROR_INVALID_PARAMETER
);
95 hDC
= CreateCompatibleDC(NULL
);
96 SetMapMode(hDC
, MM_TEXT
);
97 GetWindowExtEx(hDC
, &WindowExt
);
98 GetViewportExtEx(hDC
, &ViewportExt
);
99 TEST(WindowExt
.cx
== 1);
100 TEST(WindowExt
.cy
== 1);
101 TEST(ViewportExt
.cx
== 1);
102 TEST(ViewportExt
.cy
== 1);
105 /* Test MM_ISOTROPIC */
106 hDC
= CreateCompatibleDC(NULL
);
107 SetMapMode(hDC
, MM_ISOTROPIC
);
108 GetWindowExtEx(hDC
, &WindowExt
);
109 GetViewportExtEx(hDC
, &ViewportExt
);
110 //TEST(WindowExt.cx == 3600);
111 //TEST(WindowExt.cy == 2700);
112 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
113 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
116 /* Test MM_ANISOTROPIC */
117 hDC
= CreateCompatibleDC(NULL
);
118 SetMapMode(hDC
, MM_ANISOTROPIC
);
119 GetWindowExtEx(hDC
, &WindowExt
);
120 GetViewportExtEx(hDC
, &ViewportExt
);
121 TEST(WindowExt
.cx
== 1);
122 TEST(WindowExt
.cy
== 1);
123 TEST(ViewportExt
.cx
== 1);
124 TEST(ViewportExt
.cy
== 1);
126 /* set MM_ISOTROPIC first, the values will be kept */
127 SetMapMode(hDC
, MM_ISOTROPIC
);
128 SetMapMode(hDC
, MM_ANISOTROPIC
);
129 GetWindowExtEx(hDC
, &WindowExt
);
130 GetViewportExtEx(hDC
, &ViewportExt
);
131 //TEST(WindowExt.cx == 3600);
132 //TEST(WindowExt.cy == 2700);
133 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
134 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
137 /* Test MM_LOMETRIC */
138 hDC
= CreateCompatibleDC(NULL
);
139 SetMapMode(hDC
, MM_LOMETRIC
);
140 GetWindowExtEx(hDC
, &WindowExt
);
141 GetViewportExtEx(hDC
, &ViewportExt
);
142 //TEST(WindowExt.cx == 3600);
143 //TEST(WindowExt.cy == 2700);
144 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
145 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
148 /* Test MM_HIMETRIC */
149 hDC
= CreateCompatibleDC(NULL
);
150 SetMapMode(hDC
, MM_HIMETRIC
);
151 GetWindowExtEx(hDC
, &WindowExt
);
152 GetViewportExtEx(hDC
, &ViewportExt
);
153 //TEST(WindowExt.cx == 36000);
154 //TEST(WindowExt.cy == 27000);
155 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
156 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
159 /* Test MM_LOENGLISH */
160 hDC
= CreateCompatibleDC(NULL
);
161 SetMapMode(hDC
, MM_LOENGLISH
);
162 GetWindowExtEx(hDC
, &WindowExt
);
163 GetViewportExtEx(hDC
, &ViewportExt
);
164 //TEST(WindowExt.cx == 1417);
165 //TEST(WindowExt.cy == 1063);
166 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
167 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
170 /* Test MM_HIENGLISH */
171 hDC
= CreateCompatibleDC(NULL
);
172 SetMapMode(hDC
, MM_HIENGLISH
);
173 GetWindowExtEx(hDC
, &WindowExt
);
174 GetViewportExtEx(hDC
, &ViewportExt
);
175 //TEST(WindowExt.cx == 14173);
176 //TEST(WindowExt.cy == 10630);
177 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
178 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
182 hDC
= CreateCompatibleDC(NULL
);
183 SetMapMode(hDC
, MM_TWIPS
);
184 GetWindowExtEx(hDC
, &WindowExt
);
185 GetViewportExtEx(hDC
, &ViewportExt
);
186 //TEST(WindowExt.cx == 20409);
187 //TEST(WindowExt.cy == 15307);
188 TEST(ViewportExt
.cx
== GetDeviceCaps(GetDC(0), HORZRES
));
189 TEST(ViewportExt
.cy
== -GetDeviceCaps(GetDC(0), VERTRES
));
193 START_TEST(SetMapMode
)