oleaut32 1/3: Conformance test for olefont:ReleaseHfont

Benjamin Arai me at benjaminarai.com
Mon Aug 14 01:32:23 CDT 2006


Hi,

Fixes bug http://bugs.winehq.org/show_bug.cgi?id=4784

The series of patches allow ole applications to modify font attributes
such as bold, italic, size, and underline.  The series of patches
include conformance tests (1/3 & 2/3) for AddRefHfont, ReleaseHfont,
and a patch (3/3) that updates the handling of HFONTs in
oleaut32:olefont.  The HFONTs as shown from the conformance tests
should only be released only when the all the IFONT's have been
released first.

ChangeLog:
  - Conformance test for ReleaseHfont
---
  dlls/oleaut32/tests/olefont.c |   77 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 75 insertions(+), 2 deletions(-)

-- 
Benjamin Arai
http://www.benjaminarai.com
-------------- next part --------------

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();
 }
-- 
1.4.0


More information about the wine-patches mailing list