diff --git a/dlls/msado15/msado15_private.h b/dlls/msado15/msado15_private.h index 83c8b7c9660..f901791ea9e 100644 --- a/dlls/msado15/msado15_private.h +++ b/dlls/msado15/msado15_private.h @@ -19,6 +19,8 @@ #ifndef _WINE_MSADO15_PRIVATE_H_ #define _WINE_MSADO15_PRIVATE_H_ +#define MAKE_ADO_HRESULT( err ) MAKE_HRESULT( SEVERITY_ERROR, FACILITY_CONTROL, err ) + HRESULT Connection_create( void ** ) DECLSPEC_HIDDEN; HRESULT Recordset_create( void ** ) DECLSPEC_HIDDEN; HRESULT Stream_create( void ** ) DECLSPEC_HIDDEN; diff --git a/dlls/msado15/stream.c b/dlls/msado15/stream.c index 8e88b9aa651..3c9d885edf0 100644 --- a/dlls/msado15/stream.c +++ b/dlls/msado15/stream.c @@ -34,6 +34,7 @@ struct stream { _Stream Stream_iface; LONG refs; + ObjectStateEnum state; StreamTypeEnum type; }; @@ -198,14 +199,25 @@ static HRESULT WINAPI stream_Read( _Stream *iface, LONG size, VARIANT *val ) static HRESULT WINAPI stream_Open( _Stream *iface, VARIANT src, ConnectModeEnum mode, StreamOpenOptionsEnum options, BSTR username, BSTR password ) { - FIXME( "%p, %s, %u, %d, %s, %p\n", iface, debugstr_variant(&src), mode, options, debugstr_w(username), password ); - return E_NOTIMPL; + struct stream *stream = impl_from_Stream( iface ); + FIXME( "%p, %s, %u, %d, %s, %p\n", stream, debugstr_variant(&src), mode, options, debugstr_w(username), password ); + + if (stream->state == adStateOpen) return MAKE_ADO_HRESULT( adErrObjectOpen ); + + stream->state = adStateOpen; + return S_OK; } static HRESULT WINAPI stream_Close( _Stream *iface ) { - FIXME( "%p\n", iface ); - return E_NOTIMPL; + struct stream *stream = impl_from_Stream( iface ); + + TRACE( "%p\n", stream ); + + if (stream->state == adStateClosed) return MAKE_ADO_HRESULT( adErrObjectClosed ); + + stream->state = adStateClosed; + return S_OK; } static HRESULT WINAPI stream_SkipLine( _Stream *iface ) diff --git a/dlls/msado15/tests/msado15.c b/dlls/msado15/tests/msado15.c index ed465e20723..e562c2299f2 100644 --- a/dlls/msado15/tests/msado15.c +++ b/dlls/msado15/tests/msado15.c @@ -23,11 +23,14 @@ #include #include "wine/test.h" +#define MAKE_ADO_HRESULT( err ) MAKE_HRESULT( SEVERITY_ERROR, FACILITY_CONTROL, err ) + static void test_Stream(void) { _Stream *stream; StreamTypeEnum type; LONG refs; + VARIANT missing; HRESULT hr; hr = CoCreateInstance( &CLSID_Stream, NULL, CLSCTX_INPROC_SERVER, &IID__Stream, (void **)&stream ); @@ -51,6 +54,20 @@ static void test_Stream(void) hr = _Stream_put_Type( stream, adTypeText ); ok( hr == S_OK, "got %08x\n", hr ); + V_VT( &missing ) = VT_ERROR; + V_ERROR( &missing ) = DISP_E_PARAMNOTFOUND; + hr = _Stream_Open( stream, missing, adModeUnknown, adOpenStreamUnspecified, NULL, NULL ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = _Stream_Open( stream, missing, adModeUnknown, adOpenStreamUnspecified, NULL, NULL ); + ok( hr == MAKE_ADO_HRESULT( adErrObjectOpen ), "got %08x\n", hr ); + + hr = _Stream_Close( stream ); + ok( hr == S_OK, "got %08x\n", hr ); + + hr = _Stream_Close( stream ); + ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08x\n", hr ); + refs = _Stream_Release( stream ); ok( !refs, "got %d\n", refs ); }