1 /* OLEDB Database tests
3 * Copyright 2012 Alistair Leslie-Hughes
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define DBINITCONSTANTS
36 #include "wine/test.h"
38 DEFINE_GUID(CSLID_MSDAER
, 0xc8b522cf,0x5cf3,0x11ce,0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d);
40 static WCHAR initstring_default
[] = {'D','a','t','a',' ','S','o','u','r','c','e','=','d','u','m','m','y',';',0};
42 #define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__)
43 static void _expect_ref(IUnknown
* obj
, ULONG ref
, int line
)
45 ULONG rc
= IUnknown_AddRef(obj
);
46 IUnknown_Release(obj
);
47 ok_(__FILE__
,line
)(rc
-1 == ref
, "expected refcount %d, got %d\n", ref
, rc
-1);
50 static void test_GetDataSource(WCHAR
*initstring
)
52 IDataInitialize
*datainit
= NULL
;
53 IDBInitialize
*dbinit
= NULL
;
56 trace("Data Source: %s\n", wine_dbgstr_w(initstring
));
58 hr
= CoCreateInstance(&CLSID_MSDAINITIALIZE
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataInitialize
,(void**)&datainit
);
59 ok(hr
== S_OK
, "got %08x\n", hr
);
61 EXPECT_REF(datainit
, 1);
63 /* a failure to create data source here may indicate provider is simply not present */
64 hr
= IDataInitialize_GetDataSource(datainit
, NULL
, CLSCTX_INPROC_SERVER
, initstring
, &IID_IDBInitialize
, (IUnknown
**)&dbinit
);
67 IDBProperties
*props
= NULL
;
69 EXPECT_REF(datainit
, 1);
70 EXPECT_REF(dbinit
, 1);
72 hr
= IDBInitialize_QueryInterface(dbinit
, &IID_IDBProperties
, (void**)&props
);
73 ok(hr
== S_OK
, "got %08x\n", hr
);
77 DBPROPINFOSET
*pInfoset
;
80 EXPECT_REF(dbinit
, 2);
82 hr
= IDBProperties_GetPropertyInfo(props
, 0, NULL
, &cnt
, &pInfoset
, &ary
);
83 todo_wine
ok(hr
== S_OK
, "got %08x\n", hr
);
87 for(i
=0; i
< pInfoset
->cPropertyInfos
; i
++)
89 trace("(0x%04x) '%s' %d\n", pInfoset
->rgPropertyInfos
[i
].dwPropertyID
, wine_dbgstr_w(pInfoset
->rgPropertyInfos
[i
].pwszDescription
),
90 pInfoset
->rgPropertyInfos
[i
].vtType
);
93 CoTaskMemFree(pInfoset
);
97 IDBProperties_Release(props
);
100 EXPECT_REF(dbinit
, 1);
101 IDBInitialize_Release(dbinit
);
104 EXPECT_REF(datainit
, 1);
105 IDataInitialize_Release(datainit
);
108 /* IDBProperties stub */
109 static HRESULT WINAPI
dbprops_QI(IDBProperties
*iface
, REFIID riid
, void **obj
)
111 if (IsEqualIID(riid
, &IID_IDBProperties
) || IsEqualIID(riid
, &IID_IUnknown
)) {
113 IDBProperties_AddRef(iface
);
118 return E_NOINTERFACE
;
121 static ULONG WINAPI
dbprops_AddRef(IDBProperties
*iface
)
126 static ULONG WINAPI
dbprops_Release(IDBProperties
*iface
)
131 static HRESULT WINAPI
dbprops_GetProperties(IDBProperties
*iface
, ULONG cPropertyIDSets
,
132 const DBPROPIDSET rgPropertyIDSets
[], ULONG
*pcPropertySets
, DBPROPSET
**prgPropertySets
)
134 ok(0, "unexpected call\n");
138 static HRESULT WINAPI
dbprops_GetPropertyInfo(IDBProperties
*iface
, ULONG cPropertyIDSets
,
139 const DBPROPIDSET rgPropertyIDSets
[], ULONG
*pcPropertyInfoSets
, DBPROPINFOSET
**prgPropertyInfoSets
,
140 OLECHAR
**ppDescBuffer
)
142 ok(0, "unexpected call\n");
146 static HRESULT WINAPI
dbprops_SetProperties(IDBProperties
*iface
, ULONG set_count
, DBPROPSET propsets
[])
148 ok(set_count
== 1, "got %u\n", set_count
);
150 ok(IsEqualIID(&propsets
->guidPropertySet
, &DBPROPSET_DBINIT
), "set guid %s\n", wine_dbgstr_guid(&propsets
->guidPropertySet
));
151 ok(propsets
->cProperties
== 2, "got propcount %u\n", propsets
->cProperties
);
153 if (propsets
->cProperties
== 2) {
154 ok(propsets
->rgProperties
[0].dwPropertyID
== DBPROP_INIT_DATASOURCE
, "got propid[0] %u\n", propsets
->rgProperties
[0].dwPropertyID
);
155 ok(propsets
->rgProperties
[0].dwOptions
== DBPROPOPTIONS_REQUIRED
, "got options[0] %u\n", propsets
->rgProperties
[0].dwOptions
);
156 ok(propsets
->rgProperties
[0].dwStatus
== 0, "got status[0] %u\n", propsets
->rgProperties
[0].dwStatus
);
157 ok(V_VT(&propsets
->rgProperties
[0].vValue
) == VT_BSTR
, "got vartype[0] %u\n", V_VT(&propsets
->rgProperties
[0].vValue
));
159 ok(propsets
->rgProperties
[1].dwPropertyID
== DBPROP_INIT_PROVIDERSTRING
, "got propid[1] %u\n", propsets
->rgProperties
[1].dwPropertyID
);
160 ok(propsets
->rgProperties
[1].dwOptions
== DBPROPOPTIONS_REQUIRED
, "got options[1] %u\n", propsets
->rgProperties
[1].dwOptions
);
161 ok(propsets
->rgProperties
[1].dwStatus
== 0, "got status[1] %u\n", propsets
->rgProperties
[1].dwStatus
);
162 ok(V_VT(&propsets
->rgProperties
[1].vValue
) == VT_BSTR
, "got vartype[1] %u\n", V_VT(&propsets
->rgProperties
[1].vValue
));
167 static const IDBPropertiesVtbl dbpropsvtbl
= {
171 dbprops_GetProperties
,
172 dbprops_GetPropertyInfo
,
173 dbprops_SetProperties
176 static IDBProperties dbprops
= { &dbpropsvtbl
};
179 static HRESULT WINAPI
dbpersist_QI(IPersist
*iface
, REFIID riid
, void **obj
)
181 if (IsEqualIID(riid
, &IID_IPersist
) || IsEqualIID(riid
, &IID_IUnknown
)) {
183 IPersist_AddRef(iface
);
188 return E_NOINTERFACE
;
191 static ULONG WINAPI
dbpersist_AddRef(IPersist
*iface
)
196 static ULONG WINAPI
dbpersist_Release(IPersist
*iface
)
201 static HRESULT WINAPI
dbpersist_GetClassID(IPersist
*iface
, CLSID
*clsid
)
203 static const WCHAR msdasqlW
[] = {'M','S','D','A','S','Q','L',0};
204 return CLSIDFromProgID(msdasqlW
, clsid
);
207 static const IPersistVtbl dbpersistvtbl
= {
214 static IPersist dbpersist
= { &dbpersistvtbl
};
216 /* IDBInitialize stub */
217 static HRESULT WINAPI
dbinit_QI(IDBInitialize
*iface
, REFIID riid
, void **obj
)
219 if (IsEqualIID(riid
, &IID_IDBInitialize
) || IsEqualIID(riid
, &IID_IUnknown
)) {
221 IDBInitialize_AddRef(iface
);
224 else if (IsEqualIID(riid
, &IID_IPersist
)) {
228 else if (IsEqualIID(riid
, &IID_IDBProperties
)) {
234 return E_NOINTERFACE
;
237 static ULONG WINAPI
dbinit_AddRef(IDBInitialize
*iface
)
242 static ULONG WINAPI
dbinit_Release(IDBInitialize
*iface
)
247 static HRESULT WINAPI
dbinit_Initialize(IDBInitialize
*iface
)
249 ok(0, "unexpected call\n");
253 static HRESULT WINAPI
dbinit_Uninitialize(IDBInitialize
*iface
)
255 ok(0, "unexpected call\n");
259 static const IDBInitializeVtbl dbinitvtbl
= {
267 static IDBInitialize dbinittest
= { &dbinitvtbl
};
269 static void test_GetDataSource2(WCHAR
*initstring
)
271 IDataInitialize
*datainit
= NULL
;
272 IDBInitialize
*dbinit
= NULL
;
275 hr
= CoCreateInstance(&CLSID_MSDAINITIALIZE
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataInitialize
,(void**)&datainit
);
276 ok(hr
== S_OK
, "got %08x\n", hr
);
278 dbinit
= &dbinittest
;
279 hr
= IDataInitialize_GetDataSource(datainit
, NULL
, CLSCTX_INPROC_SERVER
, initstring
, &IID_IDBInitialize
, (IUnknown
**)&dbinit
);
280 ok(hr
== S_OK
, "got %08x\n", hr
);
282 IDataInitialize_Release(datainit
);
285 static void test_database(void)
287 static WCHAR initstring_jet
[] = {'P','r','o','v','i','d','e','r','=','M','i','c','r','o','s','o','f','t','.',
288 'J','e','t','.','O','L','E','D','B','.','4','.','0',';',
289 'D','a','t','a',' ','S','o','u','r','c','e','=','d','u','m','m','y',';',
290 'P','e','r','s','i','s','t',' ','S','e','c','u','r','i','t','y',' ','I','n','f','o','=','F','a','l','s','e',';',0};
291 static WCHAR initstring_lower
[] = {'d','a','t','a',' ','s','o','u','r','c','e','=','d','u','m','m','y',';',0};
292 static WCHAR customprop
[] = {'d','a','t','a',' ','s','o','u','r','c','e','=','d','u','m','m','y',';',
293 'c','u','s','t','o','m','p','r','o','p','=','1','2','3','.','4',';',0};
294 IDataInitialize
*datainit
= NULL
;
297 hr
= CoCreateInstance(&CLSID_MSDAINITIALIZE
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataInitialize
, (void**)&datainit
);
300 win_skip("Unable to load oledb library\n");
303 IDataInitialize_Release(datainit
);
305 test_GetDataSource(NULL
);
306 test_GetDataSource(initstring_jet
);
307 test_GetDataSource(initstring_default
);
308 test_GetDataSource(initstring_lower
);
309 test_GetDataSource2(customprop
);
312 static void test_errorinfo(void)
315 IUnknown
*unk
= NULL
;
317 hr
= CoCreateInstance(&CSLID_MSDAER
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IUnknown
,(void**)&unk
);
318 ok(hr
== S_OK
, "got %08x\n", hr
);
321 IErrorInfo
*errorinfo
;
322 IErrorRecords
*errrecs
;
324 hr
= IUnknown_QueryInterface(unk
, &IID_IErrorInfo
, (void**)&errorinfo
);
325 ok(hr
== S_OK
, "got %08x\n", hr
);
328 IErrorInfo_Release(errorinfo
);
331 hr
= IUnknown_QueryInterface(unk
, &IID_IErrorRecords
, (void**)&errrecs
);
332 ok(hr
== S_OK
, "got %08x\n", hr
);
335 ERRORINFO info
, info2
, info3
;
338 memset(&info
, 0, sizeof(ERRORINFO
));
340 memset(&info2
, 0, sizeof(ERRORINFO
));
342 memset(&info3
, 0, sizeof(ERRORINFO
));
344 hr
= IErrorRecords_AddErrorRecord(errrecs
, NULL
, 268435456, NULL
, NULL
, 0);
345 ok(hr
== E_INVALIDARG
, "got %08x\n", hr
);
347 hr
= IErrorRecords_AddErrorRecord(errrecs
, &info
, 1, NULL
, NULL
, 0);
348 ok(hr
== S_OK
, "got %08x\n", hr
);
350 hr
= IErrorRecords_GetRecordCount(errrecs
, &cnt
);
351 ok(hr
== S_OK
, "got %08x\n", hr
);
352 ok(cnt
== 1, "expected 1 got %d\n", cnt
);
354 hr
= IErrorRecords_AddErrorRecord(errrecs
, &info2
, 2, NULL
, NULL
, 0);
355 ok(hr
== S_OK
, "got %08x\n", hr
);
357 hr
= IErrorRecords_GetRecordCount(errrecs
, &cnt
);
358 ok(hr
== S_OK
, "got %08x\n", hr
);
359 ok(cnt
== 2, "expected 2 got %d\n", cnt
);
361 hr
= IErrorRecords_GetBasicErrorInfo(errrecs
, 0, NULL
);
362 ok(hr
== E_INVALIDARG
, "got %08x\n", hr
);
364 hr
= IErrorRecords_GetBasicErrorInfo(errrecs
, 100, &info3
);
365 ok(hr
== DB_E_BADRECORDNUM
, "got %08x\n", hr
);
367 hr
= IErrorRecords_GetBasicErrorInfo(errrecs
, 0, &info3
);
368 todo_wine
ok(hr
== S_OK
, "got %08x\n", hr
);
371 ok(info3
.dwMinor
== 2, "expected 2 got %d\n", info3
.dwMinor
);
374 IErrorRecords_Release(errrecs
);
377 IUnknown_Release(unk
);
381 static void test_initializationstring(void)
383 static const WCHAR initstring_msdasql
[] = {'P','r','o','v','i','d','e','r','=','M','S','D','A','S','Q','L','.','1',';',
384 'D','a','t','a',' ','S','o','u','r','c','e','=','d','u','m','m','y', 0};
385 static const WCHAR initstring_sqloledb
[] = {'P','r','o','v','i','d','e','r','=','S','Q','L','O','L','E','D','B','.','1',';',
386 'D','a','t','a',' ','S','o','u','r','c','e','=','d','u','m','m','y', 0};
387 IDataInitialize
*datainit
= NULL
;
388 IDBInitialize
*dbinit
;
390 WCHAR
*initstring
= NULL
;
392 hr
= CoCreateInstance(&CLSID_MSDAINITIALIZE
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataInitialize
,(void**)&datainit
);
393 ok(hr
== S_OK
, "got %08x\n", hr
);
396 EXPECT_REF(datainit
, 1);
399 hr
= IDataInitialize_GetDataSource(datainit
, NULL
, CLSCTX_INPROC_SERVER
, initstring_default
,
400 &IID_IDBInitialize
, (IUnknown
**)&dbinit
);
403 EXPECT_REF(datainit
, 1);
404 EXPECT_REF(dbinit
, 1);
406 hr
= IDataInitialize_GetInitializationString(datainit
, (IUnknown
*)dbinit
, 0, &initstring
);
407 ok(hr
== S_OK
, "got %08x\n", hr
);
410 trace("Init String: %s\n", wine_dbgstr_w(initstring
));
411 todo_wine
ok(!lstrcmpW(initstring_msdasql
, initstring
) ||
412 !lstrcmpW(initstring_sqloledb
, initstring
), "got %s\n", wine_dbgstr_w(initstring
));
413 CoTaskMemFree(initstring
);
416 IDBInitialize_Release(dbinit
);
419 ok(dbinit
== NULL
, "got %p\n", dbinit
);
421 IDataInitialize_Release(datainit
);
425 static void test_rowposition(void)
427 IEnumConnectionPoints
*enum_points
;
428 IConnectionPointContainer
*cpc
;
429 IConnectionPoint
*cp
;
430 IRowPosition
*rowpos
;
434 hr
= CoCreateInstance(&CLSID_OLEDB_ROWPOSITIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IRowPosition
, (void**)&rowpos
);
435 ok(hr
== S_OK
, "got %08x\n", hr
);
437 hr
= IRowPosition_QueryInterface(rowpos
, &IID_IConnectionPointContainer
, (void**)&cpc
);
438 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
440 hr
= IConnectionPointContainer_EnumConnectionPoints(cpc
, &enum_points
);
442 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
444 hr
= IEnumConnectionPoints_Next(enum_points
, 1, &cp
, NULL
);
445 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
446 hr
= IConnectionPoint_GetConnectionInterface(cp
, &iid
);
447 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
448 ok(IsEqualIID(&iid
, &IID_IRowPositionChange
), "got %s\n", wine_dbgstr_guid(&iid
));
449 IConnectionPoint_Release(cp
);
451 hr
= IEnumConnectionPoints_Next(enum_points
, 1, &cp
, NULL
);
452 ok(hr
== S_FALSE
, "got 0x%08x\n", hr
);
454 IEnumConnectionPoints_Release(enum_points
);
456 IConnectionPointContainer_Release(cpc
);
457 IRowPosition_Release(rowpos
);
462 IRowset IRowset_iface
;
463 IChapteredRowset IChapteredRowset_iface
;
466 static test_rset_t test_rset
;
468 static HRESULT WINAPI
rset_QI(IRowset
*iface
, REFIID riid
, void **obj
)
470 if (IsEqualIID(riid
, &IID_IUnknown
) ||
471 IsEqualIID(riid
, &IID_IRowset
))
473 *obj
= &test_rset
.IRowset_iface
;
476 else if (IsEqualIID(riid
, &IID_IChapteredRowset
))
478 *obj
= &test_rset
.IChapteredRowset_iface
;
482 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid
));
483 return E_NOINTERFACE
;
486 static ULONG WINAPI
rset_AddRef(IRowset
*iface
)
491 static ULONG WINAPI
rset_Release(IRowset
*iface
)
496 static HRESULT WINAPI
rset_AddRefRows(IRowset
*iface
, DBCOUNTITEM cRows
,
497 const HROW rghRows
[], DBREFCOUNT rgRefCounts
[], DBROWSTATUS rgRowStatus
[])
499 trace("AddRefRows: %ld\n", rghRows
[0]);
503 static HRESULT WINAPI
rset_GetData(IRowset
*iface
, HROW hRow
, HACCESSOR hAccessor
, void *pData
)
505 ok(0, "unexpected call\n");
509 static HRESULT WINAPI
rset_GetNextRows(IRowset
*iface
, HCHAPTER hReserved
, DBROWOFFSET lRowsOffset
,
510 DBROWCOUNT cRows
, DBCOUNTITEM
*pcRowObtained
, HROW
**prghRows
)
512 ok(0, "unexpected call\n");
516 static HRESULT WINAPI
rset_ReleaseRows(IRowset
*iface
, DBCOUNTITEM cRows
, const HROW rghRows
[], DBROWOPTIONS rgRowOptions
[],
517 DBREFCOUNT rgRefCounts
[], DBROWSTATUS rgRowStatus
[])
522 static HRESULT WINAPI
rset_RestartPosition(IRowset
*iface
, HCHAPTER hReserved
)
524 ok(0, "unexpected call\n");
528 static const IRowsetVtbl rset_vtbl
= {
539 static HRESULT WINAPI
chrset_QI(IChapteredRowset
*iface
, REFIID riid
, void **obj
)
541 return IRowset_QueryInterface(&test_rset
.IRowset_iface
, riid
, obj
);
544 static ULONG WINAPI
chrset_AddRef(IChapteredRowset
*iface
)
546 return IRowset_AddRef(&test_rset
.IRowset_iface
);
549 static ULONG WINAPI
chrset_Release(IChapteredRowset
*iface
)
551 return IRowset_Release(&test_rset
.IRowset_iface
);
554 static HRESULT WINAPI
chrset_AddRefChapter(IChapteredRowset
*iface
, HCHAPTER chapter
, DBREFCOUNT
*refcount
)
559 static HRESULT WINAPI
chrset_ReleaseChapter(IChapteredRowset
*iface
, HCHAPTER chapter
, DBREFCOUNT
*refcount
)
564 static const IChapteredRowsetVtbl chrset_vtbl
= {
568 chrset_AddRefChapter
,
569 chrset_ReleaseChapter
572 static void init_test_rset(void)
574 test_rset
.IRowset_iface
.lpVtbl
= &rset_vtbl
;
575 test_rset
.IChapteredRowset_iface
.lpVtbl
= &chrset_vtbl
;
578 static void test_rowpos_initialize(void)
580 IRowPosition
*rowpos
;
583 hr
= CoCreateInstance(&CLSID_OLEDB_ROWPOSITIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IRowPosition
, (void**)&rowpos
);
584 ok(hr
== S_OK
, "got %08x\n", hr
);
587 hr
= IRowPosition_Initialize(rowpos
, (IUnknown
*)&test_rset
.IRowset_iface
);
588 ok(hr
== S_OK
, "got %08x\n", hr
);
590 IRowPosition_Release(rowpos
);
593 static HRESULT WINAPI
onchange_QI(IRowPositionChange
*iface
, REFIID riid
, void **obj
)
595 if (IsEqualIID(riid
, &IID_IUnknown
) ||
596 IsEqualIID(riid
, &IID_IRowPositionChange
))
602 return E_NOINTERFACE
;
605 static ULONG WINAPI
onchange_AddRef(IRowPositionChange
*iface
)
610 static ULONG WINAPI
onchange_Release(IRowPositionChange
*iface
)
615 static HRESULT WINAPI
onchange_OnRowPositionChange(IRowPositionChange
*iface
, DBREASON reason
,
616 DBEVENTPHASE phase
, BOOL cant_deny
)
618 trace("%d %d %d\n", reason
, phase
, cant_deny
);
622 static const IRowPositionChangeVtbl onchange_vtbl
= {
626 onchange_OnRowPositionChange
629 static IRowPositionChange onchangesink
= { &onchange_vtbl
};
631 static void init_onchange_sink(IRowPosition
*rowpos
)
633 IConnectionPointContainer
*cpc
;
634 IConnectionPoint
*cp
;
638 hr
= IRowPosition_QueryInterface(rowpos
, &IID_IConnectionPointContainer
, (void**)&cpc
);
639 ok(hr
== S_OK
, "got %08x\n", hr
);
640 hr
= IConnectionPointContainer_FindConnectionPoint(cpc
, &IID_IRowPositionChange
, &cp
);
641 ok(hr
== S_OK
, "got %08x\n", hr
);
642 hr
= IConnectionPoint_Advise(cp
, (IUnknown
*)&onchangesink
, &cookie
);
643 ok(hr
== S_OK
, "got %08x\n", hr
);
644 IConnectionPoint_Release(cp
);
645 IConnectionPointContainer_Release(cpc
);
648 static void test_rowpos_clearrowposition(void)
650 DBPOSITIONFLAGS flags
;
651 IRowPosition
*rowpos
;
657 hr
= CoCreateInstance(&CLSID_OLEDB_ROWPOSITIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IRowPosition
, (void**)&rowpos
);
658 ok(hr
== S_OK
, "got %08x\n", hr
);
660 hr
= IRowPosition_ClearRowPosition(rowpos
);
661 ok(hr
== E_UNEXPECTED
, "got %08x\n", hr
);
663 hr
= IRowPosition_GetRowset(rowpos
, &IID_IStream
, &unk
);
664 ok(hr
== E_UNEXPECTED
, "got %08x\n", hr
);
668 flags
= DBPOSITION_OK
;
669 hr
= IRowPosition_GetRowPosition(rowpos
, &chapter
, &row
, &flags
);
670 ok(hr
== E_UNEXPECTED
, "got %08x\n", hr
);
671 ok(chapter
== DB_NULL_HCHAPTER
, "got %ld\n", chapter
);
672 ok(row
== DB_NULL_HROW
, "got %ld\n", row
);
673 ok(flags
== DBPOSITION_NOROW
, "got %d\n", flags
);
676 hr
= IRowPosition_Initialize(rowpos
, (IUnknown
*)&test_rset
.IRowset_iface
);
677 ok(hr
== S_OK
, "got %08x\n", hr
);
681 flags
= DBPOSITION_OK
;
682 hr
= IRowPosition_GetRowPosition(rowpos
, &chapter
, &row
, &flags
);
683 ok(hr
== S_OK
, "got %08x\n", hr
);
684 ok(chapter
== DB_NULL_HCHAPTER
, "got %ld\n", chapter
);
685 ok(row
== DB_NULL_HROW
, "got %ld\n", row
);
686 ok(flags
== DBPOSITION_NOROW
, "got %d\n", flags
);
688 hr
= IRowPosition_GetRowset(rowpos
, &IID_IRowset
, &unk
);
689 ok(hr
== S_OK
, "got %08x\n", hr
);
691 init_onchange_sink(rowpos
);
692 hr
= IRowPosition_ClearRowPosition(rowpos
);
693 ok(hr
== S_OK
, "got %08x\n", hr
);
697 flags
= DBPOSITION_OK
;
698 hr
= IRowPosition_GetRowPosition(rowpos
, &chapter
, &row
, &flags
);
699 ok(hr
== S_OK
, "got %08x\n", hr
);
700 ok(chapter
== DB_NULL_HCHAPTER
, "got %ld\n", chapter
);
701 ok(row
== DB_NULL_HROW
, "got %ld\n", row
);
702 ok(flags
== DBPOSITION_NOROW
, "got %d\n", flags
);
704 IRowPosition_Release(rowpos
);
707 static void test_rowpos_setrowposition(void)
709 IRowPosition
*rowpos
;
712 hr
= CoCreateInstance(&CLSID_OLEDB_ROWPOSITIONLIBRARY
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IRowPosition
, (void**)&rowpos
);
713 ok(hr
== S_OK
, "got %08x\n", hr
);
716 hr
= IRowPosition_Initialize(rowpos
, (IUnknown
*)&test_rset
.IRowset_iface
);
717 ok(hr
== S_OK
, "got %08x\n", hr
);
719 hr
= IRowPosition_ClearRowPosition(rowpos
);
720 ok(hr
== S_OK
, "got %08x\n", hr
);
722 init_onchange_sink(rowpos
);
723 hr
= IRowPosition_SetRowPosition(rowpos
, 0x123, 0x456, DBPOSITION_OK
);
724 ok(hr
== S_OK
, "got %08x\n", hr
);
726 IRowPosition_Release(rowpos
);
729 static void test_dslocator(void)
731 IDataSourceLocator
*dslocator
= NULL
;
734 hr
= CoCreateInstance(&CLSID_DataLinks
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IDataSourceLocator
,(void**)&dslocator
);
735 ok(hr
== S_OK
, "got %08x\n", hr
);
738 COMPATIBLE_LONG hwnd
= 0;
740 if (0) /* Crashes under Window 7 */
741 hr
= IDataSourceLocator_get_hWnd(dslocator
, NULL
);
743 hr
= IDataSourceLocator_get_hWnd(dslocator
, &hwnd
);
744 ok(hr
== S_OK
, "got %08x\n", hr
);
745 ok(hwnd
== 0, "got %p\n", (HWND
)hwnd
);
748 hr
= IDataSourceLocator_get_hWnd(dslocator
, &hwnd
);
749 ok(hr
== S_OK
, "got %08x\n", hr
);
750 ok(hwnd
== 0, "got %p\n", (HWND
)hwnd
);
753 hr
= IDataSourceLocator_put_hWnd(dslocator
, hwnd
);
754 ok(hr
== S_OK
, "got %08x\n", hr
);
757 hr
= IDataSourceLocator_get_hWnd(dslocator
, &hwnd
);
758 ok(hr
== S_OK
, "got %08x\n", hr
);
759 ok(hwnd
== 0xDEADBEEF, "got %p\n", (HWND
)hwnd
);
762 hr
= IDataSourceLocator_put_hWnd(dslocator
, hwnd
);
763 ok(hr
== S_OK
, "got %08x\n", hr
);
766 hr
= IDataSourceLocator_get_hWnd(dslocator
, &hwnd
);
767 ok(hr
== S_OK
, "got %08x\n", hr
);
768 ok(hwnd
== 0, "got %p\n", (HWND
)hwnd
);
770 IDataSourceLocator_Release(dslocator
);
780 test_initializationstring();
785 test_rowpos_initialize();
786 test_rowpos_clearrowposition();
787 test_rowpos_setrowposition();