2019-12-06 14:54:21 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2019 Hans Leidekker for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#define COBJMACROS
|
|
|
|
#include <initguid.h>
|
|
|
|
#include <oledb.h>
|
2020-06-01 13:42:18 +02:00
|
|
|
#include <olectl.h>
|
2019-12-06 14:54:21 +01:00
|
|
|
#include <msado15_backcompat.h>
|
|
|
|
#include "wine/test.h"
|
2020-11-18 10:42:20 +01:00
|
|
|
#include "msdasql.h"
|
|
|
|
|
|
|
|
DEFINE_GUID(DBPROPSET_ROWSET, 0xc8b522be, 0x5cf3, 0x11ce, 0xad, 0xe5, 0x00, 0xaa, 0x00, 0x44, 0x77, 0x3d);
|
2019-12-06 14:54:21 +01:00
|
|
|
|
2019-12-09 11:24:29 +01:00
|
|
|
#define MAKE_ADO_HRESULT( err ) MAKE_HRESULT( SEVERITY_ERROR, FACILITY_CONTROL, err )
|
|
|
|
|
2019-12-13 15:52:26 +01:00
|
|
|
static BOOL is_bof( _Recordset *recordset )
|
|
|
|
{
|
|
|
|
VARIANT_BOOL bof = VARIANT_FALSE;
|
|
|
|
_Recordset_get_BOF( recordset, &bof );
|
|
|
|
return bof == VARIANT_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL is_eof( _Recordset *recordset )
|
|
|
|
{
|
|
|
|
VARIANT_BOOL eof = VARIANT_FALSE;
|
|
|
|
_Recordset_get_EOF( recordset, &eof );
|
|
|
|
return eof == VARIANT_TRUE;
|
|
|
|
}
|
|
|
|
|
2019-12-11 17:18:26 +01:00
|
|
|
static void test_Recordset(void)
|
|
|
|
{
|
|
|
|
_Recordset *recordset;
|
2020-06-07 15:51:19 +02:00
|
|
|
IRunnableObject *runtime;
|
2019-12-13 15:52:30 +01:00
|
|
|
ISupportErrorInfo *errorinfo;
|
2019-12-11 17:18:26 +01:00
|
|
|
Fields *fields, *fields2;
|
2019-12-13 15:52:29 +01:00
|
|
|
Field *field;
|
2021-04-23 00:24:57 +02:00
|
|
|
Properties *props;
|
|
|
|
Property *prop;
|
2021-06-07 08:28:55 +02:00
|
|
|
LONG count, state;
|
2022-02-04 15:33:23 +01:00
|
|
|
ADO_LONGPTR rec_count;
|
2019-12-13 15:52:29 +01:00
|
|
|
VARIANT missing, val, index;
|
2020-01-24 00:43:38 +01:00
|
|
|
CursorLocationEnum location;
|
2020-10-22 14:46:20 +02:00
|
|
|
CursorTypeEnum cursor;
|
2019-12-13 15:52:24 +01:00
|
|
|
BSTR name;
|
2019-12-11 17:18:26 +01:00
|
|
|
HRESULT hr;
|
2021-03-25 22:09:17 +01:00
|
|
|
VARIANT bookmark;
|
2019-12-11 17:18:26 +01:00
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_Recordset, NULL, CLSCTX_INPROC_SERVER, &IID__Recordset, (void **)&recordset );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-11 17:18:26 +01:00
|
|
|
|
2020-06-07 15:51:19 +02:00
|
|
|
hr = _Recordset_QueryInterface( recordset, &IID_IRunnableObject, (void**)&runtime);
|
|
|
|
ok(hr == E_NOINTERFACE, "Unexpected IRunnableObject interface\n");
|
|
|
|
ok(runtime == NULL, "expected NULL\n");
|
|
|
|
|
2019-12-13 15:52:30 +01:00
|
|
|
/* _Recordset object supports ISupportErrorInfo */
|
|
|
|
errorinfo = NULL;
|
|
|
|
hr = _Recordset_QueryInterface( recordset, &IID_ISupportErrorInfo, (void **)&errorinfo );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:30 +01:00
|
|
|
if (errorinfo) ISupportErrorInfo_Release( errorinfo );
|
|
|
|
|
2019-12-11 17:18:26 +01:00
|
|
|
hr = _Recordset_get_Fields( recordset, &fields );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-11 17:18:26 +01:00
|
|
|
|
2021-06-07 08:28:55 +02:00
|
|
|
/* calling get_Fields again returns the same object */
|
2019-12-11 17:18:26 +01:00
|
|
|
hr = _Recordset_get_Fields( recordset, &fields2 );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-11 17:18:26 +01:00
|
|
|
ok( fields2 == fields, "expected same object\n" );
|
|
|
|
|
|
|
|
count = -1;
|
|
|
|
hr = Fields_get_Count( fields2, &count );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( !count, "got %ld\n", count );
|
2019-12-11 17:18:26 +01:00
|
|
|
|
2019-12-13 15:52:31 +01:00
|
|
|
hr = _Recordset_Close( recordset );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08lx\n", hr );
|
2019-12-13 15:52:31 +01:00
|
|
|
|
2021-06-07 08:28:55 +02:00
|
|
|
Fields_Release( fields2 );
|
2019-12-13 15:52:24 +01:00
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_Recordset, NULL, CLSCTX_INPROC_SERVER, &IID__Recordset, (void **)&recordset );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:24 +01:00
|
|
|
|
|
|
|
state = -1;
|
|
|
|
hr = _Recordset_get_State( recordset, &state );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( state == adStateClosed, "got %ld\n", state );
|
2019-12-13 15:52:24 +01:00
|
|
|
|
2020-01-24 00:43:38 +01:00
|
|
|
location = -1;
|
|
|
|
hr = _Recordset_get_CursorLocation( recordset, &location );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2020-01-24 00:43:38 +01:00
|
|
|
ok( location == adUseServer, "got %d\n", location );
|
|
|
|
|
2020-10-22 14:46:20 +02:00
|
|
|
cursor = adOpenUnspecified;
|
|
|
|
hr = _Recordset_get_CursorType( recordset, &cursor );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2020-10-22 14:46:20 +02:00
|
|
|
ok( cursor == adOpenForwardOnly, "got %d\n", cursor );
|
|
|
|
|
2021-03-25 22:09:17 +01:00
|
|
|
VariantInit( &bookmark );
|
|
|
|
hr = _Recordset_get_Bookmark( recordset, &bookmark );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08lx\n", hr );
|
2021-03-25 22:09:17 +01:00
|
|
|
|
|
|
|
VariantInit( &bookmark );
|
|
|
|
hr = _Recordset_put_Bookmark( recordset, bookmark );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08lx\n", hr );
|
2021-03-25 22:09:17 +01:00
|
|
|
|
2019-12-13 15:52:24 +01:00
|
|
|
VariantInit( &missing );
|
|
|
|
hr = _Recordset_AddNew( recordset, missing, missing );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08lx\n", hr );
|
2019-12-13 15:52:24 +01:00
|
|
|
|
|
|
|
V_VT( &missing ) = VT_ERROR;
|
|
|
|
V_ERROR( &missing ) = DISP_E_PARAMNOTFOUND;
|
|
|
|
hr = _Recordset_Open( recordset, missing, missing, adOpenStatic, adLockBatchOptimistic, adCmdUnspecified );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrInvalidConnection ), "got %08lx\n", hr );
|
2019-12-13 15:52:24 +01:00
|
|
|
|
|
|
|
hr = _Recordset_get_Fields( recordset, &fields );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:24 +01:00
|
|
|
|
|
|
|
name = SysAllocString( L"field" );
|
|
|
|
hr = Fields__Append( fields, name, adInteger, 4, adFldUnspecified );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:29 +01:00
|
|
|
|
2021-06-08 06:22:56 +02:00
|
|
|
V_VT( &index ) = VT_I4;
|
|
|
|
V_I4( &index ) = 1000;
|
|
|
|
hr = Fields_get_Item( fields, index, &field );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT(adErrItemNotFound), "got %08lx\n", hr );
|
2021-06-08 06:22:56 +02:00
|
|
|
|
|
|
|
V_VT( &index ) = VT_I4;
|
|
|
|
V_I4( &index ) = 0;
|
|
|
|
hr = Fields_get_Item( fields, index, &field );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2021-06-08 06:22:56 +02:00
|
|
|
Field_Release(field);
|
|
|
|
|
|
|
|
V_VT( &index ) = VT_I2;
|
|
|
|
V_I4( &index ) = 0;
|
|
|
|
hr = Fields_get_Item( fields, index, &field );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2021-06-08 06:22:56 +02:00
|
|
|
Field_Release(field);
|
|
|
|
|
2021-06-09 08:41:32 +02:00
|
|
|
V_VT( &index ) = VT_I1;
|
|
|
|
V_I1( &index ) = 0;
|
|
|
|
hr = Fields_get_Item( fields, index, &field );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2021-06-09 08:41:32 +02:00
|
|
|
Field_Release(field);
|
|
|
|
|
|
|
|
V_VT( &index ) = VT_R8;
|
|
|
|
V_R8( &index ) = 0.1;
|
|
|
|
hr = Fields_get_Item( fields, index, &field );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2021-06-09 08:41:32 +02:00
|
|
|
Field_Release(field);
|
|
|
|
|
|
|
|
V_VT( &index ) = VT_UNKNOWN;
|
|
|
|
V_UNKNOWN( &index ) = NULL;
|
|
|
|
hr = Fields_get_Item( fields, index, &field );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT(adErrItemNotFound), "got %08lx\n", hr );
|
2021-06-09 08:41:32 +02:00
|
|
|
|
2019-12-13 15:52:29 +01:00
|
|
|
V_VT( &index ) = VT_BSTR;
|
|
|
|
V_BSTR( &index ) = name;
|
|
|
|
hr = Fields_get_Item( fields, index, &field );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:24 +01:00
|
|
|
SysFreeString( name );
|
|
|
|
|
2021-04-23 00:24:57 +02:00
|
|
|
hr = Field_QueryInterface(field, &IID_Properties, (void**)&props);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == E_NOINTERFACE, "got %08lx\n", hr );
|
2021-04-23 00:24:57 +02:00
|
|
|
|
|
|
|
hr = Field_get_Properties(field, &props);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2021-04-23 00:24:57 +02:00
|
|
|
|
|
|
|
count = -1;
|
|
|
|
hr = Properties_get_Count(props, &count);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( !count, "got %ld\n", count );
|
2021-04-23 00:24:57 +02:00
|
|
|
|
|
|
|
V_VT( &index ) = VT_I4;
|
|
|
|
V_I4( &index ) = 1000;
|
|
|
|
hr = Properties_get_Item(props, index, &prop);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT(adErrItemNotFound), "got %08lx\n", hr );
|
2021-04-23 00:24:57 +02:00
|
|
|
|
|
|
|
Properties_Release(props);
|
|
|
|
|
2019-12-13 15:52:24 +01:00
|
|
|
hr = _Recordset_Open( recordset, missing, missing, adOpenStatic, adLockBatchOptimistic, adCmdUnspecified );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:26 +01:00
|
|
|
ok( is_eof( recordset ), "not eof\n" );
|
|
|
|
ok( is_bof( recordset ), "not bof\n" );
|
2019-12-13 15:52:24 +01:00
|
|
|
|
2019-12-13 15:52:31 +01:00
|
|
|
hr = _Recordset_Open( recordset, missing, missing, adOpenStatic, adLockBatchOptimistic, adCmdUnspecified );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectOpen ), "got %08lx\n", hr );
|
2019-12-13 15:52:31 +01:00
|
|
|
|
2019-12-13 15:52:24 +01:00
|
|
|
state = -1;
|
|
|
|
hr = _Recordset_get_State( recordset, &state );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( state == adStateOpen, "got %ld\n", state );
|
2019-12-13 15:52:24 +01:00
|
|
|
|
2021-03-25 22:09:17 +01:00
|
|
|
VariantInit( &bookmark );
|
|
|
|
hr = _Recordset_get_Bookmark( recordset, &bookmark );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrNoCurrentRecord ), "got %08lx\n", hr );
|
2021-03-25 22:09:17 +01:00
|
|
|
|
|
|
|
VariantInit( &bookmark );
|
|
|
|
hr = _Recordset_put_Bookmark( recordset, bookmark );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrInvalidArgument ), "got %08lx\n", hr );
|
2021-03-25 22:09:17 +01:00
|
|
|
|
2022-02-04 15:33:23 +01:00
|
|
|
rec_count = -1;
|
|
|
|
hr = _Recordset_get_RecordCount( recordset, &rec_count );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( !rec_count, "got %Id\n", rec_count );
|
2019-12-13 15:52:27 +01:00
|
|
|
|
2019-12-13 15:52:24 +01:00
|
|
|
hr = _Recordset_AddNew( recordset, missing, missing );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:26 +01:00
|
|
|
ok( !is_eof( recordset ), "eof\n" );
|
|
|
|
ok( !is_bof( recordset ), "bof\n" );
|
2019-12-13 15:52:24 +01:00
|
|
|
|
2022-02-04 15:33:23 +01:00
|
|
|
rec_count = -1;
|
|
|
|
hr = _Recordset_get_RecordCount( recordset, &rec_count );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( rec_count == 1, "got %Id\n", rec_count );
|
2019-12-13 15:52:27 +01:00
|
|
|
|
2019-12-13 15:52:29 +01:00
|
|
|
/* get_Fields still returns the same object */
|
|
|
|
hr = _Recordset_get_Fields( recordset, &fields2 );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:29 +01:00
|
|
|
ok( fields2 == fields, "expected same object\n" );
|
|
|
|
Fields_Release( fields2 );
|
|
|
|
|
|
|
|
count = -1;
|
|
|
|
hr = Fields_get_Count( fields2, &count );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( count == 1, "got %ld\n", count );
|
2019-12-13 15:52:29 +01:00
|
|
|
|
|
|
|
hr = Field_get_Value( field, &val );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:29 +01:00
|
|
|
ok( V_VT( &val ) == VT_EMPTY, "got %u\n", V_VT( &val ) );
|
|
|
|
|
|
|
|
V_VT( &val ) = VT_I4;
|
|
|
|
V_I4( &val ) = -1;
|
|
|
|
hr = Field_put_Value( field, val );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:29 +01:00
|
|
|
|
|
|
|
V_VT( &val ) = VT_ERROR;
|
|
|
|
V_ERROR( &val ) = DISP_E_PARAMNOTFOUND;
|
|
|
|
hr = Field_get_Value( field, &val );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:29 +01:00
|
|
|
ok( V_VT( &val ) == VT_I4, "got %u\n", V_VT( &val ) );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( V_I4( &val ) == -1, "got %ld\n", V_I4( &val ) );
|
2019-12-13 15:52:29 +01:00
|
|
|
|
|
|
|
hr = _Recordset_AddNew( recordset, missing, missing );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:29 +01:00
|
|
|
|
|
|
|
/* field object returns different value after AddNew */
|
|
|
|
V_VT( &val ) = VT_ERROR;
|
|
|
|
V_ERROR( &val ) = DISP_E_PARAMNOTFOUND;
|
|
|
|
hr = Field_get_Value( field, &val );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:29 +01:00
|
|
|
ok( V_VT( &val ) == VT_EMPTY, "got %u\n", V_VT( &val ) );
|
|
|
|
|
|
|
|
ok( !is_eof( recordset ), "eof\n" );
|
|
|
|
ok( !is_bof( recordset ), "bof\n" );
|
|
|
|
hr = _Recordset_MoveFirst( recordset );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:29 +01:00
|
|
|
ok( !is_eof( recordset ), "eof\n" );
|
|
|
|
ok( !is_bof( recordset ), "bof\n" );
|
|
|
|
|
|
|
|
V_VT( &val ) = VT_ERROR;
|
|
|
|
V_ERROR( &val ) = DISP_E_PARAMNOTFOUND;
|
|
|
|
hr = Field_get_Value( field, &val );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:29 +01:00
|
|
|
ok( V_VT( &val ) == VT_I4, "got %u\n", V_VT( &val ) );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( V_I4( &val ) == -1, "got %ld\n", V_I4( &val ) );
|
2019-12-13 15:52:29 +01:00
|
|
|
|
|
|
|
hr = _Recordset_MoveNext( recordset );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:29 +01:00
|
|
|
ok( !is_eof( recordset ), "eof\n" );
|
|
|
|
ok( !is_bof( recordset ), "not bof\n" );
|
|
|
|
|
|
|
|
hr = _Recordset_MoveNext( recordset );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:29 +01:00
|
|
|
ok( is_eof( recordset ), "not eof\n" );
|
|
|
|
ok( !is_bof( recordset ), "bof\n" );
|
|
|
|
|
|
|
|
hr = _Recordset_MoveFirst( recordset );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:29 +01:00
|
|
|
ok( !is_eof( recordset ), "eof\n" );
|
|
|
|
ok( !is_bof( recordset ), "bof\n" );
|
|
|
|
|
|
|
|
hr = _Recordset_MovePrevious( recordset );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:29 +01:00
|
|
|
ok( !is_eof( recordset ), "eof\n" );
|
|
|
|
ok( is_bof( recordset ), "not bof\n" );
|
|
|
|
|
|
|
|
/* try get value at BOF */
|
|
|
|
VariantInit( &val );
|
|
|
|
hr = Field_get_Value( field, &val );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrNoCurrentRecord ), "got %08lx\n", hr );
|
2019-12-13 15:52:29 +01:00
|
|
|
|
2019-12-13 15:52:24 +01:00
|
|
|
hr = _Recordset_Close( recordset );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:24 +01:00
|
|
|
|
2021-06-07 08:28:56 +02:00
|
|
|
count = -1;
|
|
|
|
hr = Fields_get_Count( fields, &count );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( !count, "got %ld\n", count );
|
2021-06-07 08:28:56 +02:00
|
|
|
|
|
|
|
hr = Field_get_Name(field, &name);
|
2022-03-01 08:33:37 +01:00
|
|
|
todo_wine ok( hr == MAKE_ADO_HRESULT( adErrObjectNotSet ), "got %08lx\n", hr );
|
2021-06-07 08:28:56 +02:00
|
|
|
|
2019-12-13 15:52:25 +01:00
|
|
|
state = -1;
|
|
|
|
hr = _Recordset_get_State( recordset, &state );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( state == adStateClosed, "got %ld\n", state );
|
2019-12-13 15:52:25 +01:00
|
|
|
|
2019-12-13 15:52:29 +01:00
|
|
|
Field_Release( field );
|
2019-12-13 15:52:24 +01:00
|
|
|
Fields_Release( fields );
|
|
|
|
_Recordset_Release( recordset );
|
2019-12-11 17:18:26 +01:00
|
|
|
}
|
|
|
|
|
2020-11-18 10:42:20 +01:00
|
|
|
/* This interface is queried for but is not documented anywhere. */
|
|
|
|
DEFINE_GUID(UKN_INTERFACE, 0x6f1e39e1, 0x05c6, 0x11d0, 0xa7, 0x8b, 0x00, 0xaa, 0x00, 0xa3, 0xf0, 0x0d);
|
|
|
|
|
|
|
|
struct test_rowset
|
|
|
|
{
|
|
|
|
IRowset IRowset_iface;
|
|
|
|
IRowsetInfo IRowsetInfo_iface;
|
|
|
|
IColumnsInfo IColumnsInfo_iface;
|
|
|
|
LONG refs;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct test_rowset *impl_from_IRowset( IRowset *iface )
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD( iface, struct test_rowset, IRowset_iface );
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct test_rowset *impl_from_IRowsetInfo( IRowsetInfo *iface )
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD( iface, struct test_rowset, IRowsetInfo_iface );
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct test_rowset *impl_from_IColumnsInfo( IColumnsInfo *iface )
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD( iface, struct test_rowset, IColumnsInfo_iface );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowset_info_QueryInterface(IRowsetInfo *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
struct test_rowset *rowset = impl_from_IRowsetInfo( iface );
|
|
|
|
return IRowset_QueryInterface(&rowset->IRowset_iface, riid, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI rowset_info_AddRef(IRowsetInfo *iface)
|
|
|
|
{
|
|
|
|
struct test_rowset *rowset = impl_from_IRowsetInfo( iface );
|
|
|
|
return IRowset_AddRef(&rowset->IRowset_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI rowset_info_Release(IRowsetInfo *iface)
|
|
|
|
{
|
|
|
|
struct test_rowset *rowset = impl_from_IRowsetInfo( iface );
|
|
|
|
return IRowset_Release(&rowset->IRowset_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowset_info_GetProperties(IRowsetInfo *iface, const ULONG count,
|
|
|
|
const DBPROPIDSET propertyidsets[], ULONG *out_count, DBPROPSET **propertysets1)
|
|
|
|
{
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( count == 2, "got %ld\n", count );
|
2020-11-18 10:42:20 +01:00
|
|
|
|
|
|
|
ok( IsEqualIID(&DBPROPSET_ROWSET, &propertyidsets[0].guidPropertySet), "got %s\n", wine_dbgstr_guid(&propertyidsets[0].guidPropertySet));
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( propertyidsets[0].cPropertyIDs == 17, "got %ld\n", propertyidsets[0].cPropertyIDs );
|
2020-11-18 10:42:20 +01:00
|
|
|
|
|
|
|
ok( IsEqualIID(&DBPROPSET_PROVIDERROWSET, &propertyidsets[1].guidPropertySet), "got %s\n", wine_dbgstr_guid(&propertyidsets[1].guidPropertySet));
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( propertyidsets[1].cPropertyIDs == 1, "got %ld\n", propertyidsets[1].cPropertyIDs );
|
2020-11-18 10:42:20 +01:00
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowset_info_GetReferencedRowset(IRowsetInfo *iface, DBORDINAL ordinal,
|
|
|
|
REFIID riid, IUnknown **unk)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowset_info_GetSpecification(IRowsetInfo *iface, REFIID riid,
|
|
|
|
IUnknown **specification)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IRowsetInfoVtbl rowset_info =
|
|
|
|
{
|
|
|
|
rowset_info_QueryInterface,
|
|
|
|
rowset_info_AddRef,
|
|
|
|
rowset_info_Release,
|
|
|
|
rowset_info_GetProperties,
|
|
|
|
rowset_info_GetReferencedRowset,
|
|
|
|
rowset_info_GetSpecification
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI column_info_QueryInterface(IColumnsInfo *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
struct test_rowset *rowset = impl_from_IColumnsInfo( iface );
|
|
|
|
return IRowset_QueryInterface(&rowset->IRowset_iface, riid, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI column_info_AddRef(IColumnsInfo *iface)
|
|
|
|
{
|
|
|
|
struct test_rowset *rowset = impl_from_IColumnsInfo( iface );
|
|
|
|
return IRowset_AddRef(&rowset->IRowset_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI column_info_Release(IColumnsInfo *iface)
|
|
|
|
{
|
|
|
|
struct test_rowset *rowset = impl_from_IColumnsInfo( iface );
|
|
|
|
return IRowset_Release(&rowset->IRowset_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI column_info_GetColumnInfo(IColumnsInfo *This, DBORDINAL *columns,
|
|
|
|
DBCOLUMNINFO **colinfo, OLECHAR **stringsbuffer)
|
|
|
|
{
|
|
|
|
DBCOLUMNINFO *dbcolumn;
|
|
|
|
*columns = 1;
|
|
|
|
|
|
|
|
*stringsbuffer = CoTaskMemAlloc(sizeof(L"Column1"));
|
|
|
|
lstrcpyW(*stringsbuffer, L"Column1");
|
|
|
|
|
|
|
|
dbcolumn = CoTaskMemAlloc(sizeof(DBCOLUMNINFO));
|
|
|
|
|
|
|
|
dbcolumn->pwszName = *stringsbuffer;
|
|
|
|
dbcolumn->pTypeInfo = NULL;
|
|
|
|
dbcolumn->iOrdinal = 1;
|
|
|
|
dbcolumn->dwFlags = DBCOLUMNFLAGS_MAYBENULL;
|
|
|
|
dbcolumn->ulColumnSize = 5;
|
|
|
|
dbcolumn->wType = DBTYPE_I4;
|
|
|
|
dbcolumn->bPrecision = 1;
|
|
|
|
dbcolumn->bScale = 1;
|
|
|
|
dbcolumn->columnid.eKind = DBKIND_NAME;
|
|
|
|
dbcolumn->columnid.uName.pwszName = *stringsbuffer;
|
|
|
|
|
|
|
|
*colinfo = dbcolumn;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI column_info_MapColumnIDs(IColumnsInfo *This, DBORDINAL column_ids,
|
|
|
|
const DBID *dbids, DBORDINAL *columns)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IColumnsInfoVtbl column_info =
|
|
|
|
{
|
|
|
|
column_info_QueryInterface,
|
|
|
|
column_info_AddRef,
|
|
|
|
column_info_Release,
|
|
|
|
column_info_GetColumnInfo,
|
|
|
|
column_info_MapColumnIDs,
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowset_QueryInterface(IRowset *iface, REFIID riid, void **obj)
|
|
|
|
{
|
|
|
|
struct test_rowset *rowset = impl_from_IRowset( iface );
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IRowset) ||
|
|
|
|
IsEqualIID(riid, &IID_IUnknown))
|
|
|
|
{
|
|
|
|
trace("Requested interface IID_IRowset\n");
|
|
|
|
*obj = &rowset->IRowset_iface;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, &IID_IRowsetInfo))
|
|
|
|
{
|
|
|
|
trace("Requested interface IID_IRowsetInfo\n");
|
|
|
|
*obj = &rowset->IRowsetInfo_iface;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, &IID_IColumnsInfo))
|
|
|
|
{
|
|
|
|
trace("Requested interface IID_IColumnsInfo\n");
|
|
|
|
*obj = &rowset->IColumnsInfo_iface;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, &IID_IRowsetLocate))
|
|
|
|
{
|
|
|
|
trace("Requested interface IID_IRowsetLocate\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, &IID_IDBAsynchStatus))
|
|
|
|
{
|
|
|
|
trace("Requested interface IID_IDBAsynchStatus\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, &IID_IAccessor))
|
|
|
|
{
|
|
|
|
trace("Requested interface IID_IAccessor\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, &UKN_INTERFACE))
|
|
|
|
{
|
|
|
|
trace("Unknown interface\n");
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*obj) {
|
|
|
|
IUnknown_AddRef((IUnknown*)*obj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(0, "Unsupported interface %s\n", wine_dbgstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI rowset_AddRef(IRowset *iface)
|
|
|
|
{
|
|
|
|
struct test_rowset *rowset = impl_from_IRowset( iface );
|
|
|
|
return InterlockedIncrement( &rowset->refs );
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI rowset_Release(IRowset *iface)
|
|
|
|
{
|
|
|
|
struct test_rowset *rowset = impl_from_IRowset( iface );
|
|
|
|
/* Object not allocated no need to destroy */
|
|
|
|
return InterlockedDecrement( &rowset->refs );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowset_AddRefRows(IRowset *iface, DBCOUNTITEM cRows, const HROW rghRows[],
|
|
|
|
DBREFCOUNT rgRefCounts[], DBROWSTATUS rgRowStatus[])
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowset_GetData(IRowset *iface, HROW hRow, HACCESSOR hAccessor, void *pData)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowset_GetNextRows(IRowset *iface, HCHAPTER hReserved, DBROWOFFSET lRowsOffset,
|
|
|
|
DBROWCOUNT cRows, DBCOUNTITEM *pcRowObtained, HROW **prghRows)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowset_ReleaseRows(IRowset *iface, DBCOUNTITEM cRows, const HROW rghRows[],
|
|
|
|
DBROWOPTIONS rgRowOptions[], DBREFCOUNT rgRefCounts[], DBROWSTATUS rgRowStatus[])
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI rowset_RestartPosition(IRowset *iface, HCHAPTER hReserved)
|
|
|
|
{
|
|
|
|
ok(0, "Unexpected call\n");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct IRowsetVtbl rowset_vtbl =
|
|
|
|
{
|
|
|
|
rowset_QueryInterface,
|
|
|
|
rowset_AddRef,
|
|
|
|
rowset_Release,
|
|
|
|
rowset_AddRefRows,
|
|
|
|
rowset_GetData,
|
|
|
|
rowset_GetNextRows,
|
|
|
|
rowset_ReleaseRows,
|
|
|
|
rowset_RestartPosition
|
|
|
|
};
|
|
|
|
|
|
|
|
static ULONG get_refcount(void *iface)
|
|
|
|
{
|
|
|
|
IUnknown *unknown = iface;
|
|
|
|
IUnknown_AddRef(unknown);
|
|
|
|
return IUnknown_Release(unknown);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_ADORecordsetConstruction(void)
|
|
|
|
{
|
|
|
|
_Recordset *recordset;
|
|
|
|
ADORecordsetConstruction *construct;
|
|
|
|
Fields *fields = NULL;
|
|
|
|
Field *field;
|
|
|
|
struct test_rowset testrowset;
|
|
|
|
IRowset *rowset;
|
|
|
|
HRESULT hr;
|
|
|
|
LONG ref, count;
|
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_Recordset, NULL, CLSCTX_INPROC_SERVER, &IID__Recordset, (void **)&recordset );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2020-11-18 10:42:20 +01:00
|
|
|
|
|
|
|
hr = _Recordset_QueryInterface( recordset, &IID_ADORecordsetConstruction, (void**)&construct );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2020-11-18 10:42:20 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
|
|
|
testrowset.IRowset_iface.lpVtbl = &rowset_vtbl;
|
|
|
|
testrowset.IRowsetInfo_iface.lpVtbl = &rowset_info;
|
|
|
|
testrowset.IColumnsInfo_iface.lpVtbl = &column_info;
|
|
|
|
testrowset.refs = 1;
|
|
|
|
|
|
|
|
rowset = &testrowset.IRowset_iface;
|
|
|
|
|
|
|
|
ref = get_refcount( rowset );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( ref == 1, "got %ld\n", ref );
|
2020-11-18 10:42:20 +01:00
|
|
|
hr = ADORecordsetConstruction_put_Rowset( construct, (IUnknown*)rowset );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2020-11-18 10:42:20 +01:00
|
|
|
|
|
|
|
ref = get_refcount( rowset );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( ref == 2, "got %ld\n", ref );
|
2020-11-18 10:42:20 +01:00
|
|
|
|
|
|
|
hr = _Recordset_get_Fields( recordset, &fields );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2020-11-18 10:42:20 +01:00
|
|
|
ok( fields != NULL, "NULL value\n");
|
|
|
|
|
|
|
|
ref = get_refcount( rowset );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( ref == 2, "got %ld\n", ref );
|
2020-11-18 10:42:20 +01:00
|
|
|
|
|
|
|
count = -1;
|
|
|
|
hr = Fields_get_Count( fields, &count );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( count == 1, "got %ld\n", count );
|
2020-11-18 10:42:20 +01:00
|
|
|
if (count > 0)
|
|
|
|
{
|
|
|
|
VARIANT index;
|
2022-02-04 15:33:23 +01:00
|
|
|
ADO_LONGPTR size;
|
2020-11-18 10:42:20 +01:00
|
|
|
DataTypeEnum type;
|
|
|
|
|
|
|
|
V_VT( &index ) = VT_BSTR;
|
|
|
|
V_BSTR( &index ) = SysAllocString( L"Column1" );
|
|
|
|
|
|
|
|
hr = Fields_get_Item( fields, index, &field );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2020-11-18 10:42:20 +01:00
|
|
|
|
|
|
|
hr = Field_get_Type( field, &type );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2020-11-18 10:42:20 +01:00
|
|
|
ok( type == adInteger, "got %d\n", type );
|
|
|
|
size = -1;
|
|
|
|
hr = Field_get_DefinedSize( field, &size );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( size == 5, "got %Id\n", size );
|
2020-11-18 10:42:20 +01:00
|
|
|
|
|
|
|
VariantClear(&index);
|
|
|
|
|
|
|
|
Field_Release(field);
|
|
|
|
}
|
|
|
|
|
|
|
|
ref = get_refcount(rowset);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( ref == 2, "got %ld\n", ref );
|
2020-11-18 10:42:20 +01:00
|
|
|
|
|
|
|
Fields_Release(fields);
|
|
|
|
|
|
|
|
ADORecordsetConstruction_Release(construct);
|
|
|
|
|
|
|
|
done:
|
|
|
|
_Recordset_Release( recordset );
|
|
|
|
}
|
|
|
|
|
2019-12-11 17:18:28 +01:00
|
|
|
static void test_Fields(void)
|
|
|
|
{
|
|
|
|
_Recordset *recordset;
|
2019-12-13 15:52:30 +01:00
|
|
|
ISupportErrorInfo *errorinfo;
|
2019-12-11 17:18:28 +01:00
|
|
|
Fields *fields;
|
2019-12-12 17:12:22 +01:00
|
|
|
Field *field, *field2;
|
|
|
|
VARIANT val, index;
|
2019-12-11 17:18:28 +01:00
|
|
|
BSTR name;
|
2022-02-04 15:33:23 +01:00
|
|
|
LONG count;
|
|
|
|
ADO_LONGPTR size;
|
2019-12-12 17:12:23 +01:00
|
|
|
DataTypeEnum type;
|
2022-03-01 08:33:31 +01:00
|
|
|
LONG attrs;
|
2019-12-11 17:18:28 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_Recordset, NULL, CLSCTX_INPROC_SERVER, &IID__Recordset, (void **)&recordset );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-11 17:18:28 +01:00
|
|
|
|
2021-06-07 08:28:56 +02:00
|
|
|
hr = _Recordset_QueryInterface( recordset, &IID_Fields, (void **)&fields );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == E_NOINTERFACE, "got %08lx\n", hr );
|
2021-06-07 08:28:56 +02:00
|
|
|
|
2019-12-11 17:18:28 +01:00
|
|
|
hr = _Recordset_get_Fields( recordset, &fields );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-11 17:18:28 +01:00
|
|
|
|
2019-12-13 15:52:30 +01:00
|
|
|
/* Fields object supports ISupportErrorInfo */
|
|
|
|
errorinfo = NULL;
|
|
|
|
hr = Fields_QueryInterface( fields, &IID_ISupportErrorInfo, (void **)&errorinfo );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:30 +01:00
|
|
|
if (errorinfo) ISupportErrorInfo_Release( errorinfo );
|
|
|
|
|
2019-12-11 17:18:28 +01:00
|
|
|
count = -1;
|
|
|
|
hr = Fields_get_Count( fields, &count );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( !count, "got %ld\n", count );
|
2019-12-11 17:18:28 +01:00
|
|
|
|
|
|
|
name = SysAllocString( L"field" );
|
|
|
|
V_VT( &val ) = VT_ERROR;
|
|
|
|
V_ERROR( &val ) = DISP_E_PARAMNOTFOUND;
|
|
|
|
hr = Fields_Append( fields, name, adInteger, 4, adFldUnspecified, val );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-11 17:18:28 +01:00
|
|
|
SysFreeString( name );
|
|
|
|
|
|
|
|
count = -1;
|
|
|
|
hr = Fields_get_Count( fields, &count );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( count == 1, "got %ld\n", count );
|
2019-12-11 17:18:28 +01:00
|
|
|
|
|
|
|
name = SysAllocString( L"field2" );
|
|
|
|
hr = Fields__Append( fields, name, adInteger, 4, adFldUnspecified );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-11 17:18:28 +01:00
|
|
|
SysFreeString( name );
|
|
|
|
|
|
|
|
count = -1;
|
|
|
|
hr = Fields_get_Count( fields, &count );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( count == 2, "got %ld\n", count );
|
2019-12-11 17:18:28 +01:00
|
|
|
|
2019-12-12 17:12:22 +01:00
|
|
|
/* handing out field object doesn't add reference to fields or recordset object */
|
|
|
|
name = SysAllocString( L"field" );
|
|
|
|
V_VT( &index ) = VT_BSTR;
|
|
|
|
V_BSTR( &index ) = name;
|
|
|
|
hr = Fields_get_Item( fields, index, &field );
|
|
|
|
|
|
|
|
/* calling get_Item again returns the same object and adds reference */
|
|
|
|
hr = Fields_get_Item( fields, index, &field2 );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-12 17:12:22 +01:00
|
|
|
ok( field2 == field, "expected same object\n" );
|
|
|
|
Field_Release( field2 );
|
|
|
|
SysFreeString( name );
|
|
|
|
|
2019-12-13 15:52:30 +01:00
|
|
|
/* Field object supports ISupportErrorInfo */
|
|
|
|
errorinfo = NULL;
|
|
|
|
hr = Field_QueryInterface( field, &IID_ISupportErrorInfo, (void **)&errorinfo );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-13 15:52:30 +01:00
|
|
|
if (errorinfo) ISupportErrorInfo_Release( errorinfo );
|
|
|
|
|
2019-12-12 17:12:23 +01:00
|
|
|
/* verify values set with _Append */
|
|
|
|
hr = Field_get_Name( field, &name );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-12 17:12:23 +01:00
|
|
|
ok( !lstrcmpW( name, L"field" ), "got %s\n", wine_dbgstr_w(name) );
|
|
|
|
SysFreeString( name );
|
|
|
|
type = 0xdead;
|
|
|
|
hr = Field_get_Type( field, &type );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-12 17:12:23 +01:00
|
|
|
ok( type == adInteger, "got %d\n", type );
|
|
|
|
size = -1;
|
|
|
|
hr = Field_get_DefinedSize( field, &size );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( size == 4, "got %Id\n", size );
|
2019-12-12 17:12:23 +01:00
|
|
|
attrs = 0xdead;
|
|
|
|
hr = Field_get_Attributes( field, &attrs );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( !attrs, "got %ld\n", attrs );
|
2019-12-12 17:12:23 +01:00
|
|
|
|
2019-12-12 17:12:22 +01:00
|
|
|
Field_Release( field );
|
2019-12-11 17:18:28 +01:00
|
|
|
Fields_Release( fields );
|
|
|
|
_Recordset_Release( recordset );
|
|
|
|
}
|
|
|
|
|
2019-12-09 11:24:31 +01:00
|
|
|
static HRESULT str_to_byte_array( const char *data, VARIANT *ret )
|
|
|
|
{
|
|
|
|
SAFEARRAY *vector;
|
|
|
|
LONG i, len = strlen(data);
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
if (!(vector = SafeArrayCreateVector( VT_UI1, 0, len ))) return E_OUTOFMEMORY;
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
{
|
|
|
|
if ((hr = SafeArrayPutElement( vector, &i, (void *)&data[i] )) != S_OK)
|
|
|
|
{
|
|
|
|
SafeArrayDestroy( vector );
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
V_VT( ret ) = VT_ARRAY | VT_UI1;
|
|
|
|
V_ARRAY( ret ) = vector;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-12-06 14:54:21 +01:00
|
|
|
static void test_Stream(void)
|
|
|
|
{
|
|
|
|
_Stream *stream;
|
2019-12-10 11:11:19 +01:00
|
|
|
VARIANT_BOOL eos;
|
2019-12-06 14:54:21 +01:00
|
|
|
StreamTypeEnum type;
|
2019-12-10 11:11:20 +01:00
|
|
|
LineSeparatorEnum sep;
|
2022-02-04 15:33:23 +01:00
|
|
|
LONG refs;
|
|
|
|
ADO_LONGPTR size, pos;
|
2019-12-09 11:24:30 +01:00
|
|
|
ObjectStateEnum state;
|
2019-12-10 11:11:21 +01:00
|
|
|
ConnectModeEnum mode;
|
2019-12-10 11:11:22 +01:00
|
|
|
BSTR charset, str;
|
2019-12-09 11:24:31 +01:00
|
|
|
VARIANT missing, val;
|
2019-12-06 14:54:21 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_Stream, NULL, CLSCTX_INPROC_SERVER, &IID__Stream, (void **)&stream );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-06 14:54:21 +01:00
|
|
|
|
2019-12-09 11:24:33 +01:00
|
|
|
hr = _Stream_get_Size( stream, &size );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08lx\n", hr );
|
2019-12-09 11:24:33 +01:00
|
|
|
|
2019-12-10 11:11:19 +01:00
|
|
|
hr = _Stream_get_EOS( stream, &eos );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08lx\n", hr );
|
2019-12-10 11:11:19 +01:00
|
|
|
|
2019-12-09 11:24:32 +01:00
|
|
|
hr = _Stream_get_Position( stream, &pos );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08lx\n", hr );
|
2019-12-09 11:24:32 +01:00
|
|
|
|
|
|
|
hr = _Stream_put_Position( stream, 0 );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08lx\n", hr );
|
2019-12-09 11:24:32 +01:00
|
|
|
|
2019-12-06 14:54:21 +01:00
|
|
|
/* check default type */
|
|
|
|
type = 0;
|
|
|
|
hr = _Stream_get_Type( stream, &type );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-06 14:54:21 +01:00
|
|
|
ok( type == adTypeText, "got %u\n", type );
|
|
|
|
|
|
|
|
hr = _Stream_put_Type( stream, adTypeBinary );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-06 14:54:21 +01:00
|
|
|
|
|
|
|
type = 0;
|
|
|
|
hr = _Stream_get_Type( stream, &type );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-06 14:54:21 +01:00
|
|
|
ok( type == adTypeBinary, "got %u\n", type );
|
|
|
|
|
|
|
|
/* revert */
|
|
|
|
hr = _Stream_put_Type( stream, adTypeText );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-06 14:54:21 +01:00
|
|
|
|
2019-12-10 11:11:20 +01:00
|
|
|
sep = 0;
|
|
|
|
hr = _Stream_get_LineSeparator( stream, &sep );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-10 11:11:20 +01:00
|
|
|
ok( sep == adCRLF, "got %d\n", sep );
|
|
|
|
|
|
|
|
hr = _Stream_put_LineSeparator( stream, adLF );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-10 11:11:20 +01:00
|
|
|
|
2019-12-09 11:24:30 +01:00
|
|
|
state = 0xdeadbeef;
|
|
|
|
hr = _Stream_get_State( stream, &state );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-09 11:24:30 +01:00
|
|
|
ok( state == adStateClosed, "got %u\n", state );
|
|
|
|
|
2019-12-10 11:11:21 +01:00
|
|
|
mode = 0xdeadbeef;
|
|
|
|
hr = _Stream_get_Mode( stream, &mode );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-10 11:11:21 +01:00
|
|
|
ok( mode == adModeUnknown, "got %u\n", mode );
|
|
|
|
|
|
|
|
hr = _Stream_put_Mode( stream, adModeReadWrite );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-10 11:11:21 +01:00
|
|
|
|
2019-12-10 11:11:22 +01:00
|
|
|
hr = _Stream_get_Charset( stream, &charset );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-10 11:11:22 +01:00
|
|
|
ok( !lstrcmpW( charset, L"Unicode" ), "got %s\n", wine_dbgstr_w(charset) );
|
|
|
|
SysFreeString( charset );
|
|
|
|
|
|
|
|
str = SysAllocString( L"Unicode" );
|
|
|
|
hr = _Stream_put_Charset( stream, str );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-10 11:11:22 +01:00
|
|
|
SysFreeString( str );
|
|
|
|
|
2019-12-09 11:24:31 +01:00
|
|
|
hr = _Stream_Read( stream, 2, &val );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08lx\n", hr );
|
2019-12-09 11:24:31 +01:00
|
|
|
|
2019-12-09 11:24:29 +01:00
|
|
|
V_VT( &missing ) = VT_ERROR;
|
|
|
|
V_ERROR( &missing ) = DISP_E_PARAMNOTFOUND;
|
|
|
|
hr = _Stream_Open( stream, missing, adModeUnknown, adOpenStreamUnspecified, NULL, NULL );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-09 11:24:29 +01:00
|
|
|
|
|
|
|
hr = _Stream_Open( stream, missing, adModeUnknown, adOpenStreamUnspecified, NULL, NULL );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectOpen ), "got %08lx\n", hr );
|
2019-12-09 11:24:29 +01:00
|
|
|
|
2019-12-09 11:24:30 +01:00
|
|
|
state = 0xdeadbeef;
|
|
|
|
hr = _Stream_get_State( stream, &state );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-09 11:24:30 +01:00
|
|
|
ok( state == adStateOpen, "got %u\n", state );
|
|
|
|
|
2019-12-09 11:24:33 +01:00
|
|
|
size = -1;
|
|
|
|
hr = _Stream_get_Size( stream, &size );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( !size, "got %Id\n", size );
|
2019-12-09 11:24:33 +01:00
|
|
|
|
2019-12-10 11:11:19 +01:00
|
|
|
eos = VARIANT_FALSE;
|
|
|
|
hr = _Stream_get_EOS( stream, &eos );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-10 11:11:19 +01:00
|
|
|
ok( eos == VARIANT_TRUE, "got %04x\n", eos );
|
|
|
|
|
2019-12-09 11:24:32 +01:00
|
|
|
pos = -1;
|
|
|
|
hr = _Stream_get_Position( stream, &pos );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( !pos, "got %Id\n", pos );
|
2019-12-09 11:24:32 +01:00
|
|
|
|
2019-12-09 11:24:33 +01:00
|
|
|
size = -1;
|
|
|
|
hr = _Stream_get_Size( stream, &size );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( !size, "got %Id\n", size );
|
2019-12-09 11:24:33 +01:00
|
|
|
|
2019-12-09 11:24:31 +01:00
|
|
|
hr = _Stream_Read( stream, 2, &val );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrIllegalOperation ), "got %08lx\n", hr );
|
2019-12-09 11:24:31 +01:00
|
|
|
|
2019-12-10 11:11:23 +01:00
|
|
|
hr = _Stream_ReadText( stream, 2, &str );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-10 11:11:23 +01:00
|
|
|
ok( !str[0], "got %s\n", wine_dbgstr_w(str) );
|
|
|
|
SysFreeString( str );
|
|
|
|
|
2019-12-09 11:24:32 +01:00
|
|
|
pos = -1;
|
|
|
|
hr = _Stream_get_Position( stream, &pos );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( !pos, "got %Id\n", pos );
|
2019-12-09 11:24:32 +01:00
|
|
|
|
2019-12-10 11:11:23 +01:00
|
|
|
str = SysAllocString( L"test" );
|
|
|
|
hr = _Stream_WriteText( stream, str, adWriteChar );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-10 11:11:23 +01:00
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
hr = _Stream_ReadText( stream, adReadAll, &str );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-10 11:11:23 +01:00
|
|
|
ok( !str[0], "got %s\n", wine_dbgstr_w(str) );
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
hr = _Stream_put_Position( stream, 0 );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-10 11:11:23 +01:00
|
|
|
hr = _Stream_ReadText( stream, adReadAll, &str );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-10 11:11:23 +01:00
|
|
|
ok( !lstrcmpW( str, L"test" ), "got %s\n", wine_dbgstr_w(str) );
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
pos = -1;
|
|
|
|
hr = _Stream_get_Position( stream, &pos );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( pos == 10, "got %Id\n", pos );
|
2019-12-10 11:11:23 +01:00
|
|
|
|
|
|
|
eos = VARIANT_FALSE;
|
|
|
|
hr = _Stream_get_EOS( stream, &eos );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-10 11:11:23 +01:00
|
|
|
ok( eos == VARIANT_TRUE, "got %04x\n", eos );
|
|
|
|
|
|
|
|
hr = _Stream_put_Position( stream, 6 );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-10 11:11:23 +01:00
|
|
|
|
|
|
|
size = -1;
|
|
|
|
hr = _Stream_get_Size( stream, &size );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( size == 10, "got %Id\n", size );
|
2019-12-10 11:11:23 +01:00
|
|
|
|
|
|
|
hr = _Stream_put_Position( stream, 2 );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-10 11:11:23 +01:00
|
|
|
|
2019-12-11 17:18:25 +01:00
|
|
|
hr = _Stream_SetEOS( stream );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-11 17:18:25 +01:00
|
|
|
|
|
|
|
pos = -1;
|
|
|
|
hr = _Stream_get_Position( stream, &pos );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( pos == 2, "got %Id\n", pos );
|
2019-12-11 17:18:25 +01:00
|
|
|
|
|
|
|
size = -1;
|
|
|
|
hr = _Stream_get_Size( stream, &size );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( size == 2, "got %Id\n", size );
|
2019-12-11 17:18:25 +01:00
|
|
|
|
2019-12-09 11:24:29 +01:00
|
|
|
hr = _Stream_Close( stream );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-09 11:24:29 +01:00
|
|
|
|
2019-12-09 11:24:30 +01:00
|
|
|
state = 0xdeadbeef;
|
|
|
|
hr = _Stream_get_State( stream, &state );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-09 11:24:30 +01:00
|
|
|
ok( state == adStateClosed, "got %u\n", state );
|
|
|
|
|
2019-12-09 11:24:29 +01:00
|
|
|
hr = _Stream_Close( stream );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08lx\n", hr );
|
2019-12-09 11:24:29 +01:00
|
|
|
|
2019-12-06 14:54:21 +01:00
|
|
|
refs = _Stream_Release( stream );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( !refs, "got %ld\n", refs );
|
2019-12-09 11:24:31 +01:00
|
|
|
|
|
|
|
/* binary type */
|
|
|
|
hr = CoCreateInstance( &CLSID_Stream, NULL, CLSCTX_INPROC_SERVER, &IID__Stream, (void **)&stream );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-09 11:24:31 +01:00
|
|
|
|
|
|
|
hr = _Stream_put_Type( stream, adTypeBinary );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-09 11:24:31 +01:00
|
|
|
|
|
|
|
hr = _Stream_Open( stream, missing, adModeUnknown, adOpenStreamUnspecified, NULL, NULL );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-09 11:24:31 +01:00
|
|
|
|
2019-12-10 11:11:23 +01:00
|
|
|
hr = _Stream_ReadText( stream, adReadAll, &str );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrIllegalOperation ), "got %08lx\n", hr );
|
2019-12-10 11:11:23 +01:00
|
|
|
|
|
|
|
str = SysAllocString( L"test" );
|
|
|
|
hr = _Stream_WriteText( stream, str, adWriteChar );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrIllegalOperation ), "got %08lx\n", hr );
|
2019-12-10 11:11:23 +01:00
|
|
|
SysFreeString( str );
|
|
|
|
|
2019-12-09 11:24:31 +01:00
|
|
|
VariantInit( &val );
|
|
|
|
hr = _Stream_Read( stream, 1, &val );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-09 11:24:31 +01:00
|
|
|
ok( V_VT( &val ) == VT_NULL, "got %u\n", V_VT( &val ) );
|
|
|
|
|
|
|
|
VariantInit( &val );
|
|
|
|
hr = _Stream_Write( stream, val );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrInvalidArgument ), "got %08lx\n", hr );
|
2019-12-09 11:24:31 +01:00
|
|
|
|
|
|
|
hr = str_to_byte_array( "data", &val );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-09 11:24:31 +01:00
|
|
|
hr = _Stream_Write( stream, val );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-09 11:24:31 +01:00
|
|
|
VariantClear( &val );
|
|
|
|
|
2019-12-09 11:24:32 +01:00
|
|
|
pos = -1;
|
|
|
|
hr = _Stream_get_Position( stream, &pos );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( pos == 4, "got %Id\n", pos );
|
2019-12-09 11:24:32 +01:00
|
|
|
|
|
|
|
hr = _Stream_put_Position( stream, 0 );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-09 11:24:32 +01:00
|
|
|
|
|
|
|
VariantInit( &val );
|
|
|
|
hr = _Stream_Read( stream, adReadAll, &val );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-09 11:24:32 +01:00
|
|
|
ok( V_VT( &val ) == (VT_ARRAY | VT_UI1), "got %04x\n", V_VT( &val ) );
|
|
|
|
VariantClear( &val );
|
|
|
|
|
|
|
|
pos = -1;
|
|
|
|
hr = _Stream_get_Position( stream, &pos );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( pos == 4, "got %Id\n", pos );
|
2019-12-09 11:24:32 +01:00
|
|
|
|
2019-12-09 11:24:31 +01:00
|
|
|
refs = _Stream_Release( stream );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( !refs, "got %ld\n", refs );
|
2019-12-06 14:54:21 +01:00
|
|
|
}
|
|
|
|
|
2019-12-11 17:16:52 +01:00
|
|
|
static void test_Connection(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
_Connection *connection;
|
|
|
|
IRunnableObject *runtime;
|
|
|
|
ISupportErrorInfo *errorinfo;
|
2020-05-28 15:13:40 +02:00
|
|
|
IConnectionPointContainer *pointcontainer;
|
2020-12-23 10:13:57 +01:00
|
|
|
ADOConnectionConstruction15 *construct;
|
2019-12-11 17:16:53 +01:00
|
|
|
LONG state, timeout;
|
2020-06-07 15:51:20 +02:00
|
|
|
BSTR str, str2, str3;
|
2020-10-08 14:00:36 +02:00
|
|
|
ConnectModeEnum mode;
|
2020-10-09 09:57:14 +02:00
|
|
|
CursorLocationEnum location;
|
2019-12-11 17:16:52 +01:00
|
|
|
|
|
|
|
hr = CoCreateInstance(&CLSID_Connection, NULL, CLSCTX_INPROC_SERVER, &IID__Connection, (void**)&connection);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-11 17:16:52 +01:00
|
|
|
|
|
|
|
hr = _Connection_QueryInterface(connection, &IID_IRunnableObject, (void**)&runtime);
|
|
|
|
ok(hr == E_NOINTERFACE, "Unexpected IRunnableObject interface\n");
|
2020-06-07 15:51:19 +02:00
|
|
|
ok(runtime == NULL, "expected NULL\n");
|
2019-12-11 17:16:52 +01:00
|
|
|
|
|
|
|
hr = _Connection_QueryInterface(connection, &IID_ISupportErrorInfo, (void**)&errorinfo);
|
2019-12-12 16:42:05 +01:00
|
|
|
ok(hr == S_OK, "Failed to get ISupportErrorInfo interface\n");
|
|
|
|
ISupportErrorInfo_Release(errorinfo);
|
2019-12-11 17:16:52 +01:00
|
|
|
|
2020-05-28 15:13:40 +02:00
|
|
|
hr = _Connection_QueryInterface(connection, &IID_IConnectionPointContainer, (void**)&pointcontainer);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed to get IConnectionPointContainer interface %08lx\n", hr);
|
2020-05-28 15:13:40 +02:00
|
|
|
IConnectionPointContainer_Release(pointcontainer);
|
|
|
|
|
2020-12-23 10:13:57 +01:00
|
|
|
hr = _Connection_QueryInterface(connection, &IID_ADOConnectionConstruction15, (void**)&construct);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed to get ADOConnectionConstruction15 interface %08lx\n", hr);
|
2020-12-23 10:13:57 +01:00
|
|
|
if (hr == S_OK)
|
|
|
|
ADOConnectionConstruction15_Release(construct);
|
|
|
|
|
2019-12-11 17:16:52 +01:00
|
|
|
if (0) /* Crashes on windows */
|
|
|
|
{
|
|
|
|
hr = _Connection_get_State(connection, NULL);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == E_INVALIDARG, "Unexpected hr 0x%08lx\n", hr);
|
2019-12-11 17:16:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
state = -1;
|
|
|
|
hr = _Connection_get_State(connection, &state);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed to get state, hr 0x%08lx\n", hr);
|
|
|
|
ok(state == adStateClosed, "Unexpected state value 0x%08lx\n", state);
|
2019-12-11 17:16:52 +01:00
|
|
|
|
2020-06-07 15:51:20 +02:00
|
|
|
hr = _Connection_Close(connection);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == MAKE_ADO_HRESULT(adErrObjectClosed), "got %08lx\n", hr);
|
2020-06-07 15:51:20 +02:00
|
|
|
|
2019-12-11 17:16:53 +01:00
|
|
|
timeout = 0;
|
|
|
|
hr = _Connection_get_CommandTimeout(connection, &timeout);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed to get state, hr 0x%08lx\n", hr);
|
|
|
|
ok(timeout == 30, "Unexpected timeout value %ld\n", timeout);
|
2019-12-11 17:16:53 +01:00
|
|
|
|
|
|
|
hr = _Connection_put_CommandTimeout(connection, 300);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed to get state, hr 0x%08lx\n", hr);
|
2019-12-11 17:16:53 +01:00
|
|
|
|
|
|
|
timeout = 0;
|
|
|
|
hr = _Connection_get_CommandTimeout(connection, &timeout);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed to get state, hr 0x%08lx\n", hr);
|
|
|
|
ok(timeout == 300, "Unexpected timeout value %ld\n", timeout);
|
2019-12-11 17:16:53 +01:00
|
|
|
|
2020-10-09 09:57:14 +02:00
|
|
|
location = 0;
|
|
|
|
hr = _Connection_get_CursorLocation(connection, &location);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed, hr 0x%08lx\n", hr);
|
2020-10-09 09:57:14 +02:00
|
|
|
ok(location == adUseServer, "Unexpected location value %d\n", location);
|
|
|
|
|
|
|
|
hr = _Connection_put_CursorLocation(connection, adUseClient);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed, hr 0x%08lx\n", hr);
|
2020-10-09 09:57:14 +02:00
|
|
|
|
|
|
|
location = 0;
|
|
|
|
hr = _Connection_get_CursorLocation(connection, &location);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed, hr 0x%08lx\n", hr);
|
2020-10-09 09:57:14 +02:00
|
|
|
ok(location == adUseClient, "Unexpected location value %d\n", location);
|
|
|
|
|
|
|
|
hr = _Connection_put_CursorLocation(connection, adUseServer);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed, hr 0x%08lx\n", hr);
|
2020-10-09 09:57:14 +02:00
|
|
|
|
2020-10-08 14:00:36 +02:00
|
|
|
mode = 0xdeadbeef;
|
|
|
|
hr = _Connection_get_Mode(connection, &mode);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed to get state, hr 0x%08lx\n", hr);
|
2020-10-08 14:00:36 +02:00
|
|
|
ok(mode == adModeUnknown, "Unexpected mode value %d\n", mode);
|
|
|
|
|
|
|
|
hr = _Connection_put_Mode(connection, adModeShareDenyNone);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed to get state, hr 0x%08lx\n", hr);
|
2020-10-08 14:00:36 +02:00
|
|
|
|
|
|
|
mode = adModeUnknown;
|
|
|
|
hr = _Connection_get_Mode(connection, &mode);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed to get state, hr 0x%08lx\n", hr);
|
2020-10-08 14:00:36 +02:00
|
|
|
ok(mode == adModeShareDenyNone, "Unexpected mode value %d\n", mode);
|
|
|
|
|
|
|
|
hr = _Connection_put_Mode(connection, adModeUnknown);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed to get state, hr 0x%08lx\n", hr);
|
2020-10-08 14:00:36 +02:00
|
|
|
|
2020-10-08 14:00:35 +02:00
|
|
|
/* Default */
|
2020-01-28 11:36:03 +01:00
|
|
|
str = (BSTR)0xdeadbeef;
|
2020-10-08 14:00:35 +02:00
|
|
|
hr = _Connection_get_Provider(connection, &str);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed, hr 0x%08lx\n", hr);
|
2020-10-08 14:00:35 +02:00
|
|
|
ok(!wcscmp(str, L"MSDASQL"), "wrong string %s\n", wine_dbgstr_w(str));
|
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
str = SysAllocString(L"MSDASQL.1");
|
|
|
|
hr = _Connection_put_Provider(connection, str);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed, hr 0x%08lx\n", hr);
|
2020-10-08 14:00:35 +02:00
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
str = (BSTR)0xdeadbeef;
|
|
|
|
hr = _Connection_get_Provider(connection, &str);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed, hr 0x%08lx\n", hr);
|
2020-10-08 14:00:35 +02:00
|
|
|
ok(!wcscmp(str, L"MSDASQL.1"), "wrong string %s\n", wine_dbgstr_w(str));
|
|
|
|
|
|
|
|
/* Restore default */
|
|
|
|
str = SysAllocString(L"MSDASQL");
|
|
|
|
hr = _Connection_put_Provider(connection, str);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed, hr 0x%08lx\n", hr);
|
2020-10-08 14:00:35 +02:00
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
hr = _Connection_put_Provider(connection, NULL);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == MAKE_ADO_HRESULT(adErrInvalidArgument), "got 0x%08lx\n", hr);
|
2020-10-08 14:00:35 +02:00
|
|
|
SysFreeString(str);
|
|
|
|
|
|
|
|
str = (BSTR)0xdeadbeef;
|
|
|
|
hr = _Connection_get_ConnectionString(connection, &str);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "got 0x%08lx\n", hr);
|
2020-01-28 11:36:03 +01:00
|
|
|
ok(str == NULL, "got %p\n", str);
|
|
|
|
|
|
|
|
str = SysAllocString(L"Provider=MSDASQL.1;Persist Security Info=False;Data Source=wine_test");
|
|
|
|
hr = _Connection_put_ConnectionString(connection, str);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed, hr 0x%08lx\n", hr);
|
2020-01-28 11:36:03 +01:00
|
|
|
|
2020-10-08 14:00:35 +02:00
|
|
|
/* Show put_ConnectionString effects Provider */
|
|
|
|
str3 = (BSTR)0xdeadbeef;
|
|
|
|
hr = _Connection_get_Provider(connection, &str3);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed, hr 0x%08lx\n", hr);
|
2020-10-08 14:00:35 +02:00
|
|
|
ok(str3 != NULL, "Expected value got NULL\n");
|
|
|
|
todo_wine ok(!wcscmp(str3, L"MSDASQL.1"), "wrong string %s\n", wine_dbgstr_w(str3));
|
|
|
|
SysFreeString(str3);
|
|
|
|
|
2020-01-28 11:36:03 +01:00
|
|
|
if (0) /* Crashes on windows */
|
|
|
|
{
|
|
|
|
hr = _Connection_get_ConnectionString(connection, NULL);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == E_POINTER, "Failed, hr 0x%08lx\n", hr);
|
2020-01-28 11:36:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
str2 = NULL;
|
|
|
|
hr = _Connection_get_ConnectionString(connection, &str2);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed, hr 0x%08lx\n", hr);
|
2020-01-28 11:36:03 +01:00
|
|
|
ok(!wcscmp(str, str2), "wrong string %s\n", wine_dbgstr_w(str2));
|
2020-06-07 15:51:20 +02:00
|
|
|
|
|
|
|
hr = _Connection_Open(connection, NULL, NULL, NULL, 0);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == E_FAIL, "Failed, hr 0x%08lx\n", hr);
|
2020-06-07 15:51:20 +02:00
|
|
|
|
|
|
|
/* Open adds trailing ; if it's missing */
|
|
|
|
str3 = SysAllocString(L"Provider=MSDASQL.1;Persist Security Info=False;Data Source=wine_test;");
|
|
|
|
hr = _Connection_Open(connection, NULL, NULL, NULL, adConnectUnspecified);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == E_FAIL, "Failed, hr 0x%08lx\n", hr);
|
2020-06-07 15:51:20 +02:00
|
|
|
|
|
|
|
str2 = NULL;
|
|
|
|
hr = _Connection_get_ConnectionString(connection, &str2);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed, hr 0x%08lx\n", hr);
|
2020-06-07 15:51:20 +02:00
|
|
|
todo_wine ok(!wcscmp(str3, str2) || broken(!wcscmp(str, str2)) /* XP */, "wrong string %s\n", wine_dbgstr_w(str2));
|
|
|
|
|
|
|
|
hr = _Connection_Open(connection, str, NULL, NULL, adConnectUnspecified);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == E_FAIL, "Failed, hr 0x%08lx\n", hr);
|
2020-01-28 11:36:03 +01:00
|
|
|
SysFreeString(str);
|
2020-06-07 15:51:20 +02:00
|
|
|
|
|
|
|
str2 = NULL;
|
|
|
|
hr = _Connection_get_ConnectionString(connection, &str2);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed, hr 0x%08lx\n", hr);
|
2020-06-07 15:51:20 +02:00
|
|
|
todo_wine ok(!wcscmp(str3, str2) || broken(!wcscmp(str, str2)) /* XP */, "wrong string %s\n", wine_dbgstr_w(str2));
|
2020-01-28 11:36:03 +01:00
|
|
|
SysFreeString(str2);
|
2020-06-07 15:51:20 +02:00
|
|
|
SysFreeString(str3);
|
2020-01-28 11:36:03 +01:00
|
|
|
|
|
|
|
hr = _Connection_put_ConnectionString(connection, NULL);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed, hr 0x%08lx\n", hr);
|
2020-01-28 11:36:03 +01:00
|
|
|
|
|
|
|
str = (BSTR)0xdeadbeef;
|
|
|
|
hr = _Connection_get_ConnectionString(connection, &str);
|
2022-03-01 08:33:37 +01:00
|
|
|
ok(hr == S_OK, "Failed, hr 0x%08lx\n", hr);
|
2020-01-28 11:36:03 +01:00
|
|
|
ok(str == NULL, "got %p\n", str);
|
2019-12-11 17:16:52 +01:00
|
|
|
_Connection_Release(connection);
|
|
|
|
}
|
|
|
|
|
2019-12-12 16:42:06 +01:00
|
|
|
static void test_Command(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
_Command *command;
|
|
|
|
_ADO *ado;
|
|
|
|
Command15 *command15;
|
|
|
|
Command25 *command25;
|
2020-05-25 16:01:30 +02:00
|
|
|
CommandTypeEnum cmd_type = adCmdUnspecified;
|
2020-05-27 16:19:03 +02:00
|
|
|
BSTR cmd_text = (BSTR)"test";
|
2020-10-09 09:57:15 +02:00
|
|
|
_Connection *connection;
|
2019-12-12 16:42:06 +01:00
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_Command, NULL, CLSCTX_INPROC_SERVER, &IID__Command, (void **)&command );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-12 16:42:06 +01:00
|
|
|
|
|
|
|
hr = _Command_QueryInterface( command, &IID__ADO, (void **)&ado );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-12 16:42:06 +01:00
|
|
|
_ADO_Release( ado );
|
|
|
|
|
|
|
|
hr = _Command_QueryInterface( command, &IID_Command15, (void **)&command15 );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-12 16:42:06 +01:00
|
|
|
Command15_Release( command15 );
|
|
|
|
|
|
|
|
hr = _Command_QueryInterface( command, &IID_Command25, (void **)&command25 );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2019-12-12 16:42:06 +01:00
|
|
|
Command25_Release( command25 );
|
|
|
|
|
2020-05-25 16:01:30 +02:00
|
|
|
hr = _Command_get_CommandType( command, &cmd_type );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2020-05-25 16:01:30 +02:00
|
|
|
ok( cmd_type == adCmdUnknown, "got %08x\n", cmd_type );
|
|
|
|
|
|
|
|
_Command_put_CommandType( command, adCmdText );
|
|
|
|
hr = _Command_get_CommandType( command, &cmd_type );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2020-05-25 16:01:30 +02:00
|
|
|
ok( cmd_type == adCmdText, "got %08x\n", cmd_type );
|
|
|
|
|
|
|
|
hr = _Command_put_CommandType( command, 0xdeadbeef );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrInvalidArgument ), "got %08lx\n", hr );
|
2020-05-25 16:01:30 +02:00
|
|
|
|
2020-05-27 16:19:03 +02:00
|
|
|
hr = _Command_get_CommandText( command, &cmd_text );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2020-05-27 16:19:03 +02:00
|
|
|
ok( !cmd_text, "got %s\n", wine_dbgstr_w( cmd_text ));
|
|
|
|
|
|
|
|
hr = _Command_put_CommandText( command, NULL );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2020-05-27 16:19:03 +02:00
|
|
|
|
|
|
|
cmd_text = SysAllocString( L"" );
|
|
|
|
hr = _Command_put_CommandText( command, cmd_text );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2020-05-27 16:19:03 +02:00
|
|
|
SysFreeString( cmd_text );
|
|
|
|
|
|
|
|
hr = _Command_get_CommandText( command, &cmd_text );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2020-05-27 16:19:03 +02:00
|
|
|
ok( cmd_text && !*cmd_text, "got %p\n", cmd_text );
|
|
|
|
|
|
|
|
cmd_text = SysAllocString( L"test" );
|
|
|
|
hr = _Command_put_CommandText( command, cmd_text );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2020-05-27 16:19:03 +02:00
|
|
|
SysFreeString( cmd_text );
|
|
|
|
|
|
|
|
hr = _Command_get_CommandText( command, &cmd_text );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2020-05-27 16:19:03 +02:00
|
|
|
ok( !wcscmp( L"test", cmd_text ), "got %p\n", wine_dbgstr_w( cmd_text ) );
|
|
|
|
|
2020-10-09 09:57:15 +02:00
|
|
|
connection = (_Connection*)0xdeadbeef;
|
|
|
|
hr = _Command_get_ActiveConnection( command, &connection );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2020-10-09 09:57:15 +02:00
|
|
|
ok( connection == NULL, "got %p\n", connection );
|
|
|
|
|
|
|
|
hr = _Command_putref_ActiveConnection( command, NULL );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2020-10-09 09:57:15 +02:00
|
|
|
|
2019-12-12 16:42:06 +01:00
|
|
|
_Command_Release( command );
|
|
|
|
}
|
|
|
|
|
2020-06-17 14:36:14 +02:00
|
|
|
struct conn_event {
|
|
|
|
ConnectionEventsVt conn_event_sink;
|
|
|
|
LONG refs;
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI conneventvt_QueryInterface( ConnectionEventsVt *iface, REFIID riid, void **obj )
|
|
|
|
{
|
|
|
|
struct conn_event *conn_event = CONTAINING_RECORD( iface, struct conn_event, conn_event_sink );
|
|
|
|
|
|
|
|
if (IsEqualGUID( &IID_ConnectionEventsVt, riid ))
|
|
|
|
{
|
|
|
|
InterlockedIncrement( &conn_event->refs );
|
|
|
|
*obj = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok( 0, "unexpected call\n" );
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI conneventvt_AddRef( ConnectionEventsVt *iface )
|
|
|
|
{
|
|
|
|
struct conn_event *conn_event = CONTAINING_RECORD( iface, struct conn_event, conn_event_sink );
|
|
|
|
return InterlockedIncrement( &conn_event->refs );
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI conneventvt_Release( ConnectionEventsVt *iface )
|
|
|
|
{
|
|
|
|
struct conn_event *conn_event = CONTAINING_RECORD( iface, struct conn_event, conn_event_sink );
|
|
|
|
return InterlockedDecrement( &conn_event->refs );
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI conneventvt_InfoMessage( ConnectionEventsVt *iface, Error *error,
|
|
|
|
EventStatusEnum *status, _Connection *Connection )
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI conneventvt_BeginTransComplete( ConnectionEventsVt *iface, LONG TransactionLevel,
|
|
|
|
Error *error, EventStatusEnum *status, _Connection *connection )
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI conneventvt_CommitTransComplete( ConnectionEventsVt *iface, Error *error,
|
|
|
|
EventStatusEnum *status, _Connection *connection )
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI conneventvt_RollbackTransComplete( ConnectionEventsVt *iface, Error *error,
|
|
|
|
EventStatusEnum *status, _Connection *connection )
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI conneventvt_WillExecute( ConnectionEventsVt *iface, BSTR *source,
|
|
|
|
CursorTypeEnum *cursor_type, LockTypeEnum *lock_type, LONG *options, EventStatusEnum *status,
|
|
|
|
_Command *command, _Recordset *record_set, _Connection *connection )
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI conneventvt_ExecuteComplete( ConnectionEventsVt *iface, LONG records_affected,
|
|
|
|
Error *error, EventStatusEnum *status, _Command *command, _Recordset *record_set,
|
|
|
|
_Connection *connection )
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI conneventvt_WillConnect( ConnectionEventsVt *iface, BSTR *string, BSTR *userid,
|
|
|
|
BSTR *password, LONG *options, EventStatusEnum *status, _Connection *connection )
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI conneventvt_ConnectComplete( ConnectionEventsVt *iface, Error *error,
|
|
|
|
EventStatusEnum *status, _Connection *connection )
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI conneventvt_Disconnect( ConnectionEventsVt *iface, EventStatusEnum *status,
|
|
|
|
_Connection *connection )
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const ConnectionEventsVtVtbl conneventvt_vtbl = {
|
|
|
|
conneventvt_QueryInterface,
|
|
|
|
conneventvt_AddRef,
|
|
|
|
conneventvt_Release,
|
|
|
|
conneventvt_InfoMessage,
|
|
|
|
conneventvt_BeginTransComplete,
|
|
|
|
conneventvt_CommitTransComplete,
|
|
|
|
conneventvt_RollbackTransComplete,
|
|
|
|
conneventvt_WillExecute,
|
|
|
|
conneventvt_ExecuteComplete,
|
|
|
|
conneventvt_WillConnect,
|
|
|
|
conneventvt_ConnectComplete,
|
|
|
|
conneventvt_Disconnect
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI supporterror_QueryInterface( ISupportErrorInfo *iface, REFIID riid, void **obj )
|
|
|
|
{
|
|
|
|
if (IsEqualGUID( &IID_ISupportErrorInfo, riid ))
|
|
|
|
{
|
|
|
|
*obj = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI supporterror_AddRef( ISupportErrorInfo *iface )
|
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI supporterror_Release( ISupportErrorInfo *iface )
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI supporterror_InterfaceSupportsErrorInfo( ISupportErrorInfo *iface, REFIID riid )
|
|
|
|
{
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ISupportErrorInfoVtbl support_error_vtbl =
|
|
|
|
{
|
|
|
|
supporterror_QueryInterface,
|
|
|
|
supporterror_AddRef,
|
|
|
|
supporterror_Release,
|
|
|
|
supporterror_InterfaceSupportsErrorInfo
|
|
|
|
};
|
|
|
|
|
2020-06-01 13:42:18 +02:00
|
|
|
static void test_ConnectionPoint(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
ULONG refs;
|
2020-06-17 14:36:14 +02:00
|
|
|
DWORD cookie;
|
2020-06-01 13:42:18 +02:00
|
|
|
IConnectionPoint *point;
|
|
|
|
IConnectionPointContainer *pointcontainer;
|
2020-06-17 14:36:14 +02:00
|
|
|
struct conn_event conn_event = { { &conneventvt_vtbl }, 0 };
|
|
|
|
ISupportErrorInfo support_err_sink = { &support_error_vtbl };
|
2020-06-01 13:42:18 +02:00
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_Connection, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IConnectionPointContainer, (void**)&pointcontainer );
|
|
|
|
|
|
|
|
hr = IConnectionPointContainer_FindConnectionPoint( pointcontainer, &DIID_ConnectionEvents, NULL );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == E_POINTER, "got %08lx\n", hr );
|
2020-06-01 13:42:18 +02:00
|
|
|
|
|
|
|
hr = IConnectionPointContainer_FindConnectionPoint( pointcontainer, &DIID_RecordsetEvents, &point );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == CONNECT_E_NOCONNECTION, "got %08lx\n", hr );
|
2020-06-01 13:42:18 +02:00
|
|
|
|
|
|
|
hr = IConnectionPointContainer_FindConnectionPoint( pointcontainer, &DIID_ConnectionEvents, &point );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2020-06-01 13:42:18 +02:00
|
|
|
|
2020-06-17 14:36:14 +02:00
|
|
|
/* nothing advised yet */
|
|
|
|
hr = IConnectionPoint_Unadvise( point, 3 );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == E_FAIL, "got %08lx\n", hr );
|
2020-06-17 14:36:14 +02:00
|
|
|
|
|
|
|
hr = IConnectionPoint_Advise( point, NULL, NULL );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == E_FAIL, "got %08lx\n", hr );
|
2020-06-17 14:36:14 +02:00
|
|
|
|
|
|
|
hr = IConnectionPoint_Advise( point, (void*)&conn_event.conn_event_sink, NULL );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == E_FAIL, "got %08lx\n", hr );
|
2020-06-17 14:36:14 +02:00
|
|
|
|
|
|
|
cookie = 0xdeadbeef;
|
|
|
|
hr = IConnectionPoint_Advise( point, NULL, &cookie );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == E_FAIL, "got %08lx\n", hr );
|
|
|
|
ok( cookie == 0xdeadbeef, "got %08lx\n", cookie );
|
2020-06-17 14:36:14 +02:00
|
|
|
|
|
|
|
/* unsupported sink */
|
|
|
|
cookie = 0xdeadbeef;
|
|
|
|
hr = IConnectionPoint_Advise( point, (void*)&support_err_sink, &cookie );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == E_FAIL, "got %08lx\n", hr );
|
|
|
|
ok( !cookie, "got %08lx\n", cookie );
|
2020-06-17 14:36:14 +02:00
|
|
|
|
|
|
|
cookie = 0;
|
|
|
|
hr = IConnectionPoint_Advise( point, (void*)&conn_event.conn_event_sink, &cookie );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( cookie, "got %08lx\n", cookie );
|
2020-06-17 14:36:14 +02:00
|
|
|
|
|
|
|
/* invalid cookie */
|
|
|
|
hr = IConnectionPoint_Unadvise( point, 0 );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == E_FAIL, "got %08lx\n", hr );
|
2020-06-17 14:36:14 +02:00
|
|
|
|
|
|
|
/* wrong cookie */
|
|
|
|
hr = IConnectionPoint_Unadvise( point, cookie + 1 );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == E_FAIL, "got %08lx\n", hr );
|
2020-06-17 14:36:14 +02:00
|
|
|
|
|
|
|
hr = IConnectionPoint_Unadvise( point, cookie );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
2020-06-17 14:36:14 +02:00
|
|
|
|
|
|
|
/* sinks are released when the connection is destroyed */
|
|
|
|
cookie = 0;
|
|
|
|
hr = IConnectionPoint_Advise( point, (void*)&conn_event.conn_event_sink, &cookie );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( hr == S_OK, "got %08lx\n", hr );
|
|
|
|
ok( cookie, "got %08lx\n", cookie );
|
|
|
|
ok( conn_event.refs == 1, "got %ld\n", conn_event.refs );
|
2020-06-17 14:36:15 +02:00
|
|
|
|
2020-06-01 13:42:18 +02:00
|
|
|
refs = IConnectionPoint_Release( point );
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( refs == 1, "got %lu", refs );
|
2020-06-01 13:42:18 +02:00
|
|
|
|
|
|
|
IConnectionPointContainer_Release( pointcontainer );
|
2020-06-17 14:36:14 +02:00
|
|
|
|
2022-03-01 08:33:37 +01:00
|
|
|
ok( !conn_event.refs, "got %ld\n", conn_event.refs );
|
2020-06-01 13:42:18 +02:00
|
|
|
}
|
|
|
|
|
2019-12-06 14:54:21 +01:00
|
|
|
START_TEST(msado15)
|
|
|
|
{
|
|
|
|
CoInitialize( NULL );
|
2019-12-11 17:16:52 +01:00
|
|
|
test_Connection();
|
2020-11-18 10:42:20 +01:00
|
|
|
test_ADORecordsetConstruction();
|
2020-06-01 13:42:18 +02:00
|
|
|
test_ConnectionPoint();
|
2019-12-11 17:18:28 +01:00
|
|
|
test_Fields();
|
2019-12-11 17:18:26 +01:00
|
|
|
test_Recordset();
|
|
|
|
test_Stream();
|
2019-12-12 16:42:06 +01:00
|
|
|
test_Command();
|
2019-12-06 14:54:21 +01:00
|
|
|
CoUninitialize();
|
|
|
|
}
|