Commit 36f11297 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

OLE: Add tests for the typelib version of ITypeComp_Bind.

parent 806cdce3
......@@ -27,6 +27,8 @@
#include "winbase.h"
#include "oleauto.h"
#define ok_ole_success(hr, func) ok(hr == S_OK, #func " failed with error 0x%08lx\n", hr)
static void ref_count_test(LPCWSTR type_lib)
{
ITypeLib *iface;
......@@ -56,8 +58,164 @@ static void ref_count_test(LPCWSTR type_lib)
ok(ITypeLib_Release(iface) == 0, "ITypeLib should be destroyed here.\n");
}
static void test_TypeComp(void)
{
ITypeLib *pTypeLib;
ITypeComp *pTypeComp;
HRESULT hr;
ULONG ulHash;
DESCKIND desckind;
BINDPTR bindptr;
ITypeInfo *pTypeInfo;
static WCHAR wszStdOle2[] = {'s','t','d','o','l','e','2','.','t','l','b',0};
static WCHAR wszStdFunctions[] = {'S','t','d','F','u','n','c','t','i','o','n','s',0};
static WCHAR wszSavePicture[] = {'S','a','v','e','P','i','c','t','u','r','e',0};
static WCHAR wszOLE_TRISTATE[] = {'O','L','E','_','T','R','I','S','T','A','T','E',0};
static WCHAR wszUnchecked[] = {'U','n','c','h','e','c','k','e','d',0};
static WCHAR wszIUnknown[] = {'I','U','n','k','n','o','w','n',0};
static WCHAR wszFont[] = {'F','o','n','t',0};
static WCHAR wszGUID[] = {'G','U','I','D',0};
static WCHAR wszStdPicture[] = {'S','t','d','P','i','c','t','u','r','e',0};
static WCHAR wszOLE_COLOR[] = {'O','L','E','_','C','O','L','O','R',0};
hr = LoadTypeLib(wszStdOle2, &pTypeLib);
ok_ole_success(hr, LoadTypeLib);
hr = ITypeLib_GetTypeComp(pTypeLib, &pTypeComp);
ok_ole_success(hr, ITypeLib_GetTypeComp);
/* test getting a TKIND_MODULE */
ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszStdFunctions);
hr = ITypeComp_Bind(pTypeComp, wszStdFunctions, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
ok_ole_success(hr, ITypeComp_Bind);
ok(desckind == DESCKIND_TYPECOMP,
"desckind should have been DESCKIND_TYPECOMP instead of %d\n",
desckind);
ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
ITypeComp_Release(bindptr.lptcomp);
/* test getting a TKIND_MODULE with INVOKE_PROPERTYGET */
ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszStdFunctions);
hr = ITypeComp_Bind(pTypeComp, wszStdFunctions, ulHash, INVOKE_PROPERTYGET, &pTypeInfo, &desckind, &bindptr);
ok_ole_success(hr, ITypeComp_Bind);
ok(desckind == DESCKIND_TYPECOMP,
"desckind should have been DESCKIND_TYPECOMP instead of %d\n",
desckind);
ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
/* test getting a function within a TKIND_MODULE */
ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszSavePicture);
hr = ITypeComp_Bind(pTypeComp, wszSavePicture, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
ok_ole_success(hr, ITypeComp_Bind);
ok(desckind == DESCKIND_FUNCDESC,
"desckind should have been DESCKIND_FUNCDESC instead of %d\n",
desckind);
ok(bindptr.lpfuncdesc != NULL, "bindptr.lpfuncdesc should not have been set to NULL\n");
ITypeInfo_ReleaseFuncDesc(pTypeInfo, bindptr.lpfuncdesc);
ITypeInfo_Release(pTypeInfo);
/* test getting a function within a TKIND_MODULE with INVOKE_PROPERTYGET */
ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszSavePicture);
hr = ITypeComp_Bind(pTypeComp, wszSavePicture, ulHash, INVOKE_PROPERTYGET, &pTypeInfo, &desckind, &bindptr);
todo_wine ok(hr == TYPE_E_TYPEMISMATCH,
"ITypeComp_Bind should have failed with TYPE_E_TYPEMISMATCH instead of 0x%08lx\n",
hr);
ok(desckind == DESCKIND_NONE,
"desckind should have been DESCKIND_NONE instead of %d\n",
desckind);
ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
/* test getting a TKIND_ENUM */
ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszOLE_TRISTATE);
hr = ITypeComp_Bind(pTypeComp, wszOLE_TRISTATE, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
ok_ole_success(hr, ITypeComp_Bind);
ok(desckind == DESCKIND_TYPECOMP,
"desckind should have been DESCKIND_TYPECOMP instead of %d\n",
desckind);
ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
ITypeComp_Release(bindptr.lptcomp);
/* test getting a value within a TKIND_ENUM */
ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszUnchecked);
hr = ITypeComp_Bind(pTypeComp, wszUnchecked, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
ok_ole_success(hr, ITypeComp_Bind);
ok(desckind == DESCKIND_VARDESC,
"desckind should have been DESCKIND_VARDESC instead of %d\n",
desckind);
ITypeInfo_ReleaseVarDesc(pTypeInfo, bindptr.lpvardesc);
ITypeInfo_Release(pTypeInfo);
/* test getting a TKIND_INTERFACE */
ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszIUnknown);
hr = ITypeComp_Bind(pTypeComp, wszIUnknown, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
ok_ole_success(hr, ITypeComp_Bind);
ok(desckind == DESCKIND_NONE,
"desckind should have been DESCKIND_NONE instead of %d\n",
desckind);
ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
/* test getting a TKIND_DISPATCH */
ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszFont);
hr = ITypeComp_Bind(pTypeComp, wszFont, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
ok_ole_success(hr, ITypeComp_Bind);
ok(desckind == DESCKIND_NONE,
"desckind should have been DESCKIND_NONE instead of %d\n",
desckind);
ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
/* test getting a TKIND_RECORD/TKIND_ALIAS */
ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszGUID);
hr = ITypeComp_Bind(pTypeComp, wszGUID, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
ok_ole_success(hr, ITypeComp_Bind);
ok(desckind == DESCKIND_NONE,
"desckind should have been DESCKIND_NONE instead of %d\n",
desckind);
ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
/* test getting a TKIND_ALIAS */
ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszOLE_COLOR);
hr = ITypeComp_Bind(pTypeComp, wszOLE_COLOR, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
ok_ole_success(hr, ITypeComp_Bind);
ok(desckind == DESCKIND_NONE,
"desckind should have been DESCKIND_NONE instead of %d\n",
desckind);
ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
/* test getting a TKIND_COCLASS */
ulHash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, wszStdPicture);
hr = ITypeComp_Bind(pTypeComp, wszStdPicture, ulHash, 0, &pTypeInfo, &desckind, &bindptr);
ok_ole_success(hr, ITypeComp_Bind);
ok(desckind == DESCKIND_NONE,
"desckind should have been DESCKIND_NONE instead of %d\n",
desckind);
ok(!pTypeInfo, "pTypeInfo should have been set to NULL\n");
ok(!bindptr.lptcomp, "bindptr should have been set to NULL\n");
ITypeComp_Release(pTypeComp);
ITypeLib_Release(pTypeLib);
}
START_TEST(typelib)
{
static const WCHAR type_lib_stdole32[] = {'s','t','d','o','l','e','3','2','.','t','l','b',0};
ref_count_test(type_lib_stdole32);
test_TypeComp();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment