browseui: Implement and test ACLMulti.
This commit is contained in:
parent
719088ca85
commit
7206e10673
|
@ -30,6 +30,9 @@ dlls/avicap32/libavicap32.def
|
|||
dlls/avifil32/libavifil32.def
|
||||
dlls/avifil32/rsrc.res
|
||||
dlls/avifile.dll16
|
||||
dlls/browseui/tests/*.ok
|
||||
dlls/browseui/tests/browseui_crosstest.exe
|
||||
dlls/browseui/tests/testlist.c
|
||||
dlls/browseui/version.res
|
||||
dlls/cabinet/cabinet.res
|
||||
dlls/cabinet/libcabinet.def
|
||||
|
@ -786,6 +789,7 @@ programs/winemine/winemine.ico
|
|||
programs/winepath/winepath
|
||||
programs/winetest/advapi32_test.exe
|
||||
programs/winetest/advpack_test.exe
|
||||
programs/winetest/browseui_test.exe
|
||||
programs/winetest/cabinet_test.exe
|
||||
programs/winetest/comcat_test.exe
|
||||
programs/winetest/comctl32_test.exe
|
||||
|
|
|
@ -165,6 +165,7 @@ ALL_MAKEFILES = \
|
|||
dlls/avicap32/Makefile \
|
||||
dlls/avifil32/Makefile \
|
||||
dlls/browseui/Makefile \
|
||||
dlls/browseui/tests/Makefile \
|
||||
dlls/cabinet/Makefile \
|
||||
dlls/cabinet/tests/Makefile \
|
||||
dlls/capi2032/Makefile \
|
||||
|
@ -495,6 +496,7 @@ dlls/atl/Makefile: dlls/atl/Makefile.in dlls/Makedll.rules
|
|||
dlls/avicap32/Makefile: dlls/avicap32/Makefile.in dlls/Makedll.rules
|
||||
dlls/avifil32/Makefile: dlls/avifil32/Makefile.in dlls/Makedll.rules
|
||||
dlls/browseui/Makefile: dlls/browseui/Makefile.in dlls/Makedll.rules
|
||||
dlls/browseui/tests/Makefile: dlls/browseui/tests/Makefile.in dlls/Maketest.rules
|
||||
dlls/cabinet/Makefile: dlls/cabinet/Makefile.in dlls/Makedll.rules
|
||||
dlls/cabinet/tests/Makefile: dlls/cabinet/tests/Makefile.in dlls/Maketest.rules
|
||||
dlls/capi2032/Makefile: dlls/capi2032/Makefile.in dlls/Makedll.rules
|
||||
|
|
|
@ -1536,6 +1536,7 @@ dlls/atl/Makefile
|
|||
dlls/avicap32/Makefile
|
||||
dlls/avifil32/Makefile
|
||||
dlls/browseui/Makefile
|
||||
dlls/browseui/tests/Makefile
|
||||
dlls/cabinet/Makefile
|
||||
dlls/cabinet/tests/Makefile
|
||||
dlls/capi2032/Makefile
|
||||
|
|
|
@ -221,6 +221,7 @@ IMPLIBSUBDIRS = \
|
|||
TESTSUBDIRS = \
|
||||
advapi32/tests \
|
||||
advpack/tests \
|
||||
browseui/tests \
|
||||
cabinet/tests \
|
||||
comcat/tests \
|
||||
comctl32/tests \
|
||||
|
|
|
@ -8,6 +8,7 @@ EXTRALIBS = -luuid
|
|||
EXTRADEFS = -DCOM_NO_WINDOWS_H
|
||||
|
||||
C_SRCS = \
|
||||
aclmulti.c \
|
||||
browseui_main.c \
|
||||
regsvr.c
|
||||
|
||||
|
|
|
@ -0,0 +1,331 @@
|
|||
/*
|
||||
* Multisource AutoComplete list
|
||||
*
|
||||
* Copyright 2007 Mikolaj Zalewski
|
||||
*
|
||||
* 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 "config.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#define COBJMACROS
|
||||
|
||||
#include "wine/debug.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winreg.h"
|
||||
#include "winuser.h"
|
||||
#include "shlwapi.h"
|
||||
#include "winerror.h"
|
||||
#include "objbase.h"
|
||||
|
||||
#include "shlguid.h"
|
||||
#include "shlobj.h"
|
||||
|
||||
#include "wine/unicode.h"
|
||||
|
||||
#include "browseui.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(browseui);
|
||||
|
||||
struct ACLMultiSublist {
|
||||
IUnknown *punk;
|
||||
IEnumString *pEnum;
|
||||
IACList *pACL;
|
||||
};
|
||||
|
||||
typedef struct tagACLMulti {
|
||||
const IEnumStringVtbl *vtbl;
|
||||
const IACListVtbl *aclVtbl;
|
||||
const IObjMgrVtbl *objmgrVtbl;
|
||||
LONG refCount;
|
||||
INT nObjs;
|
||||
INT currObj;
|
||||
struct ACLMultiSublist *objs;
|
||||
} ACLMulti;
|
||||
|
||||
const static IEnumStringVtbl ACLMultiVtbl;
|
||||
const static IACListVtbl ACLMulti_ACListVtbl;
|
||||
const static IObjMgrVtbl ACLMulti_ObjMgrVtbl;
|
||||
|
||||
static inline ACLMulti *impl_from_IACList(IACList *iface)
|
||||
{
|
||||
return (ACLMulti *)((char *)iface - FIELD_OFFSET(ACLMulti, aclVtbl));
|
||||
}
|
||||
|
||||
static inline ACLMulti *impl_from_IObjMgr(IObjMgr *iface)
|
||||
{
|
||||
return (ACLMulti *)((char *)iface - FIELD_OFFSET(ACLMulti, objmgrVtbl));
|
||||
}
|
||||
|
||||
static void release_obj(struct ACLMultiSublist *obj)
|
||||
{
|
||||
IUnknown_Release(obj->punk);
|
||||
if (obj->pEnum)
|
||||
IEnumString_Release(obj->pEnum);
|
||||
if (obj->pACL)
|
||||
IACList_Release(obj->pACL);
|
||||
}
|
||||
|
||||
HRESULT WINAPI ACLMulti_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
|
||||
{
|
||||
ACLMulti *This;
|
||||
if (pUnkOuter)
|
||||
return CLASS_E_NOAGGREGATION;
|
||||
|
||||
This = CoTaskMemAlloc(sizeof(ACLMulti));
|
||||
if (This == NULL)
|
||||
return E_OUTOFMEMORY;
|
||||
ZeroMemory(This, sizeof(*This));
|
||||
This->vtbl = &ACLMultiVtbl;
|
||||
This->aclVtbl = &ACLMulti_ACListVtbl;
|
||||
This->objmgrVtbl = &ACLMulti_ObjMgrVtbl;
|
||||
This->refCount = 1;
|
||||
|
||||
TRACE("returning %p\n", This);
|
||||
*ppOut = (IUnknown *)This;
|
||||
BROWSEUI_refCount++;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static void WINAPI ACLMulti_Destructor(ACLMulti *This)
|
||||
{
|
||||
int i;
|
||||
TRACE("destroying %p\n", This);
|
||||
for (i = 0; i < This->nObjs; i++)
|
||||
release_obj(&This->objs[i]);
|
||||
CoTaskMemFree(This->objs);
|
||||
CoTaskMemFree(This);
|
||||
BROWSEUI_refCount--;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ACLMulti_QueryInterface(IEnumString *iface, REFIID iid, LPVOID *ppvOut)
|
||||
{
|
||||
ACLMulti *This = (ACLMulti *)iface;
|
||||
*ppvOut = NULL;
|
||||
|
||||
if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_IEnumString))
|
||||
{
|
||||
*ppvOut = This;
|
||||
}
|
||||
else if (IsEqualIID(iid, &IID_IACList))
|
||||
{
|
||||
*ppvOut = &This->aclVtbl;
|
||||
}
|
||||
else if (IsEqualIID(iid, &IID_IObjMgr))
|
||||
{
|
||||
*ppvOut = &This->objmgrVtbl;
|
||||
}
|
||||
|
||||
if (*ppvOut)
|
||||
{
|
||||
IUnknown_AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
WARN("unsupported interface: %s\n", debugstr_guid(iid));
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
static ULONG WINAPI ACLMulti_AddRef(IEnumString *iface)
|
||||
{
|
||||
ACLMulti *This = (ACLMulti *)iface;
|
||||
return InterlockedIncrement(&This->refCount);
|
||||
}
|
||||
|
||||
static ULONG WINAPI ACLMulti_Release(IEnumString *iface)
|
||||
{
|
||||
ACLMulti *This = (ACLMulti *)iface;
|
||||
ULONG ret;
|
||||
|
||||
ret = InterlockedDecrement(&This->refCount);
|
||||
if (ret == 0)
|
||||
ACLMulti_Destructor(This);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ACLMulti_Append(IObjMgr *iface, IUnknown *obj)
|
||||
{
|
||||
ACLMulti *This = impl_from_IObjMgr(iface);
|
||||
|
||||
TRACE("(%p, %p)\n", This, obj);
|
||||
if (obj == NULL)
|
||||
return E_FAIL;
|
||||
|
||||
This->objs = CoTaskMemRealloc(This->objs, sizeof(This->objs[0]) * (This->nObjs+1));
|
||||
This->objs[This->nObjs].punk = obj;
|
||||
IUnknown_AddRef(obj);
|
||||
if (FAILED(IUnknown_QueryInterface(obj, &IID_IEnumString, (LPVOID *)&This->objs[This->nObjs].pEnum)))
|
||||
This->objs[This->nObjs].pEnum = NULL;
|
||||
if (FAILED(IUnknown_QueryInterface(obj, &IID_IACList, (LPVOID *)&This->objs[This->nObjs].pACL)))
|
||||
This->objs[This->nObjs].pACL = NULL;
|
||||
This->nObjs++;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ACLMulti_Remove(IObjMgr *iface, IUnknown *obj)
|
||||
{
|
||||
ACLMulti *This = impl_from_IObjMgr(iface);
|
||||
int i;
|
||||
|
||||
TRACE("(%p, %p)\n", This, obj);
|
||||
for (i = 0; i < This->nObjs; i++)
|
||||
if (This->objs[i].punk == obj)
|
||||
{
|
||||
release_obj(&This->objs[i]);
|
||||
memmove(&This->objs[i], &This->objs[i+1], (This->nObjs-i-1)*sizeof(struct ACLMultiSublist));
|
||||
This->nObjs--;
|
||||
This->objs = CoTaskMemRealloc(This->objs, sizeof(This->objs[0]) * This->nObjs);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ACLMulti_Next(IEnumString *iface, ULONG celt, LPOLESTR *rgelt, ULONG *pceltFetched)
|
||||
{
|
||||
ACLMulti *This = (ACLMulti *)iface;
|
||||
|
||||
TRACE("(%p, %d, %p, %p)\n", iface, celt, rgelt, pceltFetched);
|
||||
while (This->currObj < This->nObjs)
|
||||
{
|
||||
if (This->objs[This->currObj].pEnum)
|
||||
{
|
||||
/* native browseui 6.0 also returns only one element */
|
||||
HRESULT ret = IEnumString_Next(This->objs[This->currObj].pEnum, 1, rgelt, pceltFetched);
|
||||
if (ret != S_FALSE)
|
||||
return ret;
|
||||
}
|
||||
This->currObj++;
|
||||
}
|
||||
|
||||
if (pceltFetched)
|
||||
*pceltFetched = 0;
|
||||
*rgelt = NULL;
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ACLMulti_Reset(IEnumString *iface)
|
||||
{
|
||||
ACLMulti *This = (ACLMulti *)iface;
|
||||
int i;
|
||||
|
||||
This->currObj = 0;
|
||||
for (i = 0; i < This->nObjs; i++)
|
||||
{
|
||||
if (This->objs[i].pEnum)
|
||||
IEnumString_Reset(This->objs[i].pEnum);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ACLMulti_Skip(IEnumString *iface, ULONG celt)
|
||||
{
|
||||
/* native browseui 6.0 returns this: */
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ACLMulti_Clone(IEnumString *iface, IEnumString **ppOut)
|
||||
{
|
||||
*ppOut = NULL;
|
||||
/* native browseui 6.0 returns this: */
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ACLMulti_Expand(IACList *iface, LPCWSTR wstr)
|
||||
{
|
||||
ACLMulti *This = impl_from_IACList(iface);
|
||||
HRESULT res = S_OK;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < This->nObjs; i++)
|
||||
{
|
||||
if (!This->objs[i].pACL)
|
||||
continue;
|
||||
res = IACList_Expand(This->objs[i].pACL, wstr);
|
||||
if (res == S_OK)
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static const IEnumStringVtbl ACLMultiVtbl =
|
||||
{
|
||||
ACLMulti_QueryInterface,
|
||||
ACLMulti_AddRef,
|
||||
ACLMulti_Release,
|
||||
|
||||
ACLMulti_Next,
|
||||
ACLMulti_Skip,
|
||||
ACLMulti_Reset,
|
||||
ACLMulti_Clone
|
||||
};
|
||||
|
||||
static HRESULT WINAPI ACLMulti_IObjMgr_QueryInterface(IObjMgr *iface, REFIID iid, LPVOID *ppvOut)
|
||||
{
|
||||
ACLMulti *This = impl_from_IObjMgr(iface);
|
||||
return ACLMulti_QueryInterface((IEnumString *)This, iid, ppvOut);
|
||||
}
|
||||
|
||||
static ULONG WINAPI ACLMulti_IObjMgr_AddRef(IObjMgr *iface)
|
||||
{
|
||||
ACLMulti *This = impl_from_IObjMgr(iface);
|
||||
return ACLMulti_AddRef((IEnumString *)This);
|
||||
}
|
||||
|
||||
static ULONG WINAPI ACLMulti_IObjMgr_Release(IObjMgr *iface)
|
||||
{
|
||||
ACLMulti *This = impl_from_IObjMgr(iface);
|
||||
return ACLMulti_Release((IEnumString *)This);
|
||||
}
|
||||
|
||||
static const IObjMgrVtbl ACLMulti_ObjMgrVtbl =
|
||||
{
|
||||
ACLMulti_IObjMgr_QueryInterface,
|
||||
ACLMulti_IObjMgr_AddRef,
|
||||
ACLMulti_IObjMgr_Release,
|
||||
|
||||
ACLMulti_Append,
|
||||
ACLMulti_Remove
|
||||
};
|
||||
|
||||
static HRESULT WINAPI ACLMulti_IACList_QueryInterface(IACList *iface, REFIID iid, LPVOID *ppvOut)
|
||||
{
|
||||
ACLMulti *This = impl_from_IACList(iface);
|
||||
return ACLMulti_QueryInterface((IEnumString *)This, iid, ppvOut);
|
||||
}
|
||||
|
||||
static ULONG WINAPI ACLMulti_IACList_AddRef(IACList *iface)
|
||||
{
|
||||
ACLMulti *This = impl_from_IACList(iface);
|
||||
return ACLMulti_AddRef((IEnumString *)This);
|
||||
}
|
||||
|
||||
static ULONG WINAPI ACLMulti_IACList_Release(IACList *iface)
|
||||
{
|
||||
ACLMulti *This = impl_from_IACList(iface);
|
||||
return ACLMulti_Release((IEnumString *)This);
|
||||
}
|
||||
|
||||
static const IACListVtbl ACLMulti_ACListVtbl =
|
||||
{
|
||||
ACLMulti_IACList_QueryInterface,
|
||||
ACLMulti_IACList_AddRef,
|
||||
ACLMulti_IACList_Release,
|
||||
|
||||
ACLMulti_Expand
|
||||
};
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Internal header for browseui.dll
|
||||
*
|
||||
* Copyright 2007 Mikolaj Zalewski
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef __WINE_BROWSEUI_H
|
||||
#define __WINE_BROWSEUI_H
|
||||
|
||||
extern LONG BROWSEUI_refCount;
|
||||
|
||||
HRESULT WINAPI ACLMulti_Constructor(IUnknown *punkOuter, IUnknown **ppOut);
|
||||
|
||||
#endif /* __WINE_SHDOCVW_H */
|
|
@ -31,9 +31,12 @@
|
|||
#include "winbase.h"
|
||||
#include "winreg.h"
|
||||
#include "shlwapi.h"
|
||||
#include "shlguid.h"
|
||||
|
||||
#include "initguid.h"
|
||||
|
||||
#include "browseui.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(browseui);
|
||||
|
||||
LONG BROWSEUI_refCount = 0;
|
||||
|
@ -46,6 +49,7 @@ static const struct {
|
|||
REFCLSID clsid;
|
||||
LPFNCONSTRUCTOR ctor;
|
||||
} ClassesTable[] = {
|
||||
{&CLSID_ACLMulti, ACLMulti_Constructor},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
@ -194,5 +198,6 @@ HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, LPVOID *ppvOut)
|
|||
if (IsEqualCLSID(ClassesTable[i].clsid, clsid)) {
|
||||
return ClassFactory_Constructor(ClassesTable[i].ctor, ppvOut);
|
||||
}
|
||||
FIXME("CLSID %s not supported\n", debugstr_guid(clsid));
|
||||
return CLASS_E_CLASSNOTAVAILABLE;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "winerror.h"
|
||||
|
||||
#include "ole2.h"
|
||||
#include "shlguid.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
|
||||
|
@ -502,6 +503,13 @@ static LONG recursive_delete_keyW(HKEY base, WCHAR const *name)
|
|||
* coclass list
|
||||
*/
|
||||
static struct regsvr_coclass const coclass_list[] = {
|
||||
{
|
||||
&CLSID_ACLMulti,
|
||||
"Multiple AutoComplete List Container",
|
||||
NULL,
|
||||
"browseui.dll",
|
||||
"Apartment"
|
||||
},
|
||||
{ NULL } /* list terminator */
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
TOPSRCDIR = @top_srcdir@
|
||||
TOPOBJDIR = ../../..
|
||||
SRCDIR = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
TESTDLL = browseui.dll
|
||||
IMPORTS = ole32 user32 kernel32
|
||||
EXTRALIBS = -luuid
|
||||
|
||||
CTESTS = \
|
||||
autocomplete.c
|
||||
|
||||
@MAKE_TEST_RULES@
|
||||
|
||||
@DEPENDENCIES@ # everything below this line is overwritten by make depend
|
|
@ -0,0 +1,321 @@
|
|||
/* Unit tests for autocomplete
|
||||
*
|
||||
* Copyright 2007 Mikolaj Zalewski
|
||||
*
|
||||
* 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 <assert.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <windows.h>
|
||||
#include <shlobj.h>
|
||||
#include <shlwapi.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
#define stop_on_error(exp) \
|
||||
{ \
|
||||
HRESULT res = (exp); \
|
||||
if (FAILED(res)) \
|
||||
{ \
|
||||
ok(FALSE, #exp " failed: %x\n", res); \
|
||||
return; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define ole_ok(exp) \
|
||||
{ \
|
||||
HRESULT res = (exp); \
|
||||
if (res != S_OK) \
|
||||
ok(FALSE, #exp " failed: %x\n", res); \
|
||||
}
|
||||
|
||||
LPWSTR strdup_AtoW(LPCSTR str)
|
||||
{
|
||||
int size = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
|
||||
LPWSTR wstr = (LPWSTR)CoTaskMemAlloc((size + 1)*sizeof(WCHAR));
|
||||
MultiByteToWideChar(CP_ACP, 0, str, -1, wstr, size+1);
|
||||
return wstr;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
IEnumStringVtbl *vtbl;
|
||||
IACListVtbl *aclVtbl;
|
||||
LONG ref;
|
||||
HRESULT expret;
|
||||
INT expcount;
|
||||
INT pos;
|
||||
INT limit;
|
||||
const char **data;
|
||||
} TestACL;
|
||||
|
||||
extern IEnumStringVtbl TestACLVtbl;
|
||||
extern IACListVtbl TestACL_ACListVtbl;
|
||||
|
||||
TestACL *impl_from_IACList(IACList *iface)
|
||||
{
|
||||
return (TestACL *)((char *)iface - FIELD_OFFSET(TestACL, aclVtbl));
|
||||
}
|
||||
|
||||
TestACL *TestACL_Constructor(int limit, const char **strings)
|
||||
{
|
||||
TestACL *This = CoTaskMemAlloc(sizeof(TestACL));
|
||||
ZeroMemory(This, sizeof(*This));
|
||||
This->vtbl = &TestACLVtbl;
|
||||
This->aclVtbl = &TestACL_ACListVtbl;
|
||||
This->ref = 1;
|
||||
This->expret = S_OK;
|
||||
This->limit = limit;
|
||||
This->data = strings;
|
||||
return This;
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE TestACL_AddRef(IEnumString *iface)
|
||||
{
|
||||
TestACL *This = (TestACL *)iface;
|
||||
trace("ACL(%p): addref (%d)\n", This, This->ref+1);
|
||||
return InterlockedIncrement(&This->ref);
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE TestACL_Release(IEnumString *iface)
|
||||
{
|
||||
TestACL *This = (TestACL *)iface;
|
||||
ULONG res;
|
||||
|
||||
res = InterlockedDecrement(&This->ref);
|
||||
trace("ACL(%p): release (%d)\n", This, res);
|
||||
return res;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE TestACL_QueryInterface(IEnumString *iface, REFIID iid, LPVOID *ppvOut)
|
||||
{
|
||||
TestACL *This = (TestACL *)iface;
|
||||
*ppvOut = NULL;
|
||||
if (IsEqualGUID(iid, &IID_IUnknown) || IsEqualGUID(iid, &IID_IEnumString))
|
||||
{
|
||||
*ppvOut = iface;
|
||||
}
|
||||
else if (IsEqualGUID(iid, &IID_IACList))
|
||||
{
|
||||
*ppvOut = &This->aclVtbl;
|
||||
}
|
||||
|
||||
if (*ppvOut)
|
||||
{
|
||||
iface->lpVtbl->AddRef(iface);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#if 0 /* IID_IEnumACString not defined yet in wine */
|
||||
if (!IsEqualGUID(iid, &IID_IEnumACString))
|
||||
trace("unknown interface queried\n");
|
||||
#endif
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE TestACL_Next(IEnumString *iface, ULONG celt, LPOLESTR *rgelt, ULONG *pceltFetched)
|
||||
{
|
||||
TestACL *This = (TestACL *)iface;
|
||||
ULONG i;
|
||||
|
||||
trace("ACL(%p): read %d item(s)\n", This, celt);
|
||||
for (i = 0; i < celt; i++)
|
||||
{
|
||||
if (This->pos >= This->limit)
|
||||
break;
|
||||
rgelt[i] = strdup_AtoW(This->data[This->pos]);
|
||||
This->pos++;
|
||||
}
|
||||
|
||||
if (pceltFetched)
|
||||
*pceltFetched = i;
|
||||
if (i == celt)
|
||||
return S_OK;
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE TestACL_Skip(IEnumString *iface, ULONG celt)
|
||||
{
|
||||
ok(FALSE, "Unexpected call to TestACL_Skip\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE TestACL_Clone(IEnumString *iface, IEnumString **out)
|
||||
{
|
||||
ok(FALSE, "Unexpected call to TestACL_Clone\n");
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE TestACL_Reset(IEnumString *iface)
|
||||
{
|
||||
TestACL *This = (TestACL *)iface;
|
||||
trace("ACL(%p): Reset\n", This);
|
||||
This->pos = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE TestACL_Expand(IACList *iface, LPCOLESTR str)
|
||||
{
|
||||
TestACL *This = impl_from_IACList(iface);
|
||||
trace("ACL(%p): Expand\n", impl_from_IACList(iface));
|
||||
This->expcount++;
|
||||
return This->expret;
|
||||
}
|
||||
|
||||
IEnumStringVtbl TestACLVtbl =
|
||||
{
|
||||
TestACL_QueryInterface,
|
||||
TestACL_AddRef,
|
||||
TestACL_Release,
|
||||
|
||||
TestACL_Next,
|
||||
TestACL_Skip,
|
||||
TestACL_Reset,
|
||||
TestACL_Clone
|
||||
};
|
||||
|
||||
ULONG STDMETHODCALLTYPE TestACL_ACList_AddRef(IACList *iface)
|
||||
{
|
||||
return TestACL_AddRef((IEnumString *)impl_from_IACList(iface));
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE TestACL_ACList_Release(IACList *iface)
|
||||
{
|
||||
return TestACL_Release((IEnumString *)impl_from_IACList(iface));
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE TestACL_ACList_QueryInterface(IACList *iface, REFIID iid, LPVOID *ppvout)
|
||||
{
|
||||
return TestACL_QueryInterface((IEnumString *)impl_from_IACList(iface), iid, ppvout);
|
||||
}
|
||||
|
||||
IACListVtbl TestACL_ACListVtbl =
|
||||
{
|
||||
TestACL_ACList_QueryInterface,
|
||||
TestACL_ACList_AddRef,
|
||||
TestACL_ACList_Release,
|
||||
|
||||
TestACL_Expand
|
||||
};
|
||||
|
||||
#define expect_str(obj, str) \
|
||||
{ \
|
||||
ole_ok(obj->lpVtbl->Next(obj, 1, &wstr, &i)); \
|
||||
ok(i == 1, "Expected i == 1, got %d\n", i); \
|
||||
ok(str[0] == wstr[0], "String mismatch\n"); \
|
||||
}
|
||||
|
||||
#define expect_end(obj) \
|
||||
ok(obj->lpVtbl->Next(obj, 1, &wstr, &i) == S_FALSE, "Unexpected return from Next\n");
|
||||
|
||||
void test_ACLMulti()
|
||||
{
|
||||
const char *strings1[] = {"a", "c", "e"};
|
||||
const char *strings2[] = {"a", "b", "d"};
|
||||
WCHAR exp[] = {'A','B','C',0};
|
||||
IEnumString *obj;
|
||||
TestACL *acl1, *acl2;
|
||||
IACList *acl;
|
||||
IObjMgr *mgr;
|
||||
LPWSTR wstr;
|
||||
LPWSTR wstrtab[15];
|
||||
LPVOID tmp;
|
||||
UINT i;
|
||||
|
||||
stop_on_error(CoCreateInstance(&CLSID_ACLMulti, NULL, CLSCTX_INPROC, &IID_IEnumString, (LPVOID *)&obj));
|
||||
stop_on_error(obj->lpVtbl->QueryInterface(obj, &IID_IACList, (LPVOID *)&acl));
|
||||
ok(obj->lpVtbl->QueryInterface(obj, &IID_IACList2, &tmp) == E_NOINTERFACE,
|
||||
"Unexpected interface IACList2 in ACLMulti\n");
|
||||
stop_on_error(obj->lpVtbl->QueryInterface(obj, &IID_IObjMgr, (LPVOID *)&mgr));
|
||||
#if 0 /* IID_IEnumACString not defined yet in wine */
|
||||
ole_ok(obj->lpVtbl->QueryInterface(obj, &IID_IEnumACString, &unk));
|
||||
if (unk != NULL)
|
||||
unk->lpVtbl->Release(unk);
|
||||
#endif
|
||||
|
||||
ok(obj->lpVtbl->Next(obj, 1, (LPOLESTR *)&tmp, &i) == S_FALSE, "Unexpected return from Next\n");
|
||||
ok(i == 0, "Unexpected fetched value %d\n", i);
|
||||
ok(obj->lpVtbl->Next(obj, 44, (LPOLESTR *)&tmp, &i) == S_FALSE, "Unexpected return from Next\n");
|
||||
ok(obj->lpVtbl->Skip(obj, 1) == E_NOTIMPL, "Unexpected return from Skip\n");
|
||||
ok(obj->lpVtbl->Clone(obj, (IEnumString **)&tmp) == E_OUTOFMEMORY, "Unexpected return from Clone\n");
|
||||
ole_ok(acl->lpVtbl->Expand(acl, exp));
|
||||
|
||||
acl1 = TestACL_Constructor(3, strings1);
|
||||
acl2 = TestACL_Constructor(3, strings2);
|
||||
stop_on_error(mgr->lpVtbl->Append(mgr, (IUnknown *)acl1));
|
||||
stop_on_error(mgr->lpVtbl->Append(mgr, (IUnknown *)acl2));
|
||||
ok(mgr->lpVtbl->Append(mgr, NULL) == E_FAIL, "Unexpected return from Append\n");
|
||||
expect_str(obj, "a");
|
||||
expect_str(obj, "c");
|
||||
expect_str(obj, "e");
|
||||
expect_str(obj, "a");
|
||||
expect_str(obj, "b");
|
||||
expect_str(obj, "d");
|
||||
expect_end(obj);
|
||||
|
||||
ole_ok(obj->lpVtbl->Reset(obj));
|
||||
ok(acl1->pos == 0, "acl1 not reset\n");
|
||||
ok(acl2->pos == 0, "acl2 not reset\n");
|
||||
|
||||
ole_ok(acl->lpVtbl->Expand(acl, exp));
|
||||
ok(acl1->expcount == 1, "expcount - expected 1, got %d\n", acl1->expcount);
|
||||
ok(acl2->expcount == 0, "expcount - expected 0, got %d\n", acl2->expcount);
|
||||
|
||||
ole_ok(obj->lpVtbl->Next(obj, 15, wstrtab, &i));
|
||||
ok(i == 1, "Expected i == 1, got %d\n", i);
|
||||
ole_ok(obj->lpVtbl->Next(obj, 15, wstrtab, &i));
|
||||
ole_ok(obj->lpVtbl->Next(obj, 15, wstrtab, &i));
|
||||
ole_ok(obj->lpVtbl->Next(obj, 15, wstrtab, &i));
|
||||
ole_ok(acl->lpVtbl->Expand(acl, exp));
|
||||
ok(acl1->expcount == 2, "expcount - expected 1, got %d", acl1->expcount);
|
||||
ok(acl2->expcount == 0, "expcount - expected 0, got %d", acl2->expcount);
|
||||
acl1->expret = S_FALSE;
|
||||
ole_ok(acl->lpVtbl->Expand(acl, exp));
|
||||
ok(acl1->expcount == 3, "expcount - expected 1, got %d", acl1->expcount);
|
||||
ok(acl2->expcount == 1, "expcount - expected 0, got %d", acl2->expcount);
|
||||
acl1->expret = E_NOTIMPL;
|
||||
ole_ok(acl->lpVtbl->Expand(acl, exp));
|
||||
ok(acl1->expcount == 4, "expcount - expected 1, got %d", acl1->expcount);
|
||||
ok(acl2->expcount == 2, "expcount - expected 0, got %d", acl2->expcount);
|
||||
acl2->expret = E_OUTOFMEMORY;
|
||||
ok(acl->lpVtbl->Expand(acl, exp) == E_OUTOFMEMORY, "Unexpected Expand return\n");
|
||||
acl2->expret = E_FAIL;
|
||||
ok(acl->lpVtbl->Expand(acl, exp) == E_FAIL, "Unexpected Expand return\n");
|
||||
|
||||
ok(mgr->lpVtbl->Remove(mgr, (IUnknown *)0xdeadbeef) == E_FAIL, "Unexpected Remove return\n");
|
||||
stop_on_error(mgr->lpVtbl->Remove(mgr, (IUnknown *)acl1));
|
||||
ok(acl1->ref == 1, "acl1 not released\n");
|
||||
expect_end(obj);
|
||||
obj->lpVtbl->Reset(obj);
|
||||
expect_str(obj, "a");
|
||||
expect_str(obj, "b");
|
||||
expect_str(obj, "d");
|
||||
expect_end(obj);
|
||||
|
||||
obj->lpVtbl->Release(obj);
|
||||
acl->lpVtbl->Release(acl);
|
||||
ok(mgr->lpVtbl->Release(mgr) == 0, "Unexpected references\n");
|
||||
ok(acl1->ref == 1, "acl1 not released\n");
|
||||
ok(acl2->ref == 1, "acl2 not released\n");
|
||||
}
|
||||
|
||||
START_TEST(autocomplete)
|
||||
{
|
||||
CoInitialize(NULL);
|
||||
test_ACLMulti();
|
||||
CoUninitialize();
|
||||
}
|
|
@ -25,6 +25,7 @@ RC_BINARIES = wine.ico
|
|||
TESTBINS = \
|
||||
advapi32_test.exe \
|
||||
advpack_test.exe \
|
||||
browseui_test.exe \
|
||||
cabinet_test.exe \
|
||||
comcat_test.exe \
|
||||
comctl32_test.exe \
|
||||
|
@ -85,6 +86,8 @@ advapi32_test.exe: $(DLLDIR)/advapi32/tests/advapi32_test.exe$(DLLEXT)
|
|||
cp $(DLLDIR)/advapi32/tests/advapi32_test.exe$(DLLEXT) $@ && $(STRIP) $@
|
||||
advpack_test.exe: $(DLLDIR)/advpack/tests/advpack_test.exe$(DLLEXT)
|
||||
cp $(DLLDIR)/advpack/tests/advpack_test.exe$(DLLEXT) $@ && $(STRIP) $@
|
||||
browseui_test.exe: $(DLLDIR)/browseui/tests/browseui_test.exe$(DLLEXT)
|
||||
cp $(DLLDIR)/browseui/tests/browseui_test.exe$(DLLEXT) $@ && $(STRIP) $@
|
||||
cabinet_test.exe: $(DLLDIR)/cabinet/tests/cabinet_test.exe$(DLLEXT)
|
||||
cp $(DLLDIR)/cabinet/tests/cabinet_test.exe$(DLLEXT) $@ && $(STRIP) $@
|
||||
comcat_test.exe: $(DLLDIR)/comcat/tests/comcat_test.exe$(DLLEXT)
|
||||
|
|
|
@ -148,6 +148,7 @@ IDI_WINE ICON "wine.ico"
|
|||
|
||||
advapi32_test.exe TESTRES "advapi32_test.exe"
|
||||
advpack_test.exe TESTRES "advpack_test.exe"
|
||||
browseui_test.exe TESTRES "browseui_test.exe"
|
||||
cabinet_test.exe TESTRES "cabinet_test.exe"
|
||||
comcat_test.exe TESTRES "comcat_test.exe"
|
||||
comctl32_test.exe TESTRES "comctl32_test.exe"
|
||||
|
|
Loading…
Reference in New Issue