jscript/tests: Add more tests for the script TypeInfo.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com> Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
691faf0eae
commit
a416b0380e
|
@ -986,12 +986,16 @@ static void test_typeinfo(const WCHAR *parse_func_name)
|
|||
VARDESC *vardesc;
|
||||
IDispatchEx *disp;
|
||||
DESCKIND desckind;
|
||||
INT implTypeFlags;
|
||||
UINT count, index;
|
||||
HREFTYPE reftype;
|
||||
BINDPTR bindptr;
|
||||
MEMBERID memid;
|
||||
TYPEATTR *attr;
|
||||
UINT index;
|
||||
HRESULT hr;
|
||||
WCHAR str[64], *names = str;
|
||||
BSTR bstr, bstrs[5];
|
||||
void *obj;
|
||||
int i;
|
||||
|
||||
if (parse_func_name)
|
||||
|
@ -1053,6 +1057,20 @@ static void test_typeinfo(const WCHAR *parse_func_name)
|
|||
ok(typeinfo != typeinfo2, "TypeInfo was not supposed to be shared.\n");
|
||||
ITypeInfo_Release(typeinfo2);
|
||||
|
||||
obj = (void*)0xdeadbeef;
|
||||
hr = ITypeInfo_CreateInstance(typeinfo, NULL, NULL, NULL);
|
||||
ok(hr == E_INVALIDARG, "CreateInstance returned: %08x\n", hr);
|
||||
hr = ITypeInfo_CreateInstance(typeinfo, NULL, NULL, &obj);
|
||||
ok(hr == TYPE_E_BADMODULEKIND, "CreateInstance returned: %08x\n", hr);
|
||||
hr = ITypeInfo_CreateInstance(typeinfo, NULL, &IID_IDispatch, &obj);
|
||||
ok(hr == TYPE_E_BADMODULEKIND, "CreateInstance returned: %08x\n", hr);
|
||||
ok(!obj, "Unexpected non-null obj %p.\n", obj);
|
||||
|
||||
hr = ITypeInfo_GetDocumentation(typeinfo, MEMBERID_NIL, &bstr, NULL, NULL, NULL);
|
||||
ok(hr == S_OK, "GetDocumentation(MEMBERID_NIL) failed: %08x\n", hr);
|
||||
ok(!lstrcmpW(bstr, L"JScriptTypeInfo"), "Unexpected TypeInfo name %s\n", wine_dbgstr_w(bstr));
|
||||
SysFreeString(bstr);
|
||||
|
||||
hr = ITypeInfo_GetTypeAttr(typeinfo, &attr);
|
||||
ok(hr == S_OK, "GetTypeAttr failed: %08x\n", hr);
|
||||
ok(IsEqualGUID(&attr->guid, &IID_IScriptTypeInfo), "Unexpected GUID %s\n", wine_dbgstr_guid(&attr->guid));
|
||||
|
@ -1071,6 +1089,45 @@ static void test_typeinfo(const WCHAR *parse_func_name)
|
|||
ok(attr->idldescType.wIDLFlags == IDLFLAG_NONE, "Unexpected idldescType.wIDLFlags 0x%x\n", attr->idldescType.wIDLFlags);
|
||||
ITypeInfo_ReleaseTypeAttr(typeinfo, attr);
|
||||
|
||||
/* The type inherits from IDispatch */
|
||||
hr = ITypeInfo_GetImplTypeFlags(typeinfo, 0, NULL);
|
||||
ok(hr == E_INVALIDARG, "GetImplTypeFlags returned: %08x\n", hr);
|
||||
hr = ITypeInfo_GetImplTypeFlags(typeinfo, 1, &implTypeFlags);
|
||||
ok(hr == TYPE_E_ELEMENTNOTFOUND, "GetImplTypeFlags returned: %08x\n", hr);
|
||||
hr = ITypeInfo_GetImplTypeFlags(typeinfo, -1, &implTypeFlags);
|
||||
ok(hr == TYPE_E_ELEMENTNOTFOUND, "GetImplTypeFlags returned: %08x\n", hr);
|
||||
hr = ITypeInfo_GetImplTypeFlags(typeinfo, 0, &implTypeFlags);
|
||||
ok(hr == S_OK, "GetImplTypeFlags failed: %08x\n", hr);
|
||||
ok(implTypeFlags == 0, "Unexpected implTypeFlags 0x%x\n", implTypeFlags);
|
||||
|
||||
hr = ITypeInfo_GetRefTypeOfImplType(typeinfo, 0, NULL);
|
||||
ok(hr == E_INVALIDARG, "GetRefTypeOfImplType returned: %08x\n", hr);
|
||||
hr = ITypeInfo_GetRefTypeOfImplType(typeinfo, 1, &reftype);
|
||||
ok(hr == TYPE_E_ELEMENTNOTFOUND, "GetRefTypeOfImplType returned: %08x\n", hr);
|
||||
hr = ITypeInfo_GetRefTypeOfImplType(typeinfo, -1, &reftype);
|
||||
ok(hr == TYPE_E_ELEMENTNOTFOUND, "GetRefTypeOfImplType failed: %08x\n", hr);
|
||||
hr = ITypeInfo_GetRefTypeOfImplType(typeinfo, 0, &reftype);
|
||||
ok(hr == S_OK, "GetRefTypeOfImplType failed: %08x\n", hr);
|
||||
ok(reftype == 1, "Unexpected reftype %d\n", reftype);
|
||||
|
||||
hr = ITypeInfo_GetRefTypeInfo(typeinfo, reftype, NULL);
|
||||
ok(hr == E_INVALIDARG, "GetRefTypeInfo returned: %08x\n", hr);
|
||||
hr = ITypeInfo_GetRefTypeInfo(typeinfo, -1, &typeinfo2);
|
||||
ok(hr == E_INVALIDARG, "GetRefTypeInfo returned: %08x\n", hr);
|
||||
hr = ITypeInfo_GetRefTypeInfo(typeinfo, 4, &typeinfo2);
|
||||
ok(hr == E_FAIL, "GetRefTypeInfo returned: %08x\n", hr);
|
||||
hr = ITypeInfo_GetRefTypeInfo(typeinfo, 0, &typeinfo2);
|
||||
ok(hr == S_OK, "GetRefTypeInfo failed: %08x\n", hr);
|
||||
ok(typeinfo == typeinfo2, "Unexpected TypeInfo %p (expected %p)\n", typeinfo2, typeinfo);
|
||||
ITypeInfo_Release(typeinfo2);
|
||||
hr = ITypeInfo_GetRefTypeInfo(typeinfo, reftype, &typeinfo2);
|
||||
ok(hr == S_OK, "GetRefTypeInfo failed: %08x\n", hr);
|
||||
hr = ITypeInfo_GetDocumentation(typeinfo2, MEMBERID_NIL, &bstr, NULL, NULL, NULL);
|
||||
ok(hr == S_OK, "GetDocumentation(MEMBERID_NIL) failed: %08x\n", hr);
|
||||
ok(!lstrcmpW(bstr, L"IDispatch"), "Unexpected TypeInfo name %s\n", wine_dbgstr_w(bstr));
|
||||
ITypeInfo_Release(typeinfo2);
|
||||
SysFreeString(bstr);
|
||||
|
||||
/* GetIDsOfNames looks into the inherited types as well */
|
||||
wcscpy(str, L"queryinterface");
|
||||
hr = ITypeInfo_GetIDsOfNames(typeinfo, NULL, 1, &memid);
|
||||
|
@ -1088,6 +1145,52 @@ static void test_typeinfo(const WCHAR *parse_func_name)
|
|||
hr = ITypeInfo_GetIDsOfNames(typeinfo, &names, 1, &memid);
|
||||
ok(hr == S_OK, "GetIDsOfNames failed: %08x\n", hr);
|
||||
ok(!lstrcmpW(str, L"Math"), "Unexpected string %s\n", wine_dbgstr_w(str));
|
||||
hr = ITypeInfo_GetNames(typeinfo, memid, NULL, 1, &count);
|
||||
ok(hr == E_INVALIDARG, "GetNames returned: %08x\n", hr);
|
||||
hr = ITypeInfo_GetNames(typeinfo, memid, bstrs, 1, NULL);
|
||||
ok(hr == E_INVALIDARG, "GetNames returned: %08x\n", hr);
|
||||
hr = ITypeInfo_GetNames(typeinfo, memid, bstrs, 0, &count);
|
||||
ok(hr == S_OK, "GetNames failed: %08x\n", hr);
|
||||
ok(count == 0, "Unexpected count %u\n", count);
|
||||
hr = ITypeInfo_GetNames(typeinfo, memid, bstrs, ARRAY_SIZE(bstrs), &count);
|
||||
ok(hr == S_OK, "GetNames failed: %08x\n", hr);
|
||||
ok(count == 3, "Unexpected count %u\n", count);
|
||||
ok(!lstrcmpW(bstrs[0], L"math"), "Unexpected function name %s\n", wine_dbgstr_w(bstrs[0]));
|
||||
ok(!lstrcmpW(bstrs[1], L"x"), "Unexpected function first param name %s\n", wine_dbgstr_w(bstrs[1]));
|
||||
ok(!lstrcmpW(bstrs[2], L"y"), "Unexpected function second param name %s\n", wine_dbgstr_w(bstrs[2]));
|
||||
for (i = 0; i < count; i++) SysFreeString(bstrs[i]);
|
||||
|
||||
hr = ITypeInfo_GetMops(typeinfo, memid, NULL);
|
||||
ok(hr == E_INVALIDARG, "GetMops returned: %08x\n", hr);
|
||||
hr = ITypeInfo_GetMops(typeinfo, memid, &bstr);
|
||||
ok(hr == S_OK, "GetMops failed: %08x\n", hr);
|
||||
ok(!bstr, "Unexpected non-null string %s\n", wine_dbgstr_w(bstr));
|
||||
hr = ITypeInfo_GetMops(typeinfo, MEMBERID_NIL, &bstr);
|
||||
ok(hr == S_OK, "GetMops failed: %08x\n", hr);
|
||||
ok(!bstr, "Unexpected non-null string %s\n", wine_dbgstr_w(bstr));
|
||||
|
||||
/* These always fail */
|
||||
obj = (void*)0xdeadbeef;
|
||||
hr = ITypeInfo_AddressOfMember(typeinfo, memid, INVOKE_FUNC, NULL);
|
||||
ok(hr == E_INVALIDARG, "AddressOfMember returned: %08x\n", hr);
|
||||
hr = ITypeInfo_AddressOfMember(typeinfo, memid, INVOKE_FUNC, &obj);
|
||||
ok(hr == TYPE_E_BADMODULEKIND, "AddressOfMember returned: %08x\n", hr);
|
||||
ok(!obj, "Unexpected non-null obj %p.\n", obj);
|
||||
bstr = (BSTR)0xdeadbeef;
|
||||
hr = ITypeInfo_GetDllEntry(typeinfo, memid, INVOKE_FUNC, &bstr, NULL, NULL);
|
||||
ok(hr == TYPE_E_BADMODULEKIND, "GetDllEntry returned: %08x\n", hr);
|
||||
ok(!bstr, "Unexpected non-null str %p.\n", bstr);
|
||||
wcscpy(str, L"Invoke");
|
||||
hr = ITypeInfo_GetIDsOfNames(typeinfo, &names, 1, &memid);
|
||||
ok(hr == S_OK, "GetIDsOfNames failed: %08x\n", hr);
|
||||
obj = (void*)0xdeadbeef;
|
||||
hr = ITypeInfo_AddressOfMember(typeinfo, memid, INVOKE_FUNC, &obj);
|
||||
ok(hr == TYPE_E_BADMODULEKIND, "AddressOfMember returned: %08x\n", hr);
|
||||
ok(!obj, "Unexpected non-null obj %p.\n", obj);
|
||||
bstr = (BSTR)0xdeadbeef;
|
||||
hr = ITypeInfo_GetDllEntry(typeinfo, memid, INVOKE_FUNC, &bstr, NULL, NULL);
|
||||
ok(hr == TYPE_E_BADMODULEKIND, "GetDllEntry returned: %08x\n", hr);
|
||||
ok(!bstr, "Unexpected non-null str %p.\n", bstr);
|
||||
}
|
||||
|
||||
/* Check variable descriptions */
|
||||
|
@ -1099,6 +1202,12 @@ static void test_typeinfo(const WCHAR *parse_func_name)
|
|||
{
|
||||
hr = ITypeInfo_GetVarDesc(typeinfo, i, &vardesc);
|
||||
ok(hr == S_OK, "GetVarDesc(%u) failed: %08x\n", i, hr);
|
||||
hr = ITypeInfo_GetDocumentation(typeinfo, vardesc->memid, &bstr, &bstrs[0], NULL, NULL);
|
||||
ok(hr == S_OK, "[%u] GetDocumentation failed: %08x\n", i, hr);
|
||||
ok(!lstrcmpW(bstr, var[i].name), "[%u] Unexpected variable name %s (expected %s)\n",
|
||||
i, wine_dbgstr_w(bstr), wine_dbgstr_w(var[i].name));
|
||||
ok(!bstrs[0], "[%u] Unexpected doc string %s\n", i, wine_dbgstr_w(bstrs[0]));
|
||||
SysFreeString(bstr);
|
||||
ok(vardesc->memid <= 0xFFFF, "[%u] Unexpected memid 0x%x\n", i, vardesc->memid);
|
||||
ok(vardesc->lpstrSchema == NULL, "[%u] Unexpected lpstrSchema %p\n", i, vardesc->lpstrSchema);
|
||||
ok(vardesc->oInst == 0, "[%u] Unexpected oInst %u\n", i, vardesc->oInst);
|
||||
|
@ -1122,6 +1231,12 @@ static void test_typeinfo(const WCHAR *parse_func_name)
|
|||
{
|
||||
hr = ITypeInfo_GetFuncDesc(typeinfo, i, &funcdesc);
|
||||
ok(hr == S_OK, "GetFuncDesc(%u) failed: %08x\n", i, hr);
|
||||
hr = ITypeInfo_GetDocumentation(typeinfo, funcdesc->memid, &bstr, &bstrs[0], NULL, NULL);
|
||||
ok(hr == S_OK, "[%u] GetDocumentation failed: %08x\n", i, hr);
|
||||
ok(!lstrcmpW(bstr, func[i].name), "[%u] Unexpected function name %s (expected %s)\n",
|
||||
i, wine_dbgstr_w(bstr), wine_dbgstr_w(func[i].name));
|
||||
ok(!bstrs[0], "[%u] Unexpected doc string %s\n", i, wine_dbgstr_w(bstrs[0]));
|
||||
SysFreeString(bstr);
|
||||
ok(funcdesc->memid <= 0xFFFF, "[%u] Unexpected memid 0x%x\n", i, funcdesc->memid);
|
||||
ok(funcdesc->lprgscode == NULL, "[%u] Unexpected lprgscode %p\n", i, funcdesc->lprgscode);
|
||||
ok(func[i].num_args ? (funcdesc->lprgelemdescParam != NULL) : (funcdesc->lprgelemdescParam == NULL),
|
||||
|
|
Loading…
Reference in New Issue