msscript: Implement IScriptControl_[get|put]_State.

Signed-off-by: Gijs Vermeulen <gijsvrm@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Gijs Vermeulen 2018-03-15 21:28:41 +01:00 committed by Alexandre Julliard
parent 0b4688e198
commit 3e0a6da5d3
2 changed files with 76 additions and 4 deletions

View File

@ -91,6 +91,7 @@ struct ScriptControl {
LONG timeout; LONG timeout;
VARIANT_BOOL allow_ui; VARIANT_BOOL allow_ui;
VARIANT_BOOL use_safe_subset; VARIANT_BOOL use_safe_subset;
ScriptControlStates state;
/* connection points */ /* connection points */
ConnectionPoint *cp_list; ConnectionPoint *cp_list;
@ -761,15 +762,31 @@ static HRESULT WINAPI ScriptControl_put_Language(IScriptControl *iface, BSTR lan
static HRESULT WINAPI ScriptControl_get_State(IScriptControl *iface, ScriptControlStates *p) static HRESULT WINAPI ScriptControl_get_State(IScriptControl *iface, ScriptControlStates *p)
{ {
ScriptControl *This = impl_from_IScriptControl(iface); ScriptControl *This = impl_from_IScriptControl(iface);
FIXME("(%p)->(%p)\n", This, p); TRACE("(%p)->(%p)\n", This, p);
return E_NOTIMPL;
if(!p)
return E_POINTER;
if(!This->host)
return E_FAIL;
*p = This->state;
return S_OK;
} }
static HRESULT WINAPI ScriptControl_put_State(IScriptControl *iface, ScriptControlStates state) static HRESULT WINAPI ScriptControl_put_State(IScriptControl *iface, ScriptControlStates state)
{ {
ScriptControl *This = impl_from_IScriptControl(iface); ScriptControl *This = impl_from_IScriptControl(iface);
FIXME("(%p)->(%x)\n", This, state); TRACE("(%p)->(%x)\n", This, state);
return E_NOTIMPL;
if(!This->host)
return E_FAIL;
if(state != Initialized && state != Connected)
return CTL_E_INVALIDPROPERTYVALUE;
This->state = state;
return S_OK;
} }
static HRESULT WINAPI ScriptControl_put_SitehWnd(IScriptControl *iface, LONG hwnd) static HRESULT WINAPI ScriptControl_put_SitehWnd(IScriptControl *iface, LONG hwnd)
@ -1900,6 +1917,7 @@ static HRESULT WINAPI ScriptControl_CreateInstance(IClassFactory *iface, IUnknow
script_control->view_sink = NULL; script_control->view_sink = NULL;
script_control->allow_ui = VARIANT_TRUE; script_control->allow_ui = VARIANT_TRUE;
script_control->use_safe_subset = VARIANT_FALSE; script_control->use_safe_subset = VARIANT_FALSE;
script_control->state = Initialized;
ConnectionPoint_Init(&script_control->cp_scsource, script_control, &DIID_DScriptControlSource); ConnectionPoint_Init(&script_control->cp_scsource, script_control, &DIID_DScriptControlSource);
ConnectionPoint_Init(&script_control->cp_propnotif, script_control, &IID_IPropertyNotifySink); ConnectionPoint_Init(&script_control->cp_propnotif, script_control, &IID_IPropertyNotifySink);

View File

@ -1291,6 +1291,59 @@ static void test_UseSafeSubset(void)
IScriptControl_Release(sc); IScriptControl_Release(sc);
} }
static void test_State(void)
{
IScriptControl *sc;
ScriptControlStates state;
HRESULT hr;
BSTR str;
hr = CoCreateInstance(&CLSID_ScriptControl, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
&IID_IScriptControl, (void**)&sc);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IScriptControl_get_State(sc, NULL);
ok(hr == E_POINTER, "got 0x%08x\n", hr);
hr = IScriptControl_get_State(sc, &state);
ok(hr == E_FAIL, "got 0x%08x\n", hr);
hr = IScriptControl_put_State(sc, Connected);
ok(hr == E_FAIL, "got 0x%08x\n", hr);
str = SysAllocString(vbW);
hr = IScriptControl_put_Language(sc, str);
ok(hr == S_OK, "got 0x%08x\n", hr);
SysFreeString(str);
hr = IScriptControl_get_State(sc, &state);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(state == Initialized, "got %d\n", state);
hr = IScriptControl_put_State(sc, Connected);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IScriptControl_get_State(sc, &state);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(state == Connected, "got %d\n", state);
hr = IScriptControl_put_State(sc, 2);
ok(hr == CTL_E_INVALIDPROPERTYVALUE, "got 0x%08x\n", hr);
hr = IScriptControl_get_State(sc, &state);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(state == Connected, "got %d\n", state);
hr = IScriptControl_put_State(sc, -1);
ok(hr == CTL_E_INVALIDPROPERTYVALUE, "got 0x%08x\n", hr);
hr = IScriptControl_get_State(sc, &state);
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(state == Connected, "got %d\n", state);
IScriptControl_Release(sc);
}
START_TEST(msscript) START_TEST(msscript)
{ {
IUnknown *unk; IUnknown *unk;
@ -1319,6 +1372,7 @@ START_TEST(msscript)
test_AddObject(); test_AddObject();
test_AllowUI(); test_AllowUI();
test_UseSafeSubset(); test_UseSafeSubset();
test_State();
CoUninitialize(); CoUninitialize();
} }