ReactOS 0.4.16-dev-1521-gb8f1da6
SHChangeNotify.cpp File Reference
#include "shelltest.h"
#include "shell32_apitest_sub.h"
#include <assert.h>
Include dependency graph for SHChangeNotify.cpp:

Go to the source code of this file.

Classes

struct  TEST_ANSWER
 

Macros

#define NUM_STEP   8
 
#define NUM_CHECKS   12
 
#define INTERVAL   0
 
#define MAX_EVENT_TYPE   6
 
#define FILE_1   L"_TESTFILE_1_.txt"
 
#define FILE_2   L"_TESTFILE_2_.txt"
 
#define DIR_1   L"_TESTDIR_1_"
 
#define DIR_2   L"_TESTDIR_2_"
 
#define TRACE_PATH(path)   trace(#path ": %ls\n", path)
 

Functions

static BOOL DoCreateFile (LPCWSTR pszFileName)
 
static void DoDeleteDirectory (LPCWSTR pszDir)
 
static INT GetEventType (LONG lEvent)
 
static void DoDeleteFilesAndDirs (void)
 
static void TEST_Quit (void)
 
static void DoBuildFilesAndDirs (void)
 
static void DoTestEntry (LONG lEvent, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
 
static LPCSTR StringFromChecks (void)
 
static void DoStepCheck (INT iStage, INT iStep, LPCSTR checks)
 
static DWORD WINAPI StageThreadFunc (LPVOID arg)
 
static BOOL OnCopyData (HWND hwnd, HWND hwndSender, COPYDATASTRUCT *pCopyData)
 
static LRESULT CALLBACK MainWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static BOOL TEST_Init (void)
 
static void TEST_Main (void)
 
 START_TEST (SHChangeNotify)
 

Variables

static HWND s_hMainWnd = NULL
 
static HWND s_hSubWnd = NULL
 
static WCHAR s_szSubProgram [MAX_PATH]
 
static HANDLE s_hThread = NULL
 
static INT s_iStage = -1
 
static INT s_iStep = -1
 
static BYTE s_abChecks [NUM_CHECKS] = { 0 }
 
static BOOL s_bGotUpdateDir = FALSE
 
static WCHAR s_szDir1 [MAX_PATH]
 
static WCHAR s_szDir1InDir1 [MAX_PATH]
 
static WCHAR s_szDir2InDir1 [MAX_PATH]
 
static WCHAR s_szFile1InDir1InDir1 [MAX_PATH]
 
static WCHAR s_szFile1InDir1 [MAX_PATH]
 
static WCHAR s_szFile2InDir1 [MAX_PATH]
 

Macro Definition Documentation

◆ DIR_1

#define DIR_1   L"_TESTDIR_1_"

Definition at line 60 of file SHChangeNotify.cpp.

◆ DIR_2

#define DIR_2   L"_TESTDIR_2_"

Definition at line 61 of file SHChangeNotify.cpp.

◆ FILE_1

#define FILE_1   L"_TESTFILE_1_.txt"

Definition at line 58 of file SHChangeNotify.cpp.

◆ FILE_2

#define FILE_2   L"_TESTFILE_2_.txt"

Definition at line 59 of file SHChangeNotify.cpp.

◆ INTERVAL

#define INTERVAL   0

Definition at line 16 of file SHChangeNotify.cpp.

◆ MAX_EVENT_TYPE

#define MAX_EVENT_TYPE   6

Definition at line 17 of file SHChangeNotify.cpp.

◆ NUM_CHECKS

#define NUM_CHECKS   12

Definition at line 15 of file SHChangeNotify.cpp.

◆ NUM_STEP

#define NUM_STEP   8

Definition at line 14 of file SHChangeNotify.cpp.

◆ TRACE_PATH

#define TRACE_PATH (   path)    trace(#path ": %ls\n", path)

Function Documentation

◆ DoBuildFilesAndDirs()

static void DoBuildFilesAndDirs ( void  )
static

Definition at line 91 of file SHChangeNotify.cpp.

92{
93 WCHAR szPath1[MAX_PATH];
94 SHGetSpecialFolderPathW(NULL, szPath1, CSIDL_PERSONAL, FALSE); // My Documents
95 PathAppendW(szPath1, DIR_1);
97
98 PathAppendW(szPath1, DIR_1);
100 PathRemoveFileSpecW(szPath1);
101
102 PathAppendW(szPath1, DIR_2);
104 PathRemoveFileSpecW(szPath1);
105
106 PathAppendW(szPath1, DIR_1);
107 PathAppendW(szPath1, FILE_1);
109 PathRemoveFileSpecW(szPath1);
110 PathRemoveFileSpecW(szPath1);
111
112 PathAppendW(szPath1, FILE_1);
114 PathRemoveFileSpecW(szPath1);
115
116 PathAppendW(szPath1, FILE_2);
118 PathRemoveFileSpecW(szPath1);
119
120#define TRACE_PATH(path) trace(#path ": %ls\n", path)
126#undef TRACE_PATH
127
129
132
135}
#define TRACE_PATH(path)
#define FILE_1
#define DIR_1
static WCHAR s_szDir1InDir1[MAX_PATH]
static WCHAR s_szFile1InDir1InDir1[MAX_PATH]
#define DIR_2
static void DoDeleteFilesAndDirs(void)
static void DoDeleteDirectory(LPCWSTR pszDir)
#define FILE_2
static WCHAR s_szDir2InDir1[MAX_PATH]
static WCHAR s_szDir1[MAX_PATH]
static WCHAR s_szFile1InDir1[MAX_PATH]
static WCHAR s_szFile2InDir1[MAX_PATH]
#define ok_int(expression, result)
Definition: atltest.h:134
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
BOOL WINAPI PathRemoveFileSpecW(WCHAR *path)
Definition: path.c:1145
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:3219
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1729
#define PathAppendW
Definition: pathcch.h:310
#define CSIDL_PERSONAL
Definition: shlobj.h:2184
#define _countof(array)
Definition: sndvol32.h:70
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by TEST_Init().

◆ DoCreateFile()

static BOOL DoCreateFile ( LPCWSTR  pszFileName)
static

Definition at line 26 of file SHChangeNotify.cpp.

27{
32}
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
#define CREATE_ALWAYS
Definition: disk.h:72
_In_ HANDLE hFile
Definition: mswsock.h:90
#define GENERIC_WRITE
Definition: nt_native.h:90
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:44

Referenced by StageThreadFunc().

◆ DoDeleteDirectory()

static void DoDeleteDirectory ( LPCWSTR  pszDir)
static

Definition at line 34 of file SHChangeNotify.cpp.

35{
37 ZeroMemory(szPath, sizeof(szPath));
38 StringCchCopyW(szPath, _countof(szPath), pszDir); // Double-NULL terminated
40 SHFileOperation(&FileOp);
41}
LPCWSTR szPath
Definition: env.c:37
#define FO_DELETE
Definition: shellapi.h:138
_In_ LPCSTR pszDir
Definition: shellapi.h:601
#define FOF_NOCONFIRMATION
Definition: shellapi.h:145
#define SHFileOperation
Definition: shellapi.h:735
#define FOF_SILENT
Definition: shellapi.h:143
#define ZeroMemory
Definition: winbase.h:1753

Referenced by DoBuildFilesAndDirs(), and DoDeleteFilesAndDirs().

◆ DoDeleteFilesAndDirs()

static void DoDeleteFilesAndDirs ( void  )
static

◆ DoStepCheck()

static void DoStepCheck ( INT  iStage,
INT  iStep,
LPCSTR  checks 
)
static

Definition at line 201 of file SHChangeNotify.cpp.

202{
203 assert(0 <= iStep);
204 assert(iStep < NUM_STEP);
205
206 assert(0 <= iStage);
207 assert(iStage < NUM_STAGE);
208
209 if (s_bGotUpdateDir)
210 {
211 ok_int(TRUE, TRUE);
212 return;
213 }
214
215 LPCSTR answer = NULL;
216 INT lineno = 0;
217 switch (iStage)
218 {
219 case 0:
220 case 1:
221 case 3:
222 case 6:
223 case 9:
224 {
225 static const TEST_ANSWER c_answers[] =
226 {
227 { __LINE__, "000000010000010000000000" }, // 0
228 { __LINE__, "000000040000000000000400" }, // 1
229 { __LINE__, "000000000200020000000000" }, // 2
230 { __LINE__, "000000000000080000000000" }, // 3
231 { __LINE__, "000000000001010000000000" }, // 4
232 { __LINE__, "000000000002020000000000" }, // 5
233 { __LINE__, "000000000000000020000000" }, // 6
234 { __LINE__, "000010000000100000000000" }, // 7
235 };
236 C_ASSERT(_countof(c_answers) == NUM_STEP);
237 lineno = c_answers[iStep].lineno;
238 answer = c_answers[iStep].answer;
239 break;
240 }
241 case 2:
242 case 4:
243 case 5:
244 case 7:
245 {
246 static const TEST_ANSWER c_answers[] =
247 {
248 { __LINE__, "000000000000000000000000" }, // 0
249 { __LINE__, "000000000000000000000000" }, // 1
250 { __LINE__, "000000000000000000000000" }, // 2
251 { __LINE__, "000000000000000000000000" }, // 3
252 { __LINE__, "000000000000000000000000" }, // 4
253 { __LINE__, "000000000000000000000000" }, // 5
254 { __LINE__, "000000000000000000000000" }, // 6
255 { __LINE__, "000000000000000000000000" }, // 7
256 };
257 C_ASSERT(_countof(c_answers) == NUM_STEP);
258 lineno = c_answers[iStep].lineno;
259 answer = c_answers[iStep].answer;
260 break;
261 }
262 case 8:
263 {
264 static const TEST_ANSWER c_answers[] =
265 {
266 { __LINE__, "000000010000010000000000" }, // 0
267 { __LINE__, "000000040000000000000400" }, // 1
268 { __LINE__, "000000000200020000000000" }, // 2
269 { __LINE__, "000000000000080000000000" }, // 3
270 { __LINE__, "000000000001010000000000" }, // 4 // Recursive case
271 { __LINE__, "000000000002020000000000" }, // 5 // Recursive case
272 { __LINE__, "000000000000000020000000" }, // 6
273 { __LINE__, "000010000000100000000000" }, // 7
274 };
275 C_ASSERT(_countof(c_answers) == NUM_STEP);
276 lineno = c_answers[iStep].lineno;
277 answer = c_answers[iStep].answer;
278 if (iStep == 4 || iStep == 5) // Recursive cases
279 {
280 if (lstrcmpA(checks, "000000000000000000000000") == 0)
281 {
282 trace("Warning! Recursive cases...\n");
283 answer = "000000000000000000000000";
284 }
285 }
286 break;
287 }
289 }
290
291 ok(lstrcmpA(checks, answer) == 0,
292 "Line %d: '%s' vs '%s' at Stage %d, Step %d\n", lineno, checks, answer, iStage, iStep);
293}
static BOOL s_bGotUpdateDir
#define NUM_STEP
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4198
#define assert(x)
Definition: debug.h:53
#define C_ASSERT(e)
Definition: intsafe.h:73
#define DEFAULT_UNREACHABLE
#define NUM_STAGE
int32_t INT
Definition: typedefs.h:58
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by StageThreadFunc().

◆ DoTestEntry()

static void DoTestEntry ( LONG  lEvent,
LPCITEMIDLIST  pidl1,
LPCITEMIDLIST  pidl2 
)
static

Definition at line 137 of file SHChangeNotify.cpp.

138{
139 WCHAR szPath1[MAX_PATH], szPath2[MAX_PATH];
140
141 szPath1[0] = szPath2[0] = 0;
142 SHGetPathFromIDListW(pidl1, szPath1);
143 SHGetPathFromIDListW(pidl2, szPath2);
144
145 trace("(0x%lX, '%ls', '%ls')\n", lEvent, szPath1, szPath2);
146
147 if (lEvent == SHCNE_UPDATEDIR)
148 {
149 trace("Got SHCNE_UPDATEDIR\n");
151 return;
152 }
153
154 INT iEventType = GetEventType(lEvent);
155 if (iEventType < 0)
156 return;
157
158 assert(iEventType < MAX_EVENT_TYPE);
159
160 INT i = 0;
161 s_abChecks[i++] |= (lstrcmpiW(szPath1, L"") == 0) << iEventType;
162 s_abChecks[i++] |= (lstrcmpiW(szPath1, s_szDir1) == 0) << iEventType;
163 s_abChecks[i++] |= (lstrcmpiW(szPath1, s_szDir2InDir1) == 0) << iEventType;
164 s_abChecks[i++] |= (lstrcmpiW(szPath1, s_szFile1InDir1) == 0) << iEventType;
165 s_abChecks[i++] |= (lstrcmpiW(szPath1, s_szFile2InDir1) == 0) << iEventType;
166 s_abChecks[i++] |= (lstrcmpiW(szPath1, s_szFile1InDir1InDir1) == 0) << iEventType;
167 s_abChecks[i++] |= (lstrcmpiW(szPath2, L"") == 0) << iEventType;
168 s_abChecks[i++] |= (lstrcmpiW(szPath2, s_szDir1) == 0) << iEventType;
169 s_abChecks[i++] |= (lstrcmpiW(szPath2, s_szDir2InDir1) == 0) << iEventType;
170 s_abChecks[i++] |= (lstrcmpiW(szPath2, s_szFile1InDir1) == 0) << iEventType;
171 s_abChecks[i++] |= (lstrcmpiW(szPath2, s_szFile2InDir1) == 0) << iEventType;
172 s_abChecks[i++] |= (lstrcmpiW(szPath2, s_szFile1InDir1InDir1) == 0) << iEventType;
173 assert(i == NUM_CHECKS);
174}
#define MAX_EVENT_TYPE
#define NUM_CHECKS
static INT GetEventType(LONG lEvent)
static BYTE s_abChecks[NUM_CHECKS]
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4265
#define L(x)
Definition: resources.c:13
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
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1490
#define SHCNE_UPDATEDIR
Definition: shlobj.h:1907
HANDLE lEvent
Definition: tftpd.cpp:56

Referenced by OnCopyData().

◆ GetEventType()

static INT GetEventType ( LONG  lEvent)
static

Definition at line 43 of file SHChangeNotify.cpp.

44{
45 switch (lEvent)
46 {
47 case SHCNE_CREATE: return 0;
48 case SHCNE_DELETE: return 1;
49 case SHCNE_RENAMEITEM: return 2;
50 case SHCNE_MKDIR: return 3;
51 case SHCNE_RMDIR: return 4;
52 case SHCNE_RENAMEFOLDER: return 5;
53 C_ASSERT(5 + 1 == MAX_EVENT_TYPE);
54 default: return -1;
55 }
56}
#define SHCNE_RMDIR
Definition: shlobj.h:1899
#define SHCNE_DELETE
Definition: shlobj.h:1897
#define SHCNE_MKDIR
Definition: shlobj.h:1898
#define SHCNE_RENAMEITEM
Definition: shlobj.h:1895
#define SHCNE_CREATE
Definition: shlobj.h:1896
#define SHCNE_RENAMEFOLDER
Definition: shlobj.h:1912

Referenced by DoTestEntry().

◆ MainWndProc()

static LRESULT CALLBACK MainWndProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 450 of file SHChangeNotify.cpp.

451{
452 switch (uMsg)
453 {
454 case WM_CREATE:
456 return 0;
457
458 case WM_COMMAND:
459 switch (LOWORD(wParam))
460 {
461 case IDYES: // Start testing
462 {
463 s_iStage = 0;
466 if (!s_hThread)
467 {
468 skip("!s_hThread\n");
470 }
471 break;
472 }
473 case IDRETRY: // New stage
474 {
476 ++s_iStage;
479 if (!s_hThread)
480 {
481 skip("!s_hThread\n");
483 }
484 break;
485 }
486 case IDNO: // Quit
487 {
488 s_iStage = -1;
490 break;
491 }
492 }
493 break;
494
495 case WM_COPYDATA:
496 if (s_iStage < 0 || s_iStep < 0)
497 break;
498
500 break;
501
502 case WM_DESTROY:
504 break;
505
506 default:
507 return ::DefWindowProcW(hwnd, uMsg, wParam, lParam);
508 }
509 return 0;
510}
static DWORD WINAPI StageThreadFunc(LPVOID arg)
static HANDLE s_hThread
static BOOL OnCopyData(HWND hwnd, HWND hwndSender, COPYDATASTRUCT *pCopyData)
static HWND s_hMainWnd
static INT s_iStage
static INT s_iStep
#define skip(...)
Definition: atltest.h:64
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
#define LOWORD(l)
Definition: pedump.c:82
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define WM_CREATE
Definition: winuser.h:1636
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_COMMAND
Definition: winuser.h:1768
#define IDNO
Definition: winuser.h:847
#define WM_COPYDATA
Definition: winuser.h:1692
#define WM_DESTROY
Definition: winuser.h:1637
#define IDYES
Definition: winuser.h:846
#define IDRETRY
Definition: winuser.h:844
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by TEST_Init().

◆ OnCopyData()

static BOOL OnCopyData ( HWND  hwnd,
HWND  hwndSender,
COPYDATASTRUCT pCopyData 
)
static

Definition at line 403 of file SHChangeNotify.cpp.

404{
405 if (pCopyData->dwData != 0xBEEFCAFE)
406 return FALSE;
407
408 LPBYTE pbData = (LPBYTE)pCopyData->lpData;
409 LPBYTE pb = pbData;
410
411 LONG cbTotal = pCopyData->cbData;
412 assert(cbTotal >= LONG(sizeof(LONG) + sizeof(DWORD) + sizeof(DWORD)));
413
414 LONG lEvent = *(LONG*)pb;
415 pb += sizeof(lEvent);
416
417 DWORD cbPidl1 = *(DWORD*)pb;
418 pb += sizeof(cbPidl1);
419
420 DWORD cbPidl2 = *(DWORD*)pb;
421 pb += sizeof(cbPidl2);
422
423 LPITEMIDLIST pidl1 = NULL;
424 if (cbPidl1)
425 {
426 pidl1 = (LPITEMIDLIST)CoTaskMemAlloc(cbPidl1);
427 CopyMemory(pidl1, pb, cbPidl1);
428 pb += cbPidl1;
429 }
430
431 LPITEMIDLIST pidl2 = NULL;
432 if (cbPidl2)
433 {
434 pidl2 = (LPITEMIDLIST)CoTaskMemAlloc(cbPidl2);
435 CopyMemory(pidl2, pb, cbPidl2);
436 pb += cbPidl2;
437 }
438
439 assert((pb - pbData) == cbTotal);
440
441 DoTestEntry(lEvent, pidl1, pidl2);
442
443 CoTaskMemFree(pidl1);
444 CoTaskMemFree(pidl2);
445
446 return TRUE;
447}
static void DoTestEntry(LONG lEvent, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
long LONG
Definition: pedump.c:60
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
ULONG_PTR dwData
Definition: winuser.h:3103
unsigned char * LPBYTE
Definition: typedefs.h:53
#define CopyMemory
Definition: winbase.h:1751

Referenced by MainWndProc().

◆ StageThreadFunc()

static DWORD WINAPI StageThreadFunc ( LPVOID  arg)
static

Definition at line 295 of file SHChangeNotify.cpp.

296{
297 BOOL ret;
298
299 trace("Stage %d\n", s_iStage);
300
301 // 0: Create file1 in dir1
302 s_iStep = 0;
303 trace("Step %d\n", s_iStep);
307 ok_int(ret, TRUE);
311
312 // 1: Rename file1 as file2 in dir1
313 ++s_iStep;
314 trace("Step %d\n", s_iStep);
317 ok_int(ret, TRUE);
321
322 // 2: Delete file2 in dir1
323 ++s_iStep;
324 trace("Step %d\n", s_iStep);
327 ok_int(ret, TRUE);
331
332 // 3: Create dir1 in dir1
333 ++s_iStep;
334 trace("Step %d\n", s_iStep);
337 ok_int(ret, TRUE);
341
342 // 4: Create file1 in dir1 in dir1
343 ++s_iStep;
344 trace("Step %d\n", s_iStep);
347 ok_int(ret, TRUE);
351
352 // 5: Delete file1 in dir1 in dir1
353 ++s_iStep;
354 trace("Step %d\n", s_iStep);
357 ok_int(ret, TRUE);
361
362 // 6: Rename dir1 as dir2 in dir1
363 ++s_iStep;
364 trace("Step %d\n", s_iStep);
367 ok_int(ret, TRUE);
371
372 // 7: Remove dir2 in dir1
373 ++s_iStep;
374 trace("Step %d\n", s_iStep);
377 ok_int(ret, TRUE);
381
382 // 8: Finish
383 ++s_iStep;
385 C_ASSERT(NUM_STEP == 8);
386 if (s_iStage + 1 < NUM_STAGE)
387 {
388 ::PostMessage(s_hSubWnd, WM_COMMAND, IDRETRY, 0); // Next stage
389 }
390 else
391 {
392 // Finish
395 }
396
397 s_iStep = -1;
398
399 return 0;
400}
static HWND s_hSubWnd
static void DoStepCheck(INT iStage, INT iStep, LPCSTR checks)
#define INTERVAL
static LPCSTR StringFromChecks(void)
static BOOL DoCreateFile(LPCWSTR pszFileName)
EXTERN_C void WINAPI SHChangeNotify(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2)
BOOL WINAPI CreateDirectoryExW(IN LPCWSTR lpTemplateDirectory, IN LPCWSTR lpNewDirectory, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:193
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
BOOL WINAPI MoveFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName)
Definition: move.c:1104
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SHCNF_FLUSH
Definition: shlobj.h:1934
#define SHCNF_PATHW
Definition: shlobj.h:1931
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#define PostMessage
Definition: winuser.h:5943

Referenced by MainWndProc().

◆ START_TEST()

START_TEST ( SHChangeNotify  )

Definition at line 593 of file SHChangeNotify.cpp.

594{
595 trace("Please close all Explorer windows before testing.\n");
596 trace("Please don't operate your PC while testing.\n");
597
598 DWORD dwOldTick = GetTickCount();
599 TEST_Main();
600 DWORD dwNewTick = GetTickCount();
601
602 DWORD dwTick = dwNewTick - dwOldTick;
603 trace("SHChangeNotify: Total %lu.%lu sec\n", (dwTick / 1000), (dwTick / 100 % 10));
604}
static void TEST_Main(void)
ULONG WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
Definition: sync.c:182

◆ StringFromChecks()

static LPCSTR StringFromChecks ( void  )
static

Definition at line 176 of file SHChangeNotify.cpp.

177{
178 static char s_sz[2 * NUM_CHECKS + 1];
179
180 char *pch = s_sz;
181 for (INT i = 0; i < NUM_CHECKS; ++i)
182 {
183 WCHAR sz[3];
184 StringCchPrintfW(sz, _countof(sz), L"%02X", s_abChecks[i]);
185 *pch++ = sz[0];
186 *pch++ = sz[1];
187 }
188
189 assert((pch - s_sz) + 1 == sizeof(s_sz));
190
191 *pch = 0;
192 return s_sz;
193}
#define pch(ap)
Definition: match.c:418
STRSAFEAPI StringCchPrintfW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:530

Referenced by StageThreadFunc().

◆ TEST_Init()

static BOOL TEST_Init ( void  )
static

Definition at line 512 of file SHChangeNotify.cpp.

513{
515 {
516 skip("shell32_apitest_sub.exe not found\n");
517 return FALSE;
518 }
519
520 // close the SUB_CLASSNAME windows
522
523 // Execute sub program
525 if ((INT_PTR)hinst <= 32)
526 {
527 skip("Unable to run shell32_apitest_sub.exe.\n");
528 return FALSE;
529 }
530
531 // prepare for files and dirs
533
534 // Register main window
535 WNDCLASSW wc = { 0, MainWndProc };
539 wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
541 if (!RegisterClassW(&wc))
542 {
543 skip("RegisterClassW failed\n");
544 return FALSE;
545 }
546
547 // Create main window
549 CW_USEDEFAULT, CW_USEDEFAULT, 400, 100,
551 if (!hwnd)
552 {
553 skip("CreateWindowW failed\n");
554 return FALSE;
555 }
558
559 // Find sub-window
561 if (!s_hSubWnd)
562 {
563 skip("Unable to find sub-program window.\n");
564 return FALSE;
565 }
566
567 // Start testing
569
570 return TRUE;
571}
static WCHAR s_szSubProgram[MAX_PATH]
static LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
static void DoBuildFilesAndDirs(void)
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
static HINSTANCE hinst
Definition: edit.c:551
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
static HWND DoWaitForWindow(LPCWSTR clsname, LPCWSTR text, BOOL bClosing, BOOL bForce)
static BOOL FindSubProgram(LPWSTR pszSubProgram, DWORD cchSubProgram)
#define SUB_CLASSNAME
#define MAIN_CLASSNAME
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2607
LPCWSTR lpszClassName
Definition: winuser.h:3287
HBRUSH hbrBackground
Definition: winuser.h:3285
HICON hIcon
Definition: winuser.h:3283
HINSTANCE hInstance
Definition: winuser.h:3282
HCURSOR hCursor
Definition: winuser.h:3284
int32_t INT_PTR
Definition: typedefs.h:64
#define SW_SHOWNORMAL
Definition: winuser.h:781
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:695
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2457
#define IDI_APPLICATION
Definition: winuser.h:712
BOOL WINAPI UpdateWindow(_In_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4418
#define CW_USEDEFAULT
Definition: winuser.h:225
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2427
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define COLOR_3DFACE
Definition: winuser.h:940

Referenced by TEST_Main().

◆ TEST_Main()

static void TEST_Main ( void  )
static

Definition at line 573 of file SHChangeNotify.cpp.

574{
575 if (!TEST_Init())
576 {
577 skip("Unable to start testing.\n");
578 TEST_Quit();
579 return;
580 }
581
582 // Message loop
583 MSG msg;
584 while (GetMessageW(&msg, NULL, 0, 0))
585 {
588 }
589
590 TEST_Quit();
591}
static void TEST_Quit(void)
static BOOL TEST_Init(void)
#define msg(x)
Definition: auth_time.c:54
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
#define DispatchMessage
Definition: winuser.h:5876

Referenced by START_TEST().

◆ TEST_Quit()

static void TEST_Quit ( void  )
static

Definition at line 80 of file SHChangeNotify.cpp.

81{
84
85 PostMessageW(s_hSubWnd, WM_COMMAND, IDNO, 0); // Finish
86 DoWaitForWindow(SUB_CLASSNAME, SUB_CLASSNAME, TRUE, TRUE); // Close sub-windows
87
89}
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by TEST_Main().

Variable Documentation

◆ s_abChecks

BYTE s_abChecks[NUM_CHECKS] = { 0 }
static

Definition at line 23 of file SHChangeNotify.cpp.

Referenced by DoTestEntry(), StageThreadFunc(), and StringFromChecks().

◆ s_bGotUpdateDir

BOOL s_bGotUpdateDir = FALSE
static

Definition at line 24 of file SHChangeNotify.cpp.

Referenced by DoStepCheck(), DoTestEntry(), and MainWndProc().

◆ s_hMainWnd

HWND s_hMainWnd = NULL
static

Definition at line 19 of file SHChangeNotify.cpp.

Referenced by MainWndProc(), and StageThreadFunc().

◆ s_hSubWnd

HWND s_hSubWnd = NULL
static

Definition at line 19 of file SHChangeNotify.cpp.

Referenced by StageThreadFunc(), TEST_Init(), and TEST_Quit().

◆ s_hThread

HANDLE s_hThread = NULL
static

Definition at line 21 of file SHChangeNotify.cpp.

Referenced by MainWndProc(), and TEST_Quit().

◆ s_iStage

INT s_iStage = -1
static

Definition at line 22 of file SHChangeNotify.cpp.

Referenced by MainWndProc(), and StageThreadFunc().

◆ s_iStep

INT s_iStep = -1
static

Definition at line 22 of file SHChangeNotify.cpp.

Referenced by MainWndProc(), and StageThreadFunc().

◆ s_szDir1

WCHAR s_szDir1[MAX_PATH]
static

◆ s_szDir1InDir1

WCHAR s_szDir1InDir1[MAX_PATH]
static

Definition at line 64 of file SHChangeNotify.cpp.

Referenced by DoBuildFilesAndDirs(), DoDeleteFilesAndDirs(), and StageThreadFunc().

◆ s_szDir2InDir1

WCHAR s_szDir2InDir1[MAX_PATH]
static

◆ s_szFile1InDir1

WCHAR s_szFile1InDir1[MAX_PATH]
static

◆ s_szFile1InDir1InDir1

WCHAR s_szFile1InDir1InDir1[MAX_PATH]
static

◆ s_szFile2InDir1

WCHAR s_szFile2InDir1[MAX_PATH]
static

◆ s_szSubProgram

WCHAR s_szSubProgram[MAX_PATH]
static

Definition at line 20 of file SHChangeNotify.cpp.

Referenced by TEST_Init().