ReactOS 0.4.15-dev-8092-ge0ba2f3
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 SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:3092
BOOL WINAPI PathRemoveFileSpecW(LPWSTR lpszPath)
Definition: path.c:629
BOOL WINAPI PathIsDirectoryW(LPCWSTR lpszPath)
Definition: path.c:1723
#define PathAppendW
Definition: pathcch.h:309
#define CSIDL_PERSONAL
Definition: shlobj.h:2163
#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:584
#define FOF_NOCONFIRMATION
Definition: shellapi.h:145
#define SHFileOperation
Definition: shellapi.h:696
#define FOF_SILENT
Definition: shellapi.h:143
#define ZeroMemory
Definition: winbase.h:1712

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;
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 }
288 default:
289 {
290 assert(0);
291 break;
292 }
293 }
294
295 ok(lstrcmpA(checks, answer) == 0,
296 "Line %d: '%s' vs '%s' at Stage %d, Step %d\n", lineno, checks, answer, iStage, iStep);
297}
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:4194
#define assert(x)
Definition: debug.h:53
#define C_ASSERT(e)
Definition: intsafe.h:73
#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:4261
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
#define L(x)
Definition: ntvdm.h:50
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1353
#define SHCNE_UPDATEDIR
Definition: shlobj.h:1887
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:1879
#define SHCNE_DELETE
Definition: shlobj.h:1877
#define SHCNE_MKDIR
Definition: shlobj.h:1878
#define SHCNE_RENAMEITEM
Definition: shlobj.h:1875
#define SHCNE_CREATE
Definition: shlobj.h:1876
#define SHCNE_RENAMEFOLDER
Definition: shlobj.h:1892

Referenced by DoTestEntry().

◆ MainWndProc()

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

Definition at line 454 of file SHChangeNotify.cpp.

455{
456 switch (uMsg)
457 {
458 case WM_CREATE:
460 return 0;
461
462 case WM_COMMAND:
463 switch (LOWORD(wParam))
464 {
465 case IDYES: // Start testing
466 {
467 s_iStage = 0;
470 if (!s_hThread)
471 {
472 skip("!s_hThread\n");
474 }
475 break;
476 }
477 case IDRETRY: // New stage
478 {
480 ++s_iStage;
483 if (!s_hThread)
484 {
485 skip("!s_hThread\n");
487 }
488 break;
489 }
490 case IDNO: // Quit
491 {
492 s_iStage = -1;
494 break;
495 }
496 }
497 break;
498
499 case WM_COPYDATA:
500 if (s_iStage < 0 || s_iStep < 0)
501 break;
502
504 break;
505
506 case WM_DESTROY:
508 break;
509
510 default:
511 return ::DefWindowProcW(hwnd, uMsg, wParam, lParam);
512 }
513 return 0;
514}
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:1608
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_COMMAND
Definition: winuser.h:1740
#define IDNO
Definition: winuser.h:836
#define WM_COPYDATA
Definition: winuser.h:1664
#define WM_DESTROY
Definition: winuser.h:1609
#define IDYES
Definition: winuser.h:835
#define IDRETRY
Definition: winuser.h:833
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by TEST_Init().

◆ OnCopyData()

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

Definition at line 407 of file SHChangeNotify.cpp.

408{
409 if (pCopyData->dwData != 0xBEEFCAFE)
410 return FALSE;
411
412 LPBYTE pbData = (LPBYTE)pCopyData->lpData;
413 LPBYTE pb = pbData;
414
415 LONG cbTotal = pCopyData->cbData;
416 assert(cbTotal >= LONG(sizeof(LONG) + sizeof(DWORD) + sizeof(DWORD)));
417
418 LONG lEvent = *(LONG*)pb;
419 pb += sizeof(lEvent);
420
421 DWORD cbPidl1 = *(DWORD*)pb;
422 pb += sizeof(cbPidl1);
423
424 DWORD cbPidl2 = *(DWORD*)pb;
425 pb += sizeof(cbPidl2);
426
427 LPITEMIDLIST pidl1 = NULL;
428 if (cbPidl1)
429 {
430 pidl1 = (LPITEMIDLIST)CoTaskMemAlloc(cbPidl1);
431 CopyMemory(pidl1, pb, cbPidl1);
432 pb += cbPidl1;
433 }
434
435 LPITEMIDLIST pidl2 = NULL;
436 if (cbPidl2)
437 {
438 pidl2 = (LPITEMIDLIST)CoTaskMemAlloc(cbPidl2);
439 CopyMemory(pidl2, pb, cbPidl2);
440 pb += cbPidl2;
441 }
442
443 assert((pb - pbData) == cbTotal);
444
445 DoTestEntry(lEvent, pidl1, pidl2);
446
447 CoTaskMemFree(pidl1);
448 CoTaskMemFree(pidl2);
449
450 return TRUE;
451}
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:3001
unsigned char * LPBYTE
Definition: typedefs.h:53
#define CopyMemory
Definition: winbase.h:1710
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_updates_bytes_to_ pdwDataLen BYTE * pbData
Definition: wincrypt.h:4201

Referenced by MainWndProc().

◆ StageThreadFunc()

static DWORD WINAPI StageThreadFunc ( LPVOID  arg)
static

Definition at line 299 of file SHChangeNotify.cpp.

300{
301 BOOL ret;
302
303 trace("Stage %d\n", s_iStage);
304
305 // 0: Create file1 in dir1
306 s_iStep = 0;
307 trace("Step %d\n", s_iStep);
311 ok_int(ret, TRUE);
315
316 // 1: Rename file1 as file2 in dir1
317 ++s_iStep;
318 trace("Step %d\n", s_iStep);
321 ok_int(ret, TRUE);
325
326 // 2: Delete file2 in dir1
327 ++s_iStep;
328 trace("Step %d\n", s_iStep);
331 ok_int(ret, TRUE);
335
336 // 3: Create dir1 in dir1
337 ++s_iStep;
338 trace("Step %d\n", s_iStep);
341 ok_int(ret, TRUE);
345
346 // 4: Create file1 in dir1 in dir1
347 ++s_iStep;
348 trace("Step %d\n", s_iStep);
351 ok_int(ret, TRUE);
355
356 // 5: Delete file1 in dir1 in dir1
357 ++s_iStep;
358 trace("Step %d\n", s_iStep);
361 ok_int(ret, TRUE);
365
366 // 6: Rename dir1 as dir2 in dir1
367 ++s_iStep;
368 trace("Step %d\n", s_iStep);
371 ok_int(ret, TRUE);
375
376 // 7: Remove dir2 in dir1
377 ++s_iStep;
378 trace("Step %d\n", s_iStep);
381 ok_int(ret, TRUE);
385
386 // 8: Finish
387 ++s_iStep;
389 C_ASSERT(NUM_STEP == 8);
390 if (s_iStage + 1 < NUM_STAGE)
391 {
392 ::PostMessage(s_hSubWnd, WM_COMMAND, IDRETRY, 0); // Next stage
393 }
394 else
395 {
396 // Finish
399 }
400
401 s_iStep = -1;
402
403 return 0;
404}
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
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SHCNF_FLUSH
Definition: shlobj.h:1913
#define SHCNF_PATHW
Definition: shlobj.h:1910
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
int ret
#define PostMessage
Definition: winuser.h:5832

Referenced by MainWndProc().

◆ START_TEST()

START_TEST ( SHChangeNotify  )

Definition at line 597 of file SHChangeNotify.cpp.

598{
599 trace("Please close all Explorer windows before testing.\n");
600 trace("Please don't operate your PC while testing.\n");
601
602 DWORD dwOldTick = GetTickCount();
603 TEST_Main();
604 DWORD dwNewTick = GetTickCount();
605
606 DWORD dwTick = dwNewTick - dwOldTick;
607 trace("SHChangeNotify: Total %lu.%lu sec\n", (dwTick / 1000), (dwTick / 100 % 10));
608}
static void TEST_Main(void)
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455

◆ 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 516 of file SHChangeNotify.cpp.

517{
519 {
520 skip("shell32_apitest_sub.exe not found\n");
521 return FALSE;
522 }
523
524 // close the SUB_CLASSNAME windows
526
527 // Execute sub program
529 if ((INT_PTR)hinst <= 32)
530 {
531 skip("Unable to run shell32_apitest_sub.exe.\n");
532 return FALSE;
533 }
534
535 // prepare for files and dirs
537
538 // Register main window
539 WNDCLASSW wc = { 0, MainWndProc };
543 wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
545 if (!RegisterClassW(&wc))
546 {
547 skip("RegisterClassW failed\n");
548 return FALSE;
549 }
550
551 // Create main window
553 CW_USEDEFAULT, CW_USEDEFAULT, 400, 100,
555 if (!hwnd)
556 {
557 skip("CreateWindowW failed\n");
558 return FALSE;
559 }
562
563 // Find sub-window
565 if (!s_hSubWnd)
566 {
567 skip("Unable to find sub-program window.\n");
568 return FALSE;
569 }
570
571 // Start testing
573
574 return TRUE;
575}
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:2486
LPCWSTR lpszClassName
Definition: winuser.h:3185
HBRUSH hbrBackground
Definition: winuser.h:3183
HICON hIcon
Definition: winuser.h:3181
HINSTANCE hInstance
Definition: winuser.h:3180
HCURSOR hCursor
Definition: winuser.h:3182
int32_t INT_PTR
Definition: typedefs.h:64
#define SW_SHOWNORMAL
Definition: winuser.h:770
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:687
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2136
#define IDI_APPLICATION
Definition: winuser.h:704
BOOL WINAPI UpdateWindow(_In_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4316
#define CW_USEDEFAULT
Definition: winuser.h:225
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2106
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define COLOR_3DFACE
Definition: winuser.h:929

Referenced by TEST_Main().

◆ TEST_Main()

static void TEST_Main ( void  )
static

Definition at line 577 of file SHChangeNotify.cpp.

578{
579 if (!TEST_Init())
580 {
581 skip("Unable to start testing.\n");
582 TEST_Quit();
583 return;
584 }
585
586 // Message loop
587 MSG msg;
588 while (GetMessageW(&msg, NULL, 0, 0))
589 {
592 }
593
594 TEST_Quit();
595}
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:5765

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().