ReactOS 0.4.15-dev-8222-g9164419
IShellFolderHelpers.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Tests for SHLWAPI IShellFolder helpers
5 * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8#include <apitest.h>
9#include <shlobj.h>
10#include <shlwapi.h>
11#include <versionhelpers.h>
12
13#define SHLWAPI_ISHELLFOLDER_HELPERS
14#include <shlwapi_undoc.h>
15
16static INT s_nStep = 0;
17
19{
20public:
22 virtual ~CTestShellFolder() { }
23
24 static void *operator new(size_t size)
25 {
26 return LocalAlloc(LPTR, size);
27 }
28 static void operator delete(void *ptr)
29 {
31 }
32 static void operator delete(void *ptr, size_t size)
33 {
35 }
36
37 // IUnknown methods
39 {
40 ok_int(s_nStep, 11);
41 ok_int(IsEqualGUID(riid, IID_IShellFolder2), TRUE);
42 ++s_nStep;
43 return E_NOINTERFACE;
44 }
45 STDMETHOD_(ULONG, AddRef)() override
46 {
48 return 1;
49 }
51 {
53 return 1;
54 }
55
56 // IShellFolder methods
58 HWND hwndOwner,
59 LPBC pbc,
60 LPOLESTR lpszDisplayName,
61 ULONG *pchEaten,
62 PIDLIST_RELATIVE *ppidl,
63 ULONG *pdwAttributes) override
64 {
65 ok_ptr(*ppidl, NULL);
66 ok_long(*pdwAttributes, 0);
67 ++s_nStep;
68 return 0xDEADFACE;
69 }
71 HWND hwndOwner,
73 LPENUMIDLIST *ppEnumIDList) override
74 {
76 return E_NOTIMPL;
77 }
80 LPBC pbcReserved,
82 LPVOID *ppvOut) override
83 {
85 return E_NOTIMPL;
86 }
89 LPBC pbcReserved,
91 LPVOID *ppvOut) override
92 {
94 return E_NOTIMPL;
95 }
99 PCUIDLIST_RELATIVE pidl2) override
100 {
101 switch (s_nStep)
102 {
103 case 11:
104 // It shouldn't come here
105 ok_int(TRUE, FALSE);
106 break;
107 case 12:
108 ok_long((LONG)lParam, 0x00001234);
109 break;
110 case 13:
111 ok_long((LONG)lParam, 0x00005678);
112 break;
113 default:
114 skip("\n");
115 break;
116 }
117 ++s_nStep;
118 return 0xFEEDF00D;
119 }
121 HWND hwndOwner,
122 REFIID riid,
123 LPVOID *ppvOut) override
124 {
125 ok_int(TRUE, FALSE);
126 return E_NOTIMPL;
127 }
129 UINT cidl,
131 DWORD *rgfInOut) override
132 {
133 ok_int(TRUE, FALSE);
134 return E_NOTIMPL;
135 }
137 HWND hwndOwner,
138 UINT cidl,
140 REFIID riid,
141 UINT * prgfInOut,
142 LPVOID * ppvOut) override
143 {
144 ok_int(TRUE, FALSE);
145 return E_NOTIMPL;
146 }
148 PCUITEMID_CHILD pidl,
150 LPSTRRET strRet) override
151 {
152 switch (s_nStep)
153 {
154 case 0:
157 break;
158 case 1:
160 break;
161 case 2:
163 break;
164 case 3:
166 break;
167 case 4:
169 break;
170 case 5:
172 break;
173 case 6:
175 break;
176 case 7:
178 break;
179 case 8:
181 break;
182 case 9:
184 break;
185 default:
186 skip("\n");
187 break;
188 }
189 ++s_nStep;
190 return E_FAIL;
191 }
193 HWND hwndOwner,
194 PCUITEMID_CHILD pidl,
195 LPCOLESTR lpName,
197 PITEMID_CHILD *pPidlOut) override
198 {
199 ok_int(TRUE, FALSE);
200 return E_NOTIMPL;
201 }
202};
203
204static void Test_GetDisplayNameOf(void)
205{
207 HRESULT hr;
208
210 psf,
211 NULL,
212 SHGDN_FOREDITING | SHGDN_FORADDRESSBAR | SHGDN_FORPARSING | SHGDN_INFOLDER,
213 NULL,
214 0);
215 ok_long(hr, E_FAIL);
216 ok_int(s_nStep, 4);
217
219 psf,
220 NULL,
221 SHGDN_FOREDITING | SHGDN_FORADDRESSBAR | SHGDN_INFOLDER,
222 NULL,
223 0);
224 ok_long(hr, E_FAIL);
225 ok_int(s_nStep, 10);
226
227 if (s_nStep != 10)
228 skip("s_nStep value is wrong\n");
229
230 delete psf;
231}
232
233static void Test_ParseDisplayName(void)
234{
236 HRESULT hr;
237
238 s_nStep = 10;
239 LPITEMIDLIST pidl = (LPITEMIDLIST)UlongToPtr(0xDEADDEAD);
241 psf,
242 NULL,
243 NULL,
244 NULL,
245 NULL,
246 &pidl,
247 NULL);
248 ok_long(hr, 0xDEADFACE);
249 ok_int(s_nStep, 11);
250
251 delete psf;
252}
253
255 _In_ IShellFolder *psf,
259
260static void Test_CompareIDs(void)
261{
262 FN_IShellFolder_CompareIDs fnIShellFolder_CompareIDs;
263 fnIShellFolder_CompareIDs =
266
268 {
269 skip("Vista+\n");
270 ok(fnIShellFolder_CompareIDs == NULL, "Vista+ has no IShellFolder_CompareIDs\n");
271 return;
272 }
273
275 HRESULT hr;
276
277 s_nStep = 11;
278 hr = fnIShellFolder_CompareIDs(
279 psf,
280 0xFFFF1234,
281 NULL,
282 NULL);
283 ok_long(hr, 0xFEEDF00D);
284 ok_int(s_nStep, 13);
285
286 s_nStep = 13;
287 hr = fnIShellFolder_CompareIDs(
288 psf,
289 0x00005678,
290 NULL,
291 NULL);
292 ok_long(hr, 0xFEEDF00D);
293 ok_int(s_nStep, 14);
294
295 delete psf;
296}
297
298START_TEST(IShellFolderHelpers)
299{
300 HRESULT hrCoInit = ::CoInitialize(NULL);
301
305
306 if (SUCCEEDED(hrCoInit))
308}
static INT s_nStep
static void Test_CompareIDs(void)
static void Test_ParseDisplayName(void)
HRESULT(WINAPI * FN_IShellFolder_CompareIDs)(_In_ IShellFolder *psf, _In_ LPARAM lParam, _In_ PCUIDLIST_RELATIVE pidl1, _In_ PCUIDLIST_RELATIVE pidl2)
static void Test_GetDisplayNameOf(void)
#define ok_long(expression, result)
Definition: atltest.h:133
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
#define ok_ptr(expression, result)
Definition: atltest.h:108
#define STDMETHOD(m)
Definition: basetyps.h:62
STDMETHOD() GetDisplayNameOf(PCUITEMID_CHILD pidl, DWORD dwFlags, LPSTRRET strRet) override
STDMETHOD_(ULONG, Release)() override
STDMETHOD_(ULONG, AddRef)() override
STDMETHOD() GetUIObjectOf(HWND hwndOwner, UINT cidl, PCUITEMID_CHILD_ARRAY apidl, REFIID riid, UINT *prgfInOut, LPVOID *ppvOut) override
STDMETHOD() CreateViewObject(HWND hwndOwner, REFIID riid, LPVOID *ppvOut) override
STDMETHOD() BindToStorage(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) override
STDMETHOD() BindToObject(PCUIDLIST_RELATIVE pidl, LPBC pbcReserved, REFIID riid, LPVOID *ppvOut) override
STDMETHOD() CompareIDs(LPARAM lParam, PCUIDLIST_RELATIVE pidl1, PCUIDLIST_RELATIVE pidl2) override
STDMETHOD() GetAttributesOf(UINT cidl, PCUITEMID_CHILD_ARRAY apidl, DWORD *rgfInOut) override
STDMETHOD() EnumObjects(HWND hwndOwner, DWORD dwFlags, LPENUMIDLIST *ppEnumIDList) override
STDMETHOD() SetNameOf(HWND hwndOwner, PCUITEMID_CHILD pidl, LPCOLESTR lpName, DWORD dwFlags, PITEMID_CHILD *pPidlOut) override
STDMETHOD() QueryInterface(REFIID riid, void **ppvObject) override
LPARAM lParam
Definition: combotst.c:139
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define IShellFolder_ParseDisplayName
Definition: utils.cpp:14
#define IShellFolder_GetDisplayNameOf
Definition: utils.cpp:13
#define UlongToPtr(u)
Definition: config.h:106
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
REFIID riid
Definition: atlbase.h:39
@ SHGDN_FORADDRESSBAR
Definition: shobjidl.idl:165
ULONG AddRef()
ULONG Release()
#define SUCCEEDED(hr)
Definition: intsafe.h:50
static PVOID ptr
Definition: dispmode.c:27
static IParseDisplayName ParseDisplayName
Definition: moniker.c:816
static LPOLESTR
Definition: stg_prop.c:27
#define _In_
Definition: ms_sal.h:308
unsigned int UINT
Definition: ndis.h:50
interface IBindCtx * LPBC
Definition: objfwd.h:18
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
HRESULT hr
Definition: shlfolder.c:183
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
const PCUITEMID_CHILD * PCUITEMID_CHILD_ARRAY
Definition: shtypes.idl:71
const ITEMID_CHILD UNALIGNED * PCUITEMID_CHILD
Definition: shtypes.idl:70
const ITEMIDLIST_RELATIVE UNALIGNED * PCUIDLIST_RELATIVE
Definition: shtypes.idl:57
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
VERSIONHELPERAPI IsWindowsVistaOrGreater()
#define LPTR
Definition: winbase.h:381
_In_ LPCSTR lpName
Definition: winbase.h:2789
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
LONG_PTR LPARAM
Definition: windef.h:208
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:2364
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581