Nikolay Sivov : oleaut32/tests: Some tests for IsMatchingType().

Alexandre Julliard julliard at wine.codeweavers.com
Tue Mar 10 10:10:02 CDT 2015


Module: wine
Branch: master
Commit: 613a65982f53897c8b927fce83ac3f5c65a57411
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=613a65982f53897c8b927fce83ac3f5c65a57411

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Sun Mar  8 18:15:47 2015 +0300

oleaut32/tests: Some tests for IsMatchingType().

---

 dlls/oleaut32/recinfo.c          |  7 +-----
 dlls/oleaut32/tests/test_reg.idl |  8 +++++++
 dlls/oleaut32/tests/test_tlb.idl | 10 ++++++++
 dlls/oleaut32/tests/typelib.c    | 12 +++++++---
 dlls/oleaut32/tests/vartype.c    | 50 ++++++++++++++++++++++++++++++++++++----
 5 files changed, 73 insertions(+), 14 deletions(-)

diff --git a/dlls/oleaut32/recinfo.c b/dlls/oleaut32/recinfo.c
index d6da64a..be61fd5 100644
--- a/dlls/oleaut32/recinfo.c
+++ b/dlls/oleaut32/recinfo.c
@@ -517,12 +517,7 @@ static BOOL WINAPI IRecordInfoImpl_IsMatchingType(IRecordInfo *iface, IRecordInf
     TRACE( "(%p)->(%p)\n", This, info2 );
 
     IRecordInfo_GetGuid( info2, &guid2 );
-    if (IsEqualGUID( &This->guid, &guid2 )) return TRUE;
-
-    FIXME( "records have different guids (%s %s) but could still match\n",
-           debugstr_guid( &This->guid ), debugstr_guid( &guid2 ) );
-
-    return FALSE;
+    return IsEqualGUID( &This->guid, &guid2 );
 }
 
 static PVOID WINAPI IRecordInfoImpl_RecordCreate(IRecordInfo *iface)
diff --git a/dlls/oleaut32/tests/test_reg.idl b/dlls/oleaut32/tests/test_reg.idl
index ff32a1c..efc7c89 100644
--- a/dlls/oleaut32/tests/test_reg.idl
+++ b/dlls/oleaut32/tests/test_reg.idl
@@ -142,4 +142,12 @@ library register_test
         [propputref, id(2)]
         LONG testprop2([in] IUnknown *i);
     }
+
+    /* uuid is same as for test_struct2 in test_tlb.idl, fields are different */
+    [uuid(4029f190-ca4a-4611-aeb9-673983cb96de)]
+    struct test_struct3
+    {
+        UINT32 field;
+        HRESULT hr;
+    };
 }
diff --git a/dlls/oleaut32/tests/test_tlb.idl b/dlls/oleaut32/tests/test_tlb.idl
index 59425be..fa084ec 100644
--- a/dlls/oleaut32/tests/test_tlb.idl
+++ b/dlls/oleaut32/tests/test_tlb.idl
@@ -48,4 +48,14 @@ library Test
 		IDispatch *disp;
 		BSTR bstr;
 	};
+
+        /* identical to 'test_struct', only guid is different */
+	[uuid(4029f190-ca4a-4611-aeb9-673983cb96de)]
+	struct test_struct2
+	{
+		HRESULT hr;
+		VARIANT_BOOL b;
+		IDispatch *disp;
+		BSTR bstr;
+	};
 }
diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c
index 45a56ea..5bde6f2 100644
--- a/dlls/oleaut32/tests/typelib.c
+++ b/dlls/oleaut32/tests/typelib.c
@@ -4002,6 +4002,11 @@ static const type_info info[] = {
   "test_struct",
   "{4029f190-ca4a-4611-aeb9-673983cb96dd}",
   /* kind */ TKIND_RECORD, /*flags*/ 0, /*align*/ 4, /*size*/ sizeof(struct test_struct)
+},
+{
+  "test_struct2",
+  "{4029f190-ca4a-4611-aeb9-673983cb96de}",
+  /* kind */ TKIND_RECORD, /*flags*/ 0, /*align*/ 4, /*size*/ sizeof(struct test_struct)
 }
 };
 
@@ -4210,7 +4215,7 @@ static void test_register_typelib(BOOL system_registration)
     {
         TYPEKIND kind;
         WORD flags;
-    } attrs[12] =
+    } attrs[13] =
     {
         { TKIND_INTERFACE, 0 },
         { TKIND_INTERFACE, TYPEFLAG_FDISPATCHABLE },
@@ -4223,7 +4228,8 @@ static void test_register_typelib(BOOL system_registration)
         { TKIND_DISPATCH,  TYPEFLAG_FDISPATCHABLE },
         { TKIND_DISPATCH,  TYPEFLAG_FDISPATCHABLE },
         { TKIND_DISPATCH,  TYPEFLAG_FDISPATCHABLE },
-        { TKIND_INTERFACE, TYPEFLAG_FDISPATCHABLE }
+        { TKIND_INTERFACE, TYPEFLAG_FDISPATCHABLE },
+        { TKIND_RECORD, 0 }
     };
 
     trace("Starting %s typelib registration tests\n",
@@ -4258,7 +4264,7 @@ static void test_register_typelib(BOOL system_registration)
     ok(hr == S_OK, "got %08x\n", hr);
 
     count = ITypeLib_GetTypeInfoCount(typelib);
-    ok(count == 12, "got %d\n", count);
+    ok(count == 13, "got %d\n", count);
 
     for(i = 0; i < count; i++)
     {
diff --git a/dlls/oleaut32/tests/vartype.c b/dlls/oleaut32/tests/vartype.c
index 7894560..774aee2 100644
--- a/dlls/oleaut32/tests/vartype.c
+++ b/dlls/oleaut32/tests/vartype.c
@@ -6382,24 +6382,32 @@ static void test_recinfo(void)
 {
     static const WCHAR testW[] = {'t','e','s','t',0};
     static WCHAR teststructW[] = {'t','e','s','t','_','s','t','r','u','c','t',0};
+    static WCHAR teststruct2W[] = {'t','e','s','t','_','s','t','r','u','c','t','2',0};
+    static WCHAR teststruct3W[] = {'t','e','s','t','_','s','t','r','u','c','t','3',0};
+    WCHAR filenameW[MAX_PATH], filename2W[MAX_PATH];
+    ITypeInfo *typeinfo, *typeinfo2, *typeinfo3;
+    IRecordInfo *recinfo, *recinfo2, *recinfo3;
     struct test_struct teststruct, testcopy;
-    WCHAR filenameW[MAX_PATH];
+    ITypeLib *typelib, *typelib2;
     const char *filename;
-    IRecordInfo *recinfo;
-    ITypeInfo *typeinfo;
     DummyDispatch dispatch;
-    ITypeLib *typelib;
     TYPEATTR *attr;
     MEMBERID memid;
     UINT16 found;
     HRESULT hr;
     ULONG size;
+    BOOL ret;
 
     filename = create_test_typelib(2);
     MultiByteToWideChar(CP_ACP, 0, filename, -1, filenameW, MAX_PATH);
     hr = LoadTypeLibEx(filenameW, REGKIND_NONE, &typelib);
     ok(hr == S_OK, "got 0x%08x\n", hr);
 
+    filename = create_test_typelib(3);
+    MultiByteToWideChar(CP_ACP, 0, filename, -1, filename2W, MAX_PATH);
+    hr = LoadTypeLibEx(filename2W, REGKIND_NONE, &typelib2);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+
     typeinfo = NULL;
     found = 1;
     hr = ITypeLib_FindName(typelib, teststructW, 0, &typeinfo, &memid, &found);
@@ -6410,9 +6418,40 @@ static void test_recinfo(void)
     ok(IsEqualGUID(&attr->guid, &UUID_test_struct), "got %s\n", wine_dbgstr_guid(&attr->guid));
     ok(attr->typekind == TKIND_RECORD, "got %d\n", attr->typekind);
 
+    typeinfo2 = NULL;
+    found = 1;
+    hr = ITypeLib_FindName(typelib, teststruct2W, 0, &typeinfo2, &memid, &found);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+    ok(typeinfo2 != NULL, "got %p\n", typeinfo2);
+
+    typeinfo3 = NULL;
+    found = 1;
+    hr = ITypeLib_FindName(typelib2, teststruct3W, 0, &typeinfo3, &memid, &found);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+    ok(typeinfo3 != NULL, "got %p\n", typeinfo3);
+
     hr = GetRecordInfoFromTypeInfo(typeinfo, &recinfo);
     ok(hr == S_OK, "got 0x%08x\n", hr);
 
+    hr = GetRecordInfoFromTypeInfo(typeinfo2, &recinfo2);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+
+    hr = GetRecordInfoFromTypeInfo(typeinfo3, &recinfo3);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+
+    /* IsMatchingType, these two records only differ in GUIDs */
+    ret = IRecordInfo_IsMatchingType(recinfo, recinfo2);
+    ok(!ret, "got %d\n", ret);
+
+    /* these two have same GUIDs, but different set of fields */
+    ret = IRecordInfo_IsMatchingType(recinfo2, recinfo3);
+    ok(ret, "got %d\n", ret);
+
+    IRecordInfo_Release(recinfo3);
+    ITypeInfo_Release(typeinfo3);
+    IRecordInfo_Release(recinfo2);
+    ITypeInfo_Release(typeinfo2);
+
     size = 0;
     hr = IRecordInfo_GetSize(recinfo, &size);
     ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -6471,7 +6510,8 @@ static void test_recinfo(void)
 
     ITypeInfo_Release(typeinfo);
     ITypeLib_Release(typelib);
-    DeleteFileA(filename);
+    DeleteFileW(filenameW);
+    DeleteFileW(filename2W);
 }
 
 START_TEST(vartype)




More information about the wine-cvs mailing list