[SHLWAPI_WINETEST] Sync with Wine 3.0. CORE-14225
[reactos.git] / modules / rostests / winetests / shlwapi / clist.c
1 /* Unit test suite for SHLWAPI Compact List and IStream ordinal functions
2 *
3 * Copyright 2002 Jon Griffiths
4 *
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.
9 *
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.
14 *
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
18 */
19
20 #include "precomp.h"
21
22 typedef struct tagSHLWAPI_CLIST
23 {
24 ULONG ulSize;
25 ULONG ulId;
26 } SHLWAPI_CLIST, *LPSHLWAPI_CLIST;
27
28 typedef const SHLWAPI_CLIST* LPCSHLWAPI_CLIST;
29
30 /* Items to add */
31 static const SHLWAPI_CLIST SHLWAPI_CLIST_items[] =
32 {
33 {4, 1},
34 {8, 3},
35 {12, 2},
36 {16, 8},
37 {20, 9},
38 {3, 11},
39 {9, 82},
40 {33, 16},
41 {32, 55},
42 {24, 100},
43 {39, 116},
44 { 0, 0}
45 };
46
47 /* Dummy IStream object for testing calls */
48 struct dummystream
49 {
50 IStream IStream_iface;
51 LONG ref;
52 int readcalls;
53 BOOL failreadcall;
54 BOOL failreadsize;
55 BOOL readbeyondend;
56 BOOL readreturnlarge;
57 int writecalls;
58 BOOL failwritecall;
59 BOOL failwritesize;
60 int seekcalls;
61 int statcalls;
62 BOOL failstatcall;
63 LPCSHLWAPI_CLIST item;
64 ULARGE_INTEGER pos;
65 };
66
67 static inline struct dummystream *impl_from_IStream(IStream *iface)
68 {
69 return CONTAINING_RECORD(iface, struct dummystream, IStream_iface);
70 }
71
72 static HRESULT WINAPI QueryInterface(IStream *iface, REFIID riid, void **ret_iface)
73 {
74 if (IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IStream, riid)) {
75 *ret_iface = iface;
76 IStream_AddRef(iface);
77 return S_OK;
78 }
79 trace("Unexpected REFIID %s\n", wine_dbgstr_guid(riid));
80 *ret_iface = NULL;
81 return E_NOINTERFACE;
82 }
83
84 static ULONG WINAPI AddRef(IStream *iface)
85 {
86 struct dummystream *This = impl_from_IStream(iface);
87
88 return InterlockedIncrement(&This->ref);
89 }
90
91 static ULONG WINAPI Release(IStream *iface)
92 {
93 struct dummystream *This = impl_from_IStream(iface);
94
95 return InterlockedDecrement(&This->ref);
96 }
97
98 static HRESULT WINAPI Read(IStream *iface, void *lpMem, ULONG ulSize, ULONG *lpRead)
99 {
100 struct dummystream *This = impl_from_IStream(iface);
101 HRESULT hRet = S_OK;
102
103 ++This->readcalls;
104 if (This->failreadcall)
105 {
106 return STG_E_ACCESSDENIED;
107 }
108 else if (This->failreadsize)
109 {
110 *lpRead = ulSize + 8;
111 return S_OK;
112 }
113 else if (This->readreturnlarge)
114 {
115 *((ULONG*)lpMem) = 0xffff01;
116 *lpRead = ulSize;
117 This->readreturnlarge = FALSE;
118 return S_OK;
119 }
120 if (ulSize == sizeof(ULONG))
121 {
122 /* Read size of item */
123 *((ULONG*)lpMem) = This->item->ulSize ? This->item->ulSize + sizeof(SHLWAPI_CLIST) : 0;
124 *lpRead = ulSize;
125 }
126 else
127 {
128 unsigned int i;
129 char* buff = lpMem;
130
131 /* Read item data */
132 if (!This->item->ulSize)
133 {
134 This->readbeyondend = TRUE;
135 *lpRead = 0;
136 return E_FAIL; /* Should never happen */
137 }
138 *((ULONG*)lpMem) = This->item->ulId;
139 *lpRead = ulSize;
140
141 for (i = 0; i < This->item->ulSize; i++)
142 buff[4+i] = i*2;
143
144 This->item++;
145 }
146 return hRet;
147 }
148
149 static HRESULT WINAPI Write(IStream *iface, const void *lpMem, ULONG ulSize, ULONG *lpWritten)
150 {
151 struct dummystream *This = impl_from_IStream(iface);
152 HRESULT hRet = S_OK;
153
154 ++This->writecalls;
155 if (This->failwritecall)
156 {
157 return STG_E_ACCESSDENIED;
158 }
159 else if (This->failwritesize)
160 {
161 *lpWritten = 0;
162 }
163 else
164 *lpWritten = ulSize;
165 return hRet;
166 }
167
168 static HRESULT WINAPI Seek(IStream *iface, LARGE_INTEGER dlibMove, DWORD dwOrigin,
169 ULARGE_INTEGER *plibNewPosition)
170 {
171 struct dummystream *This = impl_from_IStream(iface);
172
173 ++This->seekcalls;
174 This->pos.QuadPart = dlibMove.QuadPart;
175 if (plibNewPosition)
176 plibNewPosition->QuadPart = dlibMove.QuadPart;
177 return S_OK;
178 }
179
180 static HRESULT WINAPI Stat(IStream *iface, STATSTG *pstatstg, DWORD grfStatFlag)
181 {
182 struct dummystream *This = impl_from_IStream(iface);
183
184 ++This->statcalls;
185 if (This->failstatcall)
186 return E_FAIL;
187 if (pstatstg)
188 pstatstg->cbSize.QuadPart = This->pos.QuadPart;
189 return S_OK;
190 }
191
192 /* VTable */
193 static IStreamVtbl iclvt =
194 {
195 QueryInterface,
196 AddRef,
197 Release,
198 Read,
199 Write,
200 Seek,
201 NULL, /* SetSize */
202 NULL, /* CopyTo */
203 NULL, /* Commit */
204 NULL, /* Revert */
205 NULL, /* LockRegion */
206 NULL, /* UnlockRegion */
207 Stat,
208 NULL /* Clone */
209 };
210
211 /* Function ptrs for ordinal calls */
212 static HMODULE SHLWAPI_hshlwapi = 0;
213
214 static VOID (WINAPI *pSHLWAPI_19)(LPSHLWAPI_CLIST);
215 static HRESULT (WINAPI *pSHLWAPI_20)(LPSHLWAPI_CLIST*,LPCSHLWAPI_CLIST);
216 static BOOL (WINAPI *pSHLWAPI_21)(LPSHLWAPI_CLIST*,ULONG);
217 static LPSHLWAPI_CLIST (WINAPI *pSHLWAPI_22)(LPSHLWAPI_CLIST,ULONG);
218 static HRESULT (WINAPI *pSHLWAPI_17)(IStream*, SHLWAPI_CLIST*);
219 static HRESULT (WINAPI *pSHLWAPI_18)(IStream*, SHLWAPI_CLIST**);
220
221 static BOOL (WINAPI *pSHLWAPI_166)(IStream*);
222 static HRESULT (WINAPI *pSHLWAPI_184)(IStream*, void*, ULONG);
223 static HRESULT (WINAPI *pSHLWAPI_212)(IStream*, const void*, ULONG);
224 static HRESULT (WINAPI *pSHLWAPI_213)(IStream*);
225 static HRESULT (WINAPI *pSHLWAPI_214)(IStream*, ULARGE_INTEGER*);
226
227
228 static BOOL InitFunctionPtrs(void)
229 {
230 SHLWAPI_hshlwapi = GetModuleHandleA("shlwapi.dll");
231
232 /* SHCreateStreamOnFileEx was introduced in shlwapi v6.0 */
233 if(!GetProcAddress(SHLWAPI_hshlwapi, "SHCreateStreamOnFileEx")){
234 win_skip("Too old shlwapi version\n");
235 return FALSE;
236 }
237
238 pSHLWAPI_17 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)17);
239 ok(pSHLWAPI_17 != 0, "No Ordinal 17\n");
240 pSHLWAPI_18 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)18);
241 ok(pSHLWAPI_18 != 0, "No Ordinal 18\n");
242 pSHLWAPI_19 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)19);
243 ok(pSHLWAPI_19 != 0, "No Ordinal 19\n");
244 pSHLWAPI_20 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)20);
245 ok(pSHLWAPI_20 != 0, "No Ordinal 20\n");
246 pSHLWAPI_21 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)21);
247 ok(pSHLWAPI_21 != 0, "No Ordinal 21\n");
248 pSHLWAPI_22 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)22);
249 ok(pSHLWAPI_22 != 0, "No Ordinal 22\n");
250 pSHLWAPI_166 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)166);
251 ok(pSHLWAPI_166 != 0, "No Ordinal 166\n");
252 pSHLWAPI_184 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)184);
253 ok(pSHLWAPI_184 != 0, "No Ordinal 184\n");
254 pSHLWAPI_212 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)212);
255 ok(pSHLWAPI_212 != 0, "No Ordinal 212\n");
256 pSHLWAPI_213 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)213);
257 ok(pSHLWAPI_213 != 0, "No Ordinal 213\n");
258 pSHLWAPI_214 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)214);
259 ok(pSHLWAPI_214 != 0, "No Ordinal 214\n");
260
261 return TRUE;
262 }
263
264 static void InitDummyStream(struct dummystream *obj)
265 {
266 obj->IStream_iface.lpVtbl = &iclvt;
267 obj->ref = 1;
268 obj->readcalls = 0;
269 obj->failreadcall = FALSE;
270 obj->failreadsize = FALSE;
271 obj->readbeyondend = FALSE;
272 obj->readreturnlarge = FALSE;
273 obj->writecalls = 0;
274 obj->failwritecall = FALSE;
275 obj->failwritesize = FALSE;
276 obj->seekcalls = 0;
277 obj->statcalls = 0;
278 obj->failstatcall = FALSE;
279 obj->item = SHLWAPI_CLIST_items;
280 obj->pos.QuadPart = 0;
281 }
282
283
284 static void test_CList(void)
285 {
286 struct dummystream streamobj;
287 LPSHLWAPI_CLIST list = NULL;
288 LPCSHLWAPI_CLIST item = SHLWAPI_CLIST_items;
289 HRESULT hRet;
290 LPSHLWAPI_CLIST inserted;
291 BYTE buff[64];
292 unsigned int i;
293
294 if (!pSHLWAPI_17 || !pSHLWAPI_18 || !pSHLWAPI_19 || !pSHLWAPI_20 ||
295 !pSHLWAPI_21 || !pSHLWAPI_22)
296 return;
297
298 /* Populate a list and test the items are added correctly */
299 while (item->ulSize)
300 {
301 /* Create item and fill with data */
302 inserted = (LPSHLWAPI_CLIST)buff;
303 inserted->ulSize = item->ulSize + sizeof(SHLWAPI_CLIST);
304 inserted->ulId = item->ulId;
305 for (i = 0; i < item->ulSize; i++)
306 buff[sizeof(SHLWAPI_CLIST)+i] = i*2;
307
308 /* Add it */
309 hRet = pSHLWAPI_20(&list, inserted);
310 ok(hRet > S_OK, "failed list add\n");
311
312 if (hRet > S_OK)
313 {
314 ok(list && list->ulSize, "item not added\n");
315
316 /* Find it */
317 inserted = pSHLWAPI_22(list, item->ulId);
318 ok(inserted != NULL, "lost after adding\n");
319
320 ok(!inserted || inserted->ulId != ~0U, "find returned a container\n");
321
322 /* Check size */
323 if (inserted && inserted->ulSize & 0x3)
324 {
325 /* Contained */
326 ok(inserted[-1].ulId == ~0U, "invalid size is not countained\n");
327 ok(inserted[-1].ulSize > inserted->ulSize+sizeof(SHLWAPI_CLIST),
328 "container too small\n");
329 }
330 else if (inserted)
331 {
332 ok(inserted->ulSize==item->ulSize+sizeof(SHLWAPI_CLIST),
333 "id %d wrong size %d\n", inserted->ulId, inserted->ulSize);
334 }
335 if (inserted)
336 {
337 BOOL bDataOK = TRUE;
338 LPBYTE bufftest = (LPBYTE)inserted;
339
340 for (i = 0; i < inserted->ulSize - sizeof(SHLWAPI_CLIST); i++)
341 if (bufftest[sizeof(SHLWAPI_CLIST)+i] != i*2)
342 bDataOK = FALSE;
343
344 ok(bDataOK == TRUE, "data corrupted on insert\n");
345 }
346 ok(!inserted || inserted->ulId==item->ulId, "find got wrong item\n");
347 }
348 item++;
349 }
350
351 /* Write the list */
352 InitDummyStream(&streamobj);
353
354 hRet = pSHLWAPI_17(&streamobj.IStream_iface, list);
355 ok(hRet == S_OK, "write failed\n");
356 if (hRet == S_OK)
357 {
358 /* 1 call for each element, + 1 for OK (use our null element for this) */
359 ok(streamobj.writecalls == sizeof(SHLWAPI_CLIST_items)/sizeof(SHLWAPI_CLIST),
360 "wrong call count\n");
361 ok(streamobj.readcalls == 0,"called Read() in write\n");
362 ok(streamobj.seekcalls == 0,"called Seek() in write\n");
363 }
364
365 /* Failure cases for writing */
366 InitDummyStream(&streamobj);
367 streamobj.failwritecall = TRUE;
368 hRet = pSHLWAPI_17(&streamobj.IStream_iface, list);
369 ok(hRet == STG_E_ACCESSDENIED, "changed object failure return\n");
370 ok(streamobj.writecalls == 1, "called object after failure\n");
371 ok(streamobj.readcalls == 0,"called Read() after failure\n");
372 ok(streamobj.seekcalls == 0,"called Seek() after failure\n");
373
374 InitDummyStream(&streamobj);
375 streamobj.failwritesize = TRUE;
376 hRet = pSHLWAPI_17(&streamobj.IStream_iface, list);
377 ok(hRet == STG_E_MEDIUMFULL || broken(hRet == E_FAIL) /* Win7 */,
378 "changed size failure return\n");
379 ok(streamobj.writecalls == 1, "called object after size failure\n");
380 ok(streamobj.readcalls == 0,"called Read() after failure\n");
381 ok(streamobj.seekcalls == 0,"called Seek() after failure\n");
382
383 /* Invalid inputs for adding */
384 inserted = (LPSHLWAPI_CLIST)buff;
385 inserted->ulSize = sizeof(SHLWAPI_CLIST) -1;
386 inserted->ulId = 33;
387
388 /* The call succeeds but the item is not inserted, except on some early
389 * versions which return failure. Wine behaves like later versions.
390 */
391 pSHLWAPI_20(&list, inserted);
392
393 inserted = pSHLWAPI_22(list, 33);
394 ok(inserted == NULL, "inserted bad element size\n");
395
396 inserted = (LPSHLWAPI_CLIST)buff;
397 inserted->ulSize = 44;
398 inserted->ulId = ~0U;
399
400 /* See comment above, some early versions fail this call */
401 pSHLWAPI_20(&list, inserted);
402
403 item = SHLWAPI_CLIST_items;
404
405 /* Look for nonexistent item in populated list */
406 inserted = pSHLWAPI_22(list, 99999999);
407 ok(inserted == NULL, "found a nonexistent item\n");
408
409 while (item->ulSize)
410 {
411 /* Delete items */
412 BOOL bRet = pSHLWAPI_21(&list, item->ulId);
413 ok(bRet == TRUE, "couldn't find item to delete\n");
414 item++;
415 }
416
417 /* Look for nonexistent item in empty list */
418 inserted = pSHLWAPI_22(list, 99999999);
419 ok(inserted == NULL, "found an item in empty list\n");
420
421 /* Create a list by reading in data */
422 InitDummyStream(&streamobj);
423
424 hRet = pSHLWAPI_18(&streamobj.IStream_iface, &list);
425 ok(hRet == S_OK, "failed create from Read()\n");
426 if (hRet == S_OK)
427 {
428 ok(streamobj.readbeyondend == FALSE, "read beyond end\n");
429 /* 2 calls per item, but only 1 for the terminator */
430 ok(streamobj.readcalls == sizeof(SHLWAPI_CLIST_items)/sizeof(SHLWAPI_CLIST)*2-1,
431 "wrong call count\n");
432 ok(streamobj.writecalls == 0, "called Write() from create\n");
433 ok(streamobj.seekcalls == 0,"called Seek() from create\n");
434
435 item = SHLWAPI_CLIST_items;
436
437 /* Check the items were added correctly */
438 while (item->ulSize)
439 {
440 inserted = pSHLWAPI_22(list, item->ulId);
441 ok(inserted != NULL, "lost after adding\n");
442
443 ok(!inserted || inserted->ulId != ~0U, "find returned a container\n");
444
445 /* Check size */
446 if (inserted && inserted->ulSize & 0x3)
447 {
448 /* Contained */
449 ok(inserted[-1].ulId == ~0U, "invalid size is not countained\n");
450 ok(inserted[-1].ulSize > inserted->ulSize+sizeof(SHLWAPI_CLIST),
451 "container too small\n");
452 }
453 else if (inserted)
454 {
455 ok(inserted->ulSize==item->ulSize+sizeof(SHLWAPI_CLIST),
456 "id %d wrong size %d\n", inserted->ulId, inserted->ulSize);
457 }
458 ok(!inserted || inserted->ulId==item->ulId, "find got wrong item\n");
459 if (inserted)
460 {
461 BOOL bDataOK = TRUE;
462 LPBYTE bufftest = (LPBYTE)inserted;
463
464 for (i = 0; i < inserted->ulSize - sizeof(SHLWAPI_CLIST); i++)
465 if (bufftest[sizeof(SHLWAPI_CLIST)+i] != i*2)
466 bDataOK = FALSE;
467
468 ok(bDataOK == TRUE, "data corrupted on insert\n");
469 }
470 item++;
471 }
472 }
473
474 /* Failure cases for reading */
475 InitDummyStream(&streamobj);
476 streamobj.failreadcall = TRUE;
477 hRet = pSHLWAPI_18(&streamobj.IStream_iface, &list);
478 ok(hRet == STG_E_ACCESSDENIED, "changed object failure return\n");
479 ok(streamobj.readbeyondend == FALSE, "read beyond end\n");
480 ok(streamobj.readcalls == 1, "called object after read failure\n");
481 ok(streamobj.writecalls == 0,"called Write() after read failure\n");
482 ok(streamobj.seekcalls == 0,"called Seek() after read failure\n");
483
484 /* Read returns large object */
485 InitDummyStream(&streamobj);
486 streamobj.readreturnlarge = TRUE;
487 hRet = pSHLWAPI_18(&streamobj.IStream_iface, &list);
488 ok(hRet == S_OK, "failed create from Read() with large item\n");
489 ok(streamobj.readbeyondend == FALSE, "read beyond end\n");
490 ok(streamobj.readcalls == 1,"wrong call count\n");
491 ok(streamobj.writecalls == 0,"called Write() after read failure\n");
492 ok(streamobj.seekcalls == 2,"wrong Seek() call count (%d)\n", streamobj.seekcalls);
493
494 pSHLWAPI_19(list);
495 }
496
497 static BOOL test_SHLWAPI_166(void)
498 {
499 struct dummystream streamobj;
500 BOOL bRet;
501
502 if (!pSHLWAPI_166)
503 return FALSE;
504
505 InitDummyStream(&streamobj);
506 bRet = pSHLWAPI_166(&streamobj.IStream_iface);
507
508 if (bRet != TRUE)
509 return FALSE; /* This version doesn't support stream ops on clists */
510
511 ok(streamobj.readcalls == 0, "called Read()\n");
512 ok(streamobj.writecalls == 0, "called Write()\n");
513 ok(streamobj.seekcalls == 0, "called Seek()\n");
514 ok(streamobj.statcalls == 1, "wrong call count\n");
515
516 streamobj.statcalls = 0;
517 streamobj.pos.QuadPart = 50001;
518
519 bRet = pSHLWAPI_166(&streamobj.IStream_iface);
520
521 ok(bRet == FALSE, "failed after seek adjusted\n");
522 ok(streamobj.readcalls == 0, "called Read()\n");
523 ok(streamobj.writecalls == 0, "called Write()\n");
524 ok(streamobj.seekcalls == 0, "called Seek()\n");
525 ok(streamobj.statcalls == 1, "wrong call count\n");
526
527 /* Failure cases */
528 InitDummyStream(&streamobj);
529 streamobj.pos.QuadPart = 50001;
530 streamobj.failstatcall = TRUE; /* 1: Stat() Bad, Read() OK */
531 bRet = pSHLWAPI_166(&streamobj.IStream_iface);
532 ok(bRet == FALSE, "should be FALSE after read is OK\n");
533 ok(streamobj.readcalls == 1, "wrong call count\n");
534 ok(streamobj.writecalls == 0, "called Write()\n");
535 ok(streamobj.seekcalls == 1, "wrong call count\n");
536 ok(streamobj.statcalls == 1, "wrong call count\n");
537 ok(streamobj.pos.QuadPart == 0, "Didn't seek to start\n");
538
539 InitDummyStream(&streamobj);
540 streamobj.pos.QuadPart = 50001;
541 streamobj.failstatcall = TRUE;
542 streamobj.failreadcall = TRUE; /* 2: Stat() Bad, Read() Bad Also */
543 bRet = pSHLWAPI_166(&streamobj.IStream_iface);
544 ok(bRet == TRUE, "Should be true after read fails\n");
545 ok(streamobj.readcalls == 1, "wrong call count\n");
546 ok(streamobj.writecalls == 0, "called Write()\n");
547 ok(streamobj.seekcalls == 0, "Called Seek()\n");
548 ok(streamobj.statcalls == 1, "wrong call count\n");
549 ok(streamobj.pos.QuadPart == 50001, "called Seek() after read failed\n");
550 return TRUE;
551 }
552
553 static void test_SHLWAPI_184(void)
554 {
555 struct dummystream streamobj;
556 char buff[256];
557 HRESULT hRet;
558
559 if (!pSHLWAPI_184)
560 return;
561
562 InitDummyStream(&streamobj);
563 hRet = pSHLWAPI_184(&streamobj.IStream_iface, buff, sizeof(buff));
564
565 ok(hRet == S_OK, "failed Read()\n");
566 ok(streamobj.readcalls == 1, "wrong call count\n");
567 ok(streamobj.writecalls == 0, "called Write()\n");
568 ok(streamobj.seekcalls == 0, "called Seek()\n");
569 }
570
571 static void test_SHLWAPI_212(void)
572 {
573 struct dummystream streamobj;
574 char buff[256];
575 HRESULT hRet;
576
577 if (!pSHLWAPI_212)
578 return;
579
580 InitDummyStream(&streamobj);
581 hRet = pSHLWAPI_212(&streamobj.IStream_iface, buff, sizeof(buff));
582
583 ok(hRet == S_OK, "failed Write()\n");
584 ok(streamobj.readcalls == 0, "called Read()\n");
585 ok(streamobj.writecalls == 1, "wrong call count\n");
586 ok(streamobj.seekcalls == 0, "called Seek()\n");
587 }
588
589 static void test_SHLWAPI_213(void)
590 {
591 struct dummystream streamobj;
592 ULARGE_INTEGER ul;
593 LARGE_INTEGER ll;
594 HRESULT hRet;
595
596 if (!pSHLWAPI_213 || !pSHLWAPI_214)
597 return;
598
599 InitDummyStream(&streamobj);
600 ll.QuadPart = 5000l;
601 Seek(&streamobj.IStream_iface, ll, 0, NULL); /* Seek to 5000l */
602
603 streamobj.seekcalls = 0;
604 pSHLWAPI_213(&streamobj.IStream_iface); /* Should rewind */
605 ok(streamobj.statcalls == 0, "called Stat()\n");
606 ok(streamobj.readcalls == 0, "called Read()\n");
607 ok(streamobj.writecalls == 0, "called Write()\n");
608 ok(streamobj.seekcalls == 1, "wrong call count\n");
609
610 ul.QuadPart = 50001;
611 hRet = pSHLWAPI_214(&streamobj.IStream_iface, &ul);
612 ok(hRet == S_OK, "failed Stat()\n");
613 ok(ul.QuadPart == 0, "213 didn't rewind stream\n");
614 }
615
616 static void test_SHLWAPI_214(void)
617 {
618 struct dummystream streamobj;
619 ULARGE_INTEGER ul;
620 LARGE_INTEGER ll;
621 HRESULT hRet;
622
623 if (!pSHLWAPI_214)
624 return;
625
626 InitDummyStream(&streamobj);
627 ll.QuadPart = 5000l;
628 Seek(&streamobj.IStream_iface, ll, 0, NULL);
629 ul.QuadPart = 0;
630 streamobj.seekcalls = 0;
631 hRet = pSHLWAPI_214(&streamobj.IStream_iface, &ul);
632
633 ok(hRet == S_OK, "failed Stat()\n");
634 ok(streamobj.statcalls == 1, "wrong call count\n");
635 ok(streamobj.readcalls == 0, "called Read()\n");
636 ok(streamobj.writecalls == 0, "called Write()\n");
637 ok(streamobj.seekcalls == 0, "called Seek()\n");
638 ok(ul.QuadPart == 5000l, "Stat gave wrong size\n");
639 }
640
641 START_TEST(clist)
642 {
643 if(!InitFunctionPtrs())
644 return;
645
646 test_CList();
647
648 /* Test streaming if this version supports it */
649 if (test_SHLWAPI_166())
650 {
651 test_SHLWAPI_184();
652 test_SHLWAPI_212();
653 test_SHLWAPI_213();
654 test_SHLWAPI_214();
655 }
656 }