ReactOS 0.4.17-dev-116-ga4b6fe9
SHInvokeCommandsOnContextMenu.cpp File Reference
#include <apitest.h>
#include <windows.h>
#include <shlwapi.h>
#include <objbase.h>
#include <shellapi.h>
#include <shobjidl.h>
Include dependency graph for SHInvokeCommandsOnContextMenu.cpp:

Go to the source code of this file.

Classes

struct  MockContextMenu
 
struct  MockSite
 
class  SHInvokeCommandsOnContextMenuTest
 
struct  MockSiteTarget
 
struct  HwndCaptureMock
 

Typedefs

typedef HRESULT(WINAPIFN_SHInvokeCommandsOnContextMenu) (HWND, IUnknown *, IContextMenu *, DWORD, PCSTR *, UINT)
 

Functions

static void ZeroVerbs_NoDefaultItem_ReturnsEFail (void)
 
static void ZeroVerbs_WithDefaultItem_InvokesOnce (void)
 
static void ZeroVerbs_QueryReceivesCMF_DEFAULTONLY (void)
 
static void NonZeroVerbs_QueryDoesNotReceiveCMF_DEFAULTONLY (void)
 
static void SingleVerb_Success (void)
 
static void MultipleVerbs_StopsOnFirstSuccess (void)
 
static void Cancelled_BreaksLoop (void)
 
static void AsciiVerb_SetsUnicodeMaskAndVerbW (void)
 
static void FMask_IsPassedToInvokeCommand (void)
 
static void PunkSite_SetAndClearedAroundCall (void)
 
static void QueryFails_InvokeNotCalled (void)
 
static void Hwnd_IsPassedToInvokeCommand (void)
 
 START_TEST (SHInvokeCommandsOnContextMenu)
 

Variables

static FN_SHInvokeCommandsOnContextMenu g_fnSHInvokeCommandsOnContextMenu = NULL
 

Typedef Documentation

◆ FN_SHInvokeCommandsOnContextMenu

typedef HRESULT(WINAPI * FN_SHInvokeCommandsOnContextMenu) (HWND, IUnknown *, IContextMenu *, DWORD, PCSTR *, UINT)

Definition at line 15 of file SHInvokeCommandsOnContextMenu.cpp.

Function Documentation

◆ AsciiVerb_SetsUnicodeMaskAndVerbW()

static void AsciiVerb_SetsUnicodeMaskAndVerbW ( void  )
static

Definition at line 184 of file SHInvokeCommandsOnContextMenu.cpp.

185{
186 const char* verbs[] = { "open" };
188 cm.invokeResult = S_OK;
189
192 ok_wstr(cm.lastVerbW, L"open");
193}
static FN_SHInvokeCommandsOnContextMenu g_fnSHInvokeCommandsOnContextMenu
#define ok_wstr(x, y)
Definition: atltest.h:130
#define ok_int(expression, result)
Definition: atltest.h:134
Verb verbs[]
Definition: certutil.cpp:21
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define L(x)
Definition: resources.c:13
#define S_OK
Definition: intsafe.h:52

Referenced by START_TEST().

◆ Cancelled_BreaksLoop()

static void Cancelled_BreaksLoop ( void  )
static

Definition at line 173 of file SHInvokeCommandsOnContextMenu.cpp.

174{
175 const char* verbs[] = { "open", "print" };
178
181 ok_int(cm.invokeCalled, 1);
182}
#define ok_hr(status, expected)
Definition: ACListISF.cpp:31
HRESULT hr
Definition: delayimp.cpp:573
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define ERROR_CANCELLED
Definition: winerror.h:1055

Referenced by START_TEST().

◆ FMask_IsPassedToInvokeCommand()

static void FMask_IsPassedToInvokeCommand ( void  )
static

Definition at line 195 of file SHInvokeCommandsOnContextMenu.cpp.

196{
198 const char* verbs[] = { "open" };
200 cm.invokeResult = S_OK;
201
203 ok_int(!!(cm.lastFMask & kMask), TRUE);
204}
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SEE_MASK_NOASYNC
Definition: shellapi.h:35
#define SEE_MASK_FLAG_NO_UI
Definition: shellapi.h:38

Referenced by START_TEST().

◆ Hwnd_IsPassedToInvokeCommand()

static void Hwnd_IsPassedToInvokeCommand ( void  )
static

Definition at line 276 of file SHInvokeCommandsOnContextMenu.cpp.

277{
278 HwndCaptureMock mock;
279 const char* verbs[] = { "open" };
280 HWND fakeHwnd = reinterpret_cast<HWND>(static_cast<ULONG_PTR>(0xDEADBEEF));
281
282 g_fnSHInvokeCommandsOnContextMenu(fakeHwnd, NULL, &mock, 0, verbs, 1);
283 ok_ptr(mock.capturedHwnd, fakeHwnd);
284}
#define ok_ptr(expression, result)
Definition: atltest.h:108
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by START_TEST().

◆ MultipleVerbs_StopsOnFirstSuccess()

static void MultipleVerbs_StopsOnFirstSuccess ( void  )
static

Definition at line 161 of file SHInvokeCommandsOnContextMenu.cpp.

162{
163 const char* verbs[] = { "open", "print" };
165 cm.invokeResult = S_OK;
166
168 ok_hr(hr, S_OK);
169 ok_int(cm.invokeCalled, 1);
170 ok_str(cm.lastVerb, "open");
171}
#define ok_str(x, y)
Definition: atltest.h:127

Referenced by START_TEST().

◆ NonZeroVerbs_QueryDoesNotReceiveCMF_DEFAULTONLY()

static void NonZeroVerbs_QueryDoesNotReceiveCMF_DEFAULTONLY ( void  )
static

Definition at line 141 of file SHInvokeCommandsOnContextMenu.cpp.

142{
143 const char* verbs[] = { "open" };
146 ok_int(!!(cm.lastQueryFlags & CMF_DEFAULTONLY), FALSE);
147}
#define FALSE
Definition: types.h:117

Referenced by START_TEST().

◆ PunkSite_SetAndClearedAroundCall()

static void PunkSite_SetAndClearedAroundCall ( void  )
static

Definition at line 242 of file SHInvokeCommandsOnContextMenu.cpp.

243{
245 MockSite mySite;
246
247 const char* verbs[] = { "open" };
249
250 ok_int(target.siteSet, TRUE);
251 ok_int(target.siteClear, TRUE);
252}
Definition: tools.h:99

Referenced by START_TEST().

◆ QueryFails_InvokeNotCalled()

static void QueryFails_InvokeNotCalled ( void  )
static

Definition at line 254 of file SHInvokeCommandsOnContextMenu.cpp.

255{
257 cm.queryResult = E_FAIL;
258 cm.invokeResult = S_OK;
259 const char* verbs[] = { "open" };
260
262 ok_int(FAILED(hr), TRUE);
263 ok_int(cm.invokeCalled, 0);
264}
#define E_FAIL
Definition: ddrawi.h:102
#define FAILED(hr)
Definition: intsafe.h:51

Referenced by START_TEST().

◆ SingleVerb_Success()

static void SingleVerb_Success ( void  )
static

Definition at line 149 of file SHInvokeCommandsOnContextMenu.cpp.

150{
151 const char* verbs[] = { "open" };
153 cm.invokeResult = S_OK;
154
156 ok_hr(hr, S_OK);
157 ok_int(cm.invokeCalled, 1);
158 ok_str(cm.lastVerb, "open");
159}

Referenced by START_TEST().

◆ START_TEST()

Definition at line 286 of file SHInvokeCommandsOnContextMenu.cpp.

287{
288 HINSTANCE hSHLWAPI = LoadLibraryW(L"shlwapi");
289 if (!hSHLWAPI)
290 {
291 skip("shlwapi not found\n");
292 return;
293 }
294
298 {
299 skip("SHInvokeCommandsOnContextMenu not found\n");
300 FreeLibrary(hSHLWAPI);
301 return;
302 }
303
316
317 FreeLibrary(hSHLWAPI);
318}
static void FMask_IsPassedToInvokeCommand(void)
static void ZeroVerbs_QueryReceivesCMF_DEFAULTONLY(void)
static void PunkSite_SetAndClearedAroundCall(void)
static void NonZeroVerbs_QueryDoesNotReceiveCMF_DEFAULTONLY(void)
HRESULT(WINAPI * FN_SHInvokeCommandsOnContextMenu)(HWND, IUnknown *, IContextMenu *, DWORD, PCSTR *, UINT)
static void Hwnd_IsPassedToInvokeCommand(void)
static void Cancelled_BreaksLoop(void)
static void ZeroVerbs_WithDefaultItem_InvokesOnce(void)
static void MultipleVerbs_StopsOnFirstSuccess(void)
static void QueryFails_InvokeNotCalled(void)
static void ZeroVerbs_NoDefaultItem_ReturnsEFail(void)
static void AsciiVerb_SetsUnicodeMaskAndVerbW(void)
static void SingleVerb_Success(void)
#define skip(...)
Definition: atltest.h:64
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define LoadLibraryW(x)
Definition: compat.h:747
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581

◆ ZeroVerbs_NoDefaultItem_ReturnsEFail()

static void ZeroVerbs_NoDefaultItem_ReturnsEFail ( void  )
static

◆ ZeroVerbs_QueryReceivesCMF_DEFAULTONLY()

static void ZeroVerbs_QueryReceivesCMF_DEFAULTONLY ( void  )
static

Definition at line 133 of file SHInvokeCommandsOnContextMenu.cpp.

134{
136 cm.defaultItemId = 1;
138 ok_int(!!(cm.lastQueryFlags & CMF_DEFAULTONLY), TRUE);
139}

Referenced by START_TEST().

◆ ZeroVerbs_WithDefaultItem_InvokesOnce()

static void ZeroVerbs_WithDefaultItem_InvokesOnce ( void  )
static

Definition at line 121 of file SHInvokeCommandsOnContextMenu.cpp.

122{
124 cm.defaultItemId = 1;
125 cm.invokeResult = S_OK;
126
128 ok_hr(hr, S_OK);
129 ok_int(cm.queryCalled, 1);
130 ok_int(cm.invokeCalled, 1);
131}

Referenced by START_TEST().

Variable Documentation

◆ g_fnSHInvokeCommandsOnContextMenu