ReactOS 0.4.17-dev-1190-g4c812f4
CShellItem.cpp File Reference
#include "shelltest.h"
#include <shellutils.h>
#include <ntquery.h>
Include dependency graph for CShellItem.cpp:

Go to the source code of this file.

Macros

#define TestFailedDefVal(method, param, expected)
 

Functions

static IShellItem * CreateItem (PCWSTR pszPath)
 
static IShellItem2 * CreateItem2 (PCWSTR pszPath)
 
static void TestShellItemPropSys ()
 
 START_TEST (CShellItem)
 

Variables

static const PROPERTYKEY PKEY_DoesNotExist = { { 0x071ED77F,0x6DEE,0x4800,0x94,0xE7,0x1F,0xDD,0x89,0x6B,0x43,0x66 }, 42 }
 
static const PROPERTYKEY PKEY_Size = { PSGUID_STORAGE, PID_STG_SIZE }
 
static const PROPERTYKEY PKEY_DateModified = { PSGUID_STORAGE, PID_STG_WRITETIME }
 

Macro Definition Documentation

◆ TestFailedDefVal

#define TestFailedDefVal (   method,
  param,
  expected 
)
Value:
{ \
pv.uhVal.QuadPart = (expected), pv.ulVal = ~(UINT)(expected); \
hr = pItem->method(PKEY_DoesNotExist, param); \
ok(FAILED(hr) && pv.uhVal.QuadPart == (expected), #method " failure value\n"); \
}
HRESULT hr
Definition: delayimp.cpp:582
method
Definition: dragdrop.c:54
GLfloat param
Definition: glext.h:5796
unsigned int UINT
Definition: sysinfo.c:13
#define FAILED(hr)
Definition: intsafe.h:51
static const PROPERTYKEY PKEY_DoesNotExist
Definition: CShellItem.cpp:12
BOOL expected
Definition: store.c:2000

Function Documentation

◆ CreateItem()

static IShellItem * CreateItem ( PCWSTR  pszPath)
static

Definition at line 16 of file CShellItem.cpp.

17{
19 HRESULT hr = SHParseDisplayName(pszPath, NULL, &pidl, 0, NULL);
20 if (FAILED(hr))
21 return NULL;
22 IShellItem *pSI;
23 hr = SHCreateShellItem(NULL, NULL, pidl, &pSI);
24 ILFree(pidl);
25 return SUCCEEDED(hr) ? pSI : NULL;
26}
#define NULL
Definition: types.h:112
HRESULT WINAPI SHCreateShellItem(PCIDLIST_ABSOLUTE pidlParent, IShellFolder *psfParent, PCUITEMID_CHILD pidl, IShellItem **ppsi)
Definition: CShellItem.cpp:433
#define SUCCEEDED(hr)
Definition: intsafe.h:50
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1051
HRESULT WINAPI SHParseDisplayName(LPCWSTR pszName, IBindCtx *pbc, LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut)
Definition: pidl.c:1548

Referenced by CreateItem2().

◆ CreateItem2()

static IShellItem2 * CreateItem2 ( PCWSTR  pszPath)
static

Definition at line 28 of file CShellItem.cpp.

29{
30 IShellItem2 *pSI2;
31 CComPtr<IShellItem> pSI(CreateItem(pszPath));
32 HRESULT hr = pSI ? pSI->QueryInterface(IID_IShellItem2, (void**)&pSI2) : E_FAIL;
33 return SUCCEEDED(hr) ? pSI2 : NULL;
34}
#define E_FAIL
Definition: ddrawi.h:102
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
static IShellItem * CreateItem(PCWSTR pszPath)
Definition: CShellItem.cpp:16

Referenced by TestShellItemPropSys().

◆ START_TEST()

START_TEST ( CShellItem  )

Definition at line 84 of file CShellItem.cpp.

85{
86 CCoInit ComInit;
87
89}
static void TestShellItemPropSys()
Definition: CShellItem.cpp:36

◆ TestShellItemPropSys()

static void TestShellItemPropSys ( )
static

Definition at line 36 of file CShellItem.cpp.

37{
38 HRESULT hr;
39 PROPVARIANT pv;
44
45 CComPtr<IShellItem2> pItem(CreateItem2(szPath));
46 if (!pItem)
47 {
48 skip("Unable to create IShellItem2 from %ls\n", szPath);
49 return;
50 }
51
52 //ok_hr(pItem->GetInt32(PKEY_DoesNotExist, NULL), E_INVALIDARG); // Windows does not verify the pointer
53 ok_hr(pItem->GetUInt32(PKEY_DoesNotExist, &pv.ulVal), HResultFromWin32(ERROR_NOT_FOUND));
54
55 #define TestFailedDefVal(method, param, expected) \
56 { \
57 pv.uhVal.QuadPart = (expected), pv.ulVal = ~(UINT)(expected); \
58 hr = pItem->method(PKEY_DoesNotExist, param); \
59 ok(FAILED(hr) && pv.uhVal.QuadPart == (expected), #method " failure value\n"); \
60 }
61 TestFailedDefVal(GetUInt32, &pv.ulVal, 0);
62 TestFailedDefVal(GetInt32, (int*)&pv.lVal, 0);
63 TestFailedDefVal(GetUInt64, &pv.uhVal.QuadPart, 0);
64 TestFailedDefVal(GetBool, (BOOL*)&pv.lVal, FALSE);
65 TestFailedDefVal(GetFileTime, &pv.filetime, 0);
66 TestFailedDefVal(GetString, &pv.pwszVal, 0);
67 #undef TestFailedDefVal
68
69 pv.lVal = -1;
70 hr = pItem->GetUInt32(PKEY_Size, &pv.ulVal);
71 ok(hr == S_OK && pv.ulVal == fd.nFileSizeLow && fd.nFileSizeLow, "Size UInt32\n");
72 pv.lVal = -1;
73 hr = pItem->GetInt32(PKEY_Size, (int*)&pv.lVal);
74 ok(hr == S_OK && pv.ulVal == fd.nFileSizeLow && fd.nFileSizeLow, "Size Int32\n");
75 pv.lVal = -1;
76 hr = pItem->GetUInt64(PKEY_Size, &pv.uhVal.QuadPart);
77 ok(hr == S_OK && pv.uhVal.LowPart == fd.nFileSizeLow && fd.nFileSizeLow, "Size UInt64\n");
78
79 pv.lVal = -1;
80 hr = pItem->GetFileTime(PKEY_DateModified, &pv.filetime);
81 ok(hr == S_OK && pv.filetime.dwHighDateTime == fd.ftLastWriteTime.dwHighDateTime, "MDate\n"); // Only checking the high dword to avoid PIDL DOS time resolution
82}
#define ok_hr(status, expected)
Definition: ACListISF.cpp:31
static HRESULT GetString(ASSOCSTR Str, UINT Flags, LPCWSTR pszAssoc, LPCWSTR pszExtra, PWSTR Out, HKEY hProgId=NULL)
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI GetFileTime(IN HANDLE hFile, OUT LPFILETIME lpCreationTime OPTIONAL, OUT LPFILETIME lpLastAccessTime OPTIONAL, OUT LPFILETIME lpLastWriteTime OPTIONAL)
Definition: fileinfo.c:881
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
unsigned int BOOL
Definition: ntddk_ex.h:94
#define S_OK
Definition: intsafe.h:52
#define HResultFromWin32
Definition: loader.cpp:14
LPCWSTR szPath
Definition: env.c:37
#define TestFailedDefVal(method, param, expected)
static const PROPERTYKEY PKEY_Size
Definition: CShellItem.cpp:13
static const PROPERTYKEY PKEY_DateModified
Definition: CShellItem.cpp:14
static IShellItem2 * CreateItem2(PCWSTR pszPath)
Definition: CShellItem.cpp:28
short WCHAR
Definition: pedump.c:58
static int fd
Definition: io.c:51
#define _countof(array)
Definition: sndvol32.h:70
#define GetModuleFileName
Definition: winbase.h:3554
#define ERROR_NOT_FOUND
Definition: winerror.h:1014

Referenced by START_TEST().

Variable Documentation

◆ PKEY_DateModified

const PROPERTYKEY PKEY_DateModified = { PSGUID_STORAGE, PID_STG_WRITETIME }
static

Definition at line 14 of file CShellItem.cpp.

Referenced by TestShellItemPropSys().

◆ PKEY_DoesNotExist

const PROPERTYKEY PKEY_DoesNotExist = { { 0x071ED77F,0x6DEE,0x4800,0x94,0xE7,0x1F,0xDD,0x89,0x6B,0x43,0x66 }, 42 }
static

Definition at line 12 of file CShellItem.cpp.

Referenced by TestShellItemPropSys().

◆ PKEY_Size

const PROPERTYKEY PKEY_Size = { PSGUID_STORAGE, PID_STG_SIZE }
static

Definition at line 13 of file CShellItem.cpp.

Referenced by TestShellItemPropSys().