Implement A->W call for GetNamedSecurityInfo.
[wine] / dlls / user / tests / text.c
1 /*
2  * DrawText tests
3  *
4  * Copyright (c) 2004 Zach Gorman
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307
19  * 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
30
31 static void test_DrawTextCalcRect(void)
32 {
33     HWND hwnd;
34     HDC hdc;
35     HFONT hFont, hOldFont;
36     LOGFONTA lf;
37     const char text[] = "Example text for testing DrawText in "
38       "MM_HIENGLISH mode";
39     INT len;
40     RECT rect = { 0, 0, 100, 0 };
41
42     /* Initialization */
43     hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP,
44                            0, 0, 200, 200, 0, 0, 0, NULL);
45     ok(hwnd != 0, "CreateWindowExA error %lu\n", GetLastError());
46     hdc = GetDC(hwnd);
47     ok(hdc != 0, "GetDC error %lu\n", GetLastError());
48     trace("hdc %p\n", hdc);
49     len = lstrlenA(text);
50
51     /* LOGFONT initialization */
52     memset(&lf, 0, sizeof(lf));
53     lf.lfCharSet = ANSI_CHARSET;
54     lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
55     lf.lfWeight = FW_DONTCARE;
56     lf.lfHeight = 0; /* mapping mode dependent */
57     lf.lfQuality = DEFAULT_QUALITY;
58     lstrcpyA(lf.lfFaceName, "Arial");
59
60     /* DrawText in MM_HIENGLISH with DT_CALCRECT */
61     SetMapMode(hdc, MM_HIENGLISH);
62     lf.lfHeight = 100 * 9 / 72; /* 9 point */
63     hFont = CreateFontIndirectA(&lf);
64     ok(hFont != 0, "CreateFontIndirectA error %lu\n",
65        GetLastError());
66     hOldFont = SelectObject(hdc, hFont);
67
68     ok(DrawTextA(hdc, text, len, &rect, DT_CALCRECT |
69        DT_EXTERNALLEADING | DT_WORDBREAK | DT_NOCLIP | DT_LEFT |
70        DT_NOPREFIX),"DrawTextA error %lu\n", GetLastError());
71
72     trace("MM_HIENGLISH rect.bottom %ld\n", rect.bottom);
73     todo_wine ok(rect.bottom < 0, "In MM_HIENGLISH, DrawText with "
74        "DT_CALCRECT should return a negative rectangle bottom. "
75        "(bot=%ld)\n", rect.bottom);
76
77     SelectObject(hdc, hOldFont);
78     ok(DeleteObject(hFont), "DeleteObject error %lu\n",
79        GetLastError());
80
81
82     /* DrawText in MM_TEXT with DT_CALCRECT */
83     SetMapMode(hdc, MM_TEXT);
84     lf.lfHeight = -MulDiv(9, GetDeviceCaps(hdc,
85        LOGPIXELSY), 72); /* 9 point */
86     hFont = CreateFontIndirectA(&lf);
87     ok(hFont != 0, "CreateFontIndirectA error %lu\n",
88        GetLastError());
89     hOldFont = SelectObject(hdc, hFont);
90
91     ok(DrawTextA(hdc, text, len, &rect, DT_CALCRECT |
92        DT_EXTERNALLEADING | DT_WORDBREAK | DT_NOCLIP | DT_LEFT |
93        DT_NOPREFIX),"DrawTextA error %lu\n", GetLastError());
94
95     trace("MM_TEXT rect.bottom %ld\n", rect.bottom);
96     ok(rect.bottom > 0, "In MM_TEXT, DrawText with DT_CALCRECT "
97        "should return a positive rectangle bottom. (bot=%ld)\n",
98        rect.bottom);
99
100     SelectObject(hdc, hOldFont);
101     ok(DeleteObject(hFont), "DeleteObject error %lu\n",
102        GetLastError());
103
104     /* Clean up */
105     ok(ReleaseDC(hwnd, hdc), "ReleaseDC error %lu\n",
106        GetLastError());
107     ok(DestroyWindow(hwnd), "DestroyWindow error %lu\n",
108        GetLastError());
109 }
110
111 START_TEST(text)
112 {
113     test_DrawTextCalcRect();
114 }