ReactOS 0.4.16-dev-2491-g3dc6630
text.c
Go to the documentation of this file.
1/*
2 * DrawText tests
3 *
4 * Copyright (c) 2004 Zach Gorman
5 * Copyright 2007,2016 Dmitry Timoshkov
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22#include <assert.h>
23
24#include "wine/test.h"
25#include "winbase.h"
26#include "wingdi.h"
27#include "winuser.h"
28#include "winerror.h"
29#include "winnls.h"
30
31#define MODIFIED(rect) (rect.left == 10 && rect.right != 100 && rect.top == 10 && rect.bottom != 100)
32#define EMPTY(rect) (rect.left == rect.right && rect.bottom == rect.top)
33
34static void test_DrawTextCalcRect(void)
35{
36 HWND hwnd;
37 HDC hdc;
38 HFONT hFont, hOldFont;
39 LOGFONTA lf;
40 static CHAR text[] = "Example text for testing DrawText in "
41 "MM_HIENGLISH mode";
42 static WCHAR textW[] = {'W','i','d','e',' ','c','h','a','r',' ',
43 's','t','r','i','n','g','\0'};
44 static CHAR emptystring[] = "";
45 static WCHAR emptystringW[] = { 0 };
46 static CHAR wordbreak_text[] = "line1 line2";
47 static WCHAR wordbreak_textW[] = {'l','i','n','e','1',' ','l','i','n','e','2',0};
48 static WCHAR wordbreak_text_colonW[] = {'l','i','n','e','1',' ','l','i','n','e','2',' ',':',0};
49 static WCHAR wordbreak_text_csbW[] = {'l','i','n','e','1',' ','l','i','n','e','2',' ',']',0};
50 static char tabstring[] = "one\ttwo";
51 INT textlen, textheight, heightcheck;
52 RECT rect = { 0, 0, 100, 0 }, rect2;
53 BOOL ret;
55 BOOL conform_xp = TRUE;
56
57 /* Initialization */
58 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
59 0, 0, 200, 200, 0, 0, 0, NULL);
60 ok(hwnd != 0, "CreateWindowExA error %lu\n", GetLastError());
61 hdc = GetDC(hwnd);
62 ok(hdc != 0, "GetDC error %lu\n", GetLastError());
63 trace("hdc %p\n", hdc);
64 textlen = lstrlenA(text);
65
66 /* LOGFONT initialization */
67 memset(&lf, 0, sizeof(lf));
71 lf.lfHeight = 0; /* mapping mode dependent */
73 lstrcpyA(lf.lfFaceName, "Arial");
74
75 /* DrawText in MM_HIENGLISH with DT_CALCRECT */
77 lf.lfHeight = 100 * 9 / 72; /* 9 point */
79 ok(hFont != 0, "CreateFontIndirectA error %lu\n",
80 GetLastError());
81 hOldFont = SelectObject(hdc, hFont);
82
83 textheight = DrawTextA(hdc, text, textlen, &rect, DT_CALCRECT |
86 ok( textheight, "DrawTextA error %lu\n", GetLastError());
87
88 trace("MM_HIENGLISH rect.bottom %ld\n", rect.bottom);
89 ok(rect.bottom < 0, "In MM_HIENGLISH, DrawText with "
90 "DT_CALCRECT should return a negative rectangle bottom. "
91 "(bot=%ld)\n", rect.bottom);
92
93 SelectObject(hdc, hOldFont);
95 ok( ret, "DeleteObject error %lu\n", GetLastError());
96
97
98 /* DrawText in MM_TEXT with DT_CALCRECT */
101 LOGPIXELSY), 72); /* 9 point */
103 ok(hFont != 0, "CreateFontIndirectA error %lu\n",
104 GetLastError());
105 hOldFont = SelectObject(hdc, hFont);
106
107 textheight = DrawTextA(hdc, text, textlen, &rect, DT_CALCRECT |
110 ok( textheight, "DrawTextA error %lu\n", GetLastError());
111
112 trace("MM_TEXT rect.bottom %ld\n", rect.bottom);
113 ok(rect.bottom > 0, "In MM_TEXT, DrawText with DT_CALCRECT "
114 "should return a positive rectangle bottom. (bot=%ld)\n",
115 rect.bottom);
116
117 /* empty or null text should in some cases calc an empty rectangle */
118
119 SetRect( &rect, 10,10, 100, 100);
120 heightcheck = textheight = DrawTextExA(hdc, text, 0, &rect, DT_CALCRECT, NULL );
122 "rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
123 ok(textheight==0,"Got textheight from DrawTextExA\n");
124
125 SetRect( &rect, 10,10, 100, 100);
126 textheight = DrawTextA(hdc, text, 0, &rect, DT_CALCRECT);
128 "rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
129 if (conform_xp)
130 ok(textheight==0,"Got textheight from DrawTextA\n");
131 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
132
133 SetRect( &rect, 10,10, 100, 100);
134 SetLastError( 0);
135 heightcheck = textheight = DrawTextExA(hdc, emptystring, -1, &rect, DT_CALCRECT, NULL );
136 ok(EMPTY(rect), "rectangle should be empty got %s\n", wine_dbgstr_rect(&rect));
137 ok(textheight!=0,"Failed to get textheight from DrawTextExA\n");
138
139 SetRect( &rect, 10,10, 100, 100);
140 textheight = DrawTextA(hdc, emptystring, -1, &rect, DT_CALCRECT);
141 ok(EMPTY(rect), "rectangle should be empty got %s\n", wine_dbgstr_rect(&rect));
142 ok(textheight!=0,"Failed to get textheight from DrawTextA\n");
143 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
144
145 SetRect( &rect, 10,10, 100, 100);
146 SetLastError( 0);
147 heightcheck = textheight = DrawTextExA(hdc, NULL, -1, &rect, DT_CALCRECT, NULL );
148 ok(EMPTY(rect), "rectangle should be empty got %s\n", wine_dbgstr_rect(&rect));
149 if (!textheight) /* Windows NT 4 */
150 {
151 if (conform_xp)
152 win_skip("XP conformity failed, skipping XP tests. Probably winNT\n");
153 conform_xp = FALSE;
154 }
155 else
156 ok(textheight!=0,"Failed to get textheight from DrawTextExA\n");
157
158 SetRect( &rect, 10,10, 100, 100);
159 textheight = DrawTextA(hdc, NULL, -1, &rect, DT_CALCRECT);
160 ok(EMPTY(rect), "rectangle should be empty got %s\n", wine_dbgstr_rect(&rect));
161 if (conform_xp)
162 ok(textheight!=0,"Failed to get textheight from DrawTextA\n");
163 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
164
165 SetRect( &rect, 10,10, 100, 100);
166 heightcheck = textheight = DrawTextExA(hdc, NULL, 0, &rect, DT_CALCRECT, NULL );
168 "rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
169 if (conform_xp)
170 ok(textheight==0,"Got textheight from DrawTextExA\n");
171
172 SetRect( &rect, 10,10, 100, 100);
173 textheight = DrawTextA(hdc, NULL, 0, &rect, DT_CALCRECT);
175 "rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
176 if (conform_xp)
177 ok(textheight==0,"Got textheight from DrawTextA\n");
178 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
179
180 /* DT_SINGLELINE tests */
181
182 SetRect( &rect, 10,10, 100, 100);
183 heightcheck = textheight = DrawTextExA(hdc, text, 0, &rect, DT_CALCRECT|DT_SINGLELINE, NULL );
185 "rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
186 if (conform_xp)
187 ok(textheight==0,"Got textheight from DrawTextExA\n");
188
189 SetRect( &rect, 10,10, 100, 100);
190 textheight = DrawTextA(hdc, text, 0, &rect, DT_CALCRECT|DT_SINGLELINE);
192 "rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
193 if (conform_xp)
194 ok(textheight==0,"Got textheight from DrawTextA\n");
195 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
196
197 SetRect( &rect, 10,10, 100, 100);
198 SetLastError( 0);
199 heightcheck = textheight = DrawTextExA(hdc, emptystring, -1, &rect, DT_CALCRECT|DT_SINGLELINE, NULL );
200 ok(!EMPTY(rect) && MODIFIED(rect), "rectangle should be modified got %s\n",
202 ok(textheight!=0,"Failed to get textheight from DrawTextExA\n");
203
204 SetRect( &rect, 10,10, 100, 100);
205 textheight = DrawTextA(hdc, emptystring, -1, &rect, DT_CALCRECT|DT_SINGLELINE);
206 ok(!EMPTY(rect) && MODIFIED (rect), "rectangle should be modified got %s\n",
208 ok(textheight!=0,"Failed to get textheight from DrawTextA\n");
209 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
210
211 SetRect( &rect, 10,10, 100, 100);
212 SetLastError( 0);
213 heightcheck = textheight = DrawTextExA(hdc, NULL, -1, &rect, DT_CALCRECT|DT_SINGLELINE, NULL );
214 ok(!EMPTY(rect) && MODIFIED(rect), "rectangle should be modified got %s\n",
216 if (conform_xp)
217 ok(textheight!=0,"Failed to get textheight from DrawTextExA\n");
218
219 SetRect( &rect, 10,10, 100, 100);
220 textheight = DrawTextA(hdc, NULL, -1, &rect, DT_CALCRECT|DT_SINGLELINE);
221 ok(!EMPTY(rect) && MODIFIED(rect), "rectangle should be modified got %s\n",
223 if (conform_xp)
224 ok(textheight!=0,"Failed to get textheight from DrawTextA\n");
225 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
226
227 SetRect( &rect, 10,10, 100, 100);
228 heightcheck = textheight = DrawTextExA(hdc, NULL, 0, &rect, DT_CALCRECT|DT_SINGLELINE, NULL );
230 "rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
231 if (conform_xp)
232 ok(textheight==0,"Got textheight from DrawTextExA\n");
233
234 SetRect( &rect, 10,10, 100, 100);
235 textheight = DrawTextA(hdc, NULL, 0, &rect, DT_CALCRECT|DT_SINGLELINE);
237 "rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
238 if (conform_xp)
239 ok(textheight==0,"Got textheight from DrawTextA\n");
240 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
241
242 /* further tests with 0 count, NULL and empty strings */
243 heightcheck = textheight = DrawTextA(hdc, text, 0, &rect, 0);
244 if (conform_xp)
245 ok(textheight==0,"Got textheight from DrawTextA\n");
246 textheight = DrawTextExA(hdc, text, 0, &rect, 0, NULL );
247 if (conform_xp)
248 ok(textheight==0,"Got textheight from DrawTextExA\n");
249 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
250 heightcheck = textheight = DrawTextA(hdc, emptystring, 0, &rect, 0);
251 if (conform_xp)
252 ok(textheight==0,"Got textheight from DrawTextA\n");
253 textheight = DrawTextExA(hdc, emptystring, 0, &rect, 0, NULL );
254 if (conform_xp)
255 ok(textheight==0,"Got textheight from DrawTextExA\n");
256 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
257 heightcheck = textheight = DrawTextA(hdc, NULL, 0, &rect, 0);
258 if (conform_xp)
259 ok(textheight==0,"Got textheight from DrawTextA\n");
260 textheight = DrawTextExA(hdc, NULL, 0, &rect, 0, NULL );
261 if (conform_xp)
262 ok(textheight==0,"Got textheight from DrawTextExA\n");
263 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
264 heightcheck = textheight = DrawTextA(hdc, emptystring, -1, &rect, 0);
265 ok(textheight!=0,"Failed to get textheight from DrawTextA\n");
266 textheight = DrawTextExA(hdc, emptystring, -1, &rect, 0, NULL );
267 ok(textheight!=0,"Failed to get textheight from DrawTextExA\n");
268 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
269 heightcheck = textheight = DrawTextA(hdc, NULL, -1, &rect, 0);
270 if (conform_xp)
271 ok(textheight!=0,"Failed to get textheight from DrawTextA\n");
272 textheight = DrawTextExA(hdc, NULL, -1, &rect, 0, NULL );
273 if (conform_xp)
274 ok(textheight!=0,"Failed to get textheight from DrawTextExA\n");
275 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
276 heightcheck = textheight = DrawTextA(hdc, NULL, 10, &rect, 0);
277 ok(textheight==0,"Got textheight from DrawTextA\n");
278 textheight = DrawTextExA(hdc, NULL, 10, &rect, 0, NULL );
279 ok(textheight==0,"Got textheight from DrawTextA\n");
280 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
281
282 /* When offset to top is zero, return 1 */
284 textheight = DrawTextExW(hdc, textW, -1, &rect, DT_SINGLELINE | DT_CALCRECT | DT_BOTTOM, NULL);
285 ok(textheight == 1, "Expect returned height:1 got:%d\n", textheight);
286
287 SetRect(&rect, 0, 100, 0, 100);
288 textheight = DrawTextExW(hdc, textW, -1, &rect, DT_SINGLELINE | DT_CALCRECT | DT_BOTTOM, NULL);
289 ok(textheight == 1, "Expect returned height:1 got:%d\n", textheight);
290
292 textheight = DrawTextExW(hdc, textW, -1, &rect, DT_SINGLELINE | DT_CALCRECT | DT_TOP, NULL);
293 /* Set top to text height and bottom zero, so bottom of drawn text to top is zero when DT_VCENTER is used */
294 SetRect(&rect, 0, textheight, 0, 0);
296 ok(textheight == 1, "Expect returned height:1 got:%d\n", textheight);
297
298 /* invalid dtp size test */
299 dtp.cbSize = -1; /* Invalid */
300 dtp.uiLengthDrawn = 1337;
301 textheight = DrawTextExA(hdc, text, 0, &rect, 0, &dtp);
302 ok(textheight==0,"Got textheight from DrawTextExA\n");
303 ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
304 dtp.uiLengthDrawn = 1337;
305 textheight = DrawTextExA(hdc, emptystring, 0, &rect, 0, &dtp);
306 ok(textheight==0,"Got textheight from DrawTextExA\n");
307 ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
308 dtp.uiLengthDrawn = 1337;
309 textheight = DrawTextExA(hdc, NULL, 0, &rect, 0, &dtp);
310 ok(textheight==0,"Got textheight from DrawTextExA\n");
311 ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
312 dtp.uiLengthDrawn = 1337;
313 textheight = DrawTextExA(hdc, emptystring, -1, &rect, 0, &dtp);
314 ok(textheight==0,"Got textheight from DrawTextExA\n");
315 ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
316 dtp.uiLengthDrawn = 1337;
317 textheight = DrawTextExA(hdc, NULL, -1, &rect, 0, &dtp);
318 ok(textheight==0,"Got textheight from DrawTextExA\n");
319 ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
320
321 /* Margin calculations */
322 dtp.cbSize = sizeof(dtp);
323 dtp.iLeftMargin = 0;
324 dtp.iRightMargin = 0;
326 DrawTextExA(hdc, text, -1, &rect, DT_CALCRECT, &dtp);
327 textlen = rect.right; /* Width without margin */
328 dtp.iLeftMargin = 8;
330 DrawTextExA(hdc, text, -1, &rect, DT_CALCRECT, &dtp);
331 ok(rect.right==dtp.iLeftMargin+textlen ,"Incorrect left margin calculated rc(%ld,%ld)\n", rect.left, rect.right);
332 dtp.iLeftMargin = 0;
333 dtp.iRightMargin = 8;
335 DrawTextExA(hdc, text, -1, &rect, DT_CALCRECT, &dtp);
336 ok(rect.right==dtp.iRightMargin+textlen ,"Incorrect right margin calculated rc(%ld,%ld)\n", rect.left, rect.right);
337
338 /* Wide char versions */
339 SetRect( &rect, 10,10, 100, 100);
340 SetLastError( 0);
341 heightcheck = textheight = DrawTextExW(hdc, textW, 0, &rect, DT_CALCRECT, NULL );
344 "rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
345 ok(textheight!=0,"Failed to get textheight from DrawTextExW\n");
346
347 SetRect( &rect, 10,10, 100, 100);
348 textheight = DrawTextW(hdc, textW, 0, &rect, DT_CALCRECT);
350 "rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
351 ok(textheight!=0,"Failed to get textheight from DrawTextW\n");
352 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
353
354 SetRect( &rect, 10,10, 100, 100);
355 heightcheck = textheight = DrawTextExW(hdc, emptystringW, -1, &rect, DT_CALCRECT, NULL );
356 ok(EMPTY(rect), "rectangle should be empty got %s\n", wine_dbgstr_rect(&rect));
357 ok(textheight!=0,"Failed to get textheight from DrawTextExW\n");
358
359 SetRect( &rect, 10,10, 100, 100);
360 textheight = DrawTextW(hdc, emptystringW, -1, &rect, DT_CALCRECT);
361 ok(EMPTY(rect), "rectangle should be empty got %s\n", wine_dbgstr_rect(&rect));
362 ok(textheight!=0,"Failed to get textheight from DrawTextW\n");
363 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
364
365 SetRect( &rect, 10,10, 100, 100);
366 heightcheck = textheight = DrawTextExW(hdc, NULL, 0, &rect, DT_CALCRECT, NULL );
368 "rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
369 if (textheight) /* windows 2000 */
370 {
371 if (conform_xp)
372 win_skip("XP conformity failed, skipping XP tests. Probably win 2000\n");
373 conform_xp = FALSE;
374 }
375 else
376 ok(textheight==0,"Got textheight from DrawTextExW\n");
377
378 SetRect( &rect, 10,10, 100, 100);
379 textheight = DrawTextW(hdc, NULL, 0, &rect, DT_CALCRECT);
381 "rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
382 if (conform_xp)
383 ok(textheight==0,"Got textheight from DrawTextW\n");
384 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
385
386 if (conform_xp) {
387 /* Crashes on NT4 */
388 SetRect( &rect, 10,10, 100, 100);
389 heightcheck = textheight = DrawTextExW(hdc, NULL, -1, &rect, DT_CALCRECT, NULL );
391 "rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
392 ok(textheight==0,"Got textheight from DrawTextExW\n");
393
394 SetRect( &rect, 10,10, 100, 100);
395 textheight = DrawTextW(hdc, NULL, -1, &rect, DT_CALCRECT);
397 "rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
398 ok(textheight==0,"Got textheight from DrawTextW\n");
399 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
400 }
401
402
403 /* DT_SINGLELINE tests */
404
405 heightcheck = textheight = DrawTextExW(hdc, textW, 0, &rect, DT_CALCRECT|DT_SINGLELINE, NULL );
407 "rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
408 ok(textheight!=0,"Failed to get textheight from DrawTextExW\n");
409
410 SetRect( &rect, 10,10, 100, 100);
411 textheight = DrawTextW(hdc, textW, 0, &rect, DT_CALCRECT|DT_SINGLELINE);
413 "rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
414 ok(textheight!=0,"Failed to get textheight from DrawTextW\n");
415 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
416
417 SetRect( &rect, 10,10, 100, 100);
418 heightcheck = textheight = DrawTextExW(hdc, emptystringW, -1, &rect, DT_CALCRECT|DT_SINGLELINE, NULL );
419 ok(!EMPTY(rect) && MODIFIED(rect), "rectangle should be modified got %s\n",
421 ok(textheight!=0,"Failed to get textheight from DrawTextExW\n");
422
423 SetRect( &rect, 10,10, 100, 100);
425 ok(!EMPTY(rect) && MODIFIED(rect), "rectangle should be modified got %s\n",
427 ok(textheight!=0,"Failed to get textheight from DrawTextW\n");
428 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
429
430 if (conform_xp) {
431 /* Crashes on NT4 */
432 SetRect( &rect, 10,10, 100, 100);
433 heightcheck = textheight = DrawTextExW(hdc, NULL, -1, &rect, DT_CALCRECT|DT_SINGLELINE, NULL );
435 "rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
436 ok(textheight==0,"Got textheight from DrawTextExW\n");
437
438 SetRect( &rect, 10,10, 100, 100);
439 textheight = DrawTextW(hdc, NULL, -1, &rect, DT_CALCRECT|DT_SINGLELINE);
441 "rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
442 ok(textheight==0,"Got textheight from DrawTextW\n");
443 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
444 }
445
446 SetRect( &rect, 10,10, 100, 100);
447 heightcheck = textheight = DrawTextExW(hdc, NULL, 0, &rect, DT_CALCRECT|DT_SINGLELINE, NULL );
449 "rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
450 if (conform_xp)
451 ok(textheight==0,"Got textheight from DrawTextExW\n");
452
453 SetRect( &rect, 10,10, 100, 100);
454 textheight = DrawTextW(hdc, NULL, 0, &rect, DT_CALCRECT|DT_SINGLELINE);
456 "rectangle should NOT be empty and NOT modified got %s\n", wine_dbgstr_rect(&rect));
457 if (conform_xp)
458 ok(textheight==0,"Got textheight from DrawTextW\n");
459 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
460
461 /* further tests with NULL and empty strings */
462 heightcheck = textheight = DrawTextW(hdc, textW, 0, &rect, 0);
463 ok(textheight!=0,"Failed to get textheight from DrawTextW\n");
464 textheight = DrawTextExW(hdc, textW, 0, &rect, 0, NULL );
465 ok(textheight!=0,"Failed to get textheight from DrawTextExW\n");
466 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
467 heightcheck = textheight = DrawTextW(hdc, emptystringW, 0, &rect, 0);
468 ok(textheight!=0,"Failed to get textheight from DrawTextW\n");
469 textheight = DrawTextExW(hdc, emptystringW, 0, &rect, 0, NULL );
470 ok(textheight!=0,"Failed to get textheight from DrawTextExW\n");
471 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
472 heightcheck = textheight = DrawTextW(hdc, NULL, 0, &rect, 0);
473 if (conform_xp)
474 ok(textheight==0,"Got textheight from DrawTextW\n");
475 textheight = DrawTextExW(hdc, NULL, 0, &rect, 0, NULL );
476 if (conform_xp)
477 ok(textheight==0,"Got textheight from DrawTextExW\n");
478 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
479 heightcheck = textheight = DrawTextW(hdc, emptystringW, -1, &rect, 0);
480 ok(textheight!=0,"Failed to get textheight from DrawTextW\n");
481 textheight = DrawTextExW(hdc, emptystringW, -1, &rect, 0, NULL );
482 ok(textheight!=0,"Failed to get textheight from DrawTextExW\n");
483 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
484 if (conform_xp) {
485 /* Crashes on NT4 */
486 heightcheck = textheight = DrawTextW(hdc, NULL, -1, &rect, 0);
487 ok(textheight==0,"Got textheight from DrawTextW\n");
488 textheight = DrawTextExW(hdc, NULL, -1, &rect, 0, NULL );
489 ok(textheight==0,"Got textheight from DrawTextExW\n");
490 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
491 heightcheck = textheight = DrawTextW(hdc, NULL, 10, &rect, 0);
492 ok(textheight==0,"Got textheight from DrawTextW\n");
493 textheight = DrawTextExW(hdc, NULL, 10, &rect, 0, NULL );
494 ok(textheight==0,"Got textheight from DrawTextW\n");
495 ok(textheight == heightcheck,"DrawTextEx and DrawText differ in return\n");
496 }
497
498 dtp.cbSize = -1; /* Invalid */
499 dtp.uiLengthDrawn = 1337;
500 textheight = DrawTextExW(hdc, textW, 0, &rect, 0, &dtp);
501 ok(textheight!=0,"Failed to get textheight from DrawTextExW\n");
502 ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
503 dtp.uiLengthDrawn = 1337;
504 textheight = DrawTextExW(hdc, emptystringW, 0, &rect, 0, &dtp);
505 if (conform_xp)
506 ok(textheight==0,"Got textheight from DrawTextExW\n");
507 ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
508 dtp.uiLengthDrawn = 1337;
509 textheight = DrawTextExW(hdc, NULL, 0, &rect, 0, &dtp);
510 if (conform_xp)
511 ok(textheight==0,"Got textheight from DrawTextExW\n");
512 ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
513 dtp.uiLengthDrawn = 1337;
514 textheight = DrawTextExW(hdc, emptystringW, -1, &rect, 0, &dtp);
515 ok(textheight==0,"Got textheight from DrawTextExW\n");
516 ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
517 if (conform_xp) {
518 /* Crashes on NT4 */
519 dtp.uiLengthDrawn = 1337;
520 textheight = DrawTextExW(hdc, NULL, -1, &rect, 0, &dtp);
521 ok(textheight==0,"Got textheight from DrawTextExW\n");
522 ok(dtp.uiLengthDrawn==1337, "invalid dtp.uiLengthDrawn = %i\n",dtp.uiLengthDrawn);
523 }
524
525 /* When passing invalid DC, other parameters must be ignored - no crashes on invalid pointers */
526
527#ifdef __REACTOS__
528 if (is_reactos()) {
529 ok(FALSE, "FIXME: invalid pointer tests crash on ReactOS.\n");
530 } else {
531#endif
532 SetLastError(0xdeadbeef);
533 textheight = DrawTextExW((HDC)0xdeadbeef, (LPWSTR)0xdeadbeef, 100000, &rect, 0, 0);
534 ok(textheight == 0, "Got textheight from DrawTextExW\n");
535 ok(GetLastError() == 0xdeadbeef,"Got error %lu\n", GetLastError());
536
537 SetLastError(0xdeadbeef);
538 textheight = DrawTextExW((HDC)0xdeadbeef, 0, -1, (LPRECT)0xdeadbeef, DT_CALCRECT, 0);
539 ok(textheight == 0, "Got textheight from DrawTextExW\n");
540 ok(GetLastError() == 0xdeadbeef,"Got error %lu\n", GetLastError());
541
542 SetLastError(0xdeadbeef);
543 textheight = DrawTextExA((HDC)0xdeadbeef, 0, -1, (LPRECT)0xdeadbeef, DT_CALCRECT, 0);
544 ok(textheight == 0, "Got textheight from DrawTextExA\n");
546#ifdef __REACTOS__
547 }
548#endif
549
550 if (0)
551 {
552 /* Crashes */
553 textheight = DrawTextExA((HDC)0xdeadbeef, (LPSTR)0xdeadbeef, 100, &rect, 0, 0);
554 }
555 }
556
557 /* More test cases from bug 12226 */
559 textheight = DrawTextA(hdc, emptystring, -1, &rect, DT_CALCRECT | DT_LEFT | DT_SINGLELINE);
560 ok(textheight, "DrawTextA error %lu\n", GetLastError());
561 ok(0 == rect.left, "expected 0, got %ld\n", rect.left);
562 ok(0 == rect.right, "expected 0, got %ld\n", rect.right);
563 ok(0 == rect.top, "expected 0, got %ld\n", rect.top);
564 ok(rect.bottom, "rect.bottom should not be 0\n");
565
568 if (!textheight && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
569 {
570 win_skip( "DrawTextW not implemented\n" );
571 }
572 else
573 {
574 ok(textheight, "DrawTextW error %lu\n", GetLastError());
575 ok(0 == rect.left, "expected 0, got %ld\n", rect.left);
576 ok(0 == rect.right, "expected 0, got %ld\n", rect.right);
577 ok(0 == rect.top, "expected 0, got %ld\n", rect.top);
578 ok(rect.bottom, "rect.bottom should not be 0\n");
579 }
580
581 SetRect(&rect, 0, 0, 1, 1);
582 heightcheck = DrawTextA(hdc, wordbreak_text, -1, &rect, DT_CALCRECT);
583 SetRect(&rect, 0, 0, 1, 1);
584 textheight = DrawTextA(hdc, wordbreak_text, -1, &rect, DT_CALCRECT | DT_WORDBREAK);
585 ok(textheight == heightcheck * 2, "Got unexpected textheight %d, expected %d.\n",
586 textheight, heightcheck * 2);
587 SetRect(&rect, 0, 0, 1, 1);
588 textheight = DrawTextA(hdc, wordbreak_text, -1, &rect, DT_CALCRECT | DT_WORDBREAK | DT_EDITCONTROL);
589 ok(textheight >= heightcheck * 6, "Got unexpected textheight %d, expected at least %d.\n",
590 textheight, heightcheck * 6);
591
592 SetRect(&rect, 0, 0, 1, 1);
593 heightcheck = DrawTextW(hdc, wordbreak_textW, -1, &rect, DT_CALCRECT);
594 SetRect(&rect, 0, 0, 1, 1);
595 textheight = DrawTextW(hdc, wordbreak_textW, -1, &rect, DT_CALCRECT | DT_WORDBREAK);
596 ok(textheight == heightcheck * 2, "Got unexpected textheight %d, expected %d.\n",
597 textheight, heightcheck * 2);
598 SetRect(&rect, 0, 0, 1, 1);
599 textheight = DrawTextW(hdc, wordbreak_textW, -1, &rect, DT_CALCRECT | DT_WORDBREAK | DT_EDITCONTROL);
600 ok(textheight >= heightcheck * 6, "Got unexpected textheight %d, expected at least %d.\n",
601 textheight, heightcheck * 6);
602
603 /* Word break tests with space before punctuation */
604 SetRect(&rect, 0, 0, 200, 1);
605 textheight = DrawTextW(hdc, wordbreak_text_colonW, -1, &rect, DT_CALCRECT | DT_WORDBREAK);
606 ok(textheight == heightcheck, "Got unexpected textheight %d, expected %d.\n",
607 textheight, heightcheck);
608
609 rect2 = rect;
610 rect.right--;
611
612 textheight = DrawTextW(hdc, wordbreak_text_colonW, -1, &rect, DT_CALCRECT | DT_WORDBREAK);
613 ok(textheight == heightcheck * 2, "Got unexpected textheight %d, expected %d.\n",
614 textheight, heightcheck * 2);
615 ok(rect.right > rect2.right - 10, "Got unexpected textwdith %ld, expected larger than %ld.\n",
616 rect.right, rect2.right - 10);
617
618 SetRect(&rect, 0, 0, 200, 1);
619 textheight = DrawTextW(hdc, wordbreak_text_csbW, -1, &rect, DT_CALCRECT | DT_WORDBREAK);
620 ok(textheight == heightcheck, "Got unexpected textheight %d, expected %d.\n",
621 textheight, heightcheck);
622
623 rect2 = rect;
624 rect.right--;
625
626 textheight = DrawTextW(hdc, wordbreak_text_csbW, -1, &rect, DT_CALCRECT | DT_WORDBREAK);
627 ok(textheight == heightcheck * 2, "Got unexpected textheight %d, expected %d.\n",
628 textheight, heightcheck * 2);
629 ok(rect.right > rect2.right - 10, "Got unexpected textwdith %ld, expected larger than %ld.\n",
630 rect.right, rect2.right - 10);
631
632
633 /* DT_TABSTOP | DT_EXPANDTABS tests */
634 SetRect( &rect, 0,0, 10, 10);
635 textheight = DrawTextA(hdc, tabstring, -1, &rect, DT_TABSTOP | DT_EXPANDTABS );
636 ok(textheight >= heightcheck, "Got unexpected textheight %d\n", textheight);
637
638 SetRect( &rect, 0,0, 10, 10);
639 memset(&dtp, 0, sizeof(dtp));
640 dtp.cbSize = sizeof(dtp);
641 textheight = DrawTextExA(hdc, tabstring, -1, &rect, DT_CALCRECT, &dtp);
642 ok(textheight >= heightcheck, "Got unexpected textheight %d\n", textheight);
643 ok(dtp.iTabLength == 0, "invalid dtp.iTabLength = %i\n",dtp.iTabLength);
644
645 SetRect( &rect2, 0,0, 10, 10);
646 memset(&dtp, 0, sizeof(dtp));
647 dtp.cbSize = sizeof(dtp);
648 textheight = DrawTextExA(hdc, tabstring, -1, &rect2, DT_CALCRECT | DT_TABSTOP | DT_EXPANDTABS, &dtp);
649 ok(textheight >= heightcheck, "Got unexpected textheight %d\n", textheight);
650 ok(dtp.iTabLength == 0, "invalid dtp.iTabLength = %i\n",dtp.iTabLength);
651 ok(rect.left == rect2.left && rect.right != rect2.right && rect.top == rect2.top && rect.bottom == rect2.bottom,
652 "incorrect rect %s rect2 %s\n", wine_dbgstr_rect(&rect), wine_dbgstr_rect(&rect2));
653
654 SetRect( &rect, 0,0, 10, 10);
655 memset(&dtp, 0, sizeof(dtp));
656 dtp.cbSize = sizeof(dtp);
657 dtp.iTabLength = 8;
658 textheight = DrawTextExA(hdc, tabstring, -1, &rect, DT_CALCRECT | DT_TABSTOP | DT_EXPANDTABS, &dtp);
659 ok(textheight >= heightcheck, "Got unexpected textheight %d\n", textheight);
660 ok(dtp.iTabLength == 8, "invalid dtp.iTabLength = %i\n",dtp.iTabLength);
661 ok(rect.left == rect2.left, "unexpected value %ld, got %ld\n", rect.left, rect2.left);
662 /* XP, 2003 appear to not give the same values. */
663 ok(rect.right == rect2.right || broken(rect.right > rect2.right), "unexpected value %ld, got %ld\n",rect.right, rect2.right);
664 ok(rect.top == rect2.top, "unexpected value %ld, got %ld\n", rect.top, rect2.top);
665 ok(rect.bottom == rect2.bottom , "unexpected value %ld, got %ld\n", rect.bottom, rect2.bottom);
666
667
668 SelectObject(hdc, hOldFont);
670 ok( ret, "DeleteObject error %lu\n", GetLastError());
671
672 /* Clean up */
673 ret = ReleaseDC(hwnd, hdc);
674 ok( ret, "ReleaseDC error %lu\n", GetLastError());
676 ok( ret, "DestroyWindow error %lu\n", GetLastError());
677}
678
679/* replace tabs by \t */
680static void strfmt( const char *str, char *strout)
681{
682 unsigned int i,j ;
683 for(i=0,j=0;i<=strlen(str);i++,j++)
684 if((strout[j]=str[i])=='\t') {
685 strout[j++]='\\';
686 strout[j]='t';
687 }
688}
689
690
691#define TABTEST( tabval, tabcount, string, _exp) \
692{ int i; char strdisp[64];\
693 for(i=0;i<8;i++) tabs[i]=(i+1)*(tabval); \
694 extent = GetTabbedTextExtentA( hdc, string, strlen( string), (tabcount), tabs); \
695 strfmt( string, strdisp); \
696 /* trace( "Extent is %08lx\n", extent); */\
697 ok( extent == _exp, "Test case \"%s\". Text extent is 0x%lx, expected 0x%lx tab %d tabcount %d\n", \
698 strdisp, extent, _exp, tabval, tabcount); \
699} \
700
701
702static void test_TabbedText(void)
703{
704 HWND hwnd;
705 HDC hdc;
706 BOOL ret;
709 INT tabs[8], cx, cy, tab, tabcount,t,align;
710
711 /* Initialization */
712 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
713 0, 0, 200, 200, 0, 0, 0, NULL);
714 ok(hwnd != 0, "CreateWindowExA error %lu\n", GetLastError());
715 hdc = GetDC(hwnd);
716 ok(hdc != 0, "GetDC error %lu\n", GetLastError());
717
719 ok( ret, "GetTextMetrics error %lu\n", GetLastError());
720
721 extent = GetTabbedTextExtentA( hdc, "x", 0, 1, tabs);
722 ok( extent == 0, "GetTabbedTextExtentA returned non-zero on nCount == 0\n");
723
724 extent = GetTabbedTextExtentA( hdc, "x", 1, 1, tabs);
725 cx = LOWORD( extent);
726 cy = HIWORD( extent);
727 trace( "cx is %d cy is %d\n", cx, cy);
728
729 align=1;
730 for( t=-1; t<=1; t++) { /* slightly adjust the 4 char tabstop, to
731 catch the one off errors */
732 tab = (cx *4 + t);
733 /* test the special case tabcount =1 and the general array (80 of tabs */
734 for( tabcount = 1; tabcount <= 8; tabcount +=7) {
735 TABTEST( align * tab, tabcount, "\t", MAKELONG(tab, cy))
736 TABTEST( align * tab, tabcount, "xxx\t", MAKELONG(tab, cy))
737 TABTEST( align * tab, tabcount, "\tx", MAKELONG(tab+cx, cy))
738 TABTEST( align * tab, tabcount, "\t\t", MAKELONG(tab*2, cy))
739 TABTEST( align * tab, tabcount, "\tx\t", MAKELONG(tab*2, cy))
740 TABTEST( align * tab, tabcount, "x\tx", MAKELONG(tab+cx, cy))
741 TABTEST( align * tab, tabcount, "xx\tx", MAKELONG(tab+cx, cy))
742 TABTEST( align * tab, tabcount, "xxx\tx", MAKELONG(tab+cx, cy))
743 TABTEST( align * tab, tabcount, "xxxx\tx", MAKELONG(t>0 ? tab + cx : 2*tab+cx, cy))
744 TABTEST( align * tab, tabcount, "xxxxx\tx", MAKELONG(2*tab+cx, cy))
745 }
746 }
747 align=-1;
748 for( t=-1; t<=1; t++) { /* slightly adjust the 4 char tabstop, to
749 catch the one off errors */
750 tab = (cx *4 + t);
751 /* test the special case tabcount =1 and the general array (8) of tabs */
752 for( tabcount = 1; tabcount <= 8; tabcount +=7) {
753 TABTEST( align * tab, tabcount, "\t", MAKELONG(tab, cy))
754 TABTEST( align * tab, tabcount, "xxx\t", MAKELONG(tab, cy))
755 TABTEST( align * tab, tabcount, "\tx", MAKELONG(tab, cy))
756 TABTEST( align * tab, tabcount, "\t\t", MAKELONG(tab*2, cy))
757 TABTEST( align * tab, tabcount, "\tx\t", MAKELONG(tab*2, cy))
758 TABTEST( align * tab, tabcount, "x\tx", MAKELONG(tab, cy))
759 TABTEST( align * tab, tabcount, "xx\tx", MAKELONG(tab, cy))
760 TABTEST( align * tab, tabcount, "xxx\tx", MAKELONG(4 * cx >= tab ? 2*tab :tab, cy))
761 TABTEST( align * tab, tabcount, "xxxx\tx", MAKELONG(2*tab, cy))
762 TABTEST( align * tab, tabcount, "xxxxx\tx", MAKELONG(2*tab, cy))
763 }
764 }
765
766 ReleaseDC( hwnd, hdc );
768}
769
770static void test_DrawState(void)
771{
772 static const char text[] = "Sample text string";
773 HWND hwnd;
774 HDC hdc;
775 BOOL ret;
776
777 hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
778 0, 0, 200, 200, 0, 0, 0, NULL);
779 assert(hwnd);
780
781 hdc = GetDC(hwnd);
782 assert(hdc);
783
784 SetLastError(0xdeadbeef);
786 0, 0, 10, 10, DST_TEXT);
787 ok(ret, "DrawState error %lu\n", GetLastError());
788
789 SetLastError(0xdeadbeef);
791 0, 0, 10, 10, DST_TEXT);
792 ok(ret, "DrawState error %lu\n", GetLastError());
793
794 SetLastError(0xdeadbeef);
796 0, 0, 10, 10, DST_TEXT);
797 ok(!ret || broken(ret) /* win98 */, "DrawState succeeded\n");
798 ok(GetLastError() == 0xdeadbeef, "not expected error %lu\n", GetLastError());
799
800 SetLastError(0xdeadbeef);
802 0, 0, 10, 10, DST_TEXT);
803 ok(!ret || broken(ret) /* win98 */, "DrawState succeeded\n");
804 ok(GetLastError() == 0xdeadbeef, "not expected error %lu\n", GetLastError());
805
808}
809
811{
812 static const WCHAR helloWorldW[] = {'H','e','l','l','o',' ','W','o','r','l','d',0};
813 static const WCHAR emptyW[] = {0};
814 static const char helloWorld[] = "Hello World";
815 static const struct
816 {
817 BOOL src, dst, ret;
818 }
819 tests[] =
820 {
821 { FALSE, FALSE, FALSE },
822 { TRUE, FALSE, FALSE },
823 { FALSE, TRUE, FALSE },
824 { TRUE, TRUE, TRUE },
825 };
826 BOOL ret;
827 int i;
828 char oem;
829 WCHAR uni, expect;
830
831 for (i = 0; i < ARRAY_SIZE(tests); i++)
832 {
833 const char *expected = tests[i].ret ? helloWorld : "";
834 const char *src = tests[i].src ? helloWorld : NULL;
835 char buf[64], *dst = tests[i].dst ? buf : NULL;
836
837 memset(buf, 0, sizeof(buf));
838 ret = CharToOemA(src, dst);
839 ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret);
840 ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
841
842 memset(buf, 0, sizeof(buf));
843 ret = CharToOemBuffA(src, dst, sizeof(helloWorld));
844 ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret);
845 ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
846
847 memset(buf, 0, sizeof(buf));
848 ret = OemToCharA(src, dst);
849 ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret);
850 ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
851
852 memset(buf, 0, sizeof(buf));
853 ret = OemToCharBuffA(src, dst, sizeof(helloWorld));
854 ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret);
855 ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
856 }
857
858 for (i = 0; i < ARRAY_SIZE(tests); i++)
859 {
860 const char *expected = tests[i].ret ? helloWorld : "";
861 const WCHAR *src = tests[i].src ? helloWorldW : NULL;
862 char buf[64], *dst = tests[i].dst ? buf : NULL;
863
864 memset(buf, 0, sizeof(buf));
865 ret = CharToOemW(src, dst);
866 ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret);
867 ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
868
869 memset(buf, 0, sizeof(buf));
870 ret = CharToOemBuffW(src, dst, ARRAY_SIZE(helloWorldW));
871 ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret);
872 ok(!strcmp(buf, expected), "test %d: got '%s'\n", i, buf);
873 }
874
875 for (i = 0; i < ARRAY_SIZE(tests); i++)
876 {
877 const WCHAR *expected = tests[i].ret ? helloWorldW : emptyW;
878 const char *src = tests[i].src ? helloWorld : NULL;
879 WCHAR buf[64], *dst = tests[i].dst ? buf : NULL;
880
881 memset(buf, 0, sizeof(buf));
882 ret = OemToCharW(src, dst);
883 ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret);
884 ok(!lstrcmpW(buf, expected), "test %d: got '%s'\n", i, wine_dbgstr_w(buf));
885
886 memset(buf, 0, sizeof(buf));
887 ret = OemToCharBuffW(src, dst, sizeof(helloWorld));
888 ok(ret == tests[i].ret, "test %d: expected %d, got %d\n", i, tests[i].ret, ret);
889 ok(!lstrcmpW(buf, expected), "test %d: got '%s'\n", i, wine_dbgstr_w(buf));
890 }
891
892 for (i = 0; i < 0x100; i++)
893 {
894 oem = i;
895 ret = OemToCharBuffW( &oem, &uni, 1 );
896 ok( ret, "%02x: returns FALSE\n", i );
898 ok( uni == expect, "%02x: got %04x expected %04x\n", i, uni, expect );
899 }
900}
901
903{
908}
#define expect(EXPECTED, GOT)
Definition: SystemMenu.c:483
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
HFONT hFont
Definition: main.c:53
#define ARRAY_SIZE(A)
Definition: main.h:20
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define MultiByteToWideChar
Definition: compat.h:110
static const WCHAR emptystringW[]
Definition: profile.c:96
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
const WCHAR * text
Definition: package.c:1794
#define assert(_expr)
Definition: assert.h:32
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319
return ret
Definition: mutex.c:146
int align(int length, int align)
Definition: dsound8.c:36
RECT rect2
Definition: edittest.c:51
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
GLdouble GLdouble t
Definition: gl.h:2047
GLenum src
Definition: glext.h:6340
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLenum dst
Definition: glext.h:6340
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define MB_USEGLYPHCHARS
Definition: unicode.h:42
static const WCHAR emptyW[]
Definition: navigate.c:40
#define wine_dbgstr_w
Definition: kernel32.h:34
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define win_skip
Definition: minitest.h:67
LONG_PTR LPARAM
Definition: minwindef.h:175
static struct test_info tests[]
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
static const WCHAR textW[]
Definition: itemdlg.c:1559
BOOL expected
Definition: store.c:2000
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static void strfmt(const char *str, char *strout)
Definition: text.c:680
#define EMPTY(rect)
Definition: text.c:32
static void test_DrawTextCalcRect(void)
Definition: text.c:34
static void test_TabbedText(void)
Definition: text.c:702
static void test_DrawState(void)
Definition: text.c:770
#define MODIFIED(rect)
Definition: text.c:31
#define TABTEST(tabval, tabcount, string, _exp)
Definition: text.c:691
static void test_CharToOem_OemToChar(void)
Definition: text.c:810
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:16
#define LOWORD(l)
Definition: pedump.c:82
#define WS_POPUP
Definition: pedump.c:616
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
const WCHAR * str
#define memset(x, y, z)
Definition: compat.h:39
& rect
Definition: startmenu.cpp:1413
int iRightMargin
Definition: winuser.h:3208
UINT uiLengthDrawn
Definition: winuser.h:3209
BYTE lfClipPrecision
Definition: dimm.idl:52
BYTE lfQuality
Definition: dimm.idl:53
LONG lfHeight
Definition: dimm.idl:42
BYTE lfCharSet
Definition: dimm.idl:50
LONG lfWeight
Definition: dimm.idl:46
CHAR lfFaceName[LF_FACESIZE]
Definition: dimm.idl:55
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
LONG left
Definition: windef.h:106
int32_t INT
Definition: typedefs.h:58
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define HIWORD(l)
Definition: typedefs.h:247
static struct wctab tab[]
INT WINAPI DrawTextA(HDC hdc, LPCSTR str, INT count, LPRECT rect, UINT flags)
Definition: font.c:373
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
int WINAPI SetMapMode(_In_ HDC, _In_ int)
#define MM_HIENGLISH
Definition: wingdi.h:868
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define FW_DONTCARE
Definition: wingdi.h:368
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
HFONT WINAPI CreateFontIndirectA(_In_ const LOGFONTA *)
#define DKGRAY_BRUSH
Definition: wingdi.h:897
#define DEFAULT_QUALITY
Definition: wingdi.h:436
#define LOGPIXELSY
Definition: wingdi.h:719
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
#define ANSI_CHARSET
Definition: wingdi.h:383
#define MM_TEXT
Definition: wingdi.h:873
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426
BOOL WINAPI GetTextMetricsA(_In_ HDC, _Out_ LPTEXTMETRICA)
Definition: text.c:200
#define CP_OEMCP
Definition: winnls.h:249
#define MB_PRECOMPOSED
Definition: winnls.h:299
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define DT_NOPREFIX
Definition: winuser.h:537
HWND WINAPI CreateWindowExA(_In_ DWORD dwExStyle, _In_opt_ LPCSTR lpClassName, _In_opt_ LPCSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
DWORD WINAPI GetTabbedTextExtentA(_In_ HDC hdc, _In_reads_(chCount) LPCSTR lpString, _In_ int chCount, _In_ int nTabPositions, _In_reads_opt_(nTabPositions) CONST INT *lpnTabStopPositions)
#define DT_EXTERNALLEADING
Definition: winuser.h:533
BOOL WINAPI CharToOemBuffA(_In_ LPCSTR lpszSrc, _Out_writes_(cchDstLength) LPSTR lpszDst, _In_ DWORD cchDstLength)
BOOL WINAPI CharToOemA(_In_ LPCSTR pSrc, _Out_writes_(_Inexpressible_(strlen(pSrc)+1)) LPSTR pDst)
BOOL WINAPI OemToCharA(_In_ LPCSTR pSrc, _Out_writes_(_Inexpressible_(strlen(pSrc)+1)) LPSTR pDst)
#define DT_SINGLELINE
Definition: winuser.h:540
#define DT_TABSTOP
Definition: winuser.h:541
BOOL WINAPI IsRectEmpty(_In_ LPCRECT)
#define DT_NOCLIP
Definition: winuser.h:536
BOOL WINAPI OemToCharW(_In_ LPCSTR pSrc, _Out_writes_(_Inexpressible_(strlen(pSrc)+1)) LPWSTR pDst)
#define DT_LEFT
Definition: winuser.h:534
BOOL WINAPI OemToCharBuffW(_In_ LPCSTR lpszSrc, _Out_writes_(cchDstLength) LPWSTR lpszDst, _In_ DWORD cchDstLength)
#define DT_TOP
Definition: winuser.h:542
#define DT_WORDBREAK
Definition: winuser.h:544
HDC WINAPI GetDC(_In_opt_ HWND)
#define DST_TEXT
Definition: winuser.h:513
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
#define DT_VCENTER
Definition: winuser.h:543
#define DT_BOTTOM
Definition: winuser.h:525
BOOL WINAPI DrawStateA(_In_ HDC, _In_opt_ HBRUSH, _In_opt_ DRAWSTATEPROC, _In_ LPARAM, _In_ WPARAM, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
int WINAPI DrawTextExA(_In_ HDC hdc, _Inout_updates_opt_(cchText) LPSTR lpchText, _In_ int cchText, _Inout_ LPRECT lprc, _In_ UINT format, _In_opt_ LPDRAWTEXTPARAMS lpdtp)
int WINAPI DrawTextExW(_In_ HDC hdc, _Inout_updates_opt_(cchText) LPWSTR lpchText, _In_ int cchText, _Inout_ LPRECT lprc, _In_ UINT format, _In_opt_ LPDRAWTEXTPARAMS lpdtp)
#define DT_EXPANDTABS
Definition: winuser.h:532
#define DT_CALCRECT
Definition: winuser.h:526
#define DT_EDITCONTROL
Definition: winuser.h:528
BOOL WINAPI DestroyWindow(_In_ HWND)
BOOL WINAPI OemToCharBuffA(_In_ LPCSTR lpszSrc, _Out_writes_(cchDstLength) LPSTR lpszDst, _In_ DWORD cchDstLength)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI CharToOemW(_In_ LPCWSTR pSrc, _Out_writes_(_Inexpressible_(strlen(pSrc)+1)) LPSTR pDst)
BOOL WINAPI CharToOemBuffW(_In_ LPCWSTR lpszSrc, _Out_writes_(cchDstLength) LPSTR lpszDst, _In_ DWORD cchDstLength)
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
char * LPSTR
Definition: xmlstorage.h:182
char CHAR
Definition: xmlstorage.h:175