olefont: test GetIDsOfNames (fwd)
Walt Ogburn
reuben at ugcs.caltech.edu
Tue Sep 13 21:58:59 CDT 2005
Sorry! Forgot to attach again!
---------- Forwarded message ----------
Date: Tue, 13 Sep 2005 19:57:11 -0700 (PDT)
From: Walt Ogburn <reuben at ugcs.caltech.edu>
To: wine-patches at winehq.org
Subject: olefont: test GetIDsOfNames
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.8
diff -u -p -r1.8 olefont.c
--- dlls/oleaut32/tests/olefont.c 13 Sep 2005 10:36:54 -0000 1.8
+++ dlls/oleaut32/tests/olefont.c 14 Sep 2005 01:26:38 -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