From 131cfe0b65f7149c79915fb0f74b1e4d6fafa438 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Wed, 11 Dec 2019 17:16:52 +0100 Subject: [PATCH] msado15: Implement _Connection_get_State. Signed-off-by: Alistair Leslie-Hughes Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/msado15/connection.c | 9 +++++++-- dlls/msado15/tests/msado15.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/dlls/msado15/connection.c b/dlls/msado15/connection.c index 43497636a81..c9799862bf3 100644 --- a/dlls/msado15/connection.c +++ b/dlls/msado15/connection.c @@ -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 ); diff --git a/dlls/msado15/tests/msado15.c b/dlls/msado15/tests/msado15.c index 079da0a1038..8249a398ba1 100644 --- a/dlls/msado15/tests/msado15.c +++ b/dlls/msado15/tests/msado15.c @@ -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(); }