2 * Unit test suite for MLANG APIs.
4 * Copyright 2004 Dmitry Timoshkov
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.
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.
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 USA
30 #include "wine/test.h"
33 #define CP_UNICODE 1200
36 /*#define DUMP_CP_INFO*/
37 /*#define DUMP_SCRIPT_INFO*/
39 #if defined DUMP_CP_INFO || defined DUMP_SCRIPT_INFO
40 #include "wine/debug.h"
43 #define TRACE_2 OutputDebugStringA
45 static BOOL (WINAPI *pGetCPInfoExA)(UINT,DWORD,LPCPINFOEXA);
47 static void test_multibyte_to_unicode_translations(IMultiLanguage2 *iML2)
49 /* these APIs are broken regarding constness of the input buffer */
50 char stringA[] = "Just a test string\0"; /* double 0 for CP_UNICODE tests */
51 WCHAR stringW[] = {'J','u','s','t',' ','a',' ','t','e','s','t',' ','s','t','r','i','n','g',0};
54 UINT lenA, lenW, expected_len;
57 FARPROC pConvertINetMultiByteToUnicode;
58 FARPROC pConvertINetUnicodeToMultiByte;
60 hMlang = LoadLibraryA("mlang.dll");
61 ok(hMlang != 0, "couldn't load mlang.dll\n");
63 pConvertINetMultiByteToUnicode = GetProcAddress(hMlang, "ConvertINetMultiByteToUnicode");
64 ok(pConvertINetMultiByteToUnicode != NULL, "couldn't resolve ConvertINetMultiByteToUnicode\n");
65 pConvertINetUnicodeToMultiByte = GetProcAddress(hMlang, "ConvertINetUnicodeToMultiByte");
66 ok(pConvertINetUnicodeToMultiByte != NULL, "couldn't resolve ConvertINetUnicodeToMultiByte\n");
68 /* IMultiLanguage2_ConvertStringToUnicode tests */
70 memset(bufW, 'x', sizeof(bufW));
72 lenW = sizeof(bufW)/sizeof(bufW[0]);
73 TRACE_2("Call IMultiLanguage2_ConvertStringToUnicode\n");
74 ret = IMultiLanguage2_ConvertStringToUnicode(iML2, NULL, 1252, stringA, &lenA, bufW, &lenW);
75 ok(ret == S_OK, "IMultiLanguage2_ConvertStringToUnicode failed: %08lx\n", ret);
76 ok(lenA == 0, "expected lenA 0, got %u\n", lenA);
77 ok(lenW == 0, "expected lenW 0, got %u\n", lenW);
79 memset(bufW, 'x', sizeof(bufW));
81 lenW = sizeof(bufW)/sizeof(bufW[0]);
82 TRACE_2("Call IMultiLanguage2_ConvertStringToUnicode\n");
83 ret = IMultiLanguage2_ConvertStringToUnicode(iML2, NULL, 1252, stringA, &lenA, bufW, &lenW);
84 ok(ret == S_OK, "IMultiLanguage2_ConvertStringToUnicode failed: %08lx\n", ret);
85 ok(lenA == lstrlenA(stringA), "expected lenA %u, got %u\n", lstrlenA(stringA), lenA);
86 ok(lenW == lstrlenW(stringW), "expected lenW %u, got %u\n", lstrlenW(stringW), lenW);
87 ok(bufW[lenW] != 0, "buf should not be 0 terminated\n");
88 bufW[lenW] = 0; /* -1 doesn't include 0 terminator */
89 ok(!lstrcmpW(bufW, stringW), "bufW/stringW mismatch\n");
91 memset(bufW, 'x', sizeof(bufW));
94 TRACE_2("Call IMultiLanguage2_ConvertStringToUnicode\n");
95 ret = IMultiLanguage2_ConvertStringToUnicode(iML2, NULL, 1252, stringA, &lenA, bufW, &lenW);
96 ok(ret == E_FAIL, "IMultiLanguage2_ConvertStringToUnicode should fail: %08lx\n", ret);
97 ok(lenW == 0, "expected lenW 0, got %u\n", lenW);
98 /* still has to do partial conversion */
99 ok(!memcmp(bufW, stringW, 5 * sizeof(WCHAR)), "bufW/stringW mismatch\n");
101 memset(bufW, 'x', sizeof(bufW));
103 lenW = sizeof(bufW)/sizeof(bufW[0]);
104 TRACE_2("Call IMultiLanguage2_ConvertStringToUnicode\n");
105 ret = IMultiLanguage2_ConvertStringToUnicode(iML2, NULL, CP_UNICODE, stringA, &lenA, bufW, &lenW);
106 ok(ret == S_OK, "IMultiLanguage2_ConvertStringToUnicode failed: %08lx\n", ret);
107 ok(lenA == lstrlenA(stringA), "expected lenA %u, got %u\n", lstrlenA(stringA), lenA);
108 ok(lenW == lstrlenW(stringW)/(int)sizeof(WCHAR), "expected lenW %u, got %u\n", lstrlenW(stringW)/sizeof(WCHAR), lenW);
109 ok(bufW[lenW] != 0, "buf should not be 0 terminated\n");
110 bufW[lenW] = 0; /* -1 doesn't include 0 terminator */
111 ok(!lstrcmpA((LPCSTR)bufW, stringA), "bufW/stringA mismatch\n");
113 memset(bufW, 'x', sizeof(bufW));
114 lenA = lstrlenA(stringA);
116 ret = IMultiLanguage2_ConvertStringToUnicode(iML2, NULL, 1252, stringA, &lenA, NULL, &lenW);
117 ok(ret == S_OK, "IMultiLanguage2_ConvertStringToUnicode failed: %08lx\n", ret);
118 ok(lenA == lstrlenA(stringA), "expected lenA %u, got %u\n", lstrlenA(stringA), lenA);
119 expected_len = MultiByteToWideChar(1252, 0, stringA, lenA, NULL, 0);
120 ok(lenW == expected_len, "expected lenW %u, got %u\n", expected_len, lenW);
122 memset(bufW, 'x', sizeof(bufW));
123 lenA = lstrlenA(stringA);
124 lenW = sizeof(bufW)/sizeof(bufW[0]);
125 ret = pConvertINetMultiByteToUnicode(NULL, 1252, stringA, &lenA, NULL, &lenW);
126 ok(ret == S_OK, "ConvertINetMultiByteToUnicode failed: %08lx\n", ret);
127 ok(lenA == lstrlenA(stringA), "expected lenA %u, got %u\n", lstrlenA(stringA), lenA);
128 expected_len = MultiByteToWideChar(1252, 0, stringA, lenA, NULL, 0);
129 ok(lenW == expected_len, "expected lenW %u, got %u\n", expected_len, lenW);
131 memset(bufW, 'x', sizeof(bufW));
132 lenA = lstrlenA(stringA);
134 ret = pConvertINetMultiByteToUnicode(NULL, 1252, stringA, &lenA, NULL, &lenW);
135 ok(ret == S_OK, "ConvertINetMultiByteToUnicode failed: %08lx\n", ret);
136 ok(lenA == lstrlenA(stringA), "expected lenA %u, got %u\n", lstrlenA(stringA), lenA);
137 expected_len = MultiByteToWideChar(1252, 0, stringA, lenA, NULL, 0);
138 ok(lenW == expected_len, "expected lenW %u, got %u\n", expected_len, lenW);
140 /* IMultiLanguage2_ConvertStringFromUnicode tests */
142 memset(bufA, 'x', sizeof(bufA));
145 TRACE_2("Call IMultiLanguage2_ConvertStringFromUnicode\n");
146 ret = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, stringW, &lenW, bufA, &lenA);
147 ok(ret == S_OK, "IMultiLanguage2_ConvertStringFromUnicode failed: %08lx\n", ret);
148 ok(lenA == 0, "expected lenA 0, got %u\n", lenA);
149 ok(lenW == 0, "expected lenW 0, got %u\n", lenW);
151 memset(bufA, 'x', sizeof(bufA));
154 TRACE_2("Call IMultiLanguage2_ConvertStringFromUnicode\n");
155 ret = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, stringW, &lenW, bufA, &lenA);
156 ok(ret == S_OK, "IMultiLanguage2_ConvertStringFromUnicode failed: %08lx\n", ret);
157 ok(lenA == lstrlenA(stringA), "expected lenA %u, got %u\n", lstrlenA(stringA), lenA);
158 ok(lenW == lstrlenW(stringW), "expected lenW %u, got %u\n", lstrlenW(stringW), lenW);
159 ok(bufA[lenA] != 0, "buf should not be 0 terminated\n");
160 bufA[lenA] = 0; /* -1 doesn't include 0 terminator */
161 ok(!lstrcmpA(bufA, stringA), "bufA/stringA mismatch\n");
163 memset(bufA, 'x', sizeof(bufA));
166 TRACE_2("Call IMultiLanguage2_ConvertStringFromUnicode\n");
167 ret = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, stringW, &lenW, bufA, &lenA);
168 ok(ret == E_FAIL, "IMultiLanguage2_ConvertStringFromUnicode should fail: %08lx\n", ret);
169 ok(lenA == 0, "expected lenA 0, got %u\n", lenA);
170 /* still has to do partial conversion */
171 ok(!memcmp(bufA, stringA, 5), "bufW/stringW mismatch\n");
173 memset(bufA, 'x', sizeof(bufA));
176 TRACE_2("Call IMultiLanguage2_ConvertStringFromUnicode\n");
177 ret = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, CP_UNICODE, stringW, &lenW, bufA, &lenA);
178 ok(ret == S_OK, "IMultiLanguage2_ConvertStringFromUnicode failed: %08lx\n", ret);
179 ok(lenA == lstrlenA(stringA) * (int)sizeof(WCHAR), "expected lenA %u, got %u\n", lstrlenA(stringA) * sizeof(WCHAR), lenA);
180 ok(lenW == lstrlenW(stringW), "expected lenW %u, got %u\n", lstrlenW(stringW), lenW);
181 ok(bufA[lenA] != 0 && bufA[lenA+1] != 0, "buf should not be 0 terminated\n");
182 bufA[lenA] = 0; /* -1 doesn't include 0 terminator */
183 bufA[lenA+1] = 0; /* sizeof(WCHAR) */
184 ok(!lstrcmpW((LPCWSTR)bufA, stringW), "bufA/stringW mismatch\n");
186 memset(bufA, 'x', sizeof(bufA));
187 lenW = lstrlenW(stringW);
189 ret = IMultiLanguage2_ConvertStringFromUnicode(iML2, NULL, 1252, stringW, &lenW, NULL, &lenA);
190 ok(ret == S_OK, "IMultiLanguage2_ConvertStringFromUnicode failed: %08lx\n", ret);
191 ok(lenW == lstrlenW(stringW), "expected lenW %u, got %u\n", lstrlenW(stringW), lenW);
192 expected_len = WideCharToMultiByte(1252, 0, stringW, lenW, NULL, 0, NULL, NULL);
193 ok(lenA == expected_len, "expected lenA %u, got %u\n", expected_len, lenA);
195 memset(bufA, 'x', sizeof(bufA));
196 lenW = lstrlenW(stringW);
198 ret = pConvertINetUnicodeToMultiByte(NULL, 1252, stringW, &lenW, NULL, &lenA);
199 ok(ret == S_OK, "ConvertINetUnicodeToMultiByte failed: %08lx\n", ret);
200 ok(lenW == lstrlenW(stringW), "expected lenW %u, got %u\n", lstrlenW(stringW), lenW);
201 expected_len = WideCharToMultiByte(1252, 0, stringW, lenW, NULL, 0, NULL, NULL);
202 ok(lenA == expected_len, "expected lenA %u, got %u\n", expected_len, lenA);
204 memset(bufA, 'x', sizeof(bufA));
205 lenW = lstrlenW(stringW);
207 ret = pConvertINetUnicodeToMultiByte(NULL, 1252, stringW, &lenW, NULL, &lenA);
208 ok(ret == S_OK, "ConvertINetUnicodeToMultiByte failed: %08lx\n", ret);
209 ok(lenW == lstrlenW(stringW), "expected lenW %u, got %u\n", lstrlenW(stringW), lenW);
210 expected_len = WideCharToMultiByte(1252, 0, stringW, lenW, NULL, 0, NULL, NULL);
211 ok(lenA == expected_len, "expected lenA %u, got %u\n", expected_len, lenA);
214 static void inline cpinfo_cmp(MIMECPINFO *cpinfo1, MIMECPINFO *cpinfo2)
216 ok(cpinfo1->dwFlags == cpinfo2->dwFlags, "dwFlags mismatch: %08lx != %08lx\n", cpinfo1->dwFlags, cpinfo2->dwFlags);
217 ok(cpinfo1->uiCodePage == cpinfo2->uiCodePage, "uiCodePage mismatch: %u != %u\n", cpinfo1->uiCodePage, cpinfo2->uiCodePage);
218 ok(cpinfo1->uiFamilyCodePage == cpinfo2->uiFamilyCodePage, "uiFamilyCodePage mismatch: %u != %u\n", cpinfo1->uiFamilyCodePage, cpinfo2->uiFamilyCodePage);
219 ok(!lstrcmpW(cpinfo1->wszDescription, cpinfo2->wszDescription), "wszDescription mismatch\n");
220 ok(!lstrcmpW(cpinfo1->wszWebCharset, cpinfo2->wszWebCharset), "wszWebCharset mismatch\n");
221 ok(!lstrcmpW(cpinfo1->wszHeaderCharset, cpinfo2->wszHeaderCharset), "wszHeaderCharset mismatch\n");
222 ok(!lstrcmpW(cpinfo1->wszBodyCharset, cpinfo2->wszBodyCharset), "wszBodyCharset mismatch\n");
223 ok(!lstrcmpW(cpinfo1->wszFixedWidthFont, cpinfo2->wszFixedWidthFont), "wszFixedWidthFont mismatch\n");
224 ok(!lstrcmpW(cpinfo1->wszProportionalFont, cpinfo2->wszProportionalFont), "wszProportionalFont mismatch\n");
225 ok(cpinfo1->bGDICharset == cpinfo2->bGDICharset, "bGDICharset mismatch: %d != %d\n", cpinfo1->bGDICharset, cpinfo2->bGDICharset);
229 static const char *dump_mime_flags(DWORD flags)
231 static char buf[1024];
235 if (flags & MIMECONTF_MAILNEWS) strcat(buf, " MIMECONTF_MAILNEWS");
236 if (flags & MIMECONTF_BROWSER) strcat(buf, " MIMECONTF_BROWSER");
237 if (flags & MIMECONTF_MINIMAL) strcat(buf, " MIMECONTF_MINIMAL");
238 if (flags & MIMECONTF_IMPORT) strcat(buf, " MIMECONTF_IMPORT");
239 if (flags & MIMECONTF_SAVABLE_MAILNEWS) strcat(buf, " MIMECONTF_SAVABLE_MAILNEWS");
240 if (flags & MIMECONTF_SAVABLE_BROWSER) strcat(buf, " MIMECONTF_SAVABLE_BROWSER");
241 if (flags & MIMECONTF_EXPORT) strcat(buf, " MIMECONTF_EXPORT");
242 if (flags & MIMECONTF_PRIVCONVERTER) strcat(buf, " MIMECONTF_PRIVCONVERTER");
243 if (flags & MIMECONTF_VALID) strcat(buf, " MIMECONTF_VALID");
244 if (flags & MIMECONTF_VALID_NLS) strcat(buf, " MIMECONTF_VALID_NLS");
245 if (flags & MIMECONTF_MIME_IE4) strcat(buf, " MIMECONTF_MIME_IE4");
246 if (flags & MIMECONTF_MIME_LATEST) strcat(buf, " MIMECONTF_MIME_LATEST");
247 if (flags & MIMECONTF_MIME_REGISTRY) strcat(buf, " MIMECONTF_MIME_REGISTRY");
253 static void test_EnumCodePages(IMultiLanguage2 *iML2, DWORD flags)
255 IEnumCodePage *iEnumCP = NULL;
263 TRACE_2("Call IMultiLanguage2_GetNumberOfCodePageInfo\n");
264 ret = IMultiLanguage2_GetNumberOfCodePageInfo(iML2, &total);
265 ok(ret == S_OK && total != 0, "IMultiLanguage2_GetNumberOfCodePageInfo: expected S_OK/!0, got %08lx/%u\n", ret, total);
267 trace("total mlang supported codepages %u\n", total);
269 TRACE_2("Call IMultiLanguage2_EnumCodePages\n");
270 ret = IMultiLanguage2_EnumCodePages(iML2, flags, LANG_NEUTRAL, &iEnumCP);
271 trace("IMultiLanguage2_EnumCodePages = %08lx, iEnumCP = %p\n", ret, iEnumCP);
272 ok(ret == S_OK && iEnumCP, "IMultiLanguage2_EnumCodePages: expected S_OK/!NULL, got %08lx/%p\n", ret, iEnumCP);
274 TRACE_2("Call IEnumCodePage_Reset\n");
275 ret = IEnumCodePage_Reset(iEnumCP);
276 ok(ret == S_OK, "IEnumCodePage_Reset: expected S_OK, got %08lx\n", ret);
278 TRACE_2("Call IEnumCodePage_Next\n");
279 ret = IEnumCodePage_Next(iEnumCP, 0, NULL, &n);
280 ok(n == 0 && ret == S_FALSE, "IEnumCodePage_Next: expected 0/S_FALSE, got %lu/%08lx\n", n, ret);
281 TRACE_2("Call IEnumCodePage_Next\n");
282 ret = IEnumCodePage_Next(iEnumCP, 0, NULL, NULL);
283 ok(ret == S_FALSE, "IEnumCodePage_Next: expected S_FALSE, got %08lx\n", ret);
285 cpinfo = HeapAlloc(GetProcessHeap(), 0, sizeof(*cpinfo) * total * 2);
288 TRACE_2("Call IEnumCodePage_Next\n");
289 ret = IEnumCodePage_Next(iEnumCP, 0, cpinfo, &n);
290 trace("IEnumCodePage_Next = %08lx, n = %lu\n", ret, n);
291 ok(ret == S_FALSE && n == 0, "IEnumCodePage_Next: expected S_FALSE/0, got %08lx/%lu\n", ret, n);
294 TRACE_2("Call IEnumCodePage_Next\n");
295 ret = IEnumCodePage_Next(iEnumCP, n, cpinfo, &n);
296 ok(ret == S_OK && n != 0, "IEnumCodePage_Next: expected S_OK/!0, got %08lx/%lu\n", ret, n);
298 trace("flags %08lx, enumerated codepages %lu\n", flags, n);
302 ok(n == total, "IEnumCodePage_Next: expected %u, got %lu\n", total, n);
304 flags = MIMECONTF_MIME_LATEST;
309 for (i = 0; i < n; i++)
314 static const WCHAR autoW[] = {'_','a','u','t','o',0};
317 trace("MIMECPINFO #%lu:\n"
320 "uiFamilyCodePage %u\n"
321 "wszDescription %s\n"
323 "wszHeaderCharset %s\n"
324 "wszBodyCharset %s\n"
325 "wszFixedWidthFont %s\n"
326 "wszProportionalFont %s\n"
327 "bGDICharset %d\n\n",
329 cpinfo[i].dwFlags, dump_mime_flags(cpinfo[i].dwFlags),
330 cpinfo[i].uiCodePage,
331 cpinfo[i].uiFamilyCodePage,
332 wine_dbgstr_w(cpinfo[i].wszDescription),
333 wine_dbgstr_w(cpinfo[i].wszWebCharset),
334 wine_dbgstr_w(cpinfo[i].wszHeaderCharset),
335 wine_dbgstr_w(cpinfo[i].wszBodyCharset),
336 wine_dbgstr_w(cpinfo[i].wszFixedWidthFont),
337 wine_dbgstr_w(cpinfo[i].wszProportionalFont),
338 cpinfo[i].bGDICharset);
340 ok(cpinfo[i].dwFlags & flags, "enumerated flags %08lx do not include requested %08lx\n", cpinfo[i].dwFlags, flags);
342 if (TranslateCharsetInfo((DWORD *)cpinfo[i].uiFamilyCodePage, &csi, TCI_SRCCODEPAGE))
343 ok(cpinfo[i].bGDICharset == csi.ciCharset, "%d != %d\n", cpinfo[i].bGDICharset, csi.ciCharset);
345 trace("TranslateCharsetInfo failed for cp %u\n", cpinfo[i].uiFamilyCodePage);
349 if (pGetCPInfoExA(cpinfo[i].uiCodePage, 0, &cpinfoex))
350 trace("CodePage %u name: %s\n", cpinfo[i].uiCodePage, cpinfoex.CodePageName);
352 trace("GetCPInfoExA failed for cp %u\n", cpinfo[i].uiCodePage);
353 if (pGetCPInfoExA(cpinfo[i].uiFamilyCodePage, 0, &cpinfoex))
354 trace("CodePage %u name: %s\n", cpinfo[i].uiFamilyCodePage, cpinfoex.CodePageName);
356 trace("GetCPInfoExA failed for cp %u\n", cpinfo[i].uiFamilyCodePage);
359 /* Win95 does not support UTF-7 */
360 if (cpinfo[i].uiCodePage == CP_UTF7) continue;
362 /* support files for some codepages might be not installed, or
363 * the codepage is just an alias.
365 if (IsValidCodePage(cpinfo[i].uiCodePage))
367 TRACE_2("Call IMultiLanguage2_IsConvertible\n");
368 ret = IMultiLanguage2_IsConvertible(iML2, cpinfo[i].uiCodePage, CP_UNICODE);
369 ok(ret == S_OK, "IMultiLanguage2_IsConvertible(%u -> CP_UNICODE) = %08lx\n", cpinfo[i].uiCodePage, ret);
370 TRACE_2("Call IMultiLanguage2_IsConvertible\n");
371 ret = IMultiLanguage2_IsConvertible(iML2, CP_UNICODE, cpinfo[i].uiCodePage);
372 ok(ret == S_OK, "IMultiLanguage2_IsConvertible(CP_UNICODE -> %u) = %08lx\n", cpinfo[i].uiCodePage, ret);
374 TRACE_2("Call IMultiLanguage2_IsConvertible\n");
375 ret = IMultiLanguage2_IsConvertible(iML2, cpinfo[i].uiCodePage, CP_UTF8);
376 ok(ret == S_OK, "IMultiLanguage2_IsConvertible(%u -> CP_UTF8) = %08lx\n", cpinfo[i].uiCodePage, ret);
377 TRACE_2("Call IMultiLanguage2_IsConvertible\n");
378 ret = IMultiLanguage2_IsConvertible(iML2, CP_UTF8, cpinfo[i].uiCodePage);
379 ok(ret == S_OK, "IMultiLanguage2_IsConvertible(CP_UTF8 -> %u) = %08lx\n", cpinfo[i].uiCodePage, ret);
382 trace("IsValidCodePage failed for cp %u\n", cpinfo[i].uiCodePage);
384 ret = IMultiLanguage2_GetCharsetInfo(iML2, cpinfo[i].wszWebCharset, &mcsi);
385 /* _autoxxx charsets are a fake and GetCharsetInfo fails for them */
386 if (memcmp(cpinfo[i].wszWebCharset, autoW, 5 * sizeof(WCHAR)))
388 ok (ret == S_OK, "IMultiLanguage2_GetCharsetInfo failed: %08lx\n", ret);
390 trace("%s: %u %u %s\n", wine_dbgstr_w(cpinfo[i].wszWebCharset), mcsi.uiCodePage, mcsi.uiInternetEncoding, wine_dbgstr_w(mcsi.wszCharset));
392 ok(!lstrcmpiW(cpinfo[i].wszWebCharset, mcsi.wszCharset),
395 wine_dbgstr_w(cpinfo[i].wszWebCharset), wine_dbgstr_w(mcsi.wszCharset));
397 "wszWebCharset mismatch");
400 #if 0 /* native mlang returns completely messed up encodings in some cases */
401 ok(mcsi.uiInternetEncoding == cpinfo[i].uiCodePage || mcsi.uiInternetEncoding == cpinfo[i].uiFamilyCodePage,
402 "%u != %u || %u\n", mcsi.uiInternetEncoding, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage);
403 ok(mcsi.uiCodePage == cpinfo[i].uiCodePage || mcsi.uiCodePage == cpinfo[i].uiFamilyCodePage,
404 "%u != %u || %u\n", mcsi.uiCodePage, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage);
408 ret = IMultiLanguage2_GetCharsetInfo(iML2, cpinfo[i].wszHeaderCharset, &mcsi);
409 /* _autoxxx charsets are a fake and GetCharsetInfo fails for them */
410 if (memcmp(cpinfo[i].wszHeaderCharset, autoW, 5 * sizeof(WCHAR)))
412 ok (ret == S_OK, "IMultiLanguage2_GetCharsetInfo failed: %08lx\n", ret);
414 trace("%s: %u %u %s\n", wine_dbgstr_w(cpinfo[i].wszHeaderCharset), mcsi.uiCodePage, mcsi.uiInternetEncoding, wine_dbgstr_w(mcsi.wszCharset));
416 ok(!lstrcmpiW(cpinfo[i].wszHeaderCharset, mcsi.wszCharset),
419 wine_dbgstr_w(cpinfo[i].wszHeaderCharset), wine_dbgstr_w(mcsi.wszCharset));
421 "wszHeaderCharset mismatch");
424 #if 0 /* native mlang returns completely messed up encodings in some cases */
425 ok(mcsi.uiInternetEncoding == cpinfo[i].uiCodePage || mcsi.uiInternetEncoding == cpinfo[i].uiFamilyCodePage,
426 "%u != %u || %u\n", mcsi.uiInternetEncoding, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage);
427 ok(mcsi.uiCodePage == cpinfo[i].uiCodePage || mcsi.uiCodePage == cpinfo[i].uiFamilyCodePage,
428 "%u != %u || %u\n", mcsi.uiCodePage, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage);
432 ret = IMultiLanguage2_GetCharsetInfo(iML2, cpinfo[i].wszBodyCharset, &mcsi);
433 /* _autoxxx charsets are a fake and GetCharsetInfo fails for them */
434 if (memcmp(cpinfo[i].wszBodyCharset, autoW, 5 * sizeof(WCHAR)))
436 ok (ret == S_OK, "IMultiLanguage2_GetCharsetInfo failed: %08lx\n", ret);
438 trace("%s: %u %u %s\n", wine_dbgstr_w(cpinfo[i].wszBodyCharset), mcsi.uiCodePage, mcsi.uiInternetEncoding, wine_dbgstr_w(mcsi.wszCharset));
440 ok(!lstrcmpiW(cpinfo[i].wszBodyCharset, mcsi.wszCharset),
443 wine_dbgstr_w(cpinfo[i].wszBodyCharset), wine_dbgstr_w(mcsi.wszCharset));
445 "wszBodyCharset mismatch");
448 #if 0 /* native mlang returns completely messed up encodings in some cases */
449 ok(mcsi.uiInternetEncoding == cpinfo[i].uiCodePage || mcsi.uiInternetEncoding == cpinfo[i].uiFamilyCodePage,
450 "%u != %u || %u\n", mcsi.uiInternetEncoding, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage);
451 ok(mcsi.uiCodePage == cpinfo[i].uiCodePage || mcsi.uiCodePage == cpinfo[i].uiFamilyCodePage,
452 "%u != %u || %u\n", mcsi.uiCodePage, cpinfo[i].uiCodePage, cpinfo[i].uiFamilyCodePage);
459 /* now IEnumCodePage_Next should fail, since pointer is at the end */
461 ret = IEnumCodePage_Next(iEnumCP, 1, &cpinfo2, &n);
462 ok(ret == S_FALSE && n == 0, "IEnumCodePage_Next: expected S_FALSE/0, got %08lx/%lu\n", ret, n);
464 ret = IEnumCodePage_Reset(iEnumCP);
465 ok(ret == S_OK, "IEnumCodePage_Reset: expected S_OK, got %08lx\n", ret);
467 ret = IEnumCodePage_Next(iEnumCP, 1, &cpinfo2, &n);
468 ok(n == 1 && ret == S_OK, "IEnumCodePage_Next: expected 1/S_OK, got %lu/%08lx\n", n, ret);
469 cpinfo_cmp(&cpinfo[0], &cpinfo2);
472 /* Due to a bug in MS' implementation of IEnumCodePage_Skip
473 * it's not used here.
475 ret = IEnumCodePage_Skip(iEnumCP, 1);
476 ok(ret == S_OK, "IEnumCodePage_Skip: expected S_OK, got %08lx\n", ret);
478 for (i = 0; i < total - 1; i++)
481 ret = IEnumCodePage_Next(iEnumCP, 1, &cpinfo2, &n);
482 ok(n == 1 && ret == S_OK, "IEnumCodePage_Next: expected 1/S_OK, got %lu/%08lx\n", n, ret);
483 cpinfo_cmp(&cpinfo[i + 1], &cpinfo2);
486 HeapFree(GetProcessHeap(), 0, cpinfo);
487 IEnumCodePage_Release(iEnumCP);
490 static void inline scriptinfo_cmp(SCRIPTINFO *sinfo1, SCRIPTINFO *sinfo2)
492 ok(sinfo1->ScriptId == sinfo2->ScriptId, "ScriptId mismatch: %d != %d\n", sinfo1->ScriptId, sinfo2->ScriptId);
493 ok(sinfo1->uiCodePage == sinfo2->uiCodePage, "uiCodePage mismatch: %u != %u\n", sinfo1->uiCodePage, sinfo2->uiCodePage);
494 ok(!lstrcmpW(sinfo1->wszDescription, sinfo2->wszDescription), "wszDescription mismatch\n");
495 ok(!lstrcmpW(sinfo1->wszFixedWidthFont, sinfo2->wszFixedWidthFont), "wszFixedWidthFont mismatch\n");
496 ok(!lstrcmpW(sinfo1->wszProportionalFont, sinfo2->wszProportionalFont), "wszProportionalFont mismatch\n");
499 static void test_EnumScripts(IMultiLanguage2 *iML2, DWORD flags)
501 IEnumScript *iEnumScript = NULL;
509 TRACE_2("Call IMultiLanguage2_GetNumberOfScripts\n");
510 ret = IMultiLanguage2_GetNumberOfScripts(iML2, &total);
511 ok(ret == S_OK && total != 0, "IMultiLanguage2_GetNumberOfScripts: expected S_OK/!0, got %08lx/%u\n", ret, total);
513 trace("total mlang supported scripts %u\n", total);
515 TRACE_2("Call IMultiLanguage2_EnumScripts\n");
516 ret = IMultiLanguage2_EnumScripts(iML2, flags, LANG_NEUTRAL, &iEnumScript);
517 trace("IMultiLanguage2_EnumScripts = %08lx, iEnumScript = %p\n", ret, iEnumScript);
518 ok(ret == S_OK && iEnumScript, "IMultiLanguage2_EnumScripts: expected S_OK/!NULL, got %08lx/%p\n", ret, iEnumScript);
520 TRACE_2("Call IEnumScript_Reset\n");
521 ret = IEnumScript_Reset(iEnumScript);
522 ok(ret == S_OK, "IEnumScript_Reset: expected S_OK, got %08lx\n", ret);
524 TRACE_2("Call IEnumScript_Next\n");
525 ret = IEnumScript_Next(iEnumScript, 0, NULL, &n);
526 ok(n == 65536 && ret == E_FAIL, "IEnumScript_Next: expected 65536/E_FAIL, got %lu/%08lx\n", n, ret);
527 TRACE_2("Call IEnumScript_Next\n");
528 ret = IEnumScript_Next(iEnumScript, 0, NULL, NULL);
529 ok(ret == E_FAIL, "IEnumScript_Next: expected E_FAIL, got %08lx\n", ret);
531 sinfo = HeapAlloc(GetProcessHeap(), 0, sizeof(*sinfo) * total * 2);
534 TRACE_2("Call IEnumScript_Next\n");
535 ret = IEnumScript_Next(iEnumScript, 0, sinfo, &n);
536 ok(ret == S_FALSE && n == 0, "IEnumScript_Next: expected S_FALSE/0, got %08lx/%lu\n", ret, n);
539 TRACE_2("Call IEnumScript_Next\n");
540 ret = IEnumScript_Next(iEnumScript, n, sinfo, &n);
541 ok(ret == S_OK && n != 0, "IEnumScript_Next: expected S_OK, got %08lx/%lu\n", ret, n);
543 trace("flags %08lx, enumerated scripts %lu\n", flags, n);
547 ok(n == total, "IEnumScript_Next: expected %u, got %lu\n", total, n);
548 flags = SCRIPTCONTF_SCRIPT_USER | SCRIPTCONTF_SCRIPT_HIDE | SCRIPTCONTF_SCRIPT_SYSTEM;
553 for (i = 0; pGetCPInfoExA && i < n; i++)
556 #ifdef DUMP_SCRIPT_INFO
557 trace("SCRIPTINFO #%lu:\n"
560 "wszDescription %s\n"
561 "wszFixedWidthFont %s\n"
562 "wszProportionalFont %s\n\n",
566 wine_dbgstr_w(sinfo[i].wszDescription),
567 wine_dbgstr_w(sinfo[i].wszFixedWidthFont),
568 wine_dbgstr_w(sinfo[i].wszProportionalFont));
570 if (pGetCPInfoExA(sinfo[i].uiCodePage, 0, &cpinfoex))
571 trace("CodePage %u name: %s\n", sinfo[i].uiCodePage, cpinfoex.CodePageName);
573 trace("GetCPInfoExA failed for cp %u\n", sinfo[i].uiCodePage);
578 /* now IEnumScript_Next should fail, since pointer is at the end */
580 ret = IEnumScript_Next(iEnumScript, 1, &sinfo2, &n);
581 ok(ret == S_FALSE && n == 0, "IEnumScript_Next: expected S_FALSE/0, got %08lx/%lu\n", ret, n);
583 ret = IEnumScript_Reset(iEnumScript);
584 ok(ret == S_OK, "IEnumScript_Reset: expected S_OK, got %08lx\n", ret);
586 ret = IEnumScript_Next(iEnumScript, 1, &sinfo2, &n);
587 ok(n == 1 && ret == S_OK, "IEnumScript_Next: expected 1/S_OK, got %lu/%08lx\n", n, ret);
588 scriptinfo_cmp(&sinfo[0], &sinfo2);
591 /* Due to a bug in MS' implementation of IEnumScript_Skip
592 * it's not used here.
594 ret = IEnumScript_Skip(iEnumScript, 1);
595 ok(ret == S_OK, "IEnumScript_Skip: expected S_OK, got %08lx\n", ret);
597 for (i = 0; i < total - 1; i++)
600 ret = IEnumScript_Next(iEnumScript, 1, &sinfo2, &n);
601 ok(n == 1 && ret == S_OK, "IEnumScript_Next: expected 1/S_OK, got %lu/%08lx\n", n, ret);
602 scriptinfo_cmp(&sinfo[i + 1], &sinfo2);
605 HeapFree(GetProcessHeap(), 0, sinfo);
606 IEnumScript_Release(iEnumScript);
609 static void IMLangFontLink_Test(IMLangFontLink* iMLFL)
611 DWORD dwCodePages = 0;
612 DWORD dwManyCodePages = 0;
615 ok(IMLangFontLink_CodePageToCodePages(iMLFL, 932, &dwCodePages)==S_OK,
616 "IMLangFontLink_CodePageToCodePages failed\n");
617 ok (dwCodePages != 0, "No CodePages returned\n");
618 ok(IMLangFontLink_CodePagesToCodePage(iMLFL, dwCodePages, 1035,
620 "IMLangFontLink_CodePagesToCodePage failed\n");
621 ok(CodePage == 932, "Incorrect CodePage Returned (%i)\n",CodePage);
623 ok(IMLangFontLink_CodePageToCodePages(iMLFL, 1252, &dwCodePages)==S_OK,
624 "IMLangFontLink_CodePageToCodePages failed\n");
625 dwManyCodePages = dwManyCodePages | dwCodePages;
626 ok(IMLangFontLink_CodePageToCodePages(iMLFL, 1256, &dwCodePages)==S_OK,
627 "IMLangFontLink_CodePageToCodePages failed\n");
628 dwManyCodePages = dwManyCodePages | dwCodePages;
629 ok(IMLangFontLink_CodePageToCodePages(iMLFL, 874, &dwCodePages)==S_OK,
630 "IMLangFontLink_CodePageToCodePages failed\n");
631 dwManyCodePages = dwManyCodePages | dwCodePages;
633 ok(IMLangFontLink_CodePagesToCodePage(iMLFL, dwManyCodePages, 1256,
635 "IMLangFontLink_CodePagesToCodePage failed\n");
636 ok(CodePage == 1256, "Incorrect CodePage Returned (%i)\n",CodePage);
638 ok(IMLangFontLink_CodePagesToCodePage(iMLFL, dwManyCodePages, 936,
640 "IMLangFontLink_CodePagesToCodePage failed\n");
641 ok(CodePage == 1252, "Incorrect CodePage Returned (%i)\n",CodePage);
644 static void test_rfc1766(IMultiLanguage2 *iML2)
646 IEnumRfc1766 *pEnumRfc1766;
651 ret = IMultiLanguage2_EnumRfc1766(iML2, LANG_NEUTRAL, &pEnumRfc1766);
652 ok(ret == S_OK, "IMultiLanguage2_EnumRfc1766 error %08lx\n", ret);
656 ret = IEnumRfc1766_Next(pEnumRfc1766, 1, &info, &n);
657 if (ret != S_OK) break;
660 trace("lcid %04lx rfc_name %s locale_name %s\n",
661 info.lcid, wine_dbgstr_w(info.wszRfc1766), wine_dbgstr_w(info.wszLocaleName));
664 ok(n == 1, "couldn't fetch 1 RFC1766INFO structure\n");
665 ok(IsValidLocale(info.lcid, LCID_SUPPORTED), "invalid lcid %04lx\n", info.lcid);
671 IMultiLanguage2 *iML2 = NULL;
672 IMLangFontLink *iMLFL = NULL;
675 pGetCPInfoExA = (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetCPInfoExA");
678 TRACE_2("Call CoCreateInstance\n");
679 ret = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
680 &IID_IMultiLanguage2, (void **)&iML2);
682 trace("ret = %08lx, MultiLanguage2 iML2 = %p\n", ret, iML2);
683 if (ret != S_OK || !iML2) return;
687 test_EnumCodePages(iML2, 0);
688 test_EnumCodePages(iML2, MIMECONTF_MIME_LATEST);
689 test_EnumCodePages(iML2, MIMECONTF_BROWSER);
690 test_EnumCodePages(iML2, MIMECONTF_MINIMAL);
691 test_EnumCodePages(iML2, MIMECONTF_VALID);
692 /* FIXME: why MIMECONTF_MIME_REGISTRY returns 0 of supported codepages? */
693 /*test_EnumCodePages(iML2, MIMECONTF_MIME_REGISTRY);*/
695 test_EnumScripts(iML2, 0);
696 test_EnumScripts(iML2, SCRIPTCONTF_SCRIPT_USER);
697 test_EnumScripts(iML2, SCRIPTCONTF_SCRIPT_USER | SCRIPTCONTF_SCRIPT_HIDE | SCRIPTCONTF_SCRIPT_SYSTEM);
699 TRACE_2("Call IMultiLanguage2_IsConvertible\n");
700 ret = IMultiLanguage2_IsConvertible(iML2, CP_UTF8, CP_UNICODE);
701 ok(ret == S_OK, "IMultiLanguage2_IsConvertible(CP_UTF8 -> CP_UNICODE) = %08lx\n", ret);
702 TRACE_2("Call IMultiLanguage2_IsConvertible\n");
703 ret = IMultiLanguage2_IsConvertible(iML2, CP_UNICODE, CP_UTF8);
704 ok(ret == S_OK, "IMultiLanguage2_IsConvertible(CP_UNICODE -> CP_UTF8) = %08lx\n", ret);
706 test_multibyte_to_unicode_translations(iML2);
708 IMultiLanguage2_Release(iML2);
710 ret = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
711 &IID_IMLangFontLink, (void **)&iMLFL);
713 trace("ret = %08lx, IMLangFontLink iMLFL = %p\n", ret, iMLFL);
714 if (ret != S_OK || !iML2) return;
716 IMLangFontLink_Test(iMLFL);
717 IMLangFontLink_Release(iMLFL);