ReactOS 0.4.15-dev-8191-gbc6c731
CFSFolder.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
4 * PURPOSE: Test for CMyComputer
5 * PROGRAMMER: Giannis Adamopoulos
6 */
7
8#include "shelltest.h"
9
10#define NDEBUG
11#include <debug.h>
12#include <stdio.h>
13#include <shellutils.h>
14#include <versionhelpers.h>
15
17{
18 /* Create a tiny pidl with no contents */
19 LPITEMIDLIST testpidl = (LPITEMIDLIST)SHAlloc(3 * sizeof(WORD));
20 testpidl->mkid.cb = 2 * sizeof(WORD);
21 *(WORD*)((char*)testpidl + (int)(2 * sizeof(WORD))) = 0;
22
23 return testpidl;
24}
25
27{
28 CComPtr<IShellFolder> psf;
29 CComPtr<IEnumIDList> penum;
30 CComPtr<IDropTarget> pdt;
31 CComPtr<IContextMenu> pcm;
32 CComPtr<IShellView> psv;
33 LPITEMIDLIST retrievedPidl;
34 ULONG pceltFetched;
35 HRESULT hr;
36
37 /* Create a CFSFolder */
38 hr = CoCreateInstance(CLSID_ShellFSFolder, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IShellFolder, &psf));
39 ok(hr == S_OK, "hr = %lx\n", hr);
40
41 /* An uninitialized CFSFolder doesn't contain any items */
42 hr = psf->EnumObjects(NULL, 0, &penum);
43 ok(hr == S_OK, "hr = %lx\n", hr);
44 hr = penum->Next(0, &retrievedPidl, &pceltFetched);
45 ok(hr == S_FALSE, "hr = %lx\n", hr);
46 hr = penum->Next(1, &retrievedPidl, &pceltFetched);
47 ok(hr == S_FALSE, "hr = %lx\n", hr);
48
49 /* It supports viewing */
50 hr = psf->CreateViewObject(NULL, IID_PPV_ARG(IDropTarget, &pdt));
51 ok(hr == S_OK, "hr = %lx\n", hr);
52 hr = psf->CreateViewObject(NULL, IID_PPV_ARG(IContextMenu, &pcm));
53 ok(hr == S_OK, "hr = %lx\n", hr);
54 hr = psf->CreateViewObject(NULL, IID_PPV_ARG(IShellView, &psv));
55 ok(hr == S_OK, "hr = %lx\n", hr);
56
57 /* And its display name is ... "C:\Documents and Settings<username>\Desktop" */
58 STRRET strretName;
59 hr = psf->GetDisplayNameOf(NULL,SHGDN_FORPARSING,&strretName);
60 ok(hr == S_OK, "hr = %lx\n", hr);
61 ok(strretName.uType == STRRET_WSTR, "strretName.uType == %x\n", strretName.uType);
62 ok((wcsncmp(strretName.pOleStr, L"C:\\Documents and Settings\\", 26) == 0) ||
63 (wcsncmp(strretName.pOleStr, L"C:\\Users\\", 9) == 0),
64 "wrong name, got: %S\n", strretName.pOleStr);
65 ok(wcscmp(strretName.pOleStr + wcslen(strretName.pOleStr) - 8, L"\\Desktop") == NULL,
66 "wrong name, got: %S\n", strretName.pOleStr);
67
68 hr = psf->GetDisplayNameOf(NULL,SHGDN_FORPARSING|SHGDN_INFOLDER,&strretName);
69 ok(hr == E_INVALIDARG, "hr = %lx\n", hr);
70
71
72
73
74 /* Use Initialize method with a dummy pidl and test the still non initialized CFSFolder */
75 CComPtr<IPersistFolder2> ppf2;
77 ok(hr == S_OK, "hr = %lx\n", hr);
78
79 LPITEMIDLIST testpidl = _CreateDummyPidl();
80
81 hr = ppf2->Initialize(testpidl);
82 ok(hr == S_OK, "hr = %lx\n", hr);
83
84 CComHeapPtr<ITEMIDLIST> pidl;
85 hr = ppf2->GetCurFolder(&pidl);
86 ok(hr == S_OK, "hr = %lx\n", hr);
87 ok(pidl->mkid.cb == 2 * sizeof(WORD), "got wrong pidl size, cb = %x\n", pidl->mkid.cb);
88
89 /* methods that worked before, now fail */
90 hr = psf->GetDisplayNameOf(NULL,SHGDN_FORPARSING,&strretName);
91 ok(hr == (IsWindows7OrGreater() ? E_INVALIDARG : E_FAIL), "hr = %lx\n", hr);
92 hr = psf->EnumObjects(NULL, 0, &penum);
94
95 /* The following continue to work though */
96 hr = psf->CreateViewObject(NULL, IID_PPV_ARG(IDropTarget, &pdt));
97 ok(hr == S_OK, "hr = %lx\n", hr);
98 hr = psf->CreateViewObject(NULL, IID_PPV_ARG(IContextMenu, &pcm));
99 ok(hr == S_OK, "hr = %lx\n", hr);
100 hr = psf->CreateViewObject(NULL, IID_PPV_ARG(IShellView, &psv));
101 ok(hr == S_OK, "hr = %lx\n", hr);
102
103}
104
106{
107 HRESULT hr;
108 STRRET strretName;
109
110 /* Create a CFSFolder */
111 CComPtr<IShellFolder> psf;
112 hr = CoCreateInstance(CLSID_ShellFSFolder, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IShellFolder, &psf));
113 ok(hr == S_OK, "hr = %lx\n", hr);
114
115 CComPtr<IPersistFolder3> ppf3;
117 ok(hr == S_OK, "hr = %lx\n", hr);
118
119 LPITEMIDLIST testpidl = _CreateDummyPidl();
120 PERSIST_FOLDER_TARGET_INFO pfti = {0};
121 PERSIST_FOLDER_TARGET_INFO queriedPfti;
122 hr = ppf3->InitializeEx(NULL, NULL, NULL);
123 ok(hr == (IsWindows7OrGreater() ? E_INVALIDARG : E_OUTOFMEMORY), "hr = %lx\n", hr);
124
125 hr = ppf3->InitializeEx(NULL, NULL, &pfti);
126 ok(hr == (IsWindows7OrGreater() ? E_INVALIDARG : E_OUTOFMEMORY), "hr = %lx\n", hr);
127
128 wcscpy(pfti.szTargetParsingName, L"C:\\");
129 hr = ppf3->InitializeEx(NULL, NULL, &pfti);
130 ok(hr == (IsWindows7OrGreater() ? E_INVALIDARG : E_OUTOFMEMORY), "hr = %lx\n", hr);
131
132 hr = ppf3->InitializeEx(NULL, testpidl, NULL);
133 ok(hr == S_OK, "hr = %lx\n", hr);
134
135 hr = ppf3->GetFolderTargetInfo(&queriedPfti);
136 ok(hr == (IsWindows7OrGreater() ? E_FAIL : S_OK), "hr = %lx\n", hr);
137
138 hr = psf->GetDisplayNameOf(NULL,SHGDN_FORPARSING,&strretName);
139 ok(hr == (IsWindows7OrGreater() ? E_INVALIDARG : E_FAIL), "hr = %lx\n", hr);
140
141 pfti.szTargetParsingName[0] = 0;
142 hr = ppf3->InitializeEx(NULL, testpidl, &pfti);
143 ok(hr == S_OK, "hr = %lx\n", hr);
144
145 hr = ppf3->GetFolderTargetInfo(&queriedPfti);
146 ok(hr == S_OK, "hr = %lx\n", hr);
147 ok(wcscmp(queriedPfti.szTargetParsingName, L"") == 0, "wrong name, got: %S\n", queriedPfti.szTargetParsingName);
148
149 hr = psf->GetDisplayNameOf(NULL,SHGDN_FORPARSING,&strretName);
150 ok(hr == (IsWindows7OrGreater() ? E_INVALIDARG : E_FAIL), "hr = %lx\n", hr);
151
152 wcscpy(pfti.szTargetParsingName, L"C:\\");
153 hr = ppf3->InitializeEx(NULL, testpidl, &pfti);
154 ok(hr == S_OK, "hr = %lx\n", hr);
155
156 hr = ppf3->GetFolderTargetInfo(&queriedPfti);
157 ok(hr == S_OK, "hr = %lx\n", hr);
158 ok(wcscmp(queriedPfti.szTargetParsingName, L"C:\\") == 0, "wrong name, got: %S\n", queriedPfti.szTargetParsingName);
159
160 hr = psf->GetDisplayNameOf(NULL,SHGDN_FORPARSING,&strretName);
161 ok(hr == S_OK, "hr = %lx\n", hr);
162 ok(strretName.uType == STRRET_WSTR, "strretName.uType == %x\n", strretName.uType);
163 ok(wcscmp(strretName.pOleStr, L"C:\\") == 0, "wrong name, got: %S\n", strretName.pOleStr);
164}
165
167{
168 HRESULT hr;
169
170 /* Create a CFSFolder */
171 CComPtr<IShellFolder> psf;
172 hr = CoCreateInstance(CLSID_ShellFSFolder, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARG(IShellFolder, &psf));
173 ok(hr == S_OK, "hr = %lx\n", hr);
174
175 /* test 0 cidl for IDataObject */
176 CComPtr<IDataObject> pdo;
177 hr = psf->GetUIObjectOf(NULL, 0, NULL, IID_NULL_PPV_ARG(IDataObject, &pdo));
178 ok(hr == E_INVALIDARG, "hr = %lx\n", hr);
179}
180
182{
184
188}
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:304
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
unsigned short WORD
Definition: ntddk_ex.h:93
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define S_OK
Definition: intsafe.h:52
VOID TestGetUIObjectOf()
Definition: CFSFolder.cpp:166
VOID TestInitialize()
Definition: CFSFolder.cpp:105
VOID TestUninitialized()
Definition: CFSFolder.cpp:26
LPITEMIDLIST _CreateDummyPidl()
Definition: CFSFolder.cpp:16
#define L(x)
Definition: ntvdm.h:50
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:278
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_Check_return_ _CRTIMP int __cdecl wcsncmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
HRESULT hr
Definition: shlfolder.c:183
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
@ STRRET_WSTR
Definition: shtypes.idl:85
UINT uType
Definition: shtypes.idl:93
LPWSTR pOleStr
Definition: shtypes.idl:96
uint32_t ULONG
Definition: typedefs.h:59
VERSIONHELPERAPI IsWindows7OrGreater()
#define S_FALSE
Definition: winerror.h:2357
#define ERROR_CANCELLED
Definition: winerror.h:726
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define IID_PPV_ARG(Itype, ppType)
#define IID_NULL_PPV_ARG(Itype, ppType)