Module: wine Branch: master Commit: c4ba8a8c87b3fab44422546f70f1bf0dfc433fa4 URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=c4ba8a8c87b3fab44422546f...
Author: Benjamin Arai me@benjaminarai.com Date: Sun Aug 13 23:32:23 2006 -0700
oleaut32: Conformance test for olefont:ReleaseHfont.
---
dlls/oleaut32/tests/olefont.c | 77 ++++++++++++++++++++++++++++++++++++++++- 1 files changed, 75 insertions(+), 2 deletions(-)
diff --git a/dlls/oleaut32/tests/olefont.c b/dlls/oleaut32/tests/olefont.c index 42eb332..73c460f 100644 --- a/dlls/oleaut32/tests/olefont.c +++ b/dlls/oleaut32/tests/olefont.c @@ -599,6 +599,78 @@ static void test_IsEqual() IFont_Release(ifnt); }
+static void test_ReleaseHfont(void) +{ + FONTDESC fd; + static const WCHAR system_font[] = { 'S','y','s','t','e','m',0 }; + static const WCHAR arial_font[] = { 'A','r','i','a','l',0 }; + LPVOID pvObj1 = NULL; + LPVOID pvObj2 = NULL; + IFont* ifnt1 = NULL; + IFont* ifnt2 = NULL; + HFONT hfnt1 = 0; + HFONT hfnt2 = 0; + HRESULT hres; + + /* Basic font description */ + fd.cbSizeofstruct = sizeof(FONTDESC); + fd.lpstrName = (WCHAR*)system_font; + S(fd.cySize).Lo = 100; + S(fd.cySize).Hi = 100; + fd.sWeight = 0; + fd.sCharset = 0; + fd.fItalic = 0; + fd.fUnderline = 0; + fd.fStrikethrough = 0; + + /* Create HFONTs and IFONTs */ + pOleCreateFontIndirect(&fd, &IID_IFont, &pvObj1); + ifnt1 = pvObj1; + IFont_get_hFont(ifnt1,&hfnt1); + fd.lpstrName = (WCHAR*)arial_font; + pOleCreateFontIndirect(&fd, &IID_IFont, &pvObj2); + ifnt2 = pvObj2; + IFont_get_hFont(ifnt2,&hfnt2); + + /* Try invalid HFONT */ + hres = IFont_ReleaseHfont(ifnt1,(HFONT)0); + ok(hres == E_INVALIDARG, + "IFont_ReleaseHfont: (Bad HFONT) Expected E_INVALIDARG but got 0x%08lx\n", + hres); + + /* Try to add a bad HFONT */ + hres = IFont_ReleaseHfont(ifnt1,(HFONT)32); + todo_wine {ok(hres == S_FALSE, + "IFont_ReleaseHfont: (Bad HFONT) Expected S_FALSE but got 0x%08lx\n", + hres);} + + /* Release all refs */ + hres = IFont_ReleaseHfont(ifnt1,hfnt1); + ok(hres == S_OK, + "IFont_AddRefHfont: (Release ref) Expected S_OK but got 0x%08lx\n", + hres); + + hres = IFont_ReleaseHfont(ifnt2,hfnt2); + ok(hres == S_OK, + "IFont_AddRefHfont: (Release ref) Expected S_OK but got 0x%08lx\n", + hres); + + /* Check that both lists are empty */ + hres = IFont_ReleaseHfont(ifnt1,hfnt1); + todo_wine {ok(hres == S_FALSE, + "IFont_AddRefHfont: (Release ref) Expected S_FALSE but got 0x%08lx\n", + hres);} + + /* The list should be empty */ + hres = IFont_ReleaseHfont(ifnt2,hfnt2); + todo_wine {ok(hres == S_FALSE, + "IFont_AddRefHfont: (Release ref) Expected S_FALSE but got 0x%08lx\n", + hres);} + + IFont_Release(ifnt1); + IFont_Release(ifnt2); +} + START_TEST(olefont) { hOleaut32 = LoadLibraryA("oleaut32.dll"); @@ -616,11 +688,12 @@ START_TEST(olefont) test_ifont_sizes(180000, 0, 72, 1270, -36, "ratio2"); /* 2nd part of ratio */
/* These depend on details of how IFont rounds sizes internally. */ - /* test_ifont_sizes(0, 0, 72, 2540, 0, "zero size"); */ /* zero size */ - /* test_ifont_sizes(186000, 0, 72, 2540, -19, "rounding"); */ /* test rounding */ + test_ifont_sizes(0, 0, 72, 2540, 0, "zero size"); /* zero size */ + test_ifont_sizes(186000, 0, 72, 2540, -19, "rounding"); /* test rounding */
test_font_events_disp(); test_GetIDsOfNames(); test_Invoke(); test_IsEqual(); + test_ReleaseHfont(); }