2002-07-16 03:21:52 +02:00
|
|
|
/* Unit test suite for SHLWAPI Compact List and IStream ordinal functions
|
2002-07-09 04:01:56 +02:00
|
|
|
*
|
|
|
|
* Copyright 2002 Jon Griffiths
|
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-07-09 04:01:56 +02:00
|
|
|
*/
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2002-07-09 04:01:56 +02:00
|
|
|
#include "wine/test.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2002-07-09 04:01:56 +02:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "objbase.h"
|
|
|
|
|
|
|
|
typedef struct tagSHLWAPI_CLIST
|
|
|
|
{
|
|
|
|
ULONG ulSize;
|
|
|
|
ULONG ulId;
|
|
|
|
} SHLWAPI_CLIST, *LPSHLWAPI_CLIST;
|
|
|
|
|
|
|
|
typedef const SHLWAPI_CLIST* LPCSHLWAPI_CLIST;
|
|
|
|
|
|
|
|
/* Items to add */
|
|
|
|
static const SHLWAPI_CLIST SHLWAPI_CLIST_items[] =
|
|
|
|
{
|
|
|
|
{4, 1},
|
|
|
|
{8, 3},
|
|
|
|
{12, 2},
|
|
|
|
{16, 8},
|
|
|
|
{20, 9},
|
|
|
|
{3, 11},
|
|
|
|
{9, 82},
|
|
|
|
{33, 16},
|
|
|
|
{32, 55},
|
|
|
|
{24, 100},
|
|
|
|
{39, 116},
|
|
|
|
{ 0, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Dummy IStream object for testing calls */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
void* lpVtbl;
|
2005-07-13 13:59:15 +02:00
|
|
|
LONG ref;
|
2002-07-09 04:01:56 +02:00
|
|
|
int readcalls;
|
|
|
|
BOOL failreadcall;
|
|
|
|
BOOL failreadsize;
|
|
|
|
BOOL readbeyondend;
|
|
|
|
BOOL readreturnlarge;
|
|
|
|
int writecalls;
|
|
|
|
BOOL failwritecall;
|
|
|
|
BOOL failwritesize;
|
|
|
|
int seekcalls;
|
|
|
|
int statcalls;
|
2002-07-16 03:21:52 +02:00
|
|
|
BOOL failstatcall;
|
2002-07-09 04:01:56 +02:00
|
|
|
LPCSHLWAPI_CLIST item;
|
2002-07-16 03:21:52 +02:00
|
|
|
ULARGE_INTEGER pos;
|
2002-07-09 04:01:56 +02:00
|
|
|
} _IDummyStream;
|
|
|
|
|
|
|
|
static
|
|
|
|
HRESULT WINAPI QueryInterface(_IDummyStream *This,REFIID riid, LPVOID *ppvObj)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI AddRef(_IDummyStream *This)
|
|
|
|
{
|
2005-01-17 14:42:13 +01:00
|
|
|
return InterlockedIncrement(&This->ref);
|
2002-07-09 04:01:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI Release(_IDummyStream *This)
|
|
|
|
{
|
2005-01-17 14:42:13 +01:00
|
|
|
return InterlockedDecrement(&This->ref);
|
2002-07-09 04:01:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Read(_IDummyStream* This, LPVOID lpMem, ULONG ulSize,
|
2002-09-17 03:35:09 +02:00
|
|
|
PULONG lpRead)
|
2002-07-09 04:01:56 +02:00
|
|
|
{
|
|
|
|
HRESULT hRet = S_OK;
|
|
|
|
++This->readcalls;
|
|
|
|
|
|
|
|
if (This->failreadcall)
|
|
|
|
{
|
|
|
|
return STG_E_ACCESSDENIED;
|
|
|
|
}
|
|
|
|
else if (This->failreadsize)
|
|
|
|
{
|
|
|
|
*lpRead = ulSize + 8;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else if (This->readreturnlarge)
|
|
|
|
{
|
|
|
|
*((ULONG*)lpMem) = 0xffff01;
|
|
|
|
*lpRead = ulSize;
|
|
|
|
This->readreturnlarge = FALSE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
if (ulSize == sizeof(ULONG))
|
|
|
|
{
|
|
|
|
/* Read size of item */
|
|
|
|
*((ULONG*)lpMem) = This->item->ulSize ? This->item->ulSize + sizeof(SHLWAPI_CLIST) : 0;
|
|
|
|
*lpRead = ulSize;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned int i;
|
2009-01-22 09:52:44 +01:00
|
|
|
char* buff = lpMem;
|
2002-07-09 04:01:56 +02:00
|
|
|
|
|
|
|
/* Read item data */
|
|
|
|
if (!This->item->ulSize)
|
|
|
|
{
|
|
|
|
This->readbeyondend = TRUE;
|
|
|
|
*lpRead = 0;
|
|
|
|
return E_FAIL; /* Should never happen */
|
|
|
|
}
|
|
|
|
*((ULONG*)lpMem) = This->item->ulId;
|
|
|
|
*lpRead = ulSize;
|
|
|
|
|
|
|
|
for (i = 0; i < This->item->ulSize; i++)
|
|
|
|
buff[4+i] = i*2;
|
|
|
|
|
|
|
|
This->item++;
|
|
|
|
}
|
|
|
|
return hRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Write(_IDummyStream* This, LPVOID lpMem, ULONG ulSize,
|
2002-09-17 03:35:09 +02:00
|
|
|
PULONG lpWritten)
|
2002-07-09 04:01:56 +02:00
|
|
|
{
|
|
|
|
HRESULT hRet = S_OK;
|
|
|
|
|
|
|
|
++This->writecalls;
|
|
|
|
if (This->failwritecall)
|
|
|
|
{
|
|
|
|
return STG_E_ACCESSDENIED;
|
|
|
|
}
|
|
|
|
else if (This->failwritesize)
|
|
|
|
{
|
|
|
|
*lpWritten = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*lpWritten = ulSize;
|
|
|
|
return hRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Seek(_IDummyStream* This, LARGE_INTEGER dlibMove,
|
|
|
|
DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition)
|
|
|
|
{
|
|
|
|
++This->seekcalls;
|
2002-07-16 03:21:52 +02:00
|
|
|
This->pos.QuadPart = dlibMove.QuadPart;
|
2002-07-09 04:01:56 +02:00
|
|
|
if (plibNewPosition)
|
2002-07-16 03:21:52 +02:00
|
|
|
plibNewPosition->QuadPart = dlibMove.QuadPart;
|
2002-07-09 04:01:56 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI Stat(_IDummyStream* This, STATSTG* pstatstg,
|
|
|
|
DWORD grfStatFlag)
|
|
|
|
{
|
|
|
|
++This->statcalls;
|
2002-07-16 03:21:52 +02:00
|
|
|
if (This->failstatcall)
|
|
|
|
return E_FAIL;
|
2002-07-09 04:01:56 +02:00
|
|
|
if (pstatstg)
|
2002-07-16 03:21:52 +02:00
|
|
|
pstatstg->cbSize.QuadPart = This->pos.QuadPart;
|
2002-07-09 04:01:56 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* VTable */
|
|
|
|
static void* iclvt[] =
|
|
|
|
{
|
|
|
|
QueryInterface,
|
|
|
|
AddRef,
|
|
|
|
Release,
|
|
|
|
Read,
|
|
|
|
Write,
|
|
|
|
Seek,
|
|
|
|
NULL, /* SetSize */
|
|
|
|
NULL, /* CopyTo */
|
|
|
|
NULL, /* Commit */
|
|
|
|
NULL, /* Revert */
|
|
|
|
NULL, /* LockRegion */
|
|
|
|
NULL, /* UnlockRegion */
|
|
|
|
Stat,
|
|
|
|
NULL /* Clone */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Function ptrs for ordinal calls */
|
|
|
|
static HMODULE SHLWAPI_hshlwapi = 0;
|
|
|
|
|
|
|
|
static VOID (WINAPI *pSHLWAPI_19)(LPSHLWAPI_CLIST);
|
|
|
|
static HRESULT (WINAPI *pSHLWAPI_20)(LPSHLWAPI_CLIST*,LPCSHLWAPI_CLIST);
|
|
|
|
static BOOL (WINAPI *pSHLWAPI_21)(LPSHLWAPI_CLIST*,ULONG);
|
|
|
|
static LPSHLWAPI_CLIST (WINAPI *pSHLWAPI_22)(LPSHLWAPI_CLIST,ULONG);
|
|
|
|
static HRESULT (WINAPI *pSHLWAPI_17)(_IDummyStream*,LPSHLWAPI_CLIST);
|
|
|
|
static HRESULT (WINAPI *pSHLWAPI_18)(_IDummyStream*,LPSHLWAPI_CLIST*);
|
|
|
|
|
2002-07-16 03:21:52 +02:00
|
|
|
static BOOL (WINAPI *pSHLWAPI_166)(_IDummyStream*);
|
|
|
|
static HRESULT (WINAPI *pSHLWAPI_184)(_IDummyStream*,LPVOID,ULONG);
|
|
|
|
static HRESULT (WINAPI *pSHLWAPI_212)(_IDummyStream*,LPCVOID,ULONG);
|
|
|
|
static HRESULT (WINAPI *pSHLWAPI_213)(_IDummyStream*);
|
|
|
|
static HRESULT (WINAPI *pSHLWAPI_214)(_IDummyStream*,ULARGE_INTEGER*);
|
|
|
|
|
|
|
|
|
2005-06-20 16:18:03 +02:00
|
|
|
static void InitFunctionPtrs(void)
|
2002-07-09 04:01:56 +02:00
|
|
|
{
|
2007-08-07 15:16:32 +02:00
|
|
|
SHLWAPI_hshlwapi = GetModuleHandleA("shlwapi.dll");
|
|
|
|
|
|
|
|
pSHLWAPI_17 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)17);
|
|
|
|
ok(pSHLWAPI_17 != 0, "No Ordinal 17\n");
|
|
|
|
pSHLWAPI_18 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)18);
|
|
|
|
ok(pSHLWAPI_18 != 0, "No Ordinal 18\n");
|
|
|
|
pSHLWAPI_19 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)19);
|
|
|
|
ok(pSHLWAPI_19 != 0, "No Ordinal 19\n");
|
|
|
|
pSHLWAPI_20 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)20);
|
|
|
|
ok(pSHLWAPI_20 != 0, "No Ordinal 20\n");
|
|
|
|
pSHLWAPI_21 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)21);
|
|
|
|
ok(pSHLWAPI_21 != 0, "No Ordinal 21\n");
|
|
|
|
pSHLWAPI_22 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)22);
|
|
|
|
ok(pSHLWAPI_22 != 0, "No Ordinal 22\n");
|
|
|
|
pSHLWAPI_166 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)166);
|
|
|
|
ok(pSHLWAPI_166 != 0, "No Ordinal 166\n");
|
|
|
|
pSHLWAPI_184 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)184);
|
|
|
|
ok(pSHLWAPI_184 != 0, "No Ordinal 184\n");
|
|
|
|
pSHLWAPI_212 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)212);
|
|
|
|
ok(pSHLWAPI_212 != 0, "No Ordinal 212\n");
|
|
|
|
pSHLWAPI_213 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)213);
|
|
|
|
ok(pSHLWAPI_213 != 0, "No Ordinal 213\n");
|
|
|
|
pSHLWAPI_214 = (void *)GetProcAddress( SHLWAPI_hshlwapi, (LPSTR)214);
|
|
|
|
ok(pSHLWAPI_214 != 0, "No Ordinal 214\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void InitDummyStream(_IDummyStream* iface)
|
|
|
|
{
|
|
|
|
iface->lpVtbl = (void*)iclvt;
|
|
|
|
iface->ref = 1;
|
|
|
|
iface->readcalls = 0;
|
|
|
|
iface->failreadcall = FALSE;
|
|
|
|
iface->failreadsize = FALSE;
|
|
|
|
iface->readbeyondend = FALSE;
|
|
|
|
iface->readreturnlarge = FALSE;
|
|
|
|
iface->writecalls = 0;
|
|
|
|
iface->failwritecall = FALSE;
|
|
|
|
iface->failwritesize = FALSE;
|
|
|
|
iface->seekcalls = 0;
|
|
|
|
iface->statcalls = 0;
|
2002-07-16 03:21:52 +02:00
|
|
|
iface->failstatcall = FALSE;
|
2002-07-09 04:01:56 +02:00
|
|
|
iface->item = SHLWAPI_CLIST_items;
|
2002-07-16 03:21:52 +02:00
|
|
|
iface->pos.QuadPart = 0;
|
2002-07-09 04:01:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void test_CList(void)
|
|
|
|
{
|
|
|
|
_IDummyStream streamobj;
|
|
|
|
LPSHLWAPI_CLIST list = NULL;
|
|
|
|
LPCSHLWAPI_CLIST item = SHLWAPI_CLIST_items;
|
|
|
|
HRESULT hRet;
|
|
|
|
LPSHLWAPI_CLIST inserted;
|
2002-12-18 21:50:49 +01:00
|
|
|
BYTE buff[64];
|
2002-07-09 04:01:56 +02:00
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (!pSHLWAPI_17 || !pSHLWAPI_18 || !pSHLWAPI_19 || !pSHLWAPI_20 ||
|
|
|
|
!pSHLWAPI_21 || !pSHLWAPI_22)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Populate a list and test the items are added correctly */
|
|
|
|
while (item->ulSize)
|
|
|
|
{
|
|
|
|
/* Create item and fill with data */
|
|
|
|
inserted = (LPSHLWAPI_CLIST)buff;
|
|
|
|
inserted->ulSize = item->ulSize + sizeof(SHLWAPI_CLIST);
|
|
|
|
inserted->ulId = item->ulId;
|
|
|
|
for (i = 0; i < item->ulSize; i++)
|
|
|
|
buff[sizeof(SHLWAPI_CLIST)+i] = i*2;
|
|
|
|
|
|
|
|
/* Add it */
|
|
|
|
hRet = pSHLWAPI_20(&list, inserted);
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(hRet > S_OK, "failed list add\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
|
|
|
|
if (hRet > S_OK)
|
|
|
|
{
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(list && list->ulSize, "item not added\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
|
|
|
|
/* Find it */
|
|
|
|
inserted = pSHLWAPI_22(list, item->ulId);
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(inserted != NULL, "lost after adding\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
|
2005-09-13 17:00:32 +02:00
|
|
|
ok(!inserted || inserted->ulId != ~0U, "find returned a container\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
|
|
|
|
/* Check size */
|
|
|
|
if (inserted && inserted->ulSize & 0x3)
|
|
|
|
{
|
|
|
|
/* Contained */
|
2005-09-13 17:00:32 +02:00
|
|
|
ok(inserted[-1].ulId == ~0U, "invalid size is not countained\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
ok(inserted[-1].ulSize > inserted->ulSize+sizeof(SHLWAPI_CLIST),
|
2004-01-27 21:13:03 +01:00
|
|
|
"container too small\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
}
|
|
|
|
else if (inserted)
|
|
|
|
{
|
|
|
|
ok(inserted->ulSize==item->ulSize+sizeof(SHLWAPI_CLIST),
|
2006-10-12 14:58:25 +02:00
|
|
|
"id %d wrong size %d\n", inserted->ulId, inserted->ulSize);
|
2002-07-09 04:01:56 +02:00
|
|
|
}
|
|
|
|
if (inserted)
|
|
|
|
{
|
|
|
|
BOOL bDataOK = TRUE;
|
|
|
|
LPBYTE bufftest = (LPBYTE)inserted;
|
|
|
|
|
|
|
|
for (i = 0; i < inserted->ulSize - sizeof(SHLWAPI_CLIST); i++)
|
|
|
|
if (bufftest[sizeof(SHLWAPI_CLIST)+i] != i*2)
|
|
|
|
bDataOK = FALSE;
|
|
|
|
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(bDataOK == TRUE, "data corrupted on insert\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
}
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(!inserted || inserted->ulId==item->ulId, "find got wrong item\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
}
|
|
|
|
item++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write the list */
|
|
|
|
InitDummyStream(&streamobj);
|
|
|
|
|
|
|
|
hRet = pSHLWAPI_17(&streamobj, list);
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(hRet == S_OK, "write failed\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
if (hRet == S_OK)
|
|
|
|
{
|
|
|
|
/* 1 call for each element, + 1 for OK (use our null element for this) */
|
|
|
|
ok(streamobj.writecalls == sizeof(SHLWAPI_CLIST_items)/sizeof(SHLWAPI_CLIST),
|
2004-01-27 21:13:03 +01:00
|
|
|
"wrong call count\n");
|
|
|
|
ok(streamobj.readcalls == 0,"called Read() in write\n");
|
|
|
|
ok(streamobj.seekcalls == 0,"called Seek() in write\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Failure cases for writing */
|
|
|
|
InitDummyStream(&streamobj);
|
|
|
|
streamobj.failwritecall = TRUE;
|
|
|
|
hRet = pSHLWAPI_17(&streamobj, list);
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(hRet == STG_E_ACCESSDENIED, "changed object failure return\n");
|
|
|
|
ok(streamobj.writecalls == 1, "called object after failure\n");
|
|
|
|
ok(streamobj.readcalls == 0,"called Read() after failure\n");
|
|
|
|
ok(streamobj.seekcalls == 0,"called Seek() after failure\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
|
|
|
|
InitDummyStream(&streamobj);
|
|
|
|
streamobj.failwritesize = TRUE;
|
|
|
|
hRet = pSHLWAPI_17(&streamobj, list);
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(hRet == STG_E_MEDIUMFULL, "changed size failure return\n");
|
|
|
|
ok(streamobj.writecalls == 1, "called object after size failure\n");
|
|
|
|
ok(streamobj.readcalls == 0,"called Read() after failure\n");
|
|
|
|
ok(streamobj.seekcalls == 0,"called Seek() after failure\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
|
|
|
|
/* Invalid inputs for adding */
|
|
|
|
inserted = (LPSHLWAPI_CLIST)buff;
|
|
|
|
inserted->ulSize = sizeof(SHLWAPI_CLIST) -1;
|
|
|
|
inserted->ulId = 33;
|
|
|
|
hRet = pSHLWAPI_20(&list, inserted);
|
2005-03-16 20:47:37 +01:00
|
|
|
/* The call succeeds but the item is not inserted, except on some early
|
|
|
|
* versions which return failure. Wine behaves like later versions.
|
|
|
|
*/
|
2006-12-14 18:10:39 +01:00
|
|
|
if (0)
|
|
|
|
{
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(hRet == S_OK, "failed bad element size\n");
|
2006-12-14 18:10:39 +01:00
|
|
|
}
|
2003-03-15 20:40:11 +01:00
|
|
|
inserted = pSHLWAPI_22(list, 33);
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(inserted == NULL, "inserted bad element size\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
|
2003-03-15 20:40:11 +01:00
|
|
|
inserted = (LPSHLWAPI_CLIST)buff;
|
2002-07-09 04:01:56 +02:00
|
|
|
inserted->ulSize = 44;
|
2005-09-13 17:00:32 +02:00
|
|
|
inserted->ulId = ~0U;
|
2002-07-09 04:01:56 +02:00
|
|
|
hRet = pSHLWAPI_20(&list, inserted);
|
2005-03-16 20:47:37 +01:00
|
|
|
/* See comment above, some early versions fail this call */
|
2006-12-14 18:10:39 +01:00
|
|
|
if (0)
|
|
|
|
{
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(hRet == S_OK, "failed adding a container\n");
|
2006-12-14 18:10:39 +01:00
|
|
|
}
|
2002-07-09 04:01:56 +02:00
|
|
|
item = SHLWAPI_CLIST_items;
|
|
|
|
|
2005-02-10 20:19:35 +01:00
|
|
|
/* Look for nonexistent item in populated list */
|
2002-07-09 04:01:56 +02:00
|
|
|
inserted = pSHLWAPI_22(list, 99999999);
|
2005-02-10 20:19:35 +01:00
|
|
|
ok(inserted == NULL, "found a nonexistent item\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
|
|
|
|
while (item->ulSize)
|
|
|
|
{
|
|
|
|
/* Delete items */
|
|
|
|
BOOL bRet = pSHLWAPI_21(&list, item->ulId);
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(bRet == TRUE, "couldn't find item to delete\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
item++;
|
|
|
|
}
|
|
|
|
|
2005-02-10 20:19:35 +01:00
|
|
|
/* Look for nonexistent item in empty list */
|
2002-07-09 04:01:56 +02:00
|
|
|
inserted = pSHLWAPI_22(list, 99999999);
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(inserted == NULL, "found an item in empty list\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
|
|
|
|
/* Create a list by reading in data */
|
|
|
|
InitDummyStream(&streamobj);
|
|
|
|
|
|
|
|
hRet = pSHLWAPI_18(&streamobj, &list);
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(hRet == S_OK, "failed create from Read()\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
if (hRet == S_OK)
|
|
|
|
{
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(streamobj.readbeyondend == FALSE, "read beyond end\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
/* 2 calls per item, but only 1 for the terminator */
|
|
|
|
ok(streamobj.readcalls == sizeof(SHLWAPI_CLIST_items)/sizeof(SHLWAPI_CLIST)*2-1,
|
2004-01-27 21:13:03 +01:00
|
|
|
"wrong call count\n");
|
|
|
|
ok(streamobj.writecalls == 0, "called Write() from create\n");
|
|
|
|
ok(streamobj.seekcalls == 0,"called Seek() from create\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
|
|
|
|
item = SHLWAPI_CLIST_items;
|
|
|
|
|
|
|
|
/* Check the items were added correctly */
|
|
|
|
while (item->ulSize)
|
|
|
|
{
|
|
|
|
inserted = pSHLWAPI_22(list, item->ulId);
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(inserted != NULL, "lost after adding\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
|
2005-09-13 17:00:32 +02:00
|
|
|
ok(!inserted || inserted->ulId != ~0U, "find returned a container\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
|
|
|
|
/* Check size */
|
|
|
|
if (inserted && inserted->ulSize & 0x3)
|
|
|
|
{
|
|
|
|
/* Contained */
|
2005-09-13 17:00:32 +02:00
|
|
|
ok(inserted[-1].ulId == ~0U, "invalid size is not countained\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
ok(inserted[-1].ulSize > inserted->ulSize+sizeof(SHLWAPI_CLIST),
|
2004-01-27 21:13:03 +01:00
|
|
|
"container too small\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
}
|
|
|
|
else if (inserted)
|
|
|
|
{
|
|
|
|
ok(inserted->ulSize==item->ulSize+sizeof(SHLWAPI_CLIST),
|
2006-10-12 14:58:25 +02:00
|
|
|
"id %d wrong size %d\n", inserted->ulId, inserted->ulSize);
|
2002-07-09 04:01:56 +02:00
|
|
|
}
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(!inserted || inserted->ulId==item->ulId, "find got wrong item\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
if (inserted)
|
|
|
|
{
|
|
|
|
BOOL bDataOK = TRUE;
|
2002-12-18 21:50:49 +01:00
|
|
|
LPBYTE bufftest = (LPBYTE)inserted;
|
2002-07-09 04:01:56 +02:00
|
|
|
|
|
|
|
for (i = 0; i < inserted->ulSize - sizeof(SHLWAPI_CLIST); i++)
|
|
|
|
if (bufftest[sizeof(SHLWAPI_CLIST)+i] != i*2)
|
|
|
|
bDataOK = FALSE;
|
|
|
|
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(bDataOK == TRUE, "data corrupted on insert\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
}
|
|
|
|
item++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Failure cases for reading */
|
|
|
|
InitDummyStream(&streamobj);
|
|
|
|
streamobj.failreadcall = TRUE;
|
|
|
|
hRet = pSHLWAPI_18(&streamobj, &list);
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(hRet == STG_E_ACCESSDENIED, "changed object failure return\n");
|
|
|
|
ok(streamobj.readbeyondend == FALSE, "read beyond end\n");
|
|
|
|
ok(streamobj.readcalls == 1, "called object after read failure\n");
|
|
|
|
ok(streamobj.writecalls == 0,"called Write() after read failure\n");
|
|
|
|
ok(streamobj.seekcalls == 0,"called Seek() after read failure\n");
|
2002-07-09 04:01:56 +02:00
|
|
|
|
|
|
|
/* Read returns large object */
|
|
|
|
InitDummyStream(&streamobj);
|
|
|
|
streamobj.readreturnlarge = TRUE;
|
|
|
|
hRet = pSHLWAPI_18(&streamobj, &list);
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(hRet == S_OK, "failed create from Read() with large item\n");
|
|
|
|
ok(streamobj.readbeyondend == FALSE, "read beyond end\n");
|
|
|
|
ok(streamobj.readcalls == 1,"wrong call count\n");
|
|
|
|
ok(streamobj.writecalls == 0,"called Write() after read failure\n");
|
|
|
|
ok(streamobj.seekcalls == 2,"wrong Seek() call count (%d)\n", streamobj.seekcalls);
|
2002-07-09 04:01:56 +02:00
|
|
|
|
|
|
|
pSHLWAPI_19(list);
|
|
|
|
}
|
|
|
|
|
2005-03-16 20:47:37 +01:00
|
|
|
static BOOL test_SHLWAPI_166(void)
|
2002-07-16 03:21:52 +02:00
|
|
|
{
|
|
|
|
_IDummyStream streamobj;
|
|
|
|
BOOL bRet;
|
|
|
|
|
|
|
|
if (!pSHLWAPI_166)
|
2005-03-16 20:47:37 +01:00
|
|
|
return FALSE;
|
2002-07-16 03:21:52 +02:00
|
|
|
|
|
|
|
InitDummyStream(&streamobj);
|
|
|
|
bRet = pSHLWAPI_166(&streamobj);
|
|
|
|
|
2005-03-16 20:47:37 +01:00
|
|
|
if (bRet != TRUE)
|
|
|
|
return FALSE; /* This version doesn't support stream ops on clists */
|
|
|
|
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(streamobj.readcalls == 0, "called Read()\n");
|
|
|
|
ok(streamobj.writecalls == 0, "called Write()\n");
|
|
|
|
ok(streamobj.seekcalls == 0, "called Seek()\n");
|
|
|
|
ok(streamobj.statcalls == 1, "wrong call count\n");
|
2002-07-16 03:21:52 +02:00
|
|
|
|
|
|
|
streamobj.statcalls = 0;
|
|
|
|
streamobj.pos.QuadPart = 50001;
|
|
|
|
|
|
|
|
bRet = pSHLWAPI_166(&streamobj);
|
|
|
|
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(bRet == FALSE, "failed after seek adjusted\n");
|
|
|
|
ok(streamobj.readcalls == 0, "called Read()\n");
|
|
|
|
ok(streamobj.writecalls == 0, "called Write()\n");
|
|
|
|
ok(streamobj.seekcalls == 0, "called Seek()\n");
|
|
|
|
ok(streamobj.statcalls == 1, "wrong call count\n");
|
2002-07-16 03:21:52 +02:00
|
|
|
|
|
|
|
/* Failure cases */
|
|
|
|
InitDummyStream(&streamobj);
|
|
|
|
streamobj.pos.QuadPart = 50001;
|
|
|
|
streamobj.failstatcall = TRUE; /* 1: Stat() Bad, Read() OK */
|
|
|
|
bRet = pSHLWAPI_166(&streamobj);
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(bRet == FALSE, "should be FALSE after read is OK\n");
|
|
|
|
ok(streamobj.readcalls == 1, "wrong call count\n");
|
|
|
|
ok(streamobj.writecalls == 0, "called Write()\n");
|
|
|
|
ok(streamobj.seekcalls == 1, "wrong call count\n");
|
|
|
|
ok(streamobj.statcalls == 1, "wrong call count\n");
|
|
|
|
ok(streamobj.pos.QuadPart == 0, "Didn't seek to start\n");
|
2002-07-16 03:21:52 +02:00
|
|
|
|
|
|
|
InitDummyStream(&streamobj);
|
|
|
|
streamobj.pos.QuadPart = 50001;
|
|
|
|
streamobj.failstatcall = TRUE;
|
|
|
|
streamobj.failreadcall = TRUE; /* 2: Stat() Bad, Read() Bad Also */
|
|
|
|
bRet = pSHLWAPI_166(&streamobj);
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(bRet == TRUE, "Should be true after read fails\n");
|
|
|
|
ok(streamobj.readcalls == 1, "wrong call count\n");
|
|
|
|
ok(streamobj.writecalls == 0, "called Write()\n");
|
|
|
|
ok(streamobj.seekcalls == 0, "Called Seek()\n");
|
|
|
|
ok(streamobj.statcalls == 1, "wrong call count\n");
|
|
|
|
ok(streamobj.pos.QuadPart == 50001, "called Seek() after read failed\n");
|
2005-03-16 20:47:37 +01:00
|
|
|
return TRUE;
|
2002-07-16 03:21:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_SHLWAPI_184(void)
|
|
|
|
{
|
|
|
|
_IDummyStream streamobj;
|
|
|
|
char buff[256];
|
|
|
|
HRESULT hRet;
|
|
|
|
|
|
|
|
if (!pSHLWAPI_184)
|
|
|
|
return;
|
|
|
|
|
|
|
|
InitDummyStream(&streamobj);
|
|
|
|
hRet = pSHLWAPI_184(&streamobj, buff, sizeof(buff));
|
|
|
|
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(hRet == S_OK, "failed Read()\n");
|
|
|
|
ok(streamobj.readcalls == 1, "wrong call count\n");
|
|
|
|
ok(streamobj.writecalls == 0, "called Write()\n");
|
|
|
|
ok(streamobj.seekcalls == 0, "called Seek()\n");
|
2002-07-16 03:21:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_SHLWAPI_212(void)
|
|
|
|
{
|
|
|
|
_IDummyStream streamobj;
|
|
|
|
char buff[256];
|
|
|
|
HRESULT hRet;
|
|
|
|
|
|
|
|
if (!pSHLWAPI_212)
|
|
|
|
return;
|
|
|
|
|
|
|
|
InitDummyStream(&streamobj);
|
|
|
|
hRet = pSHLWAPI_212(&streamobj, buff, sizeof(buff));
|
|
|
|
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(hRet == S_OK, "failed Write()\n");
|
|
|
|
ok(streamobj.readcalls == 0, "called Read()\n");
|
|
|
|
ok(streamobj.writecalls == 1, "wrong call count\n");
|
|
|
|
ok(streamobj.seekcalls == 0, "called Seek()\n");
|
2002-07-16 03:21:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_SHLWAPI_213(void)
|
|
|
|
{
|
|
|
|
_IDummyStream streamobj;
|
|
|
|
ULARGE_INTEGER ul;
|
|
|
|
LARGE_INTEGER ll;
|
|
|
|
HRESULT hRet;
|
|
|
|
|
|
|
|
if (!pSHLWAPI_213 || !pSHLWAPI_214)
|
|
|
|
return;
|
|
|
|
|
|
|
|
InitDummyStream(&streamobj);
|
|
|
|
ll.QuadPart = 5000l;
|
|
|
|
Seek(&streamobj, ll, 0, NULL); /* Seek to 5000l */
|
|
|
|
|
|
|
|
streamobj.seekcalls = 0;
|
|
|
|
pSHLWAPI_213(&streamobj); /* Should rewind */
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(streamobj.statcalls == 0, "called Stat()\n");
|
|
|
|
ok(streamobj.readcalls == 0, "called Read()\n");
|
|
|
|
ok(streamobj.writecalls == 0, "called Write()\n");
|
|
|
|
ok(streamobj.seekcalls == 1, "wrong call count\n");
|
2002-07-16 03:21:52 +02:00
|
|
|
|
|
|
|
ul.QuadPart = 50001;
|
|
|
|
hRet = pSHLWAPI_214(&streamobj, &ul);
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(hRet == S_OK, "failed Stat()\n");
|
|
|
|
ok(ul.QuadPart == 0, "213 didn't rewind stream\n");
|
2002-07-16 03:21:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_SHLWAPI_214(void)
|
|
|
|
{
|
|
|
|
_IDummyStream streamobj;
|
|
|
|
ULARGE_INTEGER ul;
|
|
|
|
LARGE_INTEGER ll;
|
|
|
|
HRESULT hRet;
|
|
|
|
|
|
|
|
if (!pSHLWAPI_214)
|
|
|
|
return;
|
|
|
|
|
|
|
|
InitDummyStream(&streamobj);
|
|
|
|
ll.QuadPart = 5000l;
|
|
|
|
Seek(&streamobj, ll, 0, NULL);
|
|
|
|
ul.QuadPart = 0;
|
|
|
|
streamobj.seekcalls = 0;
|
|
|
|
hRet = pSHLWAPI_214(&streamobj, &ul);
|
|
|
|
|
2004-01-27 21:13:03 +01:00
|
|
|
ok(hRet == S_OK, "failed Stat()\n");
|
|
|
|
ok(streamobj.statcalls == 1, "wrong call count\n");
|
|
|
|
ok(streamobj.readcalls == 0, "called Read()\n");
|
|
|
|
ok(streamobj.writecalls == 0, "called Write()\n");
|
|
|
|
ok(streamobj.seekcalls == 0, "called Seek()\n");
|
|
|
|
ok(ul.QuadPart == 5000l, "Stat gave wrong size\n");
|
2002-07-16 03:21:52 +02:00
|
|
|
}
|
2002-07-09 04:01:56 +02:00
|
|
|
|
|
|
|
START_TEST(clist)
|
|
|
|
{
|
|
|
|
InitFunctionPtrs();
|
|
|
|
|
|
|
|
test_CList();
|
|
|
|
|
2005-03-16 20:47:37 +01:00
|
|
|
/* Test streaming if this version supports it */
|
|
|
|
if (test_SHLWAPI_166())
|
|
|
|
{
|
|
|
|
test_SHLWAPI_184();
|
|
|
|
test_SHLWAPI_212();
|
|
|
|
test_SHLWAPI_213();
|
|
|
|
test_SHLWAPI_214();
|
|
|
|
}
|
2002-07-09 04:01:56 +02:00
|
|
|
}
|