ReactOS  0.4.13-dev-242-g611e6d7
ACListISF.cpp File Reference
#include <apitest.h>
#include <shlobj.h>
#include <atlbase.h>
#include <tchar.h>
#include <atlcom.h>
#include <atlwin.h>
#include <shellutils.h>
#include <shlwapi.h>
#include <strsafe.h>
Include dependency graph for ACListISF.cpp:

Go to the source code of this file.

Classes

struct  CCoInit
 

Macros

#define _UNICODE
 
#define UNICODE
 
#define WINVER_VISTA   0x0600
 
#define ok_hr(status, expected)   ok_hex(status, expected)
 
#define test_at_end   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : test_at_end_imp
 
#define test_ExpectDrives   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : test_ExpectDrives_imp
 
#define test_ExpectFolders   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : test_ExpectFolders_imp
 
#define winetest_ok_hr(expression, expected)
 

Enumerations

enum  ExpectOptions {
  None = 0, IgnoreRoot = 1, CheckLast = 2, IgnoreHidden = 4,
  IgnoreFiles = 8
}
 

Functions

ULONG DbgPrint (PCH Format,...)
 
static void test_at_end_imp (CComPtr< IEnumString > &EnumStr)
 
static bool GetDisplayname (CComPtr< IShellFolder > &spDrives, CComHeapPtr< ITEMIDLIST > &pidl, CComHeapPtr< WCHAR > &DisplayName)
 
ExpectOptions operator| (const ExpectOptions &left, const ExpectOptions &right)
 
static void test_ExpectFolders_imp (CComPtr< IEnumString > &EnumStr, LPITEMIDLIST pidlTarget, const WCHAR *Root, ExpectOptions options)
 
static void test_ExpectDrives_imp (CComPtr< IEnumString > &EnumStr, CComHeapPtr< ITEMIDLIST > &pidlTarget)
 
static void test_ACListISF_NONE ()
 
static void test_ACListISF_CURRENTDIR ()
 
static void test_ACListISF_MYCOMPUTER ()
 
static void test_ACListISF_DESKTOP ()
 
static void test_ACListISF_FAVORITES ()
 
static void test_ACListISF_FILESYSONLY ()
 
static void test_ACListISF_FILESYSDIRS ()
 
static void GetEnvStatus ()
 
 START_TEST (ACListISF)
 

Variables

static bool g_ShowHidden
 
static DWORD g_WinVersion
 

Macro Definition Documentation

◆ _UNICODE

#define _UNICODE

Definition at line 8 of file ACListISF.cpp.

◆ ok_hr

#define ok_hr (   status,
  expected 
)    ok_hex(status, expected)

Definition at line 29 of file ACListISF.cpp.

◆ test_at_end

#define test_at_end   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : test_at_end_imp

Definition at line 32 of file ACListISF.cpp.

◆ test_ExpectDrives

#define test_ExpectDrives   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : test_ExpectDrives_imp

Definition at line 33 of file ACListISF.cpp.

◆ test_ExpectFolders

#define test_ExpectFolders   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : test_ExpectFolders_imp

Definition at line 34 of file ACListISF.cpp.

◆ UNICODE

Definition at line 9 of file ACListISF.cpp.

◆ winetest_ok_hr

#define winetest_ok_hr (   expression,
  expected 
)
Value:
do { \
int _value = (expression); \
winetest_ok(_value == (expected), "Wrong value for '%s', expected: " #expected " (0x%x), got: 0x%x\n", \
#expression, (int)(expected), _value); \
} while (0)
BOOL expected
Definition: store.c:2063

Definition at line 35 of file ACListISF.cpp.

◆ WINVER_VISTA

#define WINVER_VISTA   0x0600

Definition at line 26 of file ACListISF.cpp.

Enumeration Type Documentation

◆ ExpectOptions

Enumerator
None 
IgnoreRoot 
CheckLast 
IgnoreHidden 
IgnoreFiles 

Definition at line 70 of file ACListISF.cpp.

71 {
72  None = 0,
73  IgnoreRoot = 1,
74  CheckLast = 2,
75  IgnoreHidden = 4,
76  IgnoreFiles = 8,
77 };

Function Documentation

◆ DbgPrint()

ULONG DbgPrint ( PCH  Format,
  ... 
)

◆ GetDisplayname()

static bool GetDisplayname ( CComPtr< IShellFolder > &  spDrives,
CComHeapPtr< ITEMIDLIST > &  pidl,
CComHeapPtr< WCHAR > &  DisplayName 
)
static

Definition at line 56 of file ACListISF.cpp.

57 {
58  STRRET StrRet;
59  HRESULT hr;
60  winetest_ok_hr(hr = spDrives->GetDisplayNameOf(pidl, SHGDN_INFOLDER | SHGDN_FORPARSING | SHGDN_FORADDRESSBAR, &StrRet), S_OK);
61  if (!SUCCEEDED(hr))
62  return false;
63 
64  winetest_ok_hr(hr = StrRetToStrW(&StrRet, NULL, &DisplayName), S_OK);
65  if (!SUCCEEDED(hr))
66  return false;
67  return true;
68 }
HRESULT hr
Definition: shlfolder.c:183
#define StrRet
Definition: shellclasses.h:871
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
#define winetest_ok_hr(expression, expected)
Definition: ACListISF.cpp:35
#define S_OK
Definition: intsafe.h:59
#define SUCCEEDED(hr)
Definition: intsafe.h:57
HRESULT WINAPI StrRetToStrW(LPSTRRET lpStrRet, const ITEMIDLIST *pidl, LPWSTR *ppszName)
Definition: string.c:1623

Referenced by test_ExpectFolders_imp().

◆ GetEnvStatus()

static void GetEnvStatus ( )
static

Definition at line 434 of file ACListISF.cpp.

435 {
436  RTL_OSVERSIONINFOEXW rtlinfo = {0};
437  void (__stdcall* pRtlGetVersion)(RTL_OSVERSIONINFOEXW*);
438  pRtlGetVersion = (void (__stdcall*)(RTL_OSVERSIONINFOEXW*))GetProcAddress(GetModuleHandleA("ntdll"), "RtlGetVersion");
439 
440  rtlinfo.dwOSVersionInfoSize = sizeof(rtlinfo);
441  pRtlGetVersion(&rtlinfo);
442  g_WinVersion = (rtlinfo.dwMajorVersion << 8) | rtlinfo.dwMinorVersion;
443 
444  SHELLFLAGSTATE sfs = {0};
446  g_ShowHidden = !!sfs.fShowAllObjects;
447  trace("Show hidden folders: %s\n", g_ShowHidden ? "yes" : "no");
448 }
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:265
#define trace(...)
Definition: kmt_test.h:217
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
ULONG dwMinorVersion
Definition: rtltypes.h:267
ULONG dwMajorVersion
Definition: rtltypes.h:266
#define SSF_SHOWALLOBJECTS
Definition: shlobj.h:1518
#define __stdcall
Definition: typedefs.h:25
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:819
static bool g_ShowHidden
Definition: ACListISF.cpp:24
VOID WINAPI SHGetSettings(LPSHELLFLAGSTATE lpsfs, DWORD dwMask)
Definition: shellord.c:218
static DWORD g_WinVersion
Definition: ACListISF.cpp:25
#define GetProcAddress(x, y)
Definition: compat.h:410

Referenced by START_TEST().

◆ operator|()

Definition at line 80 of file ACListISF.cpp.

81 {
82  return static_cast<ExpectOptions>(static_cast<int>(left) | static_cast<int>(right));
83 }
GLint left
Definition: glext.h:7726
GLdouble GLdouble right
Definition: glext.h:10859

◆ START_TEST()

START_TEST ( ACListISF  )

Definition at line 457 of file ACListISF.cpp.

458 {
459  GetEnvStatus();
460  CCoInit init;
461  ok_hr(init.hres, S_OK);
462  if (!SUCCEEDED(init.hres))
463  return;
464 
472 }
#define ok_hr(status, expected)
Definition: ACListISF.cpp:29
static void test_ACListISF_MYCOMPUTER()
Definition: ACListISF.cpp:264
static void GetEnvStatus()
Definition: ACListISF.cpp:434
static void test_ACListISF_FILESYSDIRS()
Definition: ACListISF.cpp:405
static void test_ACListISF_NONE()
Definition: ACListISF.cpp:154
static void test_ACListISF_FILESYSONLY()
Definition: ACListISF.cpp:375
static void test_ACListISF_DESKTOP()
Definition: ACListISF.cpp:334
static int init
Definition: wintirpc.c:33
static void test_ACListISF_FAVORITES()
Definition: ACListISF.cpp:352
static void test_ACListISF_CURRENTDIR()
Definition: ACListISF.cpp:190
#define S_OK
Definition: intsafe.h:59
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ test_ACListISF_CURRENTDIR()

static void test_ACListISF_CURRENTDIR ( )
static

Definition at line 190 of file ACListISF.cpp.

191 {
192  CComPtr<IEnumString> EnumStr;
193  HRESULT hr = CoCreateInstance(CLSID_ACListISF, NULL, CLSCTX_ALL, IID_PPV_ARG(IEnumString, &EnumStr));
194  ok_hr(hr, S_OK);
195  if (!SUCCEEDED(hr))
196  return;
197 
198  CComPtr<IACList2> ACList;
199  ok_hr(hr = EnumStr->QueryInterface(IID_IACList2, (void**)&ACList), S_OK);
200  if (!SUCCEEDED(hr))
201  return;
202 
203  CComPtr<ICurrentWorkingDirectory> CurrentWorkingDir;
204  ok_hr(hr = EnumStr->QueryInterface(IID_ICurrentWorkingDirectory, (void**)&CurrentWorkingDir), S_OK);
205  if (!SUCCEEDED(hr))
206  return;
207 
208  ok_hr(hr = ACList->SetOptions(ACLO_CURRENTDIR), S_OK);
209  test_at_end(EnumStr);
210 
211 
212  WCHAR Buffer[MAX_PATH] = { 1, 1, 1, 1, 1, 0 }, Buffer2[MAX_PATH];
214  ok_hr(hr = CurrentWorkingDir->GetDirectory(Buffer, _ARRAYSIZE(Buffer)), E_NOTIMPL);
215  else
216  ok_hr(hr = CurrentWorkingDir->GetDirectory(Buffer, _ARRAYSIZE(Buffer)), E_UNEXPECTED);
217  ok(!wcscmp(L"\x1\x1\x1\x1\x1", Buffer), "Expected %s, got %s\n", wine_dbgstr_w(L"\x1\x1\x1\x1\x1"), wine_dbgstr_w(Buffer));
218 
219  GetSystemWindowsDirectoryW(Buffer2, _ARRAYSIZE(Buffer2));
220  // Windows 2k3 does not parse it without the trailing '\\'
221  Buffer2[3] = '\0';
222  CComHeapPtr<ITEMIDLIST> pidlDiskRoot;
223  ok_hr(hr = SHParseDisplayName(Buffer2, NULL, &pidlDiskRoot, NULL, NULL), S_OK);
224  if (!SUCCEEDED(hr))
225  return;
226 
227  ok_hr(hr = CurrentWorkingDir->SetDirectory(Buffer2), S_OK);
228  test_at_end(EnumStr);
229 
230  Buffer[0] = '\0';
232  {
233  ok_hr(hr = CurrentWorkingDir->GetDirectory(Buffer, _ARRAYSIZE(Buffer)), E_NOTIMPL);
234  }
235  else
236  {
237  ok_hr(hr = CurrentWorkingDir->GetDirectory(Buffer, _ARRAYSIZE(Buffer)), S_OK);
238  ok(!wcscmp(Buffer2, Buffer), "Expected %s, got %s\n", wine_dbgstr_w(Buffer2), wine_dbgstr_w(Buffer));
239  }
240 
241  Buffer2[2] = '\0';
242  ok_hr(hr = CurrentWorkingDir->SetDirectory(Buffer2), S_OK);
243  test_at_end(EnumStr);
244 
245  Buffer[0] = '\0';
246  Buffer2[2] = '\\';
248  {
249  ok_hr(hr = CurrentWorkingDir->GetDirectory(Buffer, _ARRAYSIZE(Buffer)), E_NOTIMPL);
250  }
251  else
252  {
253  ok_hr(hr = CurrentWorkingDir->GetDirectory(Buffer, _ARRAYSIZE(Buffer)), S_OK);
254  ok(!wcscmp(Buffer2, Buffer), "Expected %s, got %s\n", wine_dbgstr_w(Buffer2), wine_dbgstr_w(Buffer));
255  }
256 
257  ok_hr(hr = ACList->Expand(Buffer2), S_OK);
258  // The first set of results are absolute paths, without hidden files?!
259  test_ExpectFolders(EnumStr, pidlDiskRoot, Buffer2, IgnoreHidden);
260  test_ExpectFolders(EnumStr, pidlDiskRoot, Buffer2, IgnoreHidden | IgnoreRoot | CheckLast);
261 }
#define ok_hr(status, expected)
Definition: ACListISF.cpp:29
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2396
#define test_ExpectFolders
Definition: ACListISF.cpp:34
HRESULT hr
Definition: shlfolder.c:183
#define _ARRAYSIZE(A)
Definition: ntbasedef.h:708
#define wine_dbgstr_w
Definition: kernel32.h:34
#define IID_PPV_ARG(Itype, ppType)
#define test_at_end
Definition: ACListISF.cpp:32
#define ACLO_CURRENTDIR
Definition: shlobj.h:731
#define ok(value,...)
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
static const WCHAR L[]
Definition: oid.c:1250
#define WINVER_VISTA
Definition: ACListISF.cpp:26
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define S_OK
Definition: intsafe.h:59
#define E_NOTIMPL
Definition: ddrawi.h:99
HRESULT WINAPI SHParseDisplayName(LPCWSTR pszName, IBindCtx *pbc, LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut)
Definition: pidl.c:1367
#define E_UNEXPECTED
Definition: winerror.h:2456
static DWORD g_WinVersion
Definition: ACListISF.cpp:25
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by START_TEST().

◆ test_ACListISF_DESKTOP()

static void test_ACListISF_DESKTOP ( )
static

Definition at line 334 of file ACListISF.cpp.

335 {
336  CComPtr<IEnumString> EnumStr;
337  HRESULT hr = CoCreateInstance(CLSID_ACListISF, NULL, CLSCTX_ALL, IID_PPV_ARG(IEnumString, &EnumStr));
338  ok_hr(hr, S_OK);
339  if (!SUCCEEDED(hr))
340  return;
341 
342  CComPtr<IACList2> ACList;
343  ok_hr(hr = EnumStr->QueryInterface(IID_IACList2, (void**)&ACList), S_OK);
344  if (!SUCCEEDED(hr))
345  return;
346 
347  ok_hr(hr = ACList->SetOptions(ACLO_DESKTOP), S_OK);
349 }
#define ok_hr(status, expected)
Definition: ACListISF.cpp:29
#define test_ExpectFolders
Definition: ACListISF.cpp:34
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
#define ACLO_DESKTOP
Definition: shlobj.h:733
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
#define S_OK
Definition: intsafe.h:59
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by START_TEST().

◆ test_ACListISF_FAVORITES()

static void test_ACListISF_FAVORITES ( )
static

Definition at line 352 of file ACListISF.cpp.

353 {
354  CComPtr<IEnumString> EnumStr;
355  HRESULT hr = CoCreateInstance(CLSID_ACListISF, NULL, CLSCTX_ALL, IID_PPV_ARG(IEnumString, &EnumStr));
356  ok_hr(hr, S_OK);
357  if (!SUCCEEDED(hr))
358  return;
359 
360  CComPtr<IACList2> ACList;
361  ok_hr(hr = EnumStr->QueryInterface(IID_IACList2, (void**)&ACList), S_OK);
362  if (!SUCCEEDED(hr))
363  return;
364 
365  CComHeapPtr<ITEMIDLIST> pidlFavorites;
367  if (!SUCCEEDED(hr))
368  return;
369 
370  ok_hr(hr = ACList->SetOptions(ACLO_FAVORITES), S_OK);
371  test_ExpectFolders(EnumStr, pidlFavorites, NULL, IgnoreRoot | CheckLast | IgnoreHidden);
372 }
#define ok_hr(status, expected)
Definition: ACListISF.cpp:29
#define test_ExpectFolders
Definition: ACListISF.cpp:34
HRESULT hr
Definition: shlfolder.c:183
#define IID_PPV_ARG(Itype, ppType)
#define CSIDL_FAVORITES
Definition: shlobj.h:2009
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:2687
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
#define ACLO_FAVORITES
Definition: shlobj.h:734
#define S_OK
Definition: intsafe.h:59
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by START_TEST().

◆ test_ACListISF_FILESYSDIRS()

static void test_ACListISF_FILESYSDIRS ( )
static

Definition at line 405 of file ACListISF.cpp.

406 {
407  CComPtr<IEnumString> EnumStr;
408  HRESULT hr = CoCreateInstance(CLSID_ACListISF, NULL, CLSCTX_ALL, IID_PPV_ARG(IEnumString, &EnumStr));
409  ok_hr(hr, S_OK);
410  if (!SUCCEEDED(hr))
411  return;
412 
413  CComPtr<IACList2> ACList;
414  ok_hr(hr = EnumStr->QueryInterface(IID_IACList2, (void**)&ACList), S_OK);
415  if (!SUCCEEDED(hr))
416  return;
417 
420  // Windows 2k3 does not parse it without the trailing '\\'
421  Buffer[3] = '\0';
422  CComHeapPtr<ITEMIDLIST> pidlDiskRoot;
423  ok_hr(hr = SHParseDisplayName(Buffer, NULL, &pidlDiskRoot, NULL, NULL), S_OK);
424  if (!SUCCEEDED(hr))
425  return;
426 
427  ok_hr(hr = ACList->SetOptions(ACLO_FILESYSDIRS), S_OK);
428  test_at_end(EnumStr);
429 
430  ok_hr(hr = ACList->Expand(Buffer), S_OK);
431  test_ExpectFolders(EnumStr, pidlDiskRoot, Buffer, CheckLast | IgnoreFiles | IgnoreHidden);
432 }
#define ok_hr(status, expected)
Definition: ACListISF.cpp:29
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2396
#define test_ExpectFolders
Definition: ACListISF.cpp:34
HRESULT hr
Definition: shlfolder.c:183
#define _ARRAYSIZE(A)
Definition: ntbasedef.h:708
#define ACLO_FILESYSDIRS
Definition: shlobj.h:736
#define IID_PPV_ARG(Itype, ppType)
#define test_at_end
Definition: ACListISF.cpp:32
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI SHParseDisplayName(LPCWSTR pszName, IBindCtx *pbc, LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut)
Definition: pidl.c:1367
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by START_TEST().

◆ test_ACListISF_FILESYSONLY()

static void test_ACListISF_FILESYSONLY ( )
static

Definition at line 375 of file ACListISF.cpp.

376 {
377  CComPtr<IEnumString> EnumStr;
378  HRESULT hr = CoCreateInstance(CLSID_ACListISF, NULL, CLSCTX_ALL, IID_PPV_ARG(IEnumString, &EnumStr));
379  ok_hr(hr, S_OK);
380  if (!SUCCEEDED(hr))
381  return;
382 
383  CComPtr<IACList2> ACList;
384  ok_hr(hr = EnumStr->QueryInterface(IID_IACList2, (void**)&ACList), S_OK);
385  if (!SUCCEEDED(hr))
386  return;
387 
390  // Windows 2k3 does not parse it without the trailing '\\'
391  Buffer[3] = '\0';
392  CComHeapPtr<ITEMIDLIST> pidlDiskRoot;
393  ok_hr(hr = SHParseDisplayName(Buffer, NULL, &pidlDiskRoot, NULL, NULL), S_OK);
394  if (!SUCCEEDED(hr))
395  return;
396 
397  ok_hr(hr = ACList->SetOptions(ACLO_FILESYSONLY), S_OK);
398  test_at_end(EnumStr);
399 
400  ok_hr(hr = ACList->Expand(Buffer), S_OK);
401  test_ExpectFolders(EnumStr, pidlDiskRoot, Buffer, CheckLast | IgnoreHidden);
402 }
#define ok_hr(status, expected)
Definition: ACListISF.cpp:29
#define ACLO_FILESYSONLY
Definition: shlobj.h:735
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2396
#define test_ExpectFolders
Definition: ACListISF.cpp:34
HRESULT hr
Definition: shlfolder.c:183
#define _ARRAYSIZE(A)
Definition: ntbasedef.h:708
#define IID_PPV_ARG(Itype, ppType)
#define test_at_end
Definition: ACListISF.cpp:32
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI SHParseDisplayName(LPCWSTR pszName, IBindCtx *pbc, LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut)
Definition: pidl.c:1367
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by START_TEST().

◆ test_ACListISF_MYCOMPUTER()

static void test_ACListISF_MYCOMPUTER ( )
static

Definition at line 264 of file ACListISF.cpp.

265 {
266  CComPtr<IACList2> ACList;
267  HRESULT hr = CoCreateInstance(CLSID_ACListISF, NULL, CLSCTX_ALL, IID_PPV_ARG(IACList2, &ACList));
268  ok_hr(hr, S_OK);
269  if (!SUCCEEDED(hr))
270  return;
271 
272  // Check the default
273  DWORD CurrentOption = 0xdeadbeef;
274  ok_hr(ACList->GetOptions(&CurrentOption), S_OK);
275  ok(CurrentOption == (ACLO_CURRENTDIR|ACLO_MYCOMPUTER), "Expected the default to be %x, was %lx\n",
276  (ACLO_CURRENTDIR|ACLO_MYCOMPUTER), CurrentOption);
277 
278 
279  CComPtr<IEnumString> EnumStr;
280  ok_hr(hr = ACList->QueryInterface(IID_IEnumString, (void**)&EnumStr), S_OK);
281  if (!SUCCEEDED(hr))
282  return;
283 
284  CComPtr<IPersistFolder> PersistFolder;
285  ok_hr(hr = EnumStr->QueryInterface(IID_IPersistFolder, (void**)&PersistFolder), S_OK);
286  if (!SUCCEEDED(hr))
287  return;
288 
289  CComHeapPtr<ITEMIDLIST> pidlMyComputer;
290  ok_hr(hr = SHGetSpecialFolderLocation(NULL, CSIDL_DRIVES, &pidlMyComputer), S_OK);
291  if (!SUCCEEDED(hr))
292  return;
293 
294 
295  hr = EnumStr->Reset();
297  ok_hr(hr, S_FALSE);
298  else
299  ok_hr(hr, S_OK);
300  test_ExpectDrives(EnumStr, pidlMyComputer);
301 
302  ok_hr(hr = ACList->SetOptions(ACLO_MYCOMPUTER), S_OK);
303  ok_hr(EnumStr->Reset(), S_OK);
304  test_ExpectDrives(EnumStr, pidlMyComputer);
305 
308  // Windows 2k3 does not parse it without the trailing '\\'
309  Buffer[3] = '\0';
310  CComHeapPtr<ITEMIDLIST> pidlDiskRoot;
311  ok_hr(hr = SHParseDisplayName(Buffer, NULL, &pidlDiskRoot, NULL, NULL), S_OK);
312  if (!SUCCEEDED(hr))
313  return;
314  Buffer[2] = '\0';
315 
316  ok_hr(hr = ACList->Expand(Buffer), S_OK);
317  test_ExpectFolders(EnumStr, pidlDiskRoot, Buffer, None);
318  test_ExpectDrives(EnumStr, pidlMyComputer);
319 
320  ok_hr(hr = ACList->Expand(Buffer), S_OK);
321  ok_hr(EnumStr->Reset(), S_OK);
322  // Pre vista does not remove the expanded data from the enumeration, it changes it to relative paths???
324  test_ExpectFolders(EnumStr, pidlDiskRoot, Buffer, IgnoreRoot);
325  test_ExpectDrives(EnumStr, pidlMyComputer);
326 
327  ok_hr(EnumStr->Reset(), S_OK);
328  ok_hr(hr = ACList->Expand(Buffer), S_OK);
329  test_ExpectFolders(EnumStr, pidlDiskRoot, Buffer, None);
330  test_ExpectDrives(EnumStr, pidlMyComputer);
331 }
#define ok_hr(status, expected)
Definition: ACListISF.cpp:29
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2396
#define test_ExpectFolders
Definition: ACListISF.cpp:34
const GUID IID_IEnumString
HRESULT hr
Definition: shlfolder.c:183
#define _ARRAYSIZE(A)
Definition: ntbasedef.h:708
#define IID_PPV_ARG(Itype, ppType)
#define CSIDL_DRIVES
Definition: shlobj.h:2019
#define ACLO_CURRENTDIR
Definition: shlobj.h:731
#define test_ExpectDrives
Definition: ACListISF.cpp:33
#define ok(value,...)
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define ACLO_MYCOMPUTER
Definition: shlobj.h:732
__wchar_t WCHAR
Definition: xmlstorage.h:180
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:2687
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WINVER_VISTA
Definition: ACListISF.cpp:26
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI SHParseDisplayName(LPCWSTR pszName, IBindCtx *pbc, LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut)
Definition: pidl.c:1367
static DWORD g_WinVersion
Definition: ACListISF.cpp:25
nsresult QueryInterface(nsIIDRef riid, void **result)
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by START_TEST().

◆ test_ACListISF_NONE()

static void test_ACListISF_NONE ( )
static

Definition at line 154 of file ACListISF.cpp.

155 {
156  CComPtr<IEnumString> EnumStr;
157  HRESULT hr = CoCreateInstance(CLSID_ACListISF, NULL, CLSCTX_ALL, IID_PPV_ARG(IEnumString, &EnumStr));
158  ok_hr(hr, S_OK);
159  if (!SUCCEEDED(hr))
160  return;
161 
162  CComPtr<IACList2> ACList;
163  ok_hr(hr = EnumStr->QueryInterface(IID_IACList2, (void**)&ACList), S_OK);
164  if (!SUCCEEDED(hr))
165  return;
166 
167  ok_hr(hr = ACList->SetOptions(ACLO_NONE), S_OK);
168  test_at_end(EnumStr);
169 
170 
173  Buffer[3] = '\0';
174 
175  CComHeapPtr<ITEMIDLIST> pidlDiskRoot;
176  ok_hr(hr = SHParseDisplayName(Buffer, NULL, &pidlDiskRoot, NULL, NULL), S_OK);
177  if (!SUCCEEDED(hr))
178  return;
179 
180  ok_hr(hr = ACList->Expand(Buffer), S_OK);
181  test_ExpectFolders(EnumStr, pidlDiskRoot, Buffer, CheckLast | IgnoreHidden);
182 
183  ok_hr(hr = EnumStr->Reset(), S_OK);
184  ok_hr(hr = ACList->Expand(Buffer), S_OK);
185  ok_hr(hr = ACList->SetOptions(ACLO_NONE), S_OK);
186  test_ExpectFolders(EnumStr, pidlDiskRoot, Buffer, CheckLast);
187 }
#define ok_hr(status, expected)
Definition: ACListISF.cpp:29
#define ACLO_NONE
Definition: shlobj.h:730
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2396
#define test_ExpectFolders
Definition: ACListISF.cpp:34
HRESULT hr
Definition: shlfolder.c:183
#define _ARRAYSIZE(A)
Definition: ntbasedef.h:708
#define IID_PPV_ARG(Itype, ppType)
#define test_at_end
Definition: ACListISF.cpp:32
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI SHParseDisplayName(LPCWSTR pszName, IBindCtx *pbc, LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut)
Definition: pidl.c:1367
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by START_TEST().

◆ test_at_end_imp()

static void test_at_end_imp ( CComPtr< IEnumString > &  EnumStr)
static

Definition at line 45 of file ACListISF.cpp.

46 {
47  CComHeapPtr<OLECHAR> Result;
48  ULONG Fetched = 12345;
49  HRESULT hr = EnumStr->Next(1, &Result, &Fetched);
50  winetest_ok(hr == S_FALSE, "Expected hr to be S_FALSE, was 0x%lx\n", hr);
51  winetest_ok(Fetched == 0u, "Expected Fetched to be 0, was: %lu\n", Fetched);
52  if (Fetched == 1u)
53  winetest_ok(0, "Expected there not to be a result, got: %s\n", wine_dbgstr_w(Result));
54 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
HRESULT hr
Definition: shlfolder.c:183
#define wine_dbgstr_w
Definition: kernel32.h:34
#define S_FALSE
Definition: winerror.h:2357
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
LONG HRESULT
Definition: typedefs.h:77
unsigned int ULONG
Definition: retypes.h:1

Referenced by test_ExpectFolders_imp().

◆ test_ExpectDrives_imp()

static void test_ExpectDrives_imp ( CComPtr< IEnumString > &  EnumStr,
CComHeapPtr< ITEMIDLIST > &  pidlTarget 
)
static

Definition at line 148 of file ACListISF.cpp.

149 {
150  test_ExpectFolders_imp(EnumStr, pidlTarget, NULL, IgnoreRoot | CheckLast);
151 }
smooth NULL
Definition: ftsmooth.c:416
static void test_ExpectFolders_imp(CComPtr< IEnumString > &EnumStr, LPITEMIDLIST pidlTarget, const WCHAR *Root, ExpectOptions options)
Definition: ACListISF.cpp:87

◆ test_ExpectFolders_imp()

static void test_ExpectFolders_imp ( CComPtr< IEnumString > &  EnumStr,
LPITEMIDLIST  pidlTarget,
const WCHAR Root,
ExpectOptions  options 
)
static

Definition at line 87 of file ACListISF.cpp.

88 {
89  CComPtr<IShellFolder> spDesktop;
90  HRESULT hr = SHGetDesktopFolder(&spDesktop);
91 
92  CComPtr<IShellFolder> spTarget;
93  if (pidlTarget)
94  {
95  winetest_ok_hr(hr = spDesktop->BindToObject(pidlTarget, NULL, IID_PPV_ARG(IShellFolder, &spTarget)), S_OK);
96  if (!SUCCEEDED(hr))
97  return;
98  }
99  else
100  {
101  spTarget = spDesktop;
102  }
103 
104  SHCONTF EnumFlags = SHCONTF_FOLDERS | SHCONTF_INIT_ON_FIRST_NEXT;
105  if (g_ShowHidden && !(options & IgnoreHidden))
106  EnumFlags |= SHCONTF_INCLUDEHIDDEN;
107  if (!(options & IgnoreFiles))
108  EnumFlags |= SHCONTF_NONFOLDERS;
109 
110  CComPtr<IEnumIDList> spEnumIDList;
111  winetest_ok_hr(hr = spTarget->EnumObjects(NULL, EnumFlags, &spEnumIDList), S_OK);
112  if (!SUCCEEDED(hr))
113  return;
114 
115  WCHAR Buffer[512];
116  CComHeapPtr<ITEMIDLIST> pidl;
117  INT Count = 0;
118  while (spEnumIDList->Next(1, &pidl, NULL) == S_OK)
119  {
120  CComHeapPtr<WCHAR> DisplayName;
121  if (!GetDisplayname(spTarget, pidl, DisplayName))
122  break;
123 
124  CComHeapPtr<OLECHAR> Result;
125  ULONG Fetched;
126  hr = EnumStr->Next(1, &Result, &Fetched);
128 
129 
130  if (hr != S_OK)
131  break;
132 
133 
134  StringCchPrintfW(Buffer, _ARRAYSIZE(Buffer), L"%s%s", (options & IgnoreRoot) ? L"" : Root, (WCHAR*)DisplayName);
135 
136  winetest_ok(!wcscmp(Buffer, Result), "Expected %s, got %s\n", wine_dbgstr_w(Buffer), wine_dbgstr_w(Result));
137 
138  pidl.Free();
139  Count++;
140  }
141  if (options & CheckLast)
142  {
143  test_at_end_imp(EnumStr);
144  }
145 }
static bool GetDisplayname(CComPtr< IShellFolder > &spDrives, CComHeapPtr< ITEMIDLIST > &pidl, CComHeapPtr< WCHAR > &DisplayName)
Definition: ACListISF.cpp:56
HRESULT hr
Definition: shlfolder.c:183
#define _ARRAYSIZE(A)
Definition: ntbasedef.h:708
#define wine_dbgstr_w
Definition: kernel32.h:34
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define IID_PPV_ARG(Itype, ppType)
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
Definition: bufpool.h:45
root entry for file system trees
Definition: entries.h:148
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
__wchar_t WCHAR
Definition: xmlstorage.h:180
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
static void test_at_end_imp(CComPtr< IEnumString > &EnumStr)
Definition: ACListISF.cpp:45
LONG HRESULT
Definition: typedefs.h:77
static const WCHAR L[]
Definition: oid.c:1250
#define winetest_ok_hr(expression, expected)
Definition: ACListISF.cpp:35
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define S_OK
Definition: intsafe.h:59
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530
static bool g_ShowHidden
Definition: ACListISF.cpp:24
unsigned int ULONG
Definition: retypes.h:1
static SHCONTF
Definition: ordinal.c:61
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by test_ExpectDrives_imp().

Variable Documentation

◆ g_ShowHidden

bool g_ShowHidden
static

Definition at line 24 of file ACListISF.cpp.

Referenced by test_ExpectFolders_imp().

◆ g_WinVersion

DWORD g_WinVersion
static