4 * Copyright 2003 Marcus Meissner
5 * Copyright 2006 (Google) Benjamin Arai
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.
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.
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
23 #define WIN32_NO_STATUS
25 #define COM_NO_WINDOWS_H
34 #include <wine/test.h>
36 //#include <winbase.h>
37 //#include <winuser.h>
40 //#include <winerror.h>
42 //#include <initguid.h>
48 DEFINE_GUID(GUID_NULL
,0,0,0,0,0,0,0,0,0,0,0);
50 static WCHAR MSSansSerif_font
[] = {'M','S',' ','S','a','n','s',' ','S','e','r','i','f',0};
51 static WCHAR system_font
[] = { 'S','y','s','t','e','m',0 };
52 static WCHAR arial_font
[] = { 'A','r','i','a','l',0 };
53 static WCHAR marlett_font
[] = { 'M','a','r','l','e','t','t',0 };
55 static HMODULE hOleaut32
;
57 static HRESULT (WINAPI
*pOleCreateFontIndirect
)(LPFONTDESC
,REFIID
,LPVOID
*);
59 #define EXPECT_HR(hr,hr_exp) \
60 ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
62 /* Create a font with cySize given by lo_size, hi_size, */
63 /* SetRatio to ratio_logical, ratio_himetric, */
64 /* check that resulting hfont has height hfont_height. */
65 /* Various checks along the way. */
66 static void test_ifont_size(LONGLONG size
, LONG ratio_logical
, LONG ratio_himetric
,
67 LONG hfont_height
, const char * test_name
)
78 fd
.cbSizeofstruct
= sizeof(FONTDESC
);
79 fd
.lpstrName
= arial_font
; /* using scalable instead of bitmap font reduces errors due to font realization */
80 fd
.cySize
.int64
= size
;
84 fd
.fUnderline
= FALSE
;
85 fd
.fStrikethrough
= FALSE
;
87 /* Create font, test that it worked. */
88 hres
= pOleCreateFontIndirect(&fd
, &IID_IFont
, &pvObj
);
90 ok(hres
== S_OK
,"%s: OCFI returns 0x%08x instead of S_OK.\n",
92 ok(pvObj
!= NULL
,"%s: OCFI returns NULL.\n", test_name
);
94 /* Change the scaling ratio */
95 hres
= IFont_SetRatio(ifnt
, ratio_logical
, ratio_himetric
);
96 ok((ratio_logical
&& ratio_himetric
) ? hres
== S_OK
: hres
== E_FAIL
,
97 "%s: IFont_SetRatio unexpectedly returned 0x%08x.\n", test_name
, hres
);
100 hres
= IFont_get_Size(ifnt
, &psize
);
101 ok(hres
== S_OK
,"%s: IFont_get_size returns 0x%08x instead of S_OK.\n",
104 /* Check returned size - allow for errors due to rounding & font realization. */
105 ok((psize
.int64
- size
) < 10000 && (psize
.int64
- size
) > -10000,
106 "%s: IFont_get_Size: Lo=%d, Hi=%d; expected Lo=%d, Hi=%d.\n",
107 test_name
, S(psize
).Lo
, S(psize
).Hi
, fd
.cySize
.Lo
, fd
.cySize
.Hi
);
109 /* Check hFont size. */
110 hres
= IFont_get_hFont (ifnt
, &hfont
);
111 ok(hres
== S_OK
, "%s: IFont_get_hFont returns 0x%08x instead of S_OK.\n",
113 rtnval
= GetObjectA(hfont
, sizeof(LOGFONTA
), &lf
);
114 ok(rtnval
> 0, "GetObject(hfont) failed\n");
116 /* Since font scaling may encounter rounding errors, allow 1 pixel deviation. */
117 ok(abs(lf
.lfHeight
- hfont_height
) <= 1,
118 "%s: hFont has lf.lfHeight=%d, expected %d.\n",
119 test_name
, lf
.lfHeight
, hfont_height
);
125 static void test_ifont_sizes(void)
127 /* Test various size operations and conversions. */
128 /* Add more as needed. */
130 /* Results of first 2 tests depend on display resolution. */
132 LONG dpi
= GetDeviceCaps(hdc
, LOGPIXELSY
); /* expected results depend on display DPI */
134 if(dpi
== 96) /* normal resolution display */
136 test_ifont_size(180000, 0, 0, -24, "default"); /* normal font */
137 test_ifont_size(186000, 0, 0, -25, "rounding"); /* test rounding */
138 } else if(dpi
== 72) /* low resolution display */
140 test_ifont_size(180000, 0, 0, -18, "default"); /* normal font */
141 test_ifont_size(186000, 0, 0, -19, "rounding"); /* test rounding */
142 } else if(dpi
== 120) /* high resolution display */
144 test_ifont_size(180000, 0, 0, -30, "default"); /* normal font */
145 test_ifont_size(186000, 0, 0, -31, "rounding"); /* test rounding */
147 skip("Skipping resolution dependent font size tests - display resolution is %d\n", dpi
);
149 /* Next 4 tests specify a scaling ratio, so display resolution is not a factor. */
150 test_ifont_size(180000, 72, 2540, -18, "ratio1"); /* change ratio */
151 test_ifont_size(180000, 144, 2540, -36, "ratio2"); /* another ratio */
152 test_ifont_size(180000, 72, 1270, -36, "ratio3"); /* yet another ratio */
153 test_ifont_size(186000, 72, 2540, -19, "rounding+ratio"); /* test rounding with ratio */
155 /* test various combinations of logical == himetric */
156 test_ifont_size(180000, 10, 10, -635, "identical ratio 1");
157 test_ifont_size(240000, 10, 10, -848, "identical ratio 2");
158 test_ifont_size(300000, 10, 10, -1058, "identical ratio 3");
160 /* test various combinations of logical and himetric both set to 1 */
161 test_ifont_size(180000, 1, 1, -24, "1:1 ratio 1");
162 test_ifont_size(240000, 1, 1, -32, "1:1 ratio 2");
163 test_ifont_size(300000, 1, 1, -40, "1:1 ratio 3");
165 /* test various combinations of logical set to 1 */
166 test_ifont_size(180000, 1, 0, -24, "1:0 ratio 1");
167 test_ifont_size(240000, 1, 0, -32, "1:0 ratio 2");
168 test_ifont_size(300000, 1, 0, -40, "1:0 ratio 3");
170 /* test various combinations of himetric set to 1 */
171 test_ifont_size(180000, 0, 1, -24, "0:1 ratio 1");
172 test_ifont_size(240000, 0, 1, -32, "0:1 ratio 2");
173 test_ifont_size(300000, 0, 1, -40, "0:1 ratio 3");
175 /* test various combinations of 2:1 logical:himetric */
176 test_ifont_size(180000, 2, 1, -1270, "2:1 ratio 1");
177 test_ifont_size(240000, 2, 1, -1694, "2:1 ratio 2");
178 test_ifont_size(300000, 2, 1, -2117, "2:1 ratio 3");
180 /* test various combinations of 1:2 logical:himetric */
181 test_ifont_size(180000, 1, 2, -318, "1:2 ratio 1");
182 test_ifont_size(240000, 1, 2, -424, "1:2 ratio 2");
183 test_ifont_size(300000, 1, 2, -529, "1:2 ratio 3");
185 /* test various combinations of logical and himetric both set to 2 */
186 test_ifont_size(180000, 2, 2, -635, "2:2 ratio 1");
187 test_ifont_size(240000, 2, 2, -848, "2:2 ratio 2");
188 test_ifont_size(300000, 2, 2, -1058, "2:2 ratio 3");
191 static void test_QueryInterface(void)
198 hr
= pOleCreateFontIndirect(NULL
, &IID_IFont
, NULL
);
199 EXPECT_HR(hr
, E_POINTER
);
201 hr
= pOleCreateFontIndirect(NULL
, &IID_IFont
, &pvObj
);
205 ok(font
!= NULL
,"OCFI (NULL,..) returns NULL, instead of !NULL\n");
208 hr
= IFont_QueryInterface( font
, &IID_IFont
, &pvObj
);
211 /* Test if QueryInterface increments ref counter for IFONTs */
212 ref
= IFont_AddRef(font
);
214 broken(ref
== 1), /* win95 */
215 "IFont_QI expected ref value 3 but instead got %d\n", ref
);
218 ok(pvObj
!= NULL
,"IFont_QI does return NULL, instead of a ptr\n");
224 static void test_type_info(void)
228 IFontDisp
* fontdisp
= NULL
;
230 WCHAR name_Name
[] = {'N','a','m','e',0};
233 LCID en_us
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),
235 DISPPARAMS dispparams
;
238 pOleCreateFontIndirect(NULL
, &IID_IFontDisp
, &pvObj
);
241 hres
= IFontDisp_GetTypeInfo(fontdisp
, 0, en_us
, &pTInfo
);
242 ok(hres
== S_OK
, "GTI returned 0x%08x instead of S_OK.\n", hres
);
243 ok(pTInfo
!= NULL
, "GTI returned NULL.\n");
245 hres
= ITypeInfo_GetNames(pTInfo
, DISPID_FONT_NAME
, names
, 3, &n
);
246 ok(hres
== S_OK
, "GetNames returned 0x%08x instead of S_OK.\n", hres
);
247 ok(n
== 1, "GetNames returned %d names instead of 1.\n", n
);
248 ok(!lstrcmpiW(names
[0],name_Name
), "DISPID_FONT_NAME doesn't get 'Names'.\n");
249 SysFreeString(names
[0]);
251 ITypeInfo_Release(pTInfo
);
253 dispparams
.cNamedArgs
= 0;
254 dispparams
.rgdispidNamedArgs
= NULL
;
255 dispparams
.cArgs
= 0;
256 dispparams
.rgvarg
= NULL
;
257 VariantInit(&varresult
);
258 hres
= IFontDisp_Invoke(fontdisp
, DISPID_FONT_NAME
, &IID_NULL
,
259 LOCALE_NEUTRAL
, DISPATCH_PROPERTYGET
, &dispparams
, &varresult
,
261 ok(hres
== S_OK
, "IFontDisp_Invoke return 0x%08x instead of S_OK.\n", hres
);
262 VariantClear(&varresult
);
264 IFontDisp_Release(fontdisp
);
267 static HRESULT WINAPI
FontEventsDisp_QueryInterface(IFontEventsDisp
*iface
, REFIID riid
, void **ppvObject
)
269 if (IsEqualIID(riid
, &IID_IFontEventsDisp
) || IsEqualIID(riid
, &IID_IUnknown
) || IsEqualIID(riid
, &IID_IDispatch
))
271 IFontEventsDisp_AddRef(iface
);
278 return E_NOINTERFACE
;
282 static ULONG WINAPI
FontEventsDisp_AddRef(
283 IFontEventsDisp
*iface
)
288 static ULONG WINAPI
FontEventsDisp_Release(
289 IFontEventsDisp
*iface
)
294 static HRESULT WINAPI
FontEventsDisp_GetTypeInfoCount(IFontEventsDisp
*iface
, UINT
*pctinfo
)
296 ok(0, "unexpected call\n");
300 static HRESULT WINAPI
FontEventsDisp_GetTypeInfo(IFontEventsDisp
*iface
, UINT itinfo
, LCID lcid
, ITypeInfo
**pptinfo
)
302 ok(0, "unexpected call\n");
306 static HRESULT WINAPI
FontEventsDisp_GetIDsOfNames(IFontEventsDisp
*iface
, REFIID riid
, LPOLESTR
*names
, UINT cNames
, LCID lcid
,
309 ok(0, "unexpected call\n");
313 static int fonteventsdisp_invoke_called
;
314 static BSTR fonteventsdisp_invoke_arg0
;
316 static HRESULT WINAPI
FontEventsDisp_Invoke(
317 IFontEventsDisp
*iface
,
322 DISPPARAMS
*pDispParams
,
324 EXCEPINFO
*pExcepInfo
,
327 VARIANTARG
*arg0
= &pDispParams
->rgvarg
[0];
329 ok(dispid
== DISPID_FONT_CHANGED
, "expected DISPID_FONT_CHANGED instead of 0x%x\n", dispid
);
330 ok(IsEqualGUID(riid
, &GUID_NULL
), "got riid %s\n", wine_dbgstr_guid(riid
));
331 ok(wFlags
== INVOKE_FUNC
, "expected INVOKE_FUNC instead of 0x%x\n", wFlags
);
332 ok(pDispParams
->cArgs
== 1, "expected arg count 1, got %d\n", pDispParams
->cArgs
);
333 ok(V_VT(arg0
) == VT_BSTR
, "expected VT_BSTR, got %d\n", V_VT(arg0
));
335 fonteventsdisp_invoke_arg0
= SysAllocString(V_BSTR(arg0
));
336 fonteventsdisp_invoke_called
++;
340 static IFontEventsDispVtbl FontEventsDisp_Vtbl
=
342 FontEventsDisp_QueryInterface
,
343 FontEventsDisp_AddRef
,
344 FontEventsDisp_Release
,
345 FontEventsDisp_GetTypeInfoCount
,
346 FontEventsDisp_GetTypeInfo
,
347 FontEventsDisp_GetIDsOfNames
,
348 FontEventsDisp_Invoke
351 static IFontEventsDisp FontEventsDisp
= { &FontEventsDisp_Vtbl
};
359 static void test_font_events_disp(void)
361 static const WCHAR nameW
[] = {'N','a','m','e',0};
362 static const WCHAR sizeW
[] = {'S','i','z','e',0};
363 static const WCHAR boldW
[] = {'B','o','l','d',0};
364 static const WCHAR italicW
[] = {'I','t','a','l','i','c',0};
365 static const WCHAR underlineW
[] = {'U','n','d','e','r','l','i','n','e',0};
366 static const WCHAR strikeW
[] = {'S','t','r','i','k','e','t','h','r','o','u','g','h',0};
367 static const WCHAR weightW
[] = {'W','e','i','g','h','t',0};
368 static const WCHAR charsetW
[] = {'C','h','a','r','s','e','t',0};
370 static const struct font_dispid font_dispids
[] =
372 { DISPID_FONT_NAME
, nameW
},
373 { DISPID_FONT_SIZE
, sizeW
},
374 { DISPID_FONT_BOLD
, boldW
},
375 { DISPID_FONT_ITALIC
, italicW
},
376 { DISPID_FONT_UNDER
, underlineW
},
377 { DISPID_FONT_STRIKE
, strikeW
},
378 { DISPID_FONT_WEIGHT
, weightW
},
379 { DISPID_FONT_CHARSET
, charsetW
}
384 IConnectionPointContainer
*pCPC
;
385 IConnectionPoint
*pCP
;
389 IFontDisp
*pFontDisp
;
390 DISPPARAMS dispparams
;
394 fontdesc
.cbSizeofstruct
= sizeof(fontdesc
);
395 fontdesc
.lpstrName
= MSSansSerif_font
;
396 fontdesc
.cySize
.int64
= 12 * 10000; /* 12 pt */
397 fontdesc
.sWeight
= FW_NORMAL
;
398 fontdesc
.sCharset
= 0;
399 fontdesc
.fItalic
= FALSE
;
400 fontdesc
.fUnderline
= FALSE
;
401 fontdesc
.fStrikethrough
= FALSE
;
403 hr
= pOleCreateFontIndirect(&fontdesc
, &IID_IFont
, (void **)&pFont
);
406 hr
= IFont_QueryInterface(pFont
, &IID_IConnectionPointContainer
, (void **)&pCPC
);
409 hr
= IConnectionPointContainer_FindConnectionPoint(pCPC
, &IID_IFontEventsDisp
, &pCP
);
411 IConnectionPointContainer_Release(pCPC
);
413 hr
= IConnectionPoint_Advise(pCP
, (IUnknown
*)&FontEventsDisp
, &dwCookie
);
415 IConnectionPoint_Release(pCP
);
417 fonteventsdisp_invoke_called
= 0;
418 fonteventsdisp_invoke_arg0
= NULL
;
419 hr
= IFont_put_Bold(pFont
, TRUE
);
422 ok(fonteventsdisp_invoke_called
== 1, "IFontEventDisp::Invoke wasn't called once\n");
423 SysFreeString(fonteventsdisp_invoke_arg0
);
425 hr
= IFont_QueryInterface(pFont
, &IID_IFontDisp
, (void **)&pFontDisp
);
428 for (i
= 0; i
< sizeof(font_dispids
)/sizeof(font_dispids
[0]); i
++)
430 switch (font_dispids
[i
].dispid
)
432 case DISPID_FONT_NAME
:
434 static const WCHAR arialW
[] = {'A','r','i','a','l',0};
435 V_VT(&vararg
) = VT_BSTR
;
436 V_BSTR(&vararg
) = SysAllocString(arialW
);
439 case DISPID_FONT_SIZE
:
440 V_VT(&vararg
) = VT_CY
;
441 S(V_CY(&vararg
)).Lo
= 25;
442 S(V_CY(&vararg
)).Hi
= 0;
444 case DISPID_FONT_BOLD
:
445 V_VT(&vararg
) = VT_BOOL
;
446 V_BOOL(&vararg
) = VARIANT_FALSE
;
448 case DISPID_FONT_ITALIC
:
449 case DISPID_FONT_UNDER
:
450 case DISPID_FONT_STRIKE
:
451 V_VT(&vararg
) = VT_BOOL
;
452 V_BOOL(&vararg
) = VARIANT_TRUE
;
454 case DISPID_FONT_WEIGHT
:
455 V_VT(&vararg
) = VT_I2
;
456 V_I2(&vararg
) = FW_BLACK
;
458 case DISPID_FONT_CHARSET
:
459 V_VT(&vararg
) = VT_I2
;
466 dispparams
.cNamedArgs
= 0;
467 dispparams
.rgdispidNamedArgs
= NULL
;
468 dispparams
.cArgs
= 1;
469 dispparams
.rgvarg
= &vararg
;
470 fonteventsdisp_invoke_called
= 0;
471 hr
= IFontDisp_Invoke(pFontDisp
, font_dispids
[i
].dispid
, &IID_NULL
, 0, DISPATCH_PROPERTYPUT
, &dispparams
, NULL
, NULL
, NULL
);
472 ok(hr
== S_OK
, "dispid=%d, got 0x%08x\n", font_dispids
[i
].dispid
, hr
);
473 ok(fonteventsdisp_invoke_called
== 1, "dispid=%d, DISPID_FONT_CHANGED not called, got %d\n", font_dispids
[i
].dispid
,
474 fonteventsdisp_invoke_called
);
477 ok(!lstrcmpW(font_dispids
[i
].name
, fonteventsdisp_invoke_arg0
), "dispid=%d, got %s, expected %s\n",
478 font_dispids
[i
].dispid
, wine_dbgstr_w(fonteventsdisp_invoke_arg0
), wine_dbgstr_w(font_dispids
[i
].name
));
479 SysFreeString(fonteventsdisp_invoke_arg0
);
481 VariantClear(&vararg
);
484 IFontDisp_Release(pFontDisp
);
486 hr
= IFont_Clone(pFont
, &pFont2
);
488 IFont_Release(pFont
);
490 /* this test shows that the notification routine isn't called again */
491 fonteventsdisp_invoke_called
= 0;
492 hr
= IFont_put_Bold(pFont2
, FALSE
);
494 ok(fonteventsdisp_invoke_called
== 0, "got %d\n", fonteventsdisp_invoke_called
);
496 IFont_Release(pFont2
);
499 static void test_names_ids(WCHAR
* w_name_1
, const char* a_name_1
,
500 WCHAR
* w_name_2
, const char* a_name_2
,
501 LCID lcid
, DISPID id_1
, DISPID id_2
,
502 HRESULT hres_expect
, int numnames
)
505 IFontDisp
*fontdisp
= NULL
;
507 DISPID rgDispId
[2] = {0xdeadbeef, 0xdeadbeef};
508 LPOLESTR names
[2] = {w_name_1
, w_name_2
};
510 pOleCreateFontIndirect(NULL
, &IID_IFontDisp
, &pvObj
);
513 hres
= IFontDisp_GetIDsOfNames(fontdisp
, &IID_NULL
, names
, numnames
,
517 ok(hres
== hres_expect
,
518 "GetIDsOfNames: \"%s\", \"%s\" returns 0x%08x, expected 0x%08x.\n",
519 a_name_1
, a_name_2
, hres
, hres_expect
);
521 /* test first DISPID */
522 ok(rgDispId
[0]==id_1
,
523 "GetIDsOfNames: \"%s\" gets DISPID 0x%08x, expected 0x%08x.\n",
524 a_name_1
, rgDispId
[0], id_1
);
526 /* test second DISPID is present */
529 ok(rgDispId
[1]==id_2
,
530 "GetIDsOfNames: ..., \"%s\" gets DISPID 0x%08x, expected 0x%08x.\n",
531 a_name_2
, rgDispId
[1], id_2
);
534 IFontDisp_Release(fontdisp
);
537 static void test_GetIDsOfNames(void)
539 WCHAR name_Name
[] = {'N','a','m','e',0};
540 WCHAR name_Italic
[] = {'I','t','a','l','i','c',0};
541 WCHAR name_Size
[] = {'S','i','z','e',0};
542 WCHAR name_Bold
[] = {'B','o','l','d',0};
543 WCHAR name_Underline
[] = {'U','n','d','e','r','l','i','n','e',0};
544 WCHAR name_Strikethrough
[] = {'S','t','r','i','k','e','t','h','r','o','u','g','h',0};
545 WCHAR name_Weight
[] = {'W','e','i','g','h','t',0};
546 WCHAR name_Charset
[] = {'C','h','a','r','s','e','t',0};
547 WCHAR name_Foo
[] = {'F','o','o',0};
548 WCHAR name_nAmE
[] = {'n','A','m','E',0};
549 WCHAR name_Nom
[] = {'N','o','m',0};
551 LCID en_us
= MAKELCID(MAKELANGID(LANG_ENGLISH
,SUBLANG_ENGLISH_US
),
553 LCID fr_fr
= MAKELCID(MAKELANGID(LANG_FRENCH
,SUBLANG_FRENCH
),
556 /* Test DISPID_FONTs for the various properties. */
557 test_names_ids(name_Name
, "Name", NULL
, "", en_us
,
558 DISPID_FONT_NAME
, 0, S_OK
,1);
559 test_names_ids(name_Size
, "Size", NULL
, "", en_us
,
560 DISPID_FONT_SIZE
, 0, S_OK
,1);
561 test_names_ids(name_Bold
, "Bold", NULL
, "", en_us
,
562 DISPID_FONT_BOLD
, 0, S_OK
,1);
563 test_names_ids(name_Italic
, "Italic", NULL
, "", en_us
,
564 DISPID_FONT_ITALIC
, 0, S_OK
,1);
565 test_names_ids(name_Underline
, "Underline", NULL
, "", en_us
,
566 DISPID_FONT_UNDER
, 0, S_OK
,1);
567 test_names_ids(name_Strikethrough
, "Strikethrough", NULL
, "", en_us
,
568 DISPID_FONT_STRIKE
, 0, S_OK
,1);
569 test_names_ids(name_Weight
, "Weight", NULL
, "", en_us
,
570 DISPID_FONT_WEIGHT
, 0, S_OK
,1);
571 test_names_ids(name_Charset
, "Charset", NULL
, "", en_us
,
572 DISPID_FONT_CHARSET
, 0, S_OK
,1);
574 /* Capitalization doesn't matter. */
575 test_names_ids(name_nAmE
, "nAmE", NULL
, "", en_us
,
576 DISPID_FONT_NAME
, 0, S_OK
,1);
579 test_names_ids(name_Foo
, "Foo", NULL
, "", en_us
,
580 DISPID_UNKNOWN
, 0, DISP_E_UNKNOWNNAME
,1);
582 /* Pass several names: first is processed, */
583 /* second gets DISPID_UNKNOWN and doesn't affect retval. */
584 test_names_ids(name_Italic
, "Italic", name_Name
, "Name", en_us
,
585 DISPID_FONT_ITALIC
, DISPID_UNKNOWN
, S_OK
,2);
586 test_names_ids(name_Italic
, "Italic", name_Foo
, "Foo", en_us
,
587 DISPID_FONT_ITALIC
, DISPID_UNKNOWN
, S_OK
,2);
589 /* Locale ID has no effect. */
590 test_names_ids(name_Name
, "Name", NULL
, "", fr_fr
,
591 DISPID_FONT_NAME
, 0, S_OK
,1);
592 test_names_ids(name_Nom
, "This is not a font", NULL
, "", fr_fr
,
593 DISPID_UNKNOWN
, 0, DISP_E_UNKNOWNNAME
,1);
595 /* One of the arguments are invalid */
596 test_names_ids(name_Name
, "Name", NULL
, "", en_us
,
597 0xdeadbeef, 0xdeadbeef, E_INVALIDARG
,0);
598 test_names_ids(name_Italic
, "Italic", NULL
, "", en_us
,
599 0xdeadbeef, 0xdeadbeef, E_INVALIDARG
,0);
600 test_names_ids(name_Foo
, "Foo", NULL
, "", en_us
,
601 0xdeadbeef, 0xdeadbeef, E_INVALIDARG
,0);
603 /* Crazy locale ID? */
604 test_names_ids(name_Name
, "Name", NULL
, "", -1,
605 DISPID_FONT_NAME
, 0, S_OK
,1);
608 static void test_Invoke(void)
613 DISPPARAMS dispparams
;
616 hr
= pOleCreateFontIndirect(NULL
, &IID_IFontDisp
, (void **)&fontdisp
);
619 V_VT(&vararg
) = VT_BOOL
;
620 V_BOOL(&vararg
) = VARIANT_FALSE
;
621 dispparams
.cNamedArgs
= 0;
622 dispparams
.rgdispidNamedArgs
= NULL
;
623 dispparams
.cArgs
= 1;
624 dispparams
.rgvarg
= &vararg
;
625 hr
= IFontDisp_Invoke(fontdisp
, DISPID_FONT_BOLD
, &IID_IFontDisp
, 0, DISPATCH_PROPERTYPUT
, &dispparams
, NULL
, NULL
, NULL
);
626 EXPECT_HR(hr
, DISP_E_UNKNOWNINTERFACE
);
628 dispparams
.cArgs
= 0;
629 dispparams
.rgvarg
= NULL
;
630 hr
= IFontDisp_Invoke(fontdisp
, DISPID_FONT_BOLD
, &IID_NULL
, 0, DISPATCH_PROPERTYPUT
, &dispparams
, NULL
, NULL
, NULL
);
631 EXPECT_HR(hr
, DISP_E_BADPARAMCOUNT
);
633 hr
= IFontDisp_Invoke(fontdisp
, DISPID_FONT_BOLD
, &IID_NULL
, 0, DISPATCH_PROPERTYPUT
, NULL
, NULL
, NULL
, NULL
);
634 EXPECT_HR(hr
, DISP_E_PARAMNOTOPTIONAL
);
636 hr
= IFontDisp_Invoke(fontdisp
, DISPID_FONT_BOLD
, &IID_NULL
, 0, DISPATCH_PROPERTYGET
, NULL
, NULL
, NULL
, NULL
);
637 EXPECT_HR(hr
, DISP_E_PARAMNOTOPTIONAL
);
639 hr
= IFontDisp_Invoke(fontdisp
, DISPID_FONT_BOLD
, &IID_NULL
, 0, DISPATCH_PROPERTYGET
, NULL
, &varresult
, NULL
, NULL
);
642 hr
= IFontDisp_Invoke(fontdisp
, DISPID_FONT_BOLD
, &IID_NULL
, 0, DISPATCH_METHOD
, NULL
, &varresult
, NULL
, NULL
);
643 EXPECT_HR(hr
, DISP_E_MEMBERNOTFOUND
);
645 hr
= IFontDisp_Invoke(fontdisp
, 0xdeadbeef, &IID_NULL
, 0, DISPATCH_PROPERTYGET
, NULL
, &varresult
, NULL
, NULL
);
646 EXPECT_HR(hr
, DISP_E_MEMBERNOTFOUND
);
648 dispparams
.cArgs
= 1;
649 dispparams
.rgvarg
= &vararg
;
650 hr
= IFontDisp_Invoke(fontdisp
, DISPID_FONT_BOLD
, &IID_NULL
, 0, DISPATCH_PROPERTYGET
, &dispparams
, &varresult
, NULL
, NULL
);
653 IFontDisp_Release(fontdisp
);
656 static void test_IsEqual(void)
663 /* Basic font description */
664 fd
.cbSizeofstruct
= sizeof(FONTDESC
);
665 fd
.lpstrName
= system_font
;
666 S(fd
.cySize
).Lo
= 100;
667 S(fd
.cySize
).Hi
= 100;
671 fd
.fUnderline
= FALSE
;
672 fd
.fStrikethrough
= FALSE
;
675 pOleCreateFontIndirect(&fd
, &IID_IFont
, (void **)&ifnt
);
677 /* Test equal fonts */
678 pOleCreateFontIndirect(&fd
, &IID_IFont
, (void **)&ifnt2
);
679 hres
= IFont_IsEqual(ifnt
,ifnt2
);
681 "IFont_IsEqual: (EQUAL) Expected S_OK but got 0x%08x\n",hres
);
682 IFont_Release(ifnt2
);
684 /* Check for bad pointer */
685 hres
= IFont_IsEqual(ifnt
,NULL
);
686 ok(hres
== E_POINTER
,
687 "IFont_IsEqual: (NULL) Expected 0x80004003 but got 0x%08x\n",hres
);
690 fd
.lpstrName
= arial_font
;
691 pOleCreateFontIndirect(&fd
, &IID_IFont
, (void **)&ifnt2
);
692 hres
= IFont_IsEqual(ifnt
,ifnt2
);
694 "IFont_IsEqual: (strName) Expected S_FALSE but got 0x%08x\n",hres
);
695 fd
.lpstrName
= system_font
;
696 IFont_Release(ifnt2
);
698 /* Test lo font size */
699 S(fd
.cySize
).Lo
= 10000;
700 pOleCreateFontIndirect(&fd
, &IID_IFont
, (void **)&ifnt2
);
701 hres
= IFont_IsEqual(ifnt
,ifnt2
);
703 "IFont_IsEqual: (Lo font size) Expected S_FALSE but got 0x%08x\n",hres
);
704 S(fd
.cySize
).Lo
= 100;
705 IFont_Release(ifnt2
);
707 /* Test hi font size */
708 S(fd
.cySize
).Hi
= 10000;
709 pOleCreateFontIndirect(&fd
, &IID_IFont
, (void **)&ifnt2
);
710 hres
= IFont_IsEqual(ifnt
,ifnt2
);
712 "IFont_IsEqual: (Hi font size) Expected S_FALSE but got 0x%08x\n",hres
);
713 S(fd
.cySize
).Hi
= 100;
714 IFont_Release(ifnt2
);
716 /* Test font weight */
718 pOleCreateFontIndirect(&fd
, &IID_IFont
, (void **)&ifnt2
);
719 hres
= IFont_IsEqual(ifnt
,ifnt2
);
721 "IFont_IsEqual: (Weight) Expected S_FALSE but got 0x%08x\n",hres
);
723 IFont_Release(ifnt2
);
727 pOleCreateFontIndirect(&fd
, &IID_IFont
, (void **)&ifnt2
);
728 hres
= IFont_IsEqual(ifnt
,ifnt2
);
730 "IFont_IsEqual: (Charset) Expected S_FALSE but got 0x%08x\n",hres
);
732 IFont_Release(ifnt2
);
734 /* Test italic setting */
736 pOleCreateFontIndirect(&fd
, &IID_IFont
, (void **)&ifnt2
);
737 hres
= IFont_IsEqual(ifnt
,ifnt2
);
739 "IFont_IsEqual: (Italic) Expected S_FALSE but got 0x%08x\n",hres
);
741 IFont_Release(ifnt2
);
743 /* Test underline setting */
744 fd
.fUnderline
= TRUE
;
745 pOleCreateFontIndirect(&fd
, &IID_IFont
, (void **)&ifnt2
);
746 hres
= IFont_IsEqual(ifnt
,ifnt2
);
748 "IFont_IsEqual: (Underline) Expected S_FALSE but got 0x%08x\n",hres
);
749 fd
.fUnderline
= FALSE
;
750 IFont_Release(ifnt2
);
752 /* Test strikethrough setting */
753 fd
.fStrikethrough
= TRUE
;
754 pOleCreateFontIndirect(&fd
, &IID_IFont
, (void **)&ifnt2
);
755 hres
= IFont_IsEqual(ifnt
,ifnt2
);
757 "IFont_IsEqual: (Strikethrough) Expected S_FALSE but got 0x%08x\n",hres
);
758 fd
.fStrikethrough
= FALSE
;
759 IFont_Release(ifnt2
);
765 static void test_ReleaseHfont(void)
768 LPVOID pvObj1
= NULL
;
769 LPVOID pvObj2
= NULL
;
776 /* Basic font description */
777 fd
.cbSizeofstruct
= sizeof(FONTDESC
);
778 fd
.lpstrName
= system_font
;
779 S(fd
.cySize
).Lo
= 100;
780 S(fd
.cySize
).Hi
= 100;
784 fd
.fUnderline
= FALSE
;
785 fd
.fStrikethrough
= FALSE
;
787 /* Create HFONTs and IFONTs */
788 pOleCreateFontIndirect(&fd
, &IID_IFont
, &pvObj1
);
790 IFont_get_hFont(ifnt1
,&hfnt1
);
791 fd
.lpstrName
= arial_font
;
792 pOleCreateFontIndirect(&fd
, &IID_IFont
, &pvObj2
);
794 IFont_get_hFont(ifnt2
,&hfnt2
);
796 /* Try invalid HFONT */
797 hres
= IFont_ReleaseHfont(ifnt1
,NULL
);
798 ok(hres
== E_INVALIDARG
,
799 "IFont_ReleaseHfont: (Bad HFONT) Expected E_INVALIDARG but got 0x%08x\n",
802 /* Try to add a bad HFONT */
803 hres
= IFont_ReleaseHfont(ifnt1
,(HFONT
)32);
805 "IFont_ReleaseHfont: (Bad HFONT) Expected S_FALSE but got 0x%08x\n",
808 /* Release all refs */
809 hres
= IFont_ReleaseHfont(ifnt1
,hfnt1
);
811 "IFont_AddRefHfont: (Release ref) Expected S_OK but got 0x%08x\n",
814 hres
= IFont_ReleaseHfont(ifnt2
,hfnt2
);
816 "IFont_AddRefHfont: (Release ref) Expected S_OK but got 0x%08x\n",
819 /* Check that both lists are empty */
820 hres
= IFont_ReleaseHfont(ifnt1
,hfnt1
);
822 "IFont_AddRefHfont: (Release ref) Expected S_FALSE but got 0x%08x\n",
825 /* The list should be empty */
826 hres
= IFont_ReleaseHfont(ifnt2
,hfnt2
);
828 "IFont_AddRefHfont: (Release ref) Expected S_FALSE but got 0x%08x\n",
831 IFont_Release(ifnt1
);
832 IFont_Release(ifnt2
);
835 static void test_AddRefHfont(void)
846 /* Basic font description */
847 fd
.cbSizeofstruct
= sizeof(FONTDESC
);
848 fd
.lpstrName
= system_font
;
849 S(fd
.cySize
).Lo
= 100;
850 S(fd
.cySize
).Hi
= 100;
854 fd
.fUnderline
= FALSE
;
855 fd
.fStrikethrough
= FALSE
;
857 /* Create HFONTs and IFONTs */
858 pOleCreateFontIndirect(&fd
, &IID_IFont
, (void **)&ifnt1
);
859 IFont_get_hFont(ifnt1
,&hfnt1
);
860 fd
.lpstrName
= arial_font
;
861 pOleCreateFontIndirect(&fd
, &IID_IFont
, (void **)&ifnt2
);
862 IFont_get_hFont(ifnt2
,&hfnt2
);
864 /* Try invalid HFONT */
865 hres
= IFont_AddRefHfont(ifnt1
,NULL
);
866 ok(hres
== E_INVALIDARG
,
867 "IFont_AddRefHfont: (Bad HFONT) Expected E_INVALIDARG but got 0x%08x\n",
870 /* Try to add a bad HFONT */
871 hres
= IFont_AddRefHfont(ifnt1
,(HFONT
)32);
873 "IFont_AddRefHfont: (Bad HFONT) Expected S_FALSE but got 0x%08x\n",
876 /* Add simple IFONT HFONT pair */
877 hres
= IFont_AddRefHfont(ifnt1
,hfnt1
);
879 "IFont_AddRefHfont: (Add ref) Expected S_OK but got 0x%08x\n",
882 /* IFONT and HFONT do not have to be the same (always looks at HFONT) */
883 hres
= IFont_AddRefHfont(ifnt2
,hfnt1
);
885 "IFont_AddRefHfont: (Add ref) Expected S_OK but got 0x%08x\n",
888 /* Release all hfnt1 refs */
889 hres
= IFont_ReleaseHfont(ifnt1
,hfnt1
);
891 "IFont_AddRefHfont: (Release ref) Expected S_OK but got 0x%08x\n",
894 hres
= IFont_ReleaseHfont(ifnt1
,hfnt1
);
896 "IFont_AddRefHfont: (Release ref) Expected S_OK but got 0x%08x\n",
899 hres
= IFont_ReleaseHfont(ifnt1
,hfnt1
);
901 "IFont_AddRefHfont: (Release ref) Expected S_OK but got 0x%08x\n",
904 /* Check if hfnt1 is empty */
905 hres
= IFont_ReleaseHfont(ifnt1
,hfnt1
);
907 "IFont_AddRefHfont: (Release ref) Expected S_FALSE but got 0x%08x\n",
910 /* Release all hfnt2 refs */
911 hres
= IFont_ReleaseHfont(ifnt2
,hfnt2
);
913 "IFont_AddRefHfont: (Release ref) Expected S_OK but got 0x%08x\n",
916 /* Check if hfnt2 is empty */
917 hres
= IFont_ReleaseHfont(ifnt2
,hfnt2
);
919 "IFont_AddRefHfont: (Release ref) Expected S_FALSE but got 0x%08x\n",
922 /* Show that releasing an IFONT does not always release it from the HFONT cache. */
924 IFont_Release(ifnt1
);
926 /* Add a reference for destroyed hfnt1 */
927 hres
= IFont_AddRefHfont(ifnt2
,hfnt1
);
929 "IFont_AddRefHfont: (Add ref) Expected S_OK but got 0x%08x\n",
932 /* Decrement reference for destroyed hfnt1 */
933 hres
= IFont_ReleaseHfont(ifnt2
,hfnt1
);
935 hres
== S_FALSE
, /* <= win2k */
936 "IFont_AddRefHfont: (Release ref) Expected S_OK or S_FALSE but got 0x%08x\n",
939 /* Shows that releasing all IFONT's does clear the HFONT cache. */
941 IFont_Release(ifnt2
);
943 /* Need to make a new IFONT for testing */
944 fd
.fUnderline
= TRUE
;
945 pOleCreateFontIndirect(&fd
, &IID_IFont
, (void **)&ifnt3
);
946 IFont_get_hFont(ifnt3
,&hfnt3
);
948 /* Add a reference for destroyed hfnt1 */
949 hres
= IFont_AddRefHfont(ifnt3
,hfnt1
);
951 "IFont_AddRefHfont: (Add ref) Expected S_OK but got 0x%08x\n",
954 /* Decrement reference for destroyed hfnt1 */
955 hres
= IFont_ReleaseHfont(ifnt3
,hfnt1
);
957 "IFont_AddRefHfont: (Release ref) Expected S_OK but got 0x%08x\n",
960 IFont_Release(ifnt3
);
963 static void test_returns(void)
969 fontdesc
.cbSizeofstruct
= sizeof(fontdesc
);
970 fontdesc
.lpstrName
= MSSansSerif_font
;
971 fontdesc
.cySize
.int64
= 12 * 10000; /* 12 pt */
972 fontdesc
.sWeight
= FW_NORMAL
;
973 fontdesc
.sCharset
= 0;
974 fontdesc
.fItalic
= FALSE
;
975 fontdesc
.fUnderline
= FALSE
;
976 fontdesc
.fStrikethrough
= FALSE
;
978 hr
= pOleCreateFontIndirect(&fontdesc
, &IID_IFont
, (void **)&pFont
);
981 hr
= IFont_put_Name(pFont
, NULL
);
982 EXPECT_HR(hr
, CTL_E_INVALIDPROPERTYVALUE
);
984 hr
= IFont_get_Name(pFont
, NULL
);
985 EXPECT_HR(hr
, E_POINTER
);
987 hr
= IFont_get_Size(pFont
, NULL
);
988 EXPECT_HR(hr
, E_POINTER
);
990 hr
= IFont_get_Bold(pFont
, NULL
);
991 EXPECT_HR(hr
, E_POINTER
);
993 IFont_Release(pFont
);
996 static void test_hfont_lifetime(void)
1001 HFONT hfont
, first_hfont
= NULL
;
1006 fontdesc
.cbSizeofstruct
= sizeof(fontdesc
);
1007 fontdesc
.lpstrName
= arial_font
;
1008 fontdesc
.cySize
.int64
= 12 * 10000; /* 12 pt */
1009 fontdesc
.sWeight
= FW_NORMAL
;
1010 fontdesc
.sCharset
= ANSI_CHARSET
;
1011 fontdesc
.fItalic
= FALSE
;
1012 fontdesc
.fUnderline
= FALSE
;
1013 fontdesc
.fStrikethrough
= FALSE
;
1015 hr
= pOleCreateFontIndirect(&fontdesc
, &IID_IFont
, (void **)&font
);
1016 EXPECT_HR(hr
, S_OK
);
1018 hr
= IFont_get_hFont(font
, &hfont
);
1019 EXPECT_HR(hr
, S_OK
);
1021 /* show that if the font is updated the old hfont is deleted when the
1022 new font is realized */
1023 for(i
= 0; i
< 100; i
++)
1025 HFONT last_hfont
= hfont
;
1027 size
.int64
= (i
+ 10) * 20000;
1029 obj_type
= GetObjectType(hfont
);
1030 ok(obj_type
== OBJ_FONT
, "got obj type %d\n", obj_type
);
1032 hr
= IFont_put_Size(font
, size
);
1033 EXPECT_HR(hr
, S_OK
);
1035 /* put_Size doesn't cause the new font to be realized */
1036 obj_type
= GetObjectType(last_hfont
);
1037 ok(obj_type
== OBJ_FONT
, "got obj type %d\n", obj_type
);
1039 hr
= IFont_get_hFont(font
, &hfont
);
1040 EXPECT_HR(hr
, S_OK
);
1042 obj_type
= GetObjectType(last_hfont
);
1043 ok(obj_type
== 0, "%d: got obj type %d\n", i
, obj_type
);
1046 /* now show that if we take a reference on the hfont, it persists
1047 until the font object is released */
1048 for(i
= 0; i
< 100; i
++)
1050 size
.int64
= (i
+ 10) * 20000;
1052 obj_type
= GetObjectType(hfont
);
1053 ok(obj_type
== OBJ_FONT
, "got obj type %d\n", obj_type
);
1055 hr
= IFont_put_Size(font
, size
);
1056 EXPECT_HR(hr
, S_OK
);
1058 hr
= IFont_get_hFont(font
, &hfont
);
1059 EXPECT_HR(hr
, S_OK
);
1061 hr
= IFont_AddRefHfont(font
, hfont
);
1062 EXPECT_HR(hr
, S_OK
);
1064 if(i
== 0) first_hfont
= hfont
;
1065 obj_type
= GetObjectType(first_hfont
);
1066 ok(obj_type
== OBJ_FONT
, "got obj type %d\n", obj_type
);
1069 IFont_Release(font
);
1071 obj_type
= GetObjectType(first_hfont
);
1072 ok(obj_type
== 0, "got obj type %d\n", obj_type
);
1074 /* An AddRefHfont followed by a ReleaseHfont means the font doesn't not persist
1075 through re-realization */
1077 hr
= pOleCreateFontIndirect(&fontdesc
, &IID_IFont
, (void **)&font
);
1078 EXPECT_HR(hr
, S_OK
);
1080 hr
= IFont_get_hFont(font
, &hfont
);
1081 EXPECT_HR(hr
, S_OK
);
1083 for(i
= 0; i
< 100; i
++)
1085 HFONT last_hfont
= hfont
;
1087 size
.int64
= (i
+ 10) * 20000;
1089 obj_type
= GetObjectType(hfont
);
1090 ok(obj_type
== OBJ_FONT
, "got obj type %d\n", obj_type
);
1092 hr
= IFont_put_Size(font
, size
);
1093 EXPECT_HR(hr
, S_OK
);
1095 /* put_Size doesn't cause the new font to be realized */
1096 obj_type
= GetObjectType(last_hfont
);
1097 ok(obj_type
== OBJ_FONT
, "got obj type %d\n", obj_type
);
1099 hr
= IFont_get_hFont(font
, &hfont
);
1100 EXPECT_HR(hr
, S_OK
);
1102 hr
= IFont_AddRefHfont(font
, hfont
);
1103 EXPECT_HR(hr
, S_OK
);
1105 hr
= IFont_ReleaseHfont(font
, hfont
);
1106 EXPECT_HR(hr
, S_OK
);
1108 obj_type
= GetObjectType(last_hfont
);
1109 ok(obj_type
== 0, "%d: got obj type %d\n", i
, obj_type
);
1112 /* Interestingly if we release a nonexistent reference on the hfont,
1113 * it persists until the font object is released
1115 for(i
= 0; i
< 100; i
++)
1117 size
.int64
= (i
+ 10) * 20000;
1119 obj_type
= GetObjectType(hfont
);
1120 ok(obj_type
== OBJ_FONT
, "got obj type %d\n", obj_type
);
1122 hr
= IFont_put_Size(font
, size
);
1123 EXPECT_HR(hr
, S_OK
);
1125 hr
= IFont_get_hFont(font
, &hfont
);
1126 EXPECT_HR(hr
, S_OK
);
1128 hr
= IFont_ReleaseHfont(font
, hfont
);
1129 EXPECT_HR(hr
, S_OK
);
1131 if(i
== 0) first_hfont
= hfont
;
1132 obj_type
= GetObjectType(first_hfont
);
1133 ok(obj_type
== OBJ_FONT
, "got obj type %d\n", obj_type
);
1136 IFont_Release(font
);
1138 obj_type
= GetObjectType(first_hfont
);
1139 ok(obj_type
== 0, "got obj type %d\n", obj_type
);
1141 /* If we take two internal references on a hfont then we can release
1142 it twice. So it looks like there's a total reference count
1143 that includes internal and external references */
1145 hr
= pOleCreateFontIndirect(&fontdesc
, &IID_IFont
, (void **)&font
);
1146 EXPECT_HR(hr
, S_OK
);
1147 hr
= pOleCreateFontIndirect(&fontdesc
, &IID_IFont
, (void **)&font2
);
1148 EXPECT_HR(hr
, S_OK
);
1150 hr
= IFont_get_hFont(font
, &hfont
);
1151 EXPECT_HR(hr
, S_OK
);
1152 hr
= IFont_get_hFont(font2
, &first_hfont
);
1153 EXPECT_HR(hr
, S_OK
);
1155 ok(hfont
== first_hfont
, "fonts differ\n");
1156 hr
= IFont_ReleaseHfont(font
, hfont
);
1157 EXPECT_HR(hr
, S_OK
);
1158 hr
= IFont_ReleaseHfont(font
, hfont
);
1160 EXPECT_HR(hr
, S_OK
);
1161 hr
= IFont_ReleaseHfont(font
, hfont
);
1162 EXPECT_HR(hr
, S_FALSE
);
1164 obj_type
= GetObjectType(hfont
);
1165 ok(obj_type
== OBJ_FONT
, "got obj type %d\n", obj_type
);
1167 IFont_Release(font
);
1169 obj_type
= GetObjectType(hfont
);
1170 ok(obj_type
== OBJ_FONT
, "got obj type %d\n", obj_type
);
1172 IFont_Release(font2
);
1174 obj_type
= GetObjectType(hfont
);
1175 ok(obj_type
== 0, "got obj type %d\n", obj_type
);
1178 static void test_realization(void)
1186 /* Try to create a symbol only font (marlett) with charset
1187 set to ANSI. This will result in another, ANSI, font
1189 fontdesc
.cbSizeofstruct
= sizeof(fontdesc
);
1190 fontdesc
.lpstrName
= marlett_font
;
1191 fontdesc
.cySize
.int64
= 12 * 10000; /* 12 pt */
1192 fontdesc
.sWeight
= FW_NORMAL
;
1193 fontdesc
.sCharset
= ANSI_CHARSET
;
1194 fontdesc
.fItalic
= FALSE
;
1195 fontdesc
.fUnderline
= FALSE
;
1196 fontdesc
.fStrikethrough
= FALSE
;
1198 hr
= pOleCreateFontIndirect(&fontdesc
, &IID_IFont
, (void **)&font
);
1199 EXPECT_HR(hr
, S_OK
);
1201 hr
= IFont_get_Charset(font
, &cs
);
1202 EXPECT_HR(hr
, S_OK
);
1203 ok(cs
== ANSI_CHARSET
, "got charset %d\n", cs
);
1205 IFont_Release(font
);
1207 /* Now create an ANSI font and change the name to marlett */
1209 fontdesc
.lpstrName
= arial_font
;
1211 hr
= pOleCreateFontIndirect(&fontdesc
, &IID_IFont
, (void **)&font
);
1212 EXPECT_HR(hr
, S_OK
);
1214 hr
= IFont_get_Charset(font
, &cs
);
1215 EXPECT_HR(hr
, S_OK
);
1216 ok(cs
== ANSI_CHARSET
, "got charset %d\n", cs
);
1218 name
= SysAllocString(marlett_font
);
1219 hr
= IFont_put_Name(font
, name
);
1220 EXPECT_HR(hr
, S_OK
);
1221 SysFreeString(name
);
1223 hr
= IFont_get_Name(font
, &name
);
1224 EXPECT_HR(hr
, S_OK
);
1225 ok(!lstrcmpiW(name
, marlett_font
), "got name %s\n", wine_dbgstr_w(name
));
1226 SysFreeString(name
);
1228 hr
= IFont_get_Charset(font
, &cs
);
1229 EXPECT_HR(hr
, S_OK
);
1230 ok(cs
== SYMBOL_CHARSET
, "got charset %d\n", cs
);
1232 IFont_Release(font
);
1235 static void test_OleCreateFontIndirect(void)
1238 IUnknown
*unk
, *unk2
;
1242 fontdesc
.cbSizeofstruct
= sizeof(fontdesc
);
1243 fontdesc
.lpstrName
= arial_font
;
1244 fontdesc
.cySize
.int64
= 12 * 10000; /* 12 pt */
1245 fontdesc
.sWeight
= FW_NORMAL
;
1246 fontdesc
.sCharset
= ANSI_CHARSET
;
1247 fontdesc
.fItalic
= FALSE
;
1248 fontdesc
.fUnderline
= FALSE
;
1249 fontdesc
.fStrikethrough
= FALSE
;
1251 hr
= pOleCreateFontIndirect(&fontdesc
, &IID_IFont
, (void**)&font
);
1252 EXPECT_HR(hr
, S_OK
);
1253 IFont_Release(font
);
1255 /* play with cbSizeofstruct value */
1256 fontdesc
.cbSizeofstruct
= sizeof(fontdesc
)-1;
1257 hr
= pOleCreateFontIndirect(&fontdesc
, &IID_IFont
, (void**)&font
);
1258 EXPECT_HR(hr
, S_OK
);
1259 IFont_Release(font
);
1261 fontdesc
.cbSizeofstruct
= sizeof(fontdesc
)+1;
1262 hr
= pOleCreateFontIndirect(&fontdesc
, &IID_IFont
, (void**)&font
);
1263 EXPECT_HR(hr
, S_OK
);
1264 IFont_Release(font
);
1266 fontdesc
.cbSizeofstruct
= 0;
1267 hr
= pOleCreateFontIndirect(&fontdesc
, &IID_IFont
, (void**)&font
);
1268 EXPECT_HR(hr
, S_OK
);
1269 IFont_Release(font
);
1271 hr
= OleInitialize(NULL
);
1272 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1274 hr
= CoGetClassObject(&CLSID_StdFont
, CLSCTX_INPROC_SERVER
, NULL
, &IID_IClassFactory
, (void**)&unk
);
1275 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1277 hr
= IUnknown_QueryInterface(unk
, &IID_IUnknown
, (void**)&unk2
);
1278 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
1280 IUnknown_Release(unk
);
1281 IUnknown_Release(unk2
);
1288 hOleaut32
= GetModuleHandleA("oleaut32.dll");
1289 pOleCreateFontIndirect
= (void*)GetProcAddress(hOleaut32
, "OleCreateFontIndirect");
1290 if (!pOleCreateFontIndirect
)
1292 win_skip("OleCreateFontIndirect not available\n");
1296 test_QueryInterface();
1299 test_font_events_disp();
1300 test_GetIDsOfNames();
1303 test_ReleaseHfont();
1306 test_hfont_lifetime();
1308 test_OleCreateFontIndirect();