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"
|
|
|
|
|
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-12 17:12:22 +01:00
|
|
|
static LONG get_refs_field( Field *field )
|
|
|
|
{
|
|
|
|
Field_AddRef( field );
|
|
|
|
return Field_Release( field );
|
|
|
|
}
|
|
|
|
|
2019-12-11 17:18:26 +01:00
|
|
|
static LONG get_refs_fields( Fields *fields )
|
|
|
|
{
|
|
|
|
Fields_AddRef( fields );
|
|
|
|
return Fields_Release( fields );
|
|
|
|
}
|
|
|
|
|
|
|
|
static LONG get_refs_recordset( _Recordset *recordset )
|
|
|
|
{
|
|
|
|
_Recordset_AddRef( recordset );
|
|
|
|
return _Recordset_Release( recordset );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_Recordset(void)
|
|
|
|
{
|
|
|
|
_Recordset *recordset;
|
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;
|
2019-12-13 15:52:24 +01:00
|
|
|
LONG refs, count, state;
|
2019-12-13 15:52:29 +01:00
|
|
|
VARIANT missing, val, index;
|
2020-01-24 00:43:38 +01:00
|
|
|
CursorLocationEnum location;
|
2019-12-13 15:52:24 +01:00
|
|
|
BSTR name;
|
2019-12-11 17:18:26 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_Recordset, NULL, CLSCTX_INPROC_SERVER, &IID__Recordset, (void **)&recordset );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2019-12-13 15:52:30 +01:00
|
|
|
/* _Recordset object supports ISupportErrorInfo */
|
|
|
|
errorinfo = NULL;
|
|
|
|
hr = _Recordset_QueryInterface( recordset, &IID_ISupportErrorInfo, (void **)&errorinfo );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
refs = get_refs_recordset( recordset );
|
|
|
|
ok( refs == 2, "got %d\n", refs );
|
|
|
|
if (errorinfo) ISupportErrorInfo_Release( errorinfo );
|
|
|
|
refs = get_refs_recordset( recordset );
|
|
|
|
ok( refs == 1, "got %d\n", refs );
|
|
|
|
|
2019-12-11 17:18:26 +01:00
|
|
|
/* handing out fields object increases recordset refcount */
|
|
|
|
refs = get_refs_recordset( recordset );
|
|
|
|
ok( refs == 1, "got %d\n", refs );
|
|
|
|
hr = _Recordset_get_Fields( recordset, &fields );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
refs = get_refs_recordset( recordset );
|
|
|
|
ok( refs == 2, "got %d\n", refs );
|
|
|
|
refs = get_refs_fields( fields );
|
|
|
|
ok( refs == 1, "got %d\n", refs );
|
|
|
|
|
|
|
|
/* releasing fields object decreases recordset refcount, but fields refcount doesn't drop to zero */
|
|
|
|
Fields_Release( fields );
|
|
|
|
refs = get_refs_recordset( recordset );
|
|
|
|
ok( refs == 1, "got %d\n", refs );
|
|
|
|
refs = get_refs_fields( fields );
|
|
|
|
ok( refs == 1, "got %d\n", refs );
|
|
|
|
|
|
|
|
/* calling get_Fields again returns the same object with the same refcount and increases recordset refcount */
|
|
|
|
hr = _Recordset_get_Fields( recordset, &fields2 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
refs = get_refs_recordset( recordset );
|
|
|
|
ok( refs == 2, "got %d\n", refs );
|
|
|
|
refs = get_refs_fields( fields2 );
|
|
|
|
ok( refs == 1, "got %d\n", refs );
|
|
|
|
ok( fields2 == fields, "expected same object\n" );
|
|
|
|
refs = Fields_Release( fields2 );
|
|
|
|
ok( refs == 1, "got %d\n", refs );
|
|
|
|
|
|
|
|
count = -1;
|
|
|
|
hr = Fields_get_Count( fields2, &count );
|
2019-12-11 17:18:28 +01:00
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( !count, "got %d\n", count );
|
2019-12-11 17:18:26 +01:00
|
|
|
|
2019-12-13 15:52:31 +01:00
|
|
|
hr = _Recordset_Close( recordset );
|
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08x\n", hr );
|
|
|
|
|
2019-12-11 17:18:26 +01:00
|
|
|
refs = _Recordset_Release( recordset );
|
|
|
|
ok( !refs, "got %d\n", refs );
|
|
|
|
|
|
|
|
/* fields object still has a reference */
|
|
|
|
refs = Fields_Release( fields2 );
|
|
|
|
ok( refs == 1, "got %d\n", refs );
|
2019-12-13 15:52:24 +01:00
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_Recordset, NULL, CLSCTX_INPROC_SERVER, &IID__Recordset, (void **)&recordset );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
state = -1;
|
|
|
|
hr = _Recordset_get_State( recordset, &state );
|
2019-12-13 15:52:25 +01:00
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( state == adStateClosed, "got %d\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 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( location == adUseServer, "got %d\n", location );
|
|
|
|
|
2019-12-13 15:52:24 +01:00
|
|
|
VariantInit( &missing );
|
|
|
|
hr = _Recordset_AddNew( recordset, missing, missing );
|
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08x\n", hr );
|
|
|
|
|
|
|
|
V_VT( &missing ) = VT_ERROR;
|
|
|
|
V_ERROR( &missing ) = DISP_E_PARAMNOTFOUND;
|
|
|
|
hr = _Recordset_Open( recordset, missing, missing, adOpenStatic, adLockBatchOptimistic, adCmdUnspecified );
|
2019-12-13 15:52:31 +01:00
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrInvalidConnection ), "got %08x\n", hr );
|
2019-12-13 15:52:24 +01:00
|
|
|
|
|
|
|
hr = _Recordset_get_Fields( recordset, &fields );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
name = SysAllocString( L"field" );
|
|
|
|
hr = Fields__Append( fields, name, adInteger, 4, adFldUnspecified );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
2019-12-13 15:52:29 +01:00
|
|
|
|
|
|
|
V_VT( &index ) = VT_BSTR;
|
|
|
|
V_BSTR( &index ) = name;
|
|
|
|
hr = Fields_get_Item( fields, index, &field );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
2019-12-13 15:52:24 +01:00
|
|
|
SysFreeString( name );
|
|
|
|
|
|
|
|
hr = _Recordset_Open( recordset, missing, missing, adOpenStatic, adLockBatchOptimistic, adCmdUnspecified );
|
|
|
|
ok( hr == S_OK, "got %08x\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 );
|
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectOpen ), "got %08x\n", hr );
|
|
|
|
|
2019-12-13 15:52:24 +01:00
|
|
|
state = -1;
|
|
|
|
hr = _Recordset_get_State( recordset, &state );
|
2019-12-13 15:52:25 +01:00
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( state == adStateOpen, "got %d\n", state );
|
2019-12-13 15:52:24 +01:00
|
|
|
|
2019-12-13 15:52:27 +01:00
|
|
|
count = -1;
|
|
|
|
hr = _Recordset_get_RecordCount( recordset, &count );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( !count, "got %d\n", count );
|
|
|
|
|
2019-12-13 15:52:24 +01:00
|
|
|
hr = _Recordset_AddNew( recordset, missing, missing );
|
|
|
|
ok( hr == S_OK, "got %08x\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
|
|
|
|
2019-12-13 15:52:27 +01:00
|
|
|
count = -1;
|
|
|
|
hr = _Recordset_get_RecordCount( recordset, &count );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( count == 1, "got %d\n", count );
|
|
|
|
|
2019-12-13 15:52:29 +01:00
|
|
|
/* get_Fields still returns the same object */
|
|
|
|
hr = _Recordset_get_Fields( recordset, &fields2 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( fields2 == fields, "expected same object\n" );
|
|
|
|
Fields_Release( fields2 );
|
|
|
|
|
|
|
|
count = -1;
|
|
|
|
hr = Fields_get_Count( fields2, &count );
|
|
|
|
ok( count == 1, "got %d\n", count );
|
|
|
|
|
|
|
|
hr = Field_get_Value( field, &val );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
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 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
V_VT( &val ) = VT_ERROR;
|
|
|
|
V_ERROR( &val ) = DISP_E_PARAMNOTFOUND;
|
|
|
|
hr = Field_get_Value( field, &val );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( V_VT( &val ) == VT_I4, "got %u\n", V_VT( &val ) );
|
|
|
|
ok( V_I4( &val ) == -1, "got %d\n", V_I4( &val ) );
|
|
|
|
|
|
|
|
hr = _Recordset_AddNew( recordset, missing, missing );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
/* field object returns different value after AddNew */
|
|
|
|
V_VT( &val ) = VT_ERROR;
|
|
|
|
V_ERROR( &val ) = DISP_E_PARAMNOTFOUND;
|
|
|
|
hr = Field_get_Value( field, &val );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
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 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
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 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( V_VT( &val ) == VT_I4, "got %u\n", V_VT( &val ) );
|
|
|
|
ok( V_I4( &val ) == -1, "got %d\n", V_I4( &val ) );
|
|
|
|
|
|
|
|
hr = _Recordset_MoveNext( recordset );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( !is_eof( recordset ), "eof\n" );
|
|
|
|
ok( !is_bof( recordset ), "not bof\n" );
|
|
|
|
|
|
|
|
hr = _Recordset_MoveNext( recordset );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( is_eof( recordset ), "not eof\n" );
|
|
|
|
ok( !is_bof( recordset ), "bof\n" );
|
|
|
|
|
|
|
|
hr = _Recordset_MoveFirst( recordset );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( !is_eof( recordset ), "eof\n" );
|
|
|
|
ok( !is_bof( recordset ), "bof\n" );
|
|
|
|
|
|
|
|
hr = _Recordset_MovePrevious( recordset );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
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 );
|
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrNoCurrentRecord ), "got %08x\n", hr );
|
|
|
|
|
2019-12-13 15:52:24 +01:00
|
|
|
hr = _Recordset_Close( recordset );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2019-12-13 15:52:25 +01:00
|
|
|
state = -1;
|
|
|
|
hr = _Recordset_get_State( recordset, &state );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( state == adStateClosed, "got %d\n", state );
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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;
|
2019-12-12 17:12:23 +01:00
|
|
|
LONG refs, count, size;
|
|
|
|
DataTypeEnum type;
|
|
|
|
FieldAttributeEnum attrs;
|
2019-12-11 17:18:28 +01:00
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_Recordset, NULL, CLSCTX_INPROC_SERVER, &IID__Recordset, (void **)&recordset );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = _Recordset_get_Fields( recordset, &fields );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2019-12-13 15:52:30 +01:00
|
|
|
/* Fields object supports ISupportErrorInfo */
|
|
|
|
errorinfo = NULL;
|
|
|
|
hr = Fields_QueryInterface( fields, &IID_ISupportErrorInfo, (void **)&errorinfo );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
refs = get_refs_fields( fields );
|
|
|
|
ok( refs == 2, "got %d\n", refs );
|
|
|
|
if (errorinfo) ISupportErrorInfo_Release( errorinfo );
|
|
|
|
refs = get_refs_fields( fields );
|
|
|
|
ok( refs == 1, "got %d\n", refs );
|
|
|
|
|
2019-12-11 17:18:28 +01:00
|
|
|
count = -1;
|
|
|
|
hr = Fields_get_Count( fields, &count );
|
|
|
|
ok( !count, "got %d\n", count );
|
|
|
|
|
|
|
|
name = SysAllocString( L"field" );
|
|
|
|
V_VT( &val ) = VT_ERROR;
|
|
|
|
V_ERROR( &val ) = DISP_E_PARAMNOTFOUND;
|
|
|
|
hr = Fields_Append( fields, name, adInteger, 4, adFldUnspecified, val );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
SysFreeString( name );
|
|
|
|
|
|
|
|
count = -1;
|
|
|
|
hr = Fields_get_Count( fields, &count );
|
|
|
|
ok( count == 1, "got %d\n", count );
|
|
|
|
|
|
|
|
name = SysAllocString( L"field2" );
|
|
|
|
hr = Fields__Append( fields, name, adInteger, 4, adFldUnspecified );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
SysFreeString( name );
|
|
|
|
|
|
|
|
count = -1;
|
|
|
|
hr = Fields_get_Count( fields, &count );
|
|
|
|
ok( count == 2, "got %d\n", count );
|
|
|
|
|
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;
|
|
|
|
refs = get_refs_recordset( recordset );
|
|
|
|
ok( refs == 2, "got %d\n", refs );
|
|
|
|
refs = get_refs_fields( fields );
|
|
|
|
ok( refs == 1, "got %d\n", refs );
|
|
|
|
hr = Fields_get_Item( fields, index, &field );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
refs = get_refs_field( field );
|
|
|
|
ok( refs == 1, "got %d\n", refs );
|
|
|
|
refs = get_refs_recordset( recordset );
|
|
|
|
ok( refs == 2, "got %d\n", refs );
|
|
|
|
refs = get_refs_fields( fields );
|
|
|
|
ok( refs == 1, "got %d\n", refs );
|
|
|
|
|
|
|
|
/* calling get_Item again returns the same object and adds reference */
|
|
|
|
hr = Fields_get_Item( fields, index, &field2 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( field2 == field, "expected same object\n" );
|
|
|
|
refs = get_refs_field( field2 );
|
|
|
|
ok( refs == 2, "got %d\n", refs );
|
|
|
|
refs = get_refs_recordset( recordset );
|
|
|
|
ok( refs == 2, "got %d\n", refs );
|
|
|
|
refs = get_refs_fields( fields );
|
|
|
|
ok( refs == 1, "got %d\n", refs );
|
|
|
|
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 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
refs = get_refs_field( field );
|
|
|
|
ok( refs == 2, "got %d\n", refs );
|
|
|
|
if (errorinfo) ISupportErrorInfo_Release( errorinfo );
|
|
|
|
refs = get_refs_field( field );
|
|
|
|
ok( refs == 1, "got %d\n", refs );
|
|
|
|
|
2019-12-12 17:12:23 +01:00
|
|
|
/* verify values set with _Append */
|
|
|
|
hr = Field_get_Name( field, &name );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( name, L"field" ), "got %s\n", wine_dbgstr_w(name) );
|
|
|
|
SysFreeString( name );
|
|
|
|
type = 0xdead;
|
|
|
|
hr = Field_get_Type( field, &type );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( type == adInteger, "got %d\n", type );
|
|
|
|
size = -1;
|
|
|
|
hr = Field_get_DefinedSize( field, &size );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( size == 4, "got %d\n", size );
|
|
|
|
attrs = 0xdead;
|
|
|
|
hr = Field_get_Attributes( field, &attrs );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( !attrs, "got %d\n", attrs );
|
|
|
|
|
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;
|
2019-12-09 11:24:33 +01:00
|
|
|
LONG refs, 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 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2019-12-09 11:24:33 +01:00
|
|
|
hr = _Stream_get_Size( stream, &size );
|
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08x\n", hr );
|
|
|
|
|
2019-12-10 11:11:19 +01:00
|
|
|
hr = _Stream_get_EOS( stream, &eos );
|
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08x\n", hr );
|
|
|
|
|
2019-12-09 11:24:32 +01:00
|
|
|
hr = _Stream_get_Position( stream, &pos );
|
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = _Stream_put_Position( stream, 0 );
|
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08x\n", hr );
|
|
|
|
|
2019-12-06 14:54:21 +01:00
|
|
|
/* check default type */
|
|
|
|
type = 0;
|
|
|
|
hr = _Stream_get_Type( stream, &type );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( type == adTypeText, "got %u\n", type );
|
|
|
|
|
|
|
|
hr = _Stream_put_Type( stream, adTypeBinary );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
type = 0;
|
|
|
|
hr = _Stream_get_Type( stream, &type );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( type == adTypeBinary, "got %u\n", type );
|
|
|
|
|
|
|
|
/* revert */
|
|
|
|
hr = _Stream_put_Type( stream, adTypeText );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2019-12-10 11:11:20 +01:00
|
|
|
sep = 0;
|
|
|
|
hr = _Stream_get_LineSeparator( stream, &sep );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( sep == adCRLF, "got %d\n", sep );
|
|
|
|
|
|
|
|
hr = _Stream_put_LineSeparator( stream, adLF );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2019-12-09 11:24:30 +01:00
|
|
|
state = 0xdeadbeef;
|
|
|
|
hr = _Stream_get_State( stream, &state );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( state == adStateClosed, "got %u\n", state );
|
|
|
|
|
2019-12-10 11:11:21 +01:00
|
|
|
mode = 0xdeadbeef;
|
|
|
|
hr = _Stream_get_Mode( stream, &mode );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( mode == adModeUnknown, "got %u\n", mode );
|
|
|
|
|
|
|
|
hr = _Stream_put_Mode( stream, adModeReadWrite );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2019-12-10 11:11:22 +01:00
|
|
|
hr = _Stream_get_Charset( stream, &charset );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( charset, L"Unicode" ), "got %s\n", wine_dbgstr_w(charset) );
|
|
|
|
SysFreeString( charset );
|
|
|
|
|
|
|
|
str = SysAllocString( L"Unicode" );
|
|
|
|
hr = _Stream_put_Charset( stream, str );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
SysFreeString( str );
|
|
|
|
|
2019-12-09 11:24:31 +01:00
|
|
|
hr = _Stream_Read( stream, 2, &val );
|
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08x\n", hr );
|
|
|
|
|
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 );
|
|
|
|
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 );
|
|
|
|
|
2019-12-09 11:24:30 +01:00
|
|
|
state = 0xdeadbeef;
|
|
|
|
hr = _Stream_get_State( stream, &state );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( state == adStateOpen, "got %u\n", state );
|
|
|
|
|
2019-12-09 11:24:33 +01:00
|
|
|
size = -1;
|
|
|
|
hr = _Stream_get_Size( stream, &size );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( !size, "got %d\n", size );
|
|
|
|
|
2019-12-10 11:11:19 +01:00
|
|
|
eos = VARIANT_FALSE;
|
|
|
|
hr = _Stream_get_EOS( stream, &eos );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( eos == VARIANT_TRUE, "got %04x\n", eos );
|
|
|
|
|
2019-12-09 11:24:32 +01:00
|
|
|
pos = -1;
|
|
|
|
hr = _Stream_get_Position( stream, &pos );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( !pos, "got %d\n", pos );
|
|
|
|
|
2019-12-09 11:24:33 +01:00
|
|
|
size = -1;
|
|
|
|
hr = _Stream_get_Size( stream, &size );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( !size, "got %d\n", size );
|
|
|
|
|
2019-12-09 11:24:31 +01:00
|
|
|
hr = _Stream_Read( stream, 2, &val );
|
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrIllegalOperation ), "got %08x\n", hr );
|
|
|
|
|
2019-12-10 11:11:23 +01:00
|
|
|
hr = _Stream_ReadText( stream, 2, &str );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
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 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( !pos, "got %d\n", pos );
|
|
|
|
|
2019-12-10 11:11:23 +01:00
|
|
|
str = SysAllocString( L"test" );
|
|
|
|
hr = _Stream_WriteText( stream, str, adWriteChar );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
hr = _Stream_ReadText( stream, adReadAll, &str );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( !str[0], "got %s\n", wine_dbgstr_w(str) );
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
hr = _Stream_put_Position( stream, 0 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
hr = _Stream_ReadText( stream, adReadAll, &str );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( !lstrcmpW( str, L"test" ), "got %s\n", wine_dbgstr_w(str) );
|
|
|
|
SysFreeString( str );
|
|
|
|
|
|
|
|
pos = -1;
|
|
|
|
hr = _Stream_get_Position( stream, &pos );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( pos == 10, "got %d\n", pos );
|
|
|
|
|
|
|
|
eos = VARIANT_FALSE;
|
|
|
|
hr = _Stream_get_EOS( stream, &eos );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( eos == VARIANT_TRUE, "got %04x\n", eos );
|
|
|
|
|
|
|
|
hr = _Stream_put_Position( stream, 6 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
size = -1;
|
|
|
|
hr = _Stream_get_Size( stream, &size );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( size == 10, "got %d\n", size );
|
|
|
|
|
|
|
|
hr = _Stream_put_Position( stream, 2 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2019-12-11 17:18:25 +01:00
|
|
|
hr = _Stream_SetEOS( stream );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
pos = -1;
|
|
|
|
hr = _Stream_get_Position( stream, &pos );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( pos == 2, "got %d\n", pos );
|
|
|
|
|
|
|
|
size = -1;
|
|
|
|
hr = _Stream_get_Size( stream, &size );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( size == 2, "got %d\n", size );
|
|
|
|
|
2019-12-09 11:24:29 +01:00
|
|
|
hr = _Stream_Close( stream );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2019-12-09 11:24:30 +01:00
|
|
|
state = 0xdeadbeef;
|
|
|
|
hr = _Stream_get_State( stream, &state );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( state == adStateClosed, "got %u\n", state );
|
|
|
|
|
2019-12-09 11:24:29 +01:00
|
|
|
hr = _Stream_Close( stream );
|
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08x\n", hr );
|
|
|
|
|
2019-12-06 14:54:21 +01:00
|
|
|
refs = _Stream_Release( stream );
|
|
|
|
ok( !refs, "got %d\n", refs );
|
2019-12-09 11:24:31 +01:00
|
|
|
|
|
|
|
/* binary type */
|
|
|
|
hr = CoCreateInstance( &CLSID_Stream, NULL, CLSCTX_INPROC_SERVER, &IID__Stream, (void **)&stream );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = _Stream_put_Type( stream, adTypeBinary );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = _Stream_Open( stream, missing, adModeUnknown, adOpenStreamUnspecified, NULL, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
2019-12-10 11:11:23 +01:00
|
|
|
hr = _Stream_ReadText( stream, adReadAll, &str );
|
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrIllegalOperation ), "got %08x\n", hr );
|
|
|
|
|
|
|
|
str = SysAllocString( L"test" );
|
|
|
|
hr = _Stream_WriteText( stream, str, adWriteChar );
|
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrIllegalOperation ), "got %08x\n", hr );
|
|
|
|
SysFreeString( str );
|
|
|
|
|
2019-12-09 11:24:31 +01:00
|
|
|
VariantInit( &val );
|
|
|
|
hr = _Stream_Read( stream, 1, &val );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( V_VT( &val ) == VT_NULL, "got %u\n", V_VT( &val ) );
|
|
|
|
|
|
|
|
VariantInit( &val );
|
|
|
|
hr = _Stream_Write( stream, val );
|
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrInvalidArgument ), "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = str_to_byte_array( "data", &val );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
hr = _Stream_Write( stream, val );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
VariantClear( &val );
|
|
|
|
|
2019-12-09 11:24:32 +01:00
|
|
|
pos = -1;
|
|
|
|
hr = _Stream_get_Position( stream, &pos );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( pos == 4, "got %d\n", pos );
|
|
|
|
|
|
|
|
hr = _Stream_put_Position( stream, 0 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
VariantInit( &val );
|
|
|
|
hr = _Stream_Read( stream, adReadAll, &val );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( V_VT( &val ) == (VT_ARRAY | VT_UI1), "got %04x\n", V_VT( &val ) );
|
|
|
|
VariantClear( &val );
|
|
|
|
|
|
|
|
pos = -1;
|
|
|
|
hr = _Stream_get_Position( stream, &pos );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( pos == 4, "got %d\n", pos );
|
|
|
|
|
2019-12-09 11:24:31 +01:00
|
|
|
refs = _Stream_Release( stream );
|
|
|
|
ok( !refs, "got %d\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;
|
2019-12-11 17:16:53 +01:00
|
|
|
LONG state, timeout;
|
2020-01-28 11:36:03 +01:00
|
|
|
BSTR str, str2;
|
2019-12-11 17:16:52 +01:00
|
|
|
|
|
|
|
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);
|
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);
|
|
|
|
ok(hr == S_OK, "Failed to get IConnectionPointContainer interface %08x\n", hr);
|
|
|
|
IConnectionPointContainer_Release(pointcontainer);
|
|
|
|
|
2019-12-11 17:16:52 +01:00
|
|
|
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);
|
|
|
|
|
2019-12-11 17:16:53 +01:00
|
|
|
timeout = 0;
|
|
|
|
hr = _Connection_get_CommandTimeout(connection, &timeout);
|
|
|
|
ok(hr == S_OK, "Failed to get state, hr 0x%08x\n", hr);
|
|
|
|
ok(timeout == 30, "Unexpected timeout value %d\n", timeout);
|
|
|
|
|
|
|
|
hr = _Connection_put_CommandTimeout(connection, 300);
|
|
|
|
ok(hr == S_OK, "Failed to get state, hr 0x%08x\n", hr);
|
|
|
|
|
|
|
|
timeout = 0;
|
|
|
|
hr = _Connection_get_CommandTimeout(connection, &timeout);
|
|
|
|
ok(hr == S_OK, "Failed to get state, hr 0x%08x\n", hr);
|
|
|
|
ok(timeout == 300, "Unexpected timeout value %d\n", timeout);
|
|
|
|
|
2020-01-28 11:36:03 +01:00
|
|
|
str = (BSTR)0xdeadbeef;
|
|
|
|
hr = _Connection_get_ConnectionString(connection, &str);
|
|
|
|
ok(hr == S_OK, "Failed, hr 0x%08x\n", hr);
|
|
|
|
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);
|
|
|
|
ok(hr == S_OK, "Failed, hr 0x%08x\n", hr);
|
|
|
|
|
|
|
|
if (0) /* Crashes on windows */
|
|
|
|
{
|
|
|
|
hr = _Connection_get_ConnectionString(connection, NULL);
|
|
|
|
ok(hr == E_POINTER, "Failed, hr 0x%08x\n", hr);
|
|
|
|
}
|
|
|
|
|
|
|
|
str2 = NULL;
|
|
|
|
hr = _Connection_get_ConnectionString(connection, &str2);
|
|
|
|
ok(hr == S_OK, "Failed, hr 0x%08x\n", hr);
|
|
|
|
ok(!wcscmp(str, str2), "wrong string %s\n", wine_dbgstr_w(str2));
|
|
|
|
SysFreeString(str);
|
|
|
|
SysFreeString(str2);
|
|
|
|
|
|
|
|
hr = _Connection_put_ConnectionString(connection, NULL);
|
|
|
|
ok(hr == S_OK, "Failed, hr 0x%08x\n", hr);
|
|
|
|
|
|
|
|
str = (BSTR)0xdeadbeef;
|
|
|
|
hr = _Connection_get_ConnectionString(connection, &str);
|
|
|
|
ok(hr == S_OK, "Failed, hr 0x%08x\n", hr);
|
|
|
|
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";
|
2019-12-12 16:42:06 +01:00
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_Command, NULL, CLSCTX_INPROC_SERVER, &IID__Command, (void **)&command );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = _Command_QueryInterface( command, &IID__ADO, (void **)&ado );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
_ADO_Release( ado );
|
|
|
|
|
|
|
|
hr = _Command_QueryInterface( command, &IID_Command15, (void **)&command15 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
Command15_Release( command15 );
|
|
|
|
|
|
|
|
hr = _Command_QueryInterface( command, &IID_Command25, (void **)&command25 );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
Command25_Release( command25 );
|
|
|
|
|
2020-05-25 16:01:30 +02:00
|
|
|
hr = _Command_get_CommandType( command, &cmd_type );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( cmd_type == adCmdUnknown, "got %08x\n", cmd_type );
|
|
|
|
|
|
|
|
_Command_put_CommandType( command, adCmdText );
|
|
|
|
hr = _Command_get_CommandType( command, &cmd_type );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( cmd_type == adCmdText, "got %08x\n", cmd_type );
|
|
|
|
|
|
|
|
hr = _Command_put_CommandType( command, 0xdeadbeef );
|
|
|
|
ok( hr == MAKE_ADO_HRESULT( adErrInvalidArgument ), "got %08x\n", hr );
|
|
|
|
|
2020-05-27 16:19:03 +02:00
|
|
|
hr = _Command_get_CommandText( command, &cmd_text );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( !cmd_text, "got %s\n", wine_dbgstr_w( cmd_text ));
|
|
|
|
|
|
|
|
hr = _Command_put_CommandText( command, NULL );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
cmd_text = SysAllocString( L"" );
|
|
|
|
hr = _Command_put_CommandText( command, cmd_text );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
SysFreeString( cmd_text );
|
|
|
|
|
|
|
|
hr = _Command_get_CommandText( command, &cmd_text );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( cmd_text && !*cmd_text, "got %p\n", cmd_text );
|
|
|
|
|
|
|
|
cmd_text = SysAllocString( L"test" );
|
|
|
|
hr = _Command_put_CommandText( command, cmd_text );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
SysFreeString( cmd_text );
|
|
|
|
|
|
|
|
hr = _Command_get_CommandText( command, &cmd_text );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
ok( !wcscmp( L"test", cmd_text ), "got %p\n", wine_dbgstr_w( cmd_text ) );
|
|
|
|
|
2019-12-12 16:42:06 +01:00
|
|
|
_Command_Release( command );
|
|
|
|
}
|
|
|
|
|
2020-06-01 13:42:18 +02:00
|
|
|
static void test_ConnectionPoint(void)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
ULONG refs;
|
|
|
|
IConnectionPoint *point;
|
|
|
|
IConnectionPointContainer *pointcontainer;
|
|
|
|
|
|
|
|
hr = CoCreateInstance( &CLSID_Connection, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IConnectionPointContainer, (void**)&pointcontainer );
|
|
|
|
|
|
|
|
hr = IConnectionPointContainer_FindConnectionPoint( pointcontainer, &DIID_ConnectionEvents, NULL );
|
|
|
|
ok( hr == E_POINTER, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IConnectionPointContainer_FindConnectionPoint( pointcontainer, &DIID_RecordsetEvents, &point );
|
|
|
|
ok( hr == CONNECT_E_NOCONNECTION, "got %08x\n", hr );
|
|
|
|
|
|
|
|
hr = IConnectionPointContainer_FindConnectionPoint( pointcontainer, &DIID_ConnectionEvents, &point );
|
|
|
|
ok( hr == S_OK, "got %08x\n", hr );
|
|
|
|
|
|
|
|
refs = IConnectionPoint_Release( point );
|
|
|
|
ok( refs == 1, "got %u", refs );
|
|
|
|
|
|
|
|
IConnectionPointContainer_Release( pointcontainer );
|
|
|
|
}
|
|
|
|
|
2019-12-06 14:54:21 +01:00
|
|
|
START_TEST(msado15)
|
|
|
|
{
|
|
|
|
CoInitialize( NULL );
|
2019-12-11 17:16:52 +01:00
|
|
|
test_Connection();
|
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();
|
|
|
|
}
|