olefont: test GetIDsOfNames

Walt Ogburn reuben at ugcs.caltech.edu
Sat Oct 8 13:01:24 CDT 2005


Changelog
	Test GetIDsOfNames for IFontDisp.

Passes after previous two patches are applied.
-------------- next part --------------
Index: dlls/oleaut32/tests/olefont.c
===================================================================
RCS file: /home/wine/wine/dlls/oleaut32/tests/olefont.c,v
retrieving revision 1.9
diff -u -p -r1.9 olefont.c
--- dlls/oleaut32/tests/olefont.c	26 Sep 2005 09:52:25 -0000	1.9
+++ dlls/oleaut32/tests/olefont.c	8 Oct 2005 17:39:25 -0000
@@ -159,6 +159,89 @@ void test_type_info(void)
 	IFontDisp_Release(fontdisp);
 }
 
+/* Test GetIDsOfNames with one or two names passed.  Give both unicode */
+/* and ASCII strings so useful messages can be printed.                */
+void test_names_ids(WCHAR* w_name_1, const char* a_name_1,
+                    WCHAR* w_name_2, const char* a_name_2,
+                    LCID lcid, DISPID id_1, DISPID id_2, HRESULT hres_expect)
+{
+        LPVOID pvObj = NULL;
+	IFontDisp *fontdisp = NULL;
+	HRESULT hres;
+	DISPID rgDispId[2] = {0xdeadbeef, 0xdeadbeef};
+	LPOLESTR names[2] = {w_name_1, w_name_2};
+	int numnames;
+
+	pOleCreateFontIndirect(NULL, &IID_IFontDisp, &pvObj);
+        fontdisp = pvObj;
+
+	if (w_name_2 == NULL) numnames = 1;
+		else numnames = 2;
+
+        hres = IFontDisp_GetIDsOfNames(fontdisp, &IID_NULL, names, numnames,
+		lcid, rgDispId);
+	ok(hres == hres_expect,
+		"GION on \"%s\", \"%s\" returns 0x%08lx, not 0x%08lx.\n",
+		a_name_1, a_name_2, hres, hres_expect);
+
+	ok(rgDispId[0]==id_1,
+                "GION on \"%s\" gets DISPID 0x%08lx, not 0x%08lx.\n",
+                a_name_1, rgDispId[0], id_1);
+        if (numnames == 2)
+		ok(rgDispId[1]==id_2,
+                	"GION on ..., \"%s\" gets DISPID 0x%08lx, not 0x%08lx.\n",
+                	a_name_2, rgDispId[1], id_2);
+
+	IFontDisp_Release(fontdisp);
+}
+
+/*    This test also tests the behavior of      */
+/*    ITypeInfo_GetIDsOfNames in typelib.c.     */
+void test_GetIDsOfNames(void)
+{
+	WCHAR name_Name[] = {'N','a','m','e',0};
+	WCHAR name_Italic[] = {'I','t','a','l','i','c',0};
+	WCHAR name_Foo[] = {'F','o','o',0};
+	WCHAR name_nAmE[] = {'n','A','m','E',0};
+	WCHAR name_Nom[] = {'N','o','m',0};
+
+        LCID en_us = MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),
+                SORT_DEFAULT);
+	LCID fr_fr = MAKELCID(MAKELANGID(LANG_FRENCH,SUBLANG_FRENCH),
+                SORT_DEFAULT);
+
+	/* Good member names: get S_OK, correct DISPID. */
+	test_names_ids(name_Name, "Name", NULL, "", en_us,
+		DISPID_FONT_NAME, 0, S_OK);
+	test_names_ids(name_Italic, "Italic", NULL, "", en_us,
+		DISPID_FONT_ITALIC, 0, S_OK);
+
+	/* Capitalization doesn't matter. */
+	test_names_ids(name_nAmE, "nAmE", NULL, "", en_us,
+		DISPID_FONT_NAME, 0, S_OK);
+
+	/* Unknown name. */
+	test_names_ids(name_Foo, "Foo", NULL, "", en_us,
+		DISPID_UNKNOWN, 0, DISP_E_UNKNOWNNAME);
+
+	/* Pass several names: first is processed,                */
+	/* second gets DISPID_UNKNOWN and doesn't affect retval.  */
+	test_names_ids(name_Italic, "Italic", name_Name, "Name", en_us,
+		DISPID_FONT_ITALIC, DISPID_UNKNOWN, S_OK);
+        test_names_ids(name_Italic, "Italic", name_Foo, "Foo", en_us,
+                DISPID_FONT_ITALIC, DISPID_UNKNOWN, S_OK);
+
+	/* Locale ID has no effect. */
+	test_names_ids(name_Name, "Name", NULL, "", fr_fr,
+		DISPID_FONT_NAME, 0, S_OK);
+        test_names_ids(name_Nom, "Nom", NULL, "", fr_fr,
+                DISPID_UNKNOWN, 0, DISP_E_UNKNOWNNAME);
+
+	/* Crazy locale ID? */
+	test_names_ids(name_Name, "Name", NULL, "", -1,
+		DISPID_FONT_NAME, 0, S_OK);
+}
+
 START_TEST(olefont)
 {
 	hOleaut32 = LoadLibraryA("oleaut32.dll");    
@@ -168,6 +251,7 @@ START_TEST(olefont)
 
 	test_QueryInterface();
 	test_type_info();
+        test_GetIDsOfNames();
 
 	/* Test various size operations and conversions. */
 	/* Add more as needed. */


More information about the wine-patches mailing list