d3d11: Implement d3d11_texture3d_GetDevice().
[wine.git] / dlls / oledb32 / tests / database.c
blob5393a915fb027b5f2f7602c1d8063677d10782eb
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
19 #include <stdarg.h>
20 #include <stdio.h>
22 #define COBJMACROS
23 #define CONST_VTABLE
24 #define DBINITCONSTANTS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "ole2.h"
29 #include "msdadc.h"
30 #include "msdasc.h"
31 #include "msdaguid.h"
32 #include "initguid.h"
33 #include "oledb.h"
34 #include "oledberr.h"
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;
54 HRESULT hr;
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);
65 if(SUCCEEDED(hr))
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);
74 if(SUCCEEDED(hr))
76 ULONG cnt;
77 DBPROPINFOSET *pInfoset;
78 OLECHAR *ary;
80 EXPECT_REF(dbinit, 2);
81 EXPECT_REF(props, 2);
82 hr = IDBProperties_GetPropertyInfo(props, 0, NULL, &cnt, &pInfoset, &ary);
83 todo_wine ok(hr == S_OK, "got %08x\n", hr);
84 if(hr == S_OK)
86 ULONG i;
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);
94 CoTaskMemFree(ary);
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)) {
112 *obj = iface;
113 IDBProperties_AddRef(iface);
114 return S_OK;
117 *obj = NULL;
118 return E_NOINTERFACE;
121 static ULONG WINAPI dbprops_AddRef(IDBProperties *iface)
123 return 2;
126 static ULONG WINAPI dbprops_Release(IDBProperties *iface)
128 return 1;
131 static HRESULT WINAPI dbprops_GetProperties(IDBProperties *iface, ULONG cPropertyIDSets,
132 const DBPROPIDSET rgPropertyIDSets[], ULONG *pcPropertySets, DBPROPSET **prgPropertySets)
134 ok(0, "unexpected call\n");
135 return E_NOTIMPL;
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");
143 return E_NOTIMPL;
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));
164 return S_OK;
167 static const IDBPropertiesVtbl dbpropsvtbl = {
168 dbprops_QI,
169 dbprops_AddRef,
170 dbprops_Release,
171 dbprops_GetProperties,
172 dbprops_GetPropertyInfo,
173 dbprops_SetProperties
176 static IDBProperties dbprops = { &dbpropsvtbl };
178 /* IPersist stub */
179 static HRESULT WINAPI dbpersist_QI(IPersist *iface, REFIID riid, void **obj)
181 if (IsEqualIID(riid, &IID_IPersist) || IsEqualIID(riid, &IID_IUnknown)) {
182 *obj = iface;
183 IPersist_AddRef(iface);
184 return S_OK;
187 *obj = NULL;
188 return E_NOINTERFACE;
191 static ULONG WINAPI dbpersist_AddRef(IPersist *iface)
193 return 2;
196 static ULONG WINAPI dbpersist_Release(IPersist *iface)
198 return 1;
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 = {
208 dbpersist_QI,
209 dbpersist_AddRef,
210 dbpersist_Release,
211 dbpersist_GetClassID
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)) {
220 *obj = iface;
221 IDBInitialize_AddRef(iface);
222 return S_OK;
224 else if (IsEqualIID(riid, &IID_IPersist)) {
225 *obj = &dbpersist;
226 return S_OK;
228 else if (IsEqualIID(riid, &IID_IDBProperties)) {
229 *obj = &dbprops;
230 return S_OK;
233 *obj = NULL;
234 return E_NOINTERFACE;
237 static ULONG WINAPI dbinit_AddRef(IDBInitialize *iface)
239 return 2;
242 static ULONG WINAPI dbinit_Release(IDBInitialize *iface)
244 return 1;
247 static HRESULT WINAPI dbinit_Initialize(IDBInitialize *iface)
249 ok(0, "unexpected call\n");
250 return E_NOTIMPL;
253 static HRESULT WINAPI dbinit_Uninitialize(IDBInitialize *iface)
255 ok(0, "unexpected call\n");
256 return E_NOTIMPL;
259 static const IDBInitializeVtbl dbinitvtbl = {
260 dbinit_QI,
261 dbinit_AddRef,
262 dbinit_Release,
263 dbinit_Initialize,
264 dbinit_Uninitialize
267 static IDBInitialize dbinittest = { &dbinitvtbl };
269 static void test_GetDataSource2(WCHAR *initstring)
271 IDataInitialize *datainit = NULL;
272 IDBInitialize *dbinit = NULL;
273 HRESULT hr;
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;
295 HRESULT hr;
297 hr = CoCreateInstance(&CLSID_MSDAINITIALIZE, NULL, CLSCTX_INPROC_SERVER, &IID_IDataInitialize, (void**)&datainit);
298 if (FAILED(hr))
300 win_skip("Unable to load oledb library\n");
301 return;
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)
314 HRESULT hr;
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);
319 if(hr == S_OK)
321 IErrorInfo *errorinfo;
322 IErrorRecords *errrecs;
324 hr = IUnknown_QueryInterface(unk, &IID_IErrorInfo, (void**)&errorinfo);
325 ok(hr == S_OK, "got %08x\n", hr);
326 if(hr == S_OK)
328 IErrorInfo_Release(errorinfo);
331 hr = IUnknown_QueryInterface(unk, &IID_IErrorRecords, (void**)&errrecs);
332 ok(hr == S_OK, "got %08x\n", hr);
333 if(hr == S_OK)
335 ERRORINFO info, info2, info3;
336 ULONG cnt = 0;
338 memset(&info, 0, sizeof(ERRORINFO));
339 info.dwMinor = 1;
340 memset(&info2, 0, sizeof(ERRORINFO));
341 info2.dwMinor = 2;
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);
369 if(hr == S_OK)
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;
389 HRESULT hr;
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);
394 if(SUCCEEDED(hr))
396 EXPECT_REF(datainit, 1);
398 dbinit = NULL;
399 hr = IDataInitialize_GetDataSource(datainit, NULL, CLSCTX_INPROC_SERVER, initstring_default,
400 &IID_IDBInitialize, (IUnknown**)&dbinit);
401 if(SUCCEEDED(hr))
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);
408 if(hr == S_OK)
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);
418 else
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;
431 HRESULT hr;
432 IID iid;
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);
441 todo_wine
442 ok(hr == S_OK, "got 0x%08x\n", hr);
443 if (hr == S_OK) {
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);
460 typedef struct
462 IRowset IRowset_iface;
463 IChapteredRowset IChapteredRowset_iface;
464 } test_rset_t;
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;
474 return S_OK;
476 else if (IsEqualIID(riid, &IID_IChapteredRowset))
478 *obj = &test_rset.IChapteredRowset_iface;
479 return S_OK;
482 ok(0, "unexpected riid %s\n", wine_dbgstr_guid(riid));
483 return E_NOINTERFACE;
486 static ULONG WINAPI rset_AddRef(IRowset *iface)
488 return 2;
491 static ULONG WINAPI rset_Release(IRowset *iface)
493 return 1;
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]);
500 return S_OK;
503 static HRESULT WINAPI rset_GetData(IRowset *iface, HROW hRow, HACCESSOR hAccessor, void *pData)
505 ok(0, "unexpected call\n");
506 return E_NOTIMPL;
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");
513 return E_NOTIMPL;
516 static HRESULT WINAPI rset_ReleaseRows(IRowset *iface, DBCOUNTITEM cRows, const HROW rghRows[], DBROWOPTIONS rgRowOptions[],
517 DBREFCOUNT rgRefCounts[], DBROWSTATUS rgRowStatus[])
519 return S_OK;
522 static HRESULT WINAPI rset_RestartPosition(IRowset *iface, HCHAPTER hReserved)
524 ok(0, "unexpected call\n");
525 return E_NOTIMPL;
528 static const IRowsetVtbl rset_vtbl = {
529 rset_QI,
530 rset_AddRef,
531 rset_Release,
532 rset_AddRefRows,
533 rset_GetData,
534 rset_GetNextRows,
535 rset_ReleaseRows,
536 rset_RestartPosition
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)
556 return S_OK;
559 static HRESULT WINAPI chrset_ReleaseChapter(IChapteredRowset *iface, HCHAPTER chapter, DBREFCOUNT *refcount)
561 return S_OK;
564 static const IChapteredRowsetVtbl chrset_vtbl = {
565 chrset_QI,
566 chrset_AddRef,
567 chrset_Release,
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;
581 HRESULT hr;
583 hr = CoCreateInstance(&CLSID_OLEDB_ROWPOSITIONLIBRARY, NULL, CLSCTX_INPROC_SERVER, &IID_IRowPosition, (void**)&rowpos);
584 ok(hr == S_OK, "got %08x\n", hr);
586 init_test_rset();
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))
598 *obj = iface;
599 return S_OK;
602 return E_NOINTERFACE;
605 static ULONG WINAPI onchange_AddRef(IRowPositionChange *iface)
607 return 2;
610 static ULONG WINAPI onchange_Release(IRowPositionChange *iface)
612 return 1;
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);
619 return S_OK;
622 static const IRowPositionChangeVtbl onchange_vtbl = {
623 onchange_QI,
624 onchange_AddRef,
625 onchange_Release,
626 onchange_OnRowPositionChange
629 static IRowPositionChange onchangesink = { &onchange_vtbl };
631 static void init_onchange_sink(IRowPosition *rowpos)
633 IConnectionPointContainer *cpc;
634 IConnectionPoint *cp;
635 DWORD cookie;
636 HRESULT hr;
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;
652 HCHAPTER chapter;
653 IUnknown *unk;
654 HRESULT hr;
655 HROW row;
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);
666 chapter = 1;
667 row = 1;
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);
675 init_test_rset();
676 hr = IRowPosition_Initialize(rowpos, (IUnknown*)&test_rset.IRowset_iface);
677 ok(hr == S_OK, "got %08x\n", hr);
679 chapter = 1;
680 row = 1;
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);
695 chapter = 1;
696 row = 1;
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;
710 HRESULT hr;
712 hr = CoCreateInstance(&CLSID_OLEDB_ROWPOSITIONLIBRARY, NULL, CLSCTX_INPROC_SERVER, &IID_IRowPosition, (void**)&rowpos);
713 ok(hr == S_OK, "got %08x\n", hr);
715 init_test_rset();
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;
732 HRESULT hr;
734 hr = CoCreateInstance(&CLSID_DataLinks, NULL, CLSCTX_INPROC_SERVER, &IID_IDataSourceLocator,(void**)&dslocator);
735 ok(hr == S_OK, "got %08x\n", hr);
736 if(SUCCEEDED(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);
747 hwnd = 0xDEADBEEF;
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);
752 hwnd = 0xDEADBEEF;
753 hr = IDataSourceLocator_put_hWnd(dslocator, hwnd);
754 ok(hr == S_OK, "got %08x\n", hr);
756 hwnd = 0;
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);
761 hwnd = 0;
762 hr = IDataSourceLocator_put_hWnd(dslocator, hwnd);
763 ok(hr == S_OK, "got %08x\n", hr);
765 hwnd = 0xDEADBEEF;
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);
774 START_TEST(database)
776 OleInitialize(NULL);
778 test_database();
779 test_errorinfo();
780 test_initializationstring();
781 test_dslocator();
783 /* row position */
784 test_rowposition();
785 test_rowpos_initialize();
786 test_rowpos_clearrowposition();
787 test_rowpos_setrowposition();
789 OleUninitialize();