Commit 1c6649d4 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

vbscript: Add SetScriptState(SCRIPTSTATE_CLOSED) implementation.

parent 8def4dfa
...@@ -1520,10 +1520,81 @@ static void test_vbscript_uninitializing(void) ...@@ -1520,10 +1520,81 @@ static void test_vbscript_uninitializing(void)
hres = IActiveScriptParse_InitNew(parse); hres = IActiveScriptParse_InitNew(parse);
ok(hres == E_UNEXPECTED, "InitNew failed: %08x\n", hres); ok(hres == E_UNEXPECTED, "InitNew failed: %08x\n", hres);
/* initialize again and use SetScriptState(SCRIPTSTATE_CLOSED) to uninitialize it */
SET_EXPECT(GetLCID);
SET_EXPECT(OnStateChange_INITIALIZED);
hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
CHECK_CALLED(GetLCID);
CHECK_CALLED(OnStateChange_INITIALIZED);
SET_EXPECT(OnStateChange_CONNECTED);
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED);
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hres);
CHECK_CALLED(OnStateChange_CONNECTED);
SET_EXPECT(OnStateChange_DISCONNECTED);
SET_EXPECT(OnStateChange_INITIALIZED);
SET_EXPECT(OnStateChange_CLOSED);
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_CLOSED);
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_CLOSED) failed: %08x\n", hres);
CHECK_CALLED(OnStateChange_DISCONNECTED);
CHECK_CALLED(OnStateChange_INITIALIZED);
CHECK_CALLED(OnStateChange_CLOSED);
test_state(script, SCRIPTSTATE_CLOSED);
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_CLOSED);
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_CLOSED) failed: %08x\n", hres);
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_INITIALIZED);
ok(hres == E_UNEXPECTED, "SetScriptState(SCRIPTSTATE_INITIALIZED) failed: %08x\n", hres);
hres = IActiveScript_Close(script);
ok(hres == S_OK, "Close failed: %08x\n", hres);
SET_EXPECT(GetLCID);
SET_EXPECT(OnStateChange_INITIALIZED);
hres = IActiveScript_SetScriptSite(script, &ActiveScriptSite);
ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres);
CHECK_CALLED(GetLCID);
CHECK_CALLED(OnStateChange_INITIALIZED);
SET_EXPECT(OnStateChange_CONNECTED);
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_CONNECTED);
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_CONNECTED) failed: %08x\n", hres);
CHECK_CALLED(OnStateChange_CONNECTED);
SET_EXPECT(OnStateChange_DISCONNECTED);
SET_EXPECT(OnStateChange_INITIALIZED);
SET_EXPECT(OnStateChange_CLOSED);
hres = IActiveScript_Close(script);
ok(hres == S_OK, "Close failed: %08x\n", hres);
CHECK_CALLED(OnStateChange_DISCONNECTED);
CHECK_CALLED(OnStateChange_INITIALIZED);
CHECK_CALLED(OnStateChange_CLOSED);
test_state(script, SCRIPTSTATE_CLOSED);
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_CLOSED);
ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_CLOSED) failed: %08x\n", hres);
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_INITIALIZED);
ok(hres == E_UNEXPECTED, "SetScriptState(SCRIPTSTATE_INITIALIZED) failed: %08x\n", hres);
IActiveScriptParse_Release(parse); IActiveScriptParse_Release(parse);
ref = IActiveScript_Release(script); ref = IActiveScript_Release(script);
ok(!ref, "ref = %d\n", ref); ok(!ref, "ref = %d\n", ref);
script = create_vbscript();
hres = IActiveScript_SetScriptState(script, SCRIPTSTATE_CLOSED);
ok(hres == E_UNEXPECTED, "SetScriptState(SCRIPTSTATE_CLOSED) failed: %08x\n", hres);
ref = IActiveScript_Release(script);
ok(!ref, "ref = %d\n", ref);
} }
static void test_vbscript_release(void) static void test_vbscript_release(void)
......
...@@ -559,7 +559,7 @@ static HRESULT WINAPI VBScript_SetScriptState(IActiveScript *iface, SCRIPTSTATE ...@@ -559,7 +559,7 @@ static HRESULT WINAPI VBScript_SetScriptState(IActiveScript *iface, SCRIPTSTATE
return S_OK; return S_OK;
} }
if(!This->is_initialized || !This->ctx->site) if(!This->is_initialized || (!This->ctx->site && ss != SCRIPTSTATE_CLOSED))
return E_UNEXPECTED; return E_UNEXPECTED;
switch(ss) { switch(ss) {
...@@ -573,6 +573,9 @@ static HRESULT WINAPI VBScript_SetScriptState(IActiveScript *iface, SCRIPTSTATE ...@@ -573,6 +573,9 @@ static HRESULT WINAPI VBScript_SetScriptState(IActiveScript *iface, SCRIPTSTATE
case SCRIPTSTATE_INITIALIZED: case SCRIPTSTATE_INITIALIZED:
decrease_state(This, SCRIPTSTATE_INITIALIZED); decrease_state(This, SCRIPTSTATE_INITIALIZED);
return S_OK; return S_OK;
case SCRIPTSTATE_CLOSED:
decrease_state(This, SCRIPTSTATE_CLOSED);
return S_OK;
case SCRIPTSTATE_DISCONNECTED: case SCRIPTSTATE_DISCONNECTED:
FIXME("unimplemented SCRIPTSTATE_DISCONNECTED\n"); FIXME("unimplemented SCRIPTSTATE_DISCONNECTED\n");
return S_OK; return S_OK;
......
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