Commit 389eb971 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Added more IActiveScript tests.

parent 01ce1873
...@@ -25,25 +25,207 @@ ...@@ -25,25 +25,207 @@
#include "wine/test.h" #include "wine/test.h"
#define DEFINE_EXPECT(func) \
static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
#define SET_EXPECT(func) \
expect_ ## func = TRUE
#define SET_CALLED(func) \
called_ ## func = TRUE
#define CHECK_EXPECT2(func) \
do { \
ok(expect_ ##func, "unexpected call " #func "\n"); \
called_ ## func = TRUE; \
}while(0)
#define CHECK_EXPECT(func) \
do { \
CHECK_EXPECT2(func); \
expect_ ## func = FALSE; \
}while(0)
#define CHECK_CALLED(func) \
do { \
ok(called_ ## func, "expected " #func "\n"); \
expect_ ## func = called_ ## func = FALSE; \
}while(0)
DEFINE_EXPECT(GetLCID);
DEFINE_EXPECT(OnStateChange_UNINITIALIZED);
DEFINE_EXPECT(OnStateChange_STARTED);
DEFINE_EXPECT(OnStateChange_CONNECTED);
DEFINE_EXPECT(OnStateChange_DISCONNECTED);
DEFINE_EXPECT(OnStateChange_CLOSED);
DEFINE_EXPECT(OnStateChange_INITIALIZED);
DEFINE_EXPECT(OnEnterScript);
DEFINE_EXPECT(OnLeaveScript);
DEFINE_GUID(CLSID_VBScript, 0xb54f3741, 0x5b07, 0x11cf, 0xa4,0xb0, 0x00,0xaa,0x00,0x4a,0x55,0xe8); DEFINE_GUID(CLSID_VBScript, 0xb54f3741, 0x5b07, 0x11cf, 0xa4,0xb0, 0x00,0xaa,0x00,0x4a,0x55,0xe8);
static HRESULT WINAPI ActiveScriptSite_QueryInterface(IActiveScriptSite *iface, REFIID riid, void **ppv)
{
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid))
*ppv = iface;
else if(IsEqualGUID(&IID_IActiveScriptSite, riid))
*ppv = iface;
else
return E_NOINTERFACE;
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
static ULONG WINAPI ActiveScriptSite_AddRef(IActiveScriptSite *iface)
{
return 2;
}
static ULONG WINAPI ActiveScriptSite_Release(IActiveScriptSite *iface)
{
return 1;
}
static HRESULT WINAPI ActiveScriptSite_GetLCID(IActiveScriptSite *iface, LCID *plcid)
{
CHECK_EXPECT(GetLCID);
return E_NOTIMPL;
}
static HRESULT WINAPI ActiveScriptSite_GetItemInfo(IActiveScriptSite *iface, LPCOLESTR pstrName,
DWORD dwReturnMask, IUnknown **ppiunkItem, ITypeInfo **ppti)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ActiveScriptSite_GetDocVersionString(IActiveScriptSite *iface, BSTR *pbstrVersion)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ActiveScriptSite_OnScriptTerminate(IActiveScriptSite *iface,
const VARIANT *pvarResult, const EXCEPINFO *pexcepinfo)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ActiveScriptSite_OnStateChange(IActiveScriptSite *iface, SCRIPTSTATE ssScriptState)
{
switch(ssScriptState) {
case SCRIPTSTATE_UNINITIALIZED:
CHECK_EXPECT(OnStateChange_UNINITIALIZED);
return S_OK;
case SCRIPTSTATE_STARTED:
CHECK_EXPECT(OnStateChange_STARTED);
return S_OK;
case SCRIPTSTATE_CONNECTED:
CHECK_EXPECT(OnStateChange_CONNECTED);
return S_OK;
case SCRIPTSTATE_DISCONNECTED:
CHECK_EXPECT(OnStateChange_DISCONNECTED);
return S_OK;
case SCRIPTSTATE_CLOSED:
CHECK_EXPECT(OnStateChange_CLOSED);
return S_OK;
case SCRIPTSTATE_INITIALIZED:
CHECK_EXPECT(OnStateChange_INITIALIZED);
return S_OK;
default:
ok(0, "unexpected call %d\n", ssScriptState);
}
return E_NOTIMPL;
}
static HRESULT WINAPI ActiveScriptSite_OnScriptError(IActiveScriptSite *iface, IActiveScriptError *pscripterror)
{
ok(0, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI ActiveScriptSite_OnEnterScript(IActiveScriptSite *iface)
{
CHECK_EXPECT(OnEnterScript);
return S_OK;
}
static HRESULT WINAPI ActiveScriptSite_OnLeaveScript(IActiveScriptSite *iface)
{
CHECK_EXPECT(OnLeaveScript);
return S_OK;
}
static const IActiveScriptSiteVtbl ActiveScriptSiteVtbl = {
ActiveScriptSite_QueryInterface,
ActiveScriptSite_AddRef,
ActiveScriptSite_Release,
ActiveScriptSite_GetLCID,
ActiveScriptSite_GetItemInfo,
ActiveScriptSite_GetDocVersionString,
ActiveScriptSite_OnScriptTerminate,
ActiveScriptSite_OnStateChange,
ActiveScriptSite_OnScriptError,
ActiveScriptSite_OnEnterScript,
ActiveScriptSite_OnLeaveScript
};
static IActiveScriptSite ActiveScriptSite = { &ActiveScriptSiteVtbl };
static IActiveScript *create_vbscript(void)
{
IActiveScript *ret;
HRESULT hres;
hres = CoCreateInstance(&CLSID_VBScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
&IID_IActiveScript, (void**)&ret);
ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
return ret;
}
static void test_vbscript(void) static void test_vbscript(void)
{ {
IActiveScriptParse *parser; IActiveScriptParse *parser;
IActiveScript *vbscript; IActiveScript *vbscript;
ULONG ref;
HRESULT hres; HRESULT hres;
hres = CoCreateInstance(&CLSID_VBScript, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER, vbscript = create_vbscript();
&IID_IActiveScript, (void**)&vbscript);
ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
hres = IActiveScript_QueryInterface(vbscript, &IID_IActiveScriptParse, (void**)&parser); hres = IActiveScript_QueryInterface(vbscript, &IID_IActiveScriptParse, (void**)&parser);
ok(hres == S_OK, "Could not get IActiveScriptParse iface: %08x\n", hres); ok(hres == S_OK, "Could not get IActiveScriptParse iface: %08x\n", hres);
SET_EXPECT(GetLCID);
hres = IActiveScript_SetScriptSite(vbscript, &ActiveScriptSite);
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
CHECK_CALLED(GetLCID);
SET_EXPECT(OnStateChange_INITIALIZED);
hres = IActiveScriptParse64_InitNew(parser);
ok(hres == S_OK, "InitNew failed: %08x\n", hres);
CHECK_CALLED(OnStateChange_INITIALIZED);
hres = IActiveScriptParse64_InitNew(parser);
ok(hres == E_UNEXPECTED, "InitNew failed: %08x, expected E_UNEXPECTED\n", hres);
SET_EXPECT(OnStateChange_CLOSED);
hres = IActiveScript_Close(vbscript);
ok(hres == S_OK, "Close failed: %08x\n", hres);
CHECK_CALLED(OnStateChange_CLOSED);
IActiveScriptParse64_Release(parser); IActiveScriptParse64_Release(parser);
IActiveScript_Release(vbscript);
ref = IActiveScript_Release(vbscript);
ok(!ref, "ref = %d\n", ref);
} }
static BOOL check_vbscript(void) static BOOL check_vbscript(void)
{ {
IActiveScript *vbscript; IActiveScript *vbscript;
...@@ -57,7 +239,6 @@ static BOOL check_vbscript(void) ...@@ -57,7 +239,6 @@ static BOOL check_vbscript(void)
return hres == S_OK; return hres == S_OK;
} }
START_TEST(vbscript) START_TEST(vbscript)
{ {
CoInitialize(NULL); CoInitialize(NULL);
......
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