oleaut32: Convert file URLs to DOS paths for special handling in OleLoadPicturePath.
[wine] / dlls / oleaut32 / tests / olefont.c
1 /*
2  * OLEFONT test program
3  *
4  * Copyright 2003 Marcus Meissner
5  * Copyright 2006 (Google) Benjamin Arai
6  *
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  */
22
23 #include <stdarg.h>
24 #include <stdio.h>
25 #include <math.h>
26 #include <float.h>
27
28 #define COBJMACROS
29
30 #include <wine/test.h>
31 #include <windef.h>
32 #include <winbase.h>
33 #include <winuser.h>
34 #include <wingdi.h>
35 #include <winnls.h>
36 #include <winerror.h>
37 #include <winnt.h>
38 #include <initguid.h>
39 #include <wtypes.h>
40 #include <olectl.h>
41 #include <ocidl.h>
42
43 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
44
45 static WCHAR MSSansSerif_font[] = {'M','S',' ','S','a','n','s',' ','S','e','r','i','f',0};
46 static WCHAR system_font[] = { 'S','y','s','t','e','m',0 };
47 static WCHAR arial_font[] = { 'A','r','i','a','l',0 };
48 static WCHAR marlett_font[] = { 'M','a','r','l','e','t','t',0 };
49
50 static HMODULE hOleaut32;
51
52 static HRESULT (WINAPI *pOleCreateFontIndirect)(LPFONTDESC,REFIID,LPVOID*);
53
54 #define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08x\n", hr)
55
56 /* Create a font with cySize given by lo_size, hi_size,  */
57 /* SetRatio to ratio_logical, ratio_himetric,            */
58 /* check that resulting hfont has height hfont_height.   */
59 /* Various checks along the way.                         */
60
61 static void test_ifont_sizes(LONG lo_size, LONG hi_size,
62         LONG ratio_logical, LONG ratio_himetric,
63         LONG hfont_height, const char * test_name)
64 {
65         FONTDESC fd;
66         LPVOID pvObj = NULL;
67         IFont* ifnt = NULL;
68         HFONT hfont;
69         LOGFONT lf;
70         CY psize;
71         HRESULT hres;
72
73         fd.cbSizeofstruct = sizeof(FONTDESC);
74         fd.lpstrName      = system_font;
75         S(fd.cySize).Lo   = lo_size;
76         S(fd.cySize).Hi   = hi_size;
77         fd.sWeight        = 0;
78         fd.sCharset       = 0;
79         fd.fItalic        = 0;
80         fd.fUnderline     = 0;
81         fd.fStrikethrough = 0;
82
83         /* Create font, test that it worked. */
84         hres = pOleCreateFontIndirect(&fd, &IID_IFont, &pvObj);
85         ifnt = pvObj;
86         ok(hres == S_OK,"%s: OCFI returns 0x%08x instead of S_OK.\n",
87                 test_name, hres);
88         ok(pvObj != NULL,"%s: OCFI returns NULL.\n", test_name);
89
90         /* Read back size.  Hi part was ignored. */
91         hres = IFont_get_Size(ifnt, &psize);
92         ok(hres == S_OK,"%s: IFont_get_size returns 0x%08x instead of S_OK.\n",
93                 test_name, hres);
94         ok(S(psize).Lo == lo_size && S(psize).Hi == 0,
95                 "%s: get_Size: Lo=%d, Hi=%d; expected Lo=%d, Hi=0.\n",
96                 test_name, S(psize).Lo, S(psize).Hi, lo_size);
97
98         /* Change ratio, check size unchanged.  Standard is 72, 2540. */
99         hres = IFont_SetRatio(ifnt, ratio_logical, ratio_himetric);
100         ok(hres == S_OK,"%s: IFont_SR returns 0x%08x instead of S_OK.\n",
101                 test_name, hres);
102         hres = IFont_get_Size(ifnt, &psize);
103         ok(hres == S_OK,"%s: IFont_get_size returns 0x%08x instead of S_OK.\n",
104                 test_name, hres);
105         ok(S(psize).Lo == lo_size && S(psize).Hi == 0,
106                 "%s: gS after SR: Lo=%d, Hi=%d; expected Lo=%d, Hi=0.\n",
107                 test_name, S(psize).Lo, S(psize).Hi, lo_size);
108
109         /* Check hFont size with this ratio.  This tests an important   */
110         /* conversion for which MSDN is very wrong.                     */
111         hres = IFont_get_hFont (ifnt, &hfont);
112         ok(hres == S_OK, "%s: IFont_get_hFont returns 0x%08x instead of S_OK.\n",
113                 test_name, hres);
114         hres = GetObject (hfont, sizeof(LOGFONT), &lf);
115         ok(lf.lfHeight == hfont_height,
116                 "%s: hFont has lf.lfHeight=%d, expected %d.\n",
117                 test_name, lf.lfHeight, hfont_height);
118
119         /* Free IFont. */
120         IFont_Release(ifnt);
121 }
122
123 static void test_QueryInterface(void)
124 {
125         LPVOID pvObj = NULL;
126         HRESULT hres;
127         IFont*  font = NULL;
128         LONG ret;
129
130         hres = pOleCreateFontIndirect(NULL, &IID_IFont, &pvObj);
131         font = pvObj;
132
133         ok(hres == S_OK,"OCFI (NULL,..) does not return 0, but 0x%08x\n",hres);
134         ok(font != NULL,"OCFI (NULL,..) returns NULL, instead of !NULL\n");
135
136         pvObj = NULL;
137         hres = IFont_QueryInterface( font, &IID_IFont, &pvObj);
138
139         /* Test if QueryInterface increments ref counter for IFONTs */
140         ret = IFont_AddRef(font);
141         ok(ret == 3 ||
142            broken(ret == 1), /* win95 */
143            "IFont_QI expected ref value 3 but instead got %d\n",ret);
144         IFont_Release(font);
145
146         ok(hres == S_OK,"IFont_QI does not return S_OK, but 0x%08x\n", hres);
147         ok(pvObj != NULL,"IFont_QI does return NULL, instead of a ptr\n");
148
149         /* Original ref and QueryInterface ref both have to be released */
150         IFont_Release(font);
151         IFont_Release(font);
152 }
153
154 static void test_type_info(void)
155 {
156         LPVOID pvObj = NULL;
157         HRESULT hres;
158         IFontDisp*  fontdisp = NULL;
159         ITypeInfo* pTInfo;
160         WCHAR name_Name[] = {'N','a','m','e',0};
161         BSTR names[3];
162         UINT n;
163         LCID en_us = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),
164                 SORT_DEFAULT);
165         DISPPARAMS dispparams;
166         VARIANT varresult;
167
168         pOleCreateFontIndirect(NULL, &IID_IFontDisp, &pvObj);
169         fontdisp = pvObj;
170
171         hres = IFontDisp_GetTypeInfo(fontdisp, 0, en_us, &pTInfo);
172         ok(hres == S_OK, "GTI returned 0x%08x instead of S_OK.\n", hres);
173         ok(pTInfo != NULL, "GTI returned NULL.\n");
174
175         hres = ITypeInfo_GetNames(pTInfo, DISPID_FONT_NAME, names, 3, &n);
176         ok(hres == S_OK, "GetNames returned 0x%08x instead of S_OK.\n", hres);
177         ok(n == 1, "GetNames returned %d names instead of 1.\n", n);
178         ok(!lstrcmpiW(names[0],name_Name), "DISPID_FONT_NAME doesn't get 'Names'.\n");
179         SysFreeString(names[0]);
180
181         ITypeInfo_Release(pTInfo);
182
183         dispparams.cNamedArgs = 0;
184         dispparams.rgdispidNamedArgs = NULL;
185         dispparams.cArgs = 0;
186         dispparams.rgvarg = NULL;
187         VariantInit(&varresult);
188         hres = IFontDisp_Invoke(fontdisp, DISPID_FONT_NAME, &IID_NULL,
189             LOCALE_NEUTRAL, DISPATCH_PROPERTYGET, &dispparams, &varresult,
190             NULL, NULL);
191         ok(hres == S_OK, "IFontDisp_Invoke return 0x%08x instead of S_OK.\n", hres);
192         VariantClear(&varresult);
193
194         IFontDisp_Release(fontdisp);
195 }
196
197 static HRESULT WINAPI FontEventsDisp_QueryInterface(
198         IFontEventsDisp *iface,
199     /* [in] */ REFIID riid,
200     /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject)
201 {
202     if (IsEqualIID(riid, &IID_IFontEventsDisp) || IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IDispatch))
203     {
204         IUnknown_AddRef(iface);
205         *ppvObject = iface;
206         return S_OK;
207     }
208     else
209     {
210         *ppvObject = NULL;
211         return E_NOINTERFACE;
212     }
213 }
214
215 static ULONG WINAPI FontEventsDisp_AddRef(
216     IFontEventsDisp *iface)
217 {
218     return 2;
219 }
220
221 static ULONG WINAPI FontEventsDisp_Release(
222         IFontEventsDisp *iface)
223 {
224     return 1;
225 }
226
227 static int fonteventsdisp_invoke_called = 0;
228
229 static HRESULT WINAPI FontEventsDisp_Invoke(
230         IFontEventsDisp __RPC_FAR * iface,
231     /* [in] */ DISPID dispIdMember,
232     /* [in] */ REFIID riid,
233     /* [in] */ LCID lcid,
234     /* [in] */ WORD wFlags,
235     /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,
236     /* [out] */ VARIANT __RPC_FAR *pVarResult,
237     /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
238     /* [out] */ UINT __RPC_FAR *puArgErr)
239 {
240     static const WCHAR wszBold[] = {'B','o','l','d',0};
241     ok(wFlags == INVOKE_FUNC, "invoke flags should have been INVOKE_FUNC instead of 0x%x\n", wFlags);
242     ok(dispIdMember == DISPID_FONT_CHANGED, "dispIdMember should have been DISPID_FONT_CHANGED instead of 0x%x\n", dispIdMember);
243     ok(pDispParams->cArgs == 1, "pDispParams->cArgs should have been 1 instead of %d\n", pDispParams->cArgs);
244     ok(V_VT(&pDispParams->rgvarg[0]) == VT_BSTR, "VT of first param should have been VT_BSTR instead of %d\n", V_VT(&pDispParams->rgvarg[0]));
245     ok(!lstrcmpW(V_BSTR(&pDispParams->rgvarg[0]), wszBold), "String in first param should have been \"Bold\"\n");
246
247     fonteventsdisp_invoke_called++;
248     return S_OK;
249 }
250
251 static IFontEventsDispVtbl FontEventsDisp_Vtbl =
252 {
253     FontEventsDisp_QueryInterface,
254     FontEventsDisp_AddRef,
255     FontEventsDisp_Release,
256     NULL,
257     NULL,
258     NULL,
259     FontEventsDisp_Invoke
260 };
261
262 static IFontEventsDisp FontEventsDisp = { &FontEventsDisp_Vtbl };
263
264 static void test_font_events_disp(void)
265 {
266     IFont *pFont;
267     IFont *pFont2;
268     IConnectionPointContainer *pCPC;
269     IConnectionPoint *pCP;
270     FONTDESC fontdesc;
271     HRESULT hr;
272     DWORD dwCookie;
273     IFontDisp *pFontDisp;
274     DISPPARAMS dispparams;
275     VARIANTARG vararg;
276
277     fontdesc.cbSizeofstruct = sizeof(fontdesc);
278     fontdesc.lpstrName = MSSansSerif_font;
279     fontdesc.cySize.int64 = 12 * 10000; /* 12 pt */
280     fontdesc.sWeight = FW_NORMAL;
281     fontdesc.sCharset = 0;
282     fontdesc.fItalic = FALSE;
283     fontdesc.fUnderline = FALSE;
284     fontdesc.fStrikethrough = FALSE;
285
286     hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void **)&pFont);
287     ok_ole_success(hr, "OleCreateFontIndirect");
288
289     hr = IFont_QueryInterface(pFont, &IID_IConnectionPointContainer, (void **)&pCPC);
290     ok_ole_success(hr, "IFont_QueryInterface");
291
292     hr = IConnectionPointContainer_FindConnectionPoint(pCPC, &IID_IFontEventsDisp, &pCP);
293     ok_ole_success(hr, "IConnectionPointContainer_FindConnectionPoint");
294     IConnectionPointContainer_Release(pCPC);
295
296     hr = IConnectionPoint_Advise(pCP, (IUnknown *)&FontEventsDisp, &dwCookie);
297     ok_ole_success(hr, "IConnectionPoint_Advise");
298     IConnectionPoint_Release(pCP);
299
300     hr = IFont_put_Bold(pFont, TRUE);
301     ok_ole_success(hr, "IFont_put_Bold");
302
303     ok(fonteventsdisp_invoke_called == 1, "IFontEventDisp::Invoke wasn't called once\n");
304
305     hr = IFont_QueryInterface(pFont, &IID_IFontDisp, (void **)&pFontDisp);
306     ok_ole_success(hr, "IFont_QueryInterface");
307
308     V_VT(&vararg) = VT_BOOL;
309     V_BOOL(&vararg) = VARIANT_FALSE;
310     dispparams.cNamedArgs = 0;
311     dispparams.rgdispidNamedArgs = NULL;
312     dispparams.cArgs = 1;
313     dispparams.rgvarg = &vararg;
314     hr = IFontDisp_Invoke(pFontDisp, DISPID_FONT_BOLD, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL);
315
316     IFontDisp_Release(pFontDisp);
317
318     ok(fonteventsdisp_invoke_called == 2, "IFontEventDisp::Invoke was called %d times instead of twice\n",
319         fonteventsdisp_invoke_called);
320
321     hr = IFont_Clone(pFont, &pFont2);
322     ok_ole_success(hr, "IFont_Clone");
323     IFont_Release(pFont);
324
325     hr = IFont_put_Bold(pFont2, FALSE);
326     ok_ole_success(hr, "IFont_put_Bold");
327
328     /* this test shows that the notification routine isn't called again */
329     ok(fonteventsdisp_invoke_called == 2, "IFontEventDisp::Invoke was called %d times instead of twice\n",
330         fonteventsdisp_invoke_called);
331
332     IFont_Release(pFont2);
333 }
334
335 static void test_names_ids(WCHAR* w_name_1, const char* a_name_1,
336                     WCHAR* w_name_2, const char* a_name_2,
337                     LCID lcid, DISPID id_1, DISPID id_2,
338                     HRESULT hres_expect, int numnames)
339 {
340     LPVOID pvObj = NULL;
341     IFontDisp *fontdisp = NULL;
342     HRESULT hres;
343     DISPID rgDispId[2] = {0xdeadbeef, 0xdeadbeef};
344     LPOLESTR names[2] = {w_name_1, w_name_2};
345
346     pOleCreateFontIndirect(NULL, &IID_IFontDisp, &pvObj);
347     fontdisp = pvObj;
348
349     hres = IFontDisp_GetIDsOfNames(fontdisp, &IID_NULL, names, numnames,
350                                    lcid, rgDispId);
351
352     /* test hres */
353     ok(hres == hres_expect,
354         "GetIDsOfNames: \"%s\", \"%s\" returns 0x%08x, expected 0x%08x.\n",
355         a_name_1, a_name_2, hres, hres_expect);
356
357     /* test first DISPID */
358     ok(rgDispId[0]==id_1,
359         "GetIDsOfNames: \"%s\" gets DISPID 0x%08x, expected 0x%08x.\n",
360         a_name_1, rgDispId[0], id_1);
361
362     /* test second DISPID is present */
363     if (numnames == 2)
364     {
365         ok(rgDispId[1]==id_2,
366             "GetIDsOfNames: ..., \"%s\" gets DISPID 0x%08x, expected 0x%08x.\n",
367             a_name_2, rgDispId[1], id_2);
368     }
369
370    IFontDisp_Release(fontdisp);
371 }
372
373 static void test_GetIDsOfNames(void)
374 {
375     WCHAR name_Name[] = {'N','a','m','e',0};
376     WCHAR name_Italic[] = {'I','t','a','l','i','c',0};
377     WCHAR name_Size[] = {'S','i','z','e',0};
378     WCHAR name_Bold[] = {'B','o','l','d',0};
379     WCHAR name_Underline[] = {'U','n','d','e','r','l','i','n','e',0};
380     WCHAR name_Strikethrough[] = {'S','t','r','i','k','e','t','h','r','o','u','g','h',0};
381     WCHAR name_Weight[] = {'W','e','i','g','h','t',0};
382     WCHAR name_Charset[] = {'C','h','a','r','s','e','t',0};
383     WCHAR name_Foo[] = {'F','o','o',0};
384     WCHAR name_nAmE[] = {'n','A','m','E',0};
385     WCHAR name_Nom[] = {'N','o','m',0};
386
387     LCID en_us = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),
388                           SORT_DEFAULT);
389     LCID fr_fr = MAKELCID(MAKELANGID(LANG_FRENCH,SUBLANG_FRENCH),
390                           SORT_DEFAULT);
391
392     /* Test DISPID_FONTs for the various properties. */
393     test_names_ids(name_Name, "Name", NULL, "", en_us,
394                    DISPID_FONT_NAME, 0, S_OK,1);
395     test_names_ids(name_Size, "Size", NULL, "", en_us,
396                    DISPID_FONT_SIZE, 0, S_OK,1);
397     test_names_ids(name_Bold, "Bold", NULL, "", en_us,
398                    DISPID_FONT_BOLD, 0, S_OK,1);
399     test_names_ids(name_Italic, "Italic", NULL, "", en_us,
400                    DISPID_FONT_ITALIC, 0, S_OK,1);
401     test_names_ids(name_Underline, "Underline", NULL, "", en_us,
402                    DISPID_FONT_UNDER, 0, S_OK,1);
403     test_names_ids(name_Strikethrough, "Strikethrough", NULL, "", en_us,
404                    DISPID_FONT_STRIKE, 0, S_OK,1);
405     test_names_ids(name_Weight, "Weight", NULL, "", en_us,
406                    DISPID_FONT_WEIGHT, 0, S_OK,1);
407     test_names_ids(name_Charset, "Charset", NULL, "", en_us,
408                    DISPID_FONT_CHARSET, 0, S_OK,1);
409
410     /* Capitalization doesn't matter. */
411     test_names_ids(name_nAmE, "nAmE", NULL, "", en_us,
412                    DISPID_FONT_NAME, 0, S_OK,1);
413
414     /* Unknown name. */
415     test_names_ids(name_Foo, "Foo", NULL, "", en_us,
416                    DISPID_UNKNOWN, 0, DISP_E_UNKNOWNNAME,1);
417
418     /* Pass several names: first is processed,                */
419     /* second gets DISPID_UNKNOWN and doesn't affect retval.  */
420     test_names_ids(name_Italic, "Italic", name_Name, "Name", en_us,
421                    DISPID_FONT_ITALIC, DISPID_UNKNOWN, S_OK,2);
422     test_names_ids(name_Italic, "Italic", name_Foo, "Foo", en_us,
423                    DISPID_FONT_ITALIC, DISPID_UNKNOWN, S_OK,2);
424
425     /* Locale ID has no effect. */
426     test_names_ids(name_Name, "Name", NULL, "", fr_fr,
427                    DISPID_FONT_NAME, 0, S_OK,1);
428     test_names_ids(name_Nom, "This is not a font", NULL, "", fr_fr,
429                    DISPID_UNKNOWN, 0, DISP_E_UNKNOWNNAME,1);
430
431     /* One of the arguments are invalid */
432     test_names_ids(name_Name, "Name", NULL, "", en_us,
433                    0xdeadbeef, 0xdeadbeef, E_INVALIDARG,0);
434     test_names_ids(name_Italic, "Italic", NULL, "", en_us,
435                    0xdeadbeef, 0xdeadbeef, E_INVALIDARG,0);
436     test_names_ids(name_Foo, "Foo", NULL, "", en_us,
437                    0xdeadbeef, 0xdeadbeef, E_INVALIDARG,0);
438
439     /* Crazy locale ID? */
440     test_names_ids(name_Name, "Name", NULL, "", -1,
441                    DISPID_FONT_NAME, 0, S_OK,1);
442 }
443
444 static void test_Invoke(void)
445 {
446     IFontDisp *fontdisp;
447     HRESULT hr;
448     VARIANTARG vararg;
449     DISPPARAMS dispparams;
450     VARIANT varresult;
451
452     hr = pOleCreateFontIndirect(NULL, &IID_IFontDisp, (void **)&fontdisp);
453     ok_ole_success(hr, "OleCreateFontIndirect");
454
455     V_VT(&vararg) = VT_BOOL;
456     V_BOOL(&vararg) = VARIANT_FALSE;
457     dispparams.cNamedArgs = 0;
458     dispparams.rgdispidNamedArgs = NULL;
459     dispparams.cArgs = 1;
460     dispparams.rgvarg = &vararg;
461     hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_IFontDisp, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL);
462     ok(hr == DISP_E_UNKNOWNINTERFACE, "IFontDisp_Invoke should have returned DISP_E_UNKNOWNINTERFACE instead of 0x%08x\n", hr);
463
464     dispparams.cArgs = 0;
465     dispparams.rgvarg = NULL;
466     hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_NULL, 0, DISPATCH_PROPERTYPUT, &dispparams, NULL, NULL, NULL);
467     ok(hr == DISP_E_BADPARAMCOUNT, "IFontDisp_Invoke should have returned DISP_E_BADPARAMCOUNT instead of 0x%08x\n", hr);
468
469     hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_NULL, 0, DISPATCH_PROPERTYPUT, NULL, NULL, NULL, NULL);
470     ok(hr == DISP_E_PARAMNOTOPTIONAL, "IFontDisp_Invoke should have returned DISP_E_PARAMNOTOPTIONAL instead of 0x%08x\n", hr);
471
472     hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_NULL, 0, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL);
473     ok(hr == DISP_E_PARAMNOTOPTIONAL, "IFontDisp_Invoke should have returned DISP_E_PARAMNOTOPTIONAL instead of 0x%08x\n", hr);
474
475     hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_NULL, 0, DISPATCH_PROPERTYGET, NULL, &varresult, NULL, NULL);
476     ok_ole_success(hr, "IFontDisp_Invoke");
477
478     hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_NULL, 0, DISPATCH_METHOD, NULL, &varresult, NULL, NULL);
479     ok(hr == DISP_E_MEMBERNOTFOUND, "IFontDisp_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
480
481     hr = IFontDisp_Invoke(fontdisp, 0xdeadbeef, &IID_NULL, 0, DISPATCH_PROPERTYGET, NULL, &varresult, NULL, NULL);
482     ok(hr == DISP_E_MEMBERNOTFOUND, "IFontDisp_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr);
483
484     dispparams.cArgs = 1;
485     dispparams.rgvarg = &vararg;
486     hr = IFontDisp_Invoke(fontdisp, DISPID_FONT_BOLD, &IID_NULL, 0, DISPATCH_PROPERTYGET, &dispparams, &varresult, NULL, NULL);
487     ok_ole_success(hr, "IFontDisp_Invoke");
488
489     IFontDisp_Release(fontdisp);
490 }
491
492 static void test_IsEqual(void)
493 {
494     FONTDESC fd;
495     IFont* ifnt = NULL;
496     IFont* ifnt2 = NULL;
497     HRESULT hres;
498
499     /* Basic font description */
500     fd.cbSizeofstruct = sizeof(FONTDESC);
501     fd.lpstrName      = system_font;
502     S(fd.cySize).Lo   = 100;
503     S(fd.cySize).Hi   = 100;
504     fd.sWeight        = 0;
505     fd.sCharset       = 0;
506     fd.fItalic        = 0;
507     fd.fUnderline     = 0;
508     fd.fStrikethrough = 0;
509
510     /* Create font */
511     pOleCreateFontIndirect(&fd, &IID_IFont, (void **)&ifnt);
512
513     /* Test equal fonts */
514     pOleCreateFontIndirect(&fd, &IID_IFont, (void **)&ifnt2);
515     hres = IFont_IsEqual(ifnt,ifnt2);
516     ok(hres == S_OK,
517         "IFont_IsEqual: (EQUAL) Expected S_OK but got 0x%08x\n",hres);
518     IFont_Release(ifnt2);
519
520     /* Check for bad pointer */
521     hres = IFont_IsEqual(ifnt,NULL);
522     ok(hres == E_POINTER,
523         "IFont_IsEqual: (NULL) Expected 0x80004003 but got 0x%08x\n",hres);
524
525     /* Test strName */
526     fd.lpstrName = arial_font;
527     pOleCreateFontIndirect(&fd, &IID_IFont, (void **)&ifnt2);
528     hres = IFont_IsEqual(ifnt,ifnt2);
529     ok(hres == S_FALSE,
530         "IFont_IsEqual: (strName) Expected S_FALSE but got 0x%08x\n",hres);
531     fd.lpstrName = system_font;
532     IFont_Release(ifnt2);
533
534     /* Test lo font size */
535     S(fd.cySize).Lo = 10000;
536     pOleCreateFontIndirect(&fd, &IID_IFont, (void **)&ifnt2);
537     hres = IFont_IsEqual(ifnt,ifnt2);
538     ok(hres == S_FALSE,
539         "IFont_IsEqual: (Lo font size) Expected S_FALSE but got 0x%08x\n",hres);
540     S(fd.cySize).Lo = 100;
541     IFont_Release(ifnt2);
542
543     /* Test hi font size */
544     S(fd.cySize).Hi = 10000;
545     pOleCreateFontIndirect(&fd, &IID_IFont, (void **)&ifnt2);
546     hres = IFont_IsEqual(ifnt,ifnt2);
547     ok(hres == S_FALSE,
548         "IFont_IsEqual: (Hi font size) Expected S_FALSE but got 0x%08x\n",hres);
549     S(fd.cySize).Hi = 100;
550     IFont_Release(ifnt2);
551
552     /* Test font weight  */
553     fd.sWeight = 100;
554     pOleCreateFontIndirect(&fd, &IID_IFont, (void **)&ifnt2);
555     hres = IFont_IsEqual(ifnt,ifnt2);
556     ok(hres == S_FALSE,
557         "IFont_IsEqual: (Weight) Expected S_FALSE but got 0x%08x\n",hres);
558     fd.sWeight = 0;
559     IFont_Release(ifnt2);
560
561     /* Test charset */
562     fd.sCharset = 1;
563     pOleCreateFontIndirect(&fd, &IID_IFont, (void **)&ifnt2);
564     hres = IFont_IsEqual(ifnt,ifnt2);
565     ok(hres == S_FALSE,
566         "IFont_IsEqual: (Charset) Expected S_FALSE but got 0x%08x\n",hres);
567     fd.sCharset = 0;
568     IFont_Release(ifnt2);
569
570     /* Test italic setting */
571     fd.fItalic = 1;
572     pOleCreateFontIndirect(&fd, &IID_IFont, (void **)&ifnt2);
573     hres = IFont_IsEqual(ifnt,ifnt2);
574     ok(hres == S_FALSE,
575         "IFont_IsEqual: (Italic) Expected S_FALSE but got 0x%08x\n",hres);
576     fd.fItalic = 0;
577     IFont_Release(ifnt2);
578
579     /* Test underline setting */
580     fd.fUnderline = 1;
581     pOleCreateFontIndirect(&fd, &IID_IFont, (void **)&ifnt2);
582     hres = IFont_IsEqual(ifnt,ifnt2);
583     ok(hres == S_FALSE,
584         "IFont_IsEqual: (Underline) Expected S_FALSE but got 0x%08x\n",hres);
585     fd.fUnderline = 0;
586     IFont_Release(ifnt2);
587
588     /* Test strikethrough setting */
589     fd.fStrikethrough = 1;
590     pOleCreateFontIndirect(&fd, &IID_IFont, (void **)&ifnt2);
591     hres = IFont_IsEqual(ifnt,ifnt2);
592     ok(hres == S_FALSE,
593         "IFont_IsEqual: (Strikethrough) Expected S_FALSE but got 0x%08x\n",hres);
594     fd.fStrikethrough = 0;
595     IFont_Release(ifnt2);
596
597     /* Free IFont. */
598     IFont_Release(ifnt);
599 }
600
601 static void test_ReleaseHfont(void)
602 {
603     FONTDESC fd;
604     LPVOID pvObj1 = NULL;
605     LPVOID pvObj2 = NULL;
606     IFont* ifnt1 = NULL;
607     IFont* ifnt2 = NULL;
608     HFONT hfnt1 = 0;
609     HFONT hfnt2 = 0;
610     HRESULT hres;
611
612     /* Basic font description */
613     fd.cbSizeofstruct = sizeof(FONTDESC);
614     fd.lpstrName      = system_font;
615     S(fd.cySize).Lo   = 100;
616     S(fd.cySize).Hi   = 100;
617     fd.sWeight        = 0;
618     fd.sCharset       = 0;
619     fd.fItalic        = 0;
620     fd.fUnderline     = 0;
621     fd.fStrikethrough = 0;
622
623     /* Create HFONTs and IFONTs */
624     pOleCreateFontIndirect(&fd, &IID_IFont, &pvObj1);
625     ifnt1 = pvObj1;
626     IFont_get_hFont(ifnt1,&hfnt1);
627     fd.lpstrName = arial_font;
628     pOleCreateFontIndirect(&fd, &IID_IFont, &pvObj2);
629     ifnt2 = pvObj2;
630     IFont_get_hFont(ifnt2,&hfnt2);
631
632     /* Try invalid HFONT */
633     hres = IFont_ReleaseHfont(ifnt1,NULL);
634     ok(hres == E_INVALIDARG,
635         "IFont_ReleaseHfont: (Bad HFONT) Expected E_INVALIDARG but got 0x%08x\n",
636         hres);
637
638     /* Try to add a bad HFONT */
639     hres = IFont_ReleaseHfont(ifnt1,(HFONT)32);
640     ok(hres == S_FALSE,
641         "IFont_ReleaseHfont: (Bad HFONT) Expected S_FALSE but got 0x%08x\n",
642         hres);
643
644     /* Release all refs */
645     hres = IFont_ReleaseHfont(ifnt1,hfnt1);
646     ok(hres == S_OK,
647         "IFont_AddRefHfont: (Release ref) Expected S_OK but got 0x%08x\n",
648         hres);
649
650     hres = IFont_ReleaseHfont(ifnt2,hfnt2);
651     ok(hres == S_OK,
652         "IFont_AddRefHfont: (Release ref) Expected S_OK but got 0x%08x\n",
653         hres);
654
655     /* Check that both lists are empty */
656     hres = IFont_ReleaseHfont(ifnt1,hfnt1);
657     ok(hres == S_FALSE,
658         "IFont_AddRefHfont: (Release ref) Expected S_FALSE but got 0x%08x\n",
659         hres);
660
661     /* The list should be empty */
662     hres = IFont_ReleaseHfont(ifnt2,hfnt2);
663     ok(hres == S_FALSE,
664         "IFont_AddRefHfont: (Release ref) Expected S_FALSE but got 0x%08x\n",
665         hres);
666
667     IFont_Release(ifnt1);
668     IFont_Release(ifnt2);
669 }
670
671 static void test_AddRefHfont(void)
672 {
673     FONTDESC fd;
674     IFont* ifnt1 = NULL;
675     IFont* ifnt2 = NULL;
676     IFont* ifnt3 = NULL;
677     HFONT hfnt1 = 0;
678     HFONT hfnt2 = 0;
679     HFONT hfnt3 = 0;
680     HRESULT hres;
681
682     /* Basic font description */
683     fd.cbSizeofstruct = sizeof(FONTDESC);
684     fd.lpstrName      = system_font;
685     S(fd.cySize).Lo   = 100;
686     S(fd.cySize).Hi   = 100;
687     fd.sWeight        = 0;
688     fd.sCharset       = 0;
689     fd.fItalic        = 0;
690     fd.fUnderline     = 0;
691     fd.fStrikethrough = 0;
692
693     /* Create HFONTs and IFONTs */
694     pOleCreateFontIndirect(&fd, &IID_IFont, (void **)&ifnt1);
695     IFont_get_hFont(ifnt1,&hfnt1);
696     fd.lpstrName = arial_font;
697     pOleCreateFontIndirect(&fd, &IID_IFont, (void **)&ifnt2);
698     IFont_get_hFont(ifnt2,&hfnt2);
699
700     /* Try invalid HFONT */
701     hres = IFont_AddRefHfont(ifnt1,NULL);
702     ok(hres == E_INVALIDARG,
703         "IFont_AddRefHfont: (Bad HFONT) Expected E_INVALIDARG but got 0x%08x\n",
704         hres);
705
706     /* Try to add a bad HFONT */
707     hres = IFont_AddRefHfont(ifnt1,(HFONT)32);
708     ok(hres == S_FALSE,
709         "IFont_AddRefHfont: (Bad HFONT) Expected S_FALSE but got 0x%08x\n",
710         hres);
711
712     /* Add simple IFONT HFONT pair */
713     hres = IFont_AddRefHfont(ifnt1,hfnt1);
714     ok(hres == S_OK,
715         "IFont_AddRefHfont: (Add ref) Expected S_OK but got 0x%08x\n",
716         hres);
717
718     /* IFONT and HFONT do not have to be the same (always looks at HFONT) */
719     hres = IFont_AddRefHfont(ifnt2,hfnt1);
720     ok(hres == S_OK,
721         "IFont_AddRefHfont: (Add ref) Expected S_OK but got 0x%08x\n",
722         hres);
723
724     /* Release all hfnt1 refs */
725     hres = IFont_ReleaseHfont(ifnt1,hfnt1);
726     ok(hres == S_OK,
727         "IFont_AddRefHfont: (Release ref) Expected S_OK but got 0x%08x\n",
728         hres);
729
730     hres = IFont_ReleaseHfont(ifnt1,hfnt1);
731     ok(hres == S_OK,
732         "IFont_AddRefHfont: (Release ref) Expected S_OK but got 0x%08x\n",
733         hres);
734
735     hres = IFont_ReleaseHfont(ifnt1,hfnt1);
736     ok(hres == S_OK,
737         "IFont_AddRefHfont: (Release ref) Expected S_OK but got 0x%08x\n",
738         hres);
739
740     /* Check if hfnt1 is empty */
741     hres = IFont_ReleaseHfont(ifnt1,hfnt1);
742     ok(hres == S_FALSE,
743         "IFont_AddRefHfont: (Release ref) Expected S_FALSE but got 0x%08x\n",
744         hres);
745
746     /* Release all hfnt2 refs */
747     hres = IFont_ReleaseHfont(ifnt2,hfnt2);
748     ok(hres == S_OK,
749         "IFont_AddRefHfont: (Release ref) Expected S_OK but got 0x%08x\n",
750         hres);
751
752     /* Check if hfnt2 is empty */
753     hres = IFont_ReleaseHfont(ifnt2,hfnt2);
754     ok(hres == S_FALSE,
755         "IFont_AddRefHfont: (Release ref) Expected S_FALSE but got 0x%08x\n",
756         hres);
757
758     /* Show that releasing an IFONT does not always release it from the HFONT cache. */
759
760     IFont_Release(ifnt1);
761
762     /* Add a reference for destroyed hfnt1 */
763     hres = IFont_AddRefHfont(ifnt2,hfnt1);
764     ok(hres == S_OK,
765         "IFont_AddRefHfont: (Add ref) Expected S_OK but got 0x%08x\n",
766         hres);
767
768     /* Decrement reference for destroyed hfnt1 */
769     hres = IFont_ReleaseHfont(ifnt2,hfnt1);
770     ok(hres == S_OK ||
771        hres == S_FALSE, /* <= win2k */
772         "IFont_AddRefHfont: (Release ref) Expected S_OK or S_FALSE but got 0x%08x\n",
773         hres);
774
775     /* Shows that releasing all IFONT's does clear the HFONT cache. */
776
777     IFont_Release(ifnt2);
778
779     /* Need to make a new IFONT for testing */
780     fd.fUnderline = 1;
781     pOleCreateFontIndirect(&fd, &IID_IFont, (void **)&ifnt3);
782     IFont_get_hFont(ifnt3,&hfnt3);
783
784     /* Add a reference for destroyed hfnt1 */
785     hres = IFont_AddRefHfont(ifnt3,hfnt1);
786     ok(hres == S_FALSE,
787         "IFont_AddRefHfont: (Add ref) Expected S_OK but got 0x%08x\n",
788         hres);
789
790     /* Decrement reference for destroyed hfnt1 */
791     hres = IFont_ReleaseHfont(ifnt3,hfnt1);
792     ok(hres == S_FALSE,
793         "IFont_AddRefHfont: (Release ref) Expected S_OK but got 0x%08x\n",
794         hres);
795
796     IFont_Release(ifnt3);
797 }
798
799 static void test_returns(void)
800 {
801     IFont *pFont;
802     FONTDESC fontdesc;
803     HRESULT hr;
804
805     fontdesc.cbSizeofstruct = sizeof(fontdesc);
806     fontdesc.lpstrName = MSSansSerif_font;
807     fontdesc.cySize.int64 = 12 * 10000; /* 12 pt */
808     fontdesc.sWeight = FW_NORMAL;
809     fontdesc.sCharset = 0;
810     fontdesc.fItalic = FALSE;
811     fontdesc.fUnderline = FALSE;
812     fontdesc.fStrikethrough = FALSE;
813
814     hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void **)&pFont);
815     ok_ole_success(hr, "OleCreateFontIndirect");
816
817     hr = IFont_put_Name(pFont, NULL);
818     ok(hr == CTL_E_INVALIDPROPERTYVALUE,
819        "IFont::put_Name: Expected CTL_E_INVALIDPROPERTYVALUE got 0x%08x\n",
820        hr);
821
822     hr = IFont_get_Name(pFont, NULL);
823     ok(hr == E_POINTER,
824        "IFont::get_Name: Expected E_POINTER got 0x%08x\n",
825        hr);
826
827     hr = IFont_get_Size(pFont, NULL);
828     ok(hr == E_POINTER,
829        "IFont::get_Size: Expected E_POINTER got 0x%08x\n",
830        hr);
831
832     hr = IFont_get_Bold(pFont, NULL);
833     ok(hr == E_POINTER,
834        "IFont::get_Bold: Expected E_POINTER got 0x%08x\n",
835        hr);
836
837     IFont_Release(pFont);
838 }
839
840 static void test_hfont_lifetime(void)
841 {
842     IFont *font, *font2;
843     FONTDESC fontdesc;
844     HRESULT hr;
845     HFONT hfont, first_hfont = NULL;
846     CY size;
847     DWORD obj_type;
848     int i;
849
850     fontdesc.cbSizeofstruct = sizeof(fontdesc);
851     fontdesc.lpstrName = arial_font;
852     fontdesc.cySize.int64 = 12 * 10000; /* 12 pt */
853     fontdesc.sWeight = FW_NORMAL;
854     fontdesc.sCharset = ANSI_CHARSET;
855     fontdesc.fItalic = FALSE;
856     fontdesc.fUnderline = FALSE;
857     fontdesc.fStrikethrough = FALSE;
858
859     hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void **)&font);
860     ok_ole_success(hr, "OleCreateFontIndirect");
861
862     hr = IFont_get_hFont(font, &hfont);
863     ok_ole_success(hr, "get_hFont");
864
865     /* show that if the font is updated the old hfont is deleted when the
866        new font is realized */
867     for(i = 0; i < 100; i++)
868     {
869         HFONT last_hfont = hfont;
870
871         size.int64 = (i + 10) * 20000;
872
873         obj_type = GetObjectType(hfont);
874         ok(obj_type == OBJ_FONT, "got obj type %d\n", obj_type);
875
876         hr = IFont_put_Size(font, size);
877         ok_ole_success(hr, "put_Size");
878
879         /* put_Size doesn't cause the new font to be realized */
880         obj_type = GetObjectType(last_hfont);
881         ok(obj_type == OBJ_FONT, "got obj type %d\n", obj_type);
882
883         hr = IFont_get_hFont(font, &hfont);
884         ok_ole_success(hr, "get_hFont");
885
886         obj_type = GetObjectType(last_hfont);
887         ok(obj_type == 0, "%d: got obj type %d\n", i, obj_type);
888     }
889
890     /* now show that if we take a reference on the hfont, it persists
891        until the font object is released */
892     for(i = 0; i < 100; i++)
893     {
894
895         size.int64 = (i + 10) * 20000;
896
897         obj_type = GetObjectType(hfont);
898         ok(obj_type == OBJ_FONT, "got obj type %d\n", obj_type);
899
900         hr = IFont_put_Size(font, size);
901         ok_ole_success(hr, "put_Size");
902
903         hr = IFont_get_hFont(font, &hfont);
904         ok_ole_success(hr, "get_hFont");
905
906         hr = IFont_AddRefHfont(font, hfont);
907         ok_ole_success(hr, "AddRefHfont");
908
909         if(i == 0) first_hfont = hfont;
910         obj_type = GetObjectType(first_hfont);
911         ok(obj_type == OBJ_FONT, "got obj type %d\n", obj_type);
912     }
913
914     IFont_Release(font);
915
916     obj_type = GetObjectType(first_hfont);
917     ok(obj_type == 0, "got obj type %d\n", obj_type);
918
919     /* An AddRefHfont followed by a ReleaseHfont means the font doesn't not persist
920        through re-realization */
921
922     hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void **)&font);
923     ok_ole_success(hr, "OleCreateFontIndirect");
924
925     hr = IFont_get_hFont(font, &hfont);
926     ok_ole_success(hr, "get_hFont");
927
928     for(i = 0; i < 100; i++)
929     {
930         HFONT last_hfont = hfont;
931
932         size.int64 = (i + 10) * 20000;
933
934         obj_type = GetObjectType(hfont);
935         ok(obj_type == OBJ_FONT, "got obj type %d\n", obj_type);
936
937         hr = IFont_put_Size(font, size);
938         ok_ole_success(hr, "put_Size");
939
940         /* put_Size doesn't cause the new font to be realized */
941         obj_type = GetObjectType(last_hfont);
942         ok(obj_type == OBJ_FONT, "got obj type %d\n", obj_type);
943
944         hr = IFont_get_hFont(font, &hfont);
945         ok_ole_success(hr, "get_hFont");
946
947         hr = IFont_AddRefHfont(font, hfont);
948         ok_ole_success(hr, "AddRefHfont");
949
950         hr = IFont_ReleaseHfont(font, hfont);
951         ok_ole_success(hr, "ReleaseHfont");
952
953         obj_type = GetObjectType(last_hfont);
954         ok(obj_type == 0, "%d: got obj type %d\n", i, obj_type);
955     }
956
957     /* Interestingly if we release a nonexistent reference on the hfont,
958      * it persists until the font object is released
959      */
960     for(i = 0; i < 100; i++)
961     {
962         size.int64 = (i + 10) * 20000;
963
964         obj_type = GetObjectType(hfont);
965         ok(obj_type == OBJ_FONT, "got obj type %d\n", obj_type);
966
967         hr = IFont_put_Size(font, size);
968         ok_ole_success(hr, "put_Size");
969
970         hr = IFont_get_hFont(font, &hfont);
971         ok_ole_success(hr, "get_hFont");
972
973         hr = IFont_ReleaseHfont(font, hfont);
974         ok_ole_success(hr, "ReleaseHfont");
975
976         if(i == 0) first_hfont = hfont;
977         obj_type = GetObjectType(first_hfont);
978         ok(obj_type == OBJ_FONT, "got obj type %d\n", obj_type);
979     }
980
981     IFont_Release(font);
982
983     obj_type = GetObjectType(first_hfont);
984     ok(obj_type == 0, "got obj type %d\n", obj_type);
985
986     /* If we take two internal references on a hfont then we can release
987        it twice.  So it looks like there's a total reference count
988        that includes internal and external references */
989
990     hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void **)&font);
991     ok_ole_success(hr, "OleCreateFontIndirect");
992     hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void **)&font2);
993     ok_ole_success(hr, "OleCreateFontIndirect");
994
995     hr = IFont_get_hFont(font, &hfont);
996     ok_ole_success(hr, "get_hFont");
997     hr = IFont_get_hFont(font2, &first_hfont);
998     ok_ole_success(hr, "get_hFont");
999 todo_wine
1000     ok(hfont == first_hfont, "fonts differ\n");
1001     hr = IFont_ReleaseHfont(font, hfont);
1002     ok(hr == S_OK, "got %08x\n", hr);
1003     hr = IFont_ReleaseHfont(font, hfont);
1004 todo_wine
1005     ok(hr == S_OK, "got %08x\n", hr);
1006     hr = IFont_ReleaseHfont(font, hfont);
1007     ok(hr == S_FALSE, "got %08x\n", hr);
1008
1009     obj_type = GetObjectType(hfont);
1010     ok(obj_type == OBJ_FONT, "got obj type %d\n", obj_type);
1011
1012     IFont_Release(font);
1013
1014     obj_type = GetObjectType(hfont);
1015     ok(obj_type == OBJ_FONT, "got obj type %d\n", obj_type);
1016
1017     IFont_Release(font2);
1018
1019     obj_type = GetObjectType(hfont);
1020     ok(obj_type == 0, "got obj type %d\n", obj_type);
1021 }
1022
1023 static void test_realization(void)
1024 {
1025     IFont *font;
1026     FONTDESC fontdesc;
1027     HRESULT hr;
1028     BSTR name;
1029     SHORT cs;
1030
1031     /* Try to create a symbol only font (marlett) with charset
1032        set to ANSI.  This will result in another, ANSI, font
1033        being selected */
1034     fontdesc.cbSizeofstruct = sizeof(fontdesc);
1035     fontdesc.lpstrName = marlett_font;
1036     fontdesc.cySize.int64 = 12 * 10000; /* 12 pt */
1037     fontdesc.sWeight = FW_NORMAL;
1038     fontdesc.sCharset = ANSI_CHARSET;
1039     fontdesc.fItalic = FALSE;
1040     fontdesc.fUnderline = FALSE;
1041     fontdesc.fStrikethrough = FALSE;
1042
1043     hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void **)&font);
1044     ok_ole_success(hr, "OleCreateFontIndirect");
1045
1046     hr = IFont_get_Charset(font, &cs);
1047     ok_ole_success(hr, "get_Charset");
1048     ok(cs == ANSI_CHARSET, "got charset %d\n", cs);
1049
1050     IFont_Release(font);
1051
1052     /* Now create an ANSI font and change the name to marlett */
1053
1054     fontdesc.lpstrName = arial_font;
1055
1056     hr = pOleCreateFontIndirect(&fontdesc, &IID_IFont, (void **)&font);
1057     ok_ole_success(hr, "OleCreateFontIndirect");
1058
1059     hr = IFont_get_Charset(font, &cs);
1060     ok_ole_success(hr, "get_Charset");
1061     ok(cs == ANSI_CHARSET, "got charset %d\n", cs);
1062
1063     name = SysAllocString(marlett_font);
1064     hr = IFont_put_Name(font, name);
1065     ok_ole_success(hr, "put_Name");
1066     SysFreeString(name);
1067
1068     hr = IFont_get_Name(font, &name);
1069     ok_ole_success(hr, "get_Name");
1070     ok(!lstrcmpiW(name, marlett_font), "got name %s\n", wine_dbgstr_w(name));
1071     SysFreeString(name);
1072
1073     hr = IFont_get_Charset(font, &cs);
1074     ok_ole_success(hr, "get_Charset");
1075     ok(cs == SYMBOL_CHARSET, "got charset %d\n", cs);
1076
1077     IFont_Release(font);
1078 }
1079
1080 START_TEST(olefont)
1081 {
1082         hOleaut32 = GetModuleHandleA("oleaut32.dll");
1083         pOleCreateFontIndirect = (void*)GetProcAddress(hOleaut32, "OleCreateFontIndirect");
1084         if (!pOleCreateFontIndirect)
1085         {
1086             win_skip("OleCreateFontIndirect not available\n");
1087             return;
1088         }
1089
1090         test_QueryInterface();
1091         test_type_info();
1092
1093         /* Test various size operations and conversions. */
1094         /* Add more as needed. */
1095         if (0) /* FIXME: failing tests */
1096         {
1097             test_ifont_sizes(180000, 0, 72, 2540, -18, "default");
1098             test_ifont_sizes(180000, 0, 144, 2540, -36, "ratio1");              /* change ratio */
1099             test_ifont_sizes(180000, 0, 72, 1270, -36, "ratio2");               /* 2nd part of ratio */
1100
1101             /* These depend on details of how IFont rounds sizes internally. */
1102             test_ifont_sizes(0, 0, 72, 2540, 0, "zero size");          /* zero size */
1103             test_ifont_sizes(186000, 0, 72, 2540, -19, "rounding");   /* test rounding */
1104         }
1105
1106         test_font_events_disp();
1107         test_GetIDsOfNames();
1108         test_Invoke();
1109         test_IsEqual();
1110         test_ReleaseHfont();
1111         test_AddRefHfont();
1112         test_returns();
1113         test_hfont_lifetime();
1114         test_realization();
1115 }