ReactOS 0.4.17-dev-1133-gc25e4fd
ShellFolder.cpp File Reference
#include "shelltest.h"
#include <shellutils.h>
#include <shlguid_undoc.h>
Include dependency graph for ShellFolder.cpp:

Go to the source code of this file.

Functions

static IShellFolder2 * CreateFolder2Instance (WORD csidl)
 
static void TestFolderSearch ()
 
static void TestGetDefaultColumn ()
 
static void TestGetDefaultColumnState ()
 
 START_TEST (ShellFolder)
 

Function Documentation

◆ CreateFolder2Instance()

static IShellFolder2 * CreateFolder2Instance ( WORD  csidl)
static

Definition at line 12 of file ShellFolder.cpp.

13{
16 if (FAILED(hr))
17 return NULL;
18 IShellFolder2 *pFolder;
19 hr = SHELL_BindToObject(NULL, pidl, NULL, IID_PPV_ARG(IShellFolder2, &pFolder));
20 ILFree(pidl);
21 return SUCCEEDED(hr) ? pFolder : NULL;
22}
#define IID_PPV_ARG(Itype, ppType)
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3385
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1051

Referenced by TestFolderSearch(), TestGetDefaultColumn(), and TestGetDefaultColumnState().

◆ START_TEST()

START_TEST ( ShellFolder  )

Definition at line 165 of file ShellFolder.cpp.

166{
167 CCoInit ComInit;
168
172}
static void TestGetDefaultColumn()
Definition: ShellFolder.cpp:89
static void TestGetDefaultColumnState()
static void TestFolderSearch()
Definition: ShellFolder.cpp:24

◆ TestFolderSearch()

static void TestFolderSearch ( )
static

Definition at line 24 of file ShellFolder.cpp.

25{
26 const bool nt5 = LOBYTE(GetVersion()) < 6;
27 static const struct {
28 BYTE csidl;
29 HRESULT hr;
30 const GUID *pExpected;
31 } defs[] =
32 {
34 { CSIDL_DRIVES, nt5 ? S_OK : E_NOTIMPL, nt5 ? &CLSID_ShellSearchExt : NULL },
35 { CSIDL_CONTROLS, nt5 ? S_OK : E_NOTIMPL, nt5 ? &CLSID_ShellSearchExt : NULL },
36 { CSIDL_BITBUCKET, nt5 ? S_OK : E_NOTIMPL, nt5 ? &CLSID_ShellSearchExt : NULL },
41 };
42 for (SIZE_T i = 0; i < _countof(defs); ++i)
43 {
44 CComPtr<IShellFolder2> pFolder(CreateFolder2Instance(defs[i].csidl));
45 if (!pFolder)
46 {
47 skip("Can't create special folder %d\n", defs[i].csidl);
48 continue;
49 }
50 GUID invalid = IID_IPersistFolder3;
52 HRESULT hr = pFolder->GetDefaultSearchGUID(&guid);
53 ok(hr == defs[i].hr, "Unexpected result %#x for %d\n", hr, defs[i].csidl);
54 ok(IsEqualGUID(guid, defs[i].pExpected ? *defs[i].pExpected : invalid), "GUID mismatch for %d!\n", defs[i].csidl);
55 }
56
57 static const struct {
58 BYTE csidl;
59 HRESULT hr;
60 bool NullOutput;
61 } enums[] =
62 {
63 { CSIDL_DESKTOP, E_NOTIMPL, true },
64 { CSIDL_DRIVES, E_NOTIMPL, true },
65 { CSIDL_CONTROLS, E_NOTIMPL, true },
66 { CSIDL_BITBUCKET, E_NOTIMPL, true },
67 { CSIDL_SYSTEM, E_NOTIMPL, true },
68 { CSIDL_FONTS, E_NOTIMPL, true },
69 { CSIDL_COOKIES, E_NOTIMPL, true },
70 };
71 for (SIZE_T i = 0; i < _countof(enums); ++i)
72 {
73 CComPtr<IShellFolder2> pFolder(CreateFolder2Instance(enums[i].csidl));
74 if (!pFolder)
75 {
76 skip("Can't create special folder %d\n", enums[i].csidl);
77 continue;
78 }
81 HRESULT hr = pFolder->EnumSearches(&pEnum);
82 ok(hr == enums[i].hr, "Unexpected result %#x for %d\n", hr, enums[i].csidl);
83 ok(pEnum == (enums[i].NullOutput ? NULL : invalid), "Result mismatch for %d!\n", enums[i].csidl);
84 if (pEnum && pEnum != invalid)
85 pEnum->Release();
86 }
87}
static IShellFolder2 * CreateFolder2Instance(WORD csidl)
Definition: ShellFolder.cpp:12
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define E_NOTIMPL
Definition: ddrawi.h:99
GUID guid
Definition: version.c:147
DWORD WINAPI GetVersion(void)
Definition: version.c:1458
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 const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
ULONG Release()
#define S_OK
Definition: intsafe.h:52
#define LOBYTE(W)
Definition: jmemdos.c:487
static const struct encodedInt enums[]
Definition: encode.c:361
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define CSIDL_FONTS
Definition: shlobj.h:2210
#define CSIDL_CONNECTIONS
Definition: shlobj.h:2239
#define CSIDL_COOKIES
Definition: shlobj.h:2223
#define CSIDL_SYSTEM
Definition: shlobj.h:2227
#define CSIDL_DESKTOP
Definition: shlobj.h:2191
#define CSIDL_DRIVES
Definition: shlobj.h:2207
#define CSIDL_CONTROLS
Definition: shlobj.h:2194
#define CSIDL_BITBUCKET
Definition: shlobj.h:2201
#define _countof(array)
Definition: sndvol32.h:70
ULONG_PTR SIZE_T
Definition: typedefs.h:80
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ TestGetDefaultColumn()

static void TestGetDefaultColumn ( )
static

Definition at line 89 of file ShellFolder.cpp.

90{
91 const bool nt5 = LOBYTE(GetVersion()) < 6;
92 static const struct {
93 BYTE csidl;
94 HRESULT hr;
95 BYTE col;
96 } defs[] =
97 {
104 { CSIDL_NETWORK, nt5 ? E_NOTIMPL : S_OK, 0 },
108 };
109 for (SIZE_T i = 0; i < _countof(defs); ++i)
110 {
111 CComPtr<IShellFolder2> pFolder(CreateFolder2Instance(defs[i].csidl));
112 if (!pFolder)
113 {
114 skip("Can't create special folder %d\n", defs[i].csidl);
115 continue;
116 }
117 ULONG invalid = (ULONG)-42;
118 ULONG sort = invalid, disp = invalid;
119 HRESULT hr = pFolder->GetDefaultColumn(0, &sort, &disp);
120 ok(hr == defs[i].hr, "Unexpected result %#x for %d\n", hr, defs[i].csidl);
121 ULONG expected = SUCCEEDED(hr) ? defs[i].col : invalid;
122 ok(sort == expected, "Unexpected output %#x for %d\n", sort, defs[i].csidl);
123 ok(disp == expected, "Unexpected output %#x for %d\n", disp, defs[i].csidl);
124 }
125}
static struct @576 sort
BOOL expected
Definition: store.c:2000
#define CSIDL_PRINTERS
Definition: shlobj.h:2195
#define CSIDL_NETWORK
Definition: shlobj.h:2208
uint32_t ULONG
Definition: typedefs.h:59

Referenced by START_TEST().

◆ TestGetDefaultColumnState()

static void TestGetDefaultColumnState ( )
static

Definition at line 127 of file ShellFolder.cpp.

128{
129 // Note: We are just testing the first column here, specific tests should be performed in the tests for each folder.
130 const bool nt5 = LOBYTE(GetVersion()) < 6;
131 static const struct {
132 BYTE csidl;
133 HRESULT hr;
134 BYTE type;
135 } states[] =
136 {
147 };
148 for (SIZE_T i = 0; i < _countof(states); ++i)
149 {
150 CComPtr<IShellFolder2> pFolder(CreateFolder2Instance(states[i].csidl));
151 if (!pFolder)
152 {
153 skip("Can't create special folder %d\n", states[i].csidl);
154 continue;
155 }
158 HRESULT hr = pFolder->GetDefaultColumnState(0, &flags);
159 ok(hr == states[i].hr, "Unexpected result %#x for %d\n", hr, states[i].csidl);
160 UINT expected = SUCCEEDED(states[i].hr) ? states[i].type : invalid;
161 ok((flags & SHCOLSTATE_TYPEMASK) == expected, "Unexpected output %#x for %d\n", flags, states[i].csidl);
162 }
163}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLbitfield flags
Definition: glext.h:7161
unsigned int UINT
Definition: sysinfo.c:13
@ SHCOLSTATE_TYPEMASK
Definition: shtypes.idl:124
@ SHCOLSTATE_TYPE_STR
Definition: shtypes.idl:121
DWORD SHCOLSTATEF
Definition: shtypes.idl:142

Referenced by START_TEST().