msado15: Implement _Connection_get_State.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alistair Leslie-Hughes 2019-12-11 17:16:52 +01:00 committed by Alexandre Julliard
parent 7f498f4607
commit 131cfe0b65
2 changed files with 41 additions and 2 deletions

View File

@ -34,6 +34,8 @@ struct connection
{
_Connection Connection_iface;
LONG refs;
ObjectStateEnum state;
};
static inline struct connection *impl_from_Connection( _Connection *iface )
@ -271,8 +273,10 @@ static HRESULT WINAPI connection_put_Provider( _Connection *iface, BSTR str )
static HRESULT WINAPI connection_get_State( _Connection *iface, LONG *state )
{
FIXME( "%p, %p\n", iface, state );
return E_NOTIMPL;
struct connection *connection = impl_from_Connection( iface );
TRACE( "%p, %p\n", connection, state );
*state = connection->state;
return S_OK;
}
static HRESULT WINAPI connection_OpenSchema( _Connection *iface, SchemaEnum schema, VARIANT restrictions,
@ -337,6 +341,7 @@ HRESULT Connection_create( void **obj )
if (!(connection = heap_alloc( sizeof(*connection) ))) return E_OUTOFMEMORY;
connection->Connection_iface.lpVtbl = &connection_vtbl;
connection->refs = 1;
connection->state = adStateClosed;
*obj = &connection->Connection_iface;
TRACE( "returning iface %p\n", *obj );

View File

@ -280,9 +280,43 @@ static void test_Stream(void)
ok( !refs, "got %d\n", refs );
}
static void test_Connection(void)
{
HRESULT hr;
_Connection *connection;
IRunnableObject *runtime;
ISupportErrorInfo *errorinfo;
LONG state;
hr = CoCreateInstance(&CLSID_Connection, NULL, CLSCTX_INPROC_SERVER, &IID__Connection, (void**)&connection);
ok( hr == S_OK, "got %08x\n", hr );
hr = _Connection_QueryInterface(connection, &IID_IRunnableObject, (void**)&runtime);
ok(hr == E_NOINTERFACE, "Unexpected IRunnableObject interface\n");
hr = _Connection_QueryInterface(connection, &IID_ISupportErrorInfo, (void**)&errorinfo);
todo_wine ok(hr == S_OK, "Failed to get ISupportErrorInfo interface\n");
if (hr == S_OK)
ISupportErrorInfo_Release(errorinfo);
if (0) /* Crashes on windows */
{
hr = _Connection_get_State(connection, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr 0x%08x\n", hr);
}
state = -1;
hr = _Connection_get_State(connection, &state);
ok(hr == S_OK, "Failed to get state, hr 0x%08x\n", hr);
ok(state == adStateClosed, "Unexpected state value 0x%08x\n", state);
_Connection_Release(connection);
}
START_TEST(msado15)
{
CoInitialize( NULL );
test_Stream();
test_Connection();
CoUninitialize();
}