https://git.reactos.org/?p=reactos.git;a=commitdiff;h=02f68dcb7a31f80c61857…
commit 02f68dcb7a31f80c61857acb4b3b420977ea95f1
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Sat Mar 7 11:36:55 2020 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Sat Mar 7 11:36:55 2020 +0900
[SHELL32_APITEST] Strengthen SHChangeNotify testcase (#2417)
Add pathname checks. CORE-13950
---
.../rostests/apitests/shell32/SHChangeNotify.cpp | 133 +++++++++++++--------
modules/rostests/apitests/shell32/shell-notify.cpp | 66 +++++++++-
2 files changed, 146 insertions(+), 53 deletions(-)
diff --git a/modules/rostests/apitests/shell32/SHChangeNotify.cpp
b/modules/rostests/apitests/shell32/SHChangeNotify.cpp
index ff36540e38c..79c9eafaaae 100644
--- a/modules/rostests/apitests/shell32/SHChangeNotify.cpp
+++ b/modules/rostests/apitests/shell32/SHChangeNotify.cpp
@@ -12,6 +12,7 @@
#define WM_SHELL_NOTIFY (WM_USER + 100)
#define WM_GET_NOTIFY_FLAGS (WM_USER + 101)
#define WM_CLEAR_FLAGS (WM_USER + 102)
+#define WM_SET_PATHS (WM_USER + 103)
static WCHAR s_dir1[MAX_PATH]; // "%TEMP%\\WatchDir1"
static WCHAR s_dir2[MAX_PATH]; // "%TEMP%\\WatchDir1\\Dir2"
@@ -45,6 +46,8 @@ typedef struct TEST_ENTRY
LPCVOID item2;
LPCSTR pattern;
ACTION action;
+ LPCWSTR path1;
+ LPCWSTR path2;
} TEST_ENTRY;
static BOOL
@@ -106,51 +109,51 @@ DoAction8(void)
}
static const TEST_ENTRY s_TestEntries[] = {
- {__LINE__, SHCNE_MKDIR, s_dir1, NULL, "000100000", NULL},
- {__LINE__, SHCNE_MKDIR, s_dir2, NULL, "000100000", NULL},
- {__LINE__, SHCNE_RMDIR, s_dir2, NULL, "000010000", NULL},
- {__LINE__, SHCNE_MKDIR, s_dir2, NULL, "000100000", DoAction1},
- {__LINE__, SHCNE_RMDIR, s_dir2, NULL, "000010000", NULL},
- {__LINE__, SHCNE_RMDIR, s_dir2, NULL, "000010000", DoAction2},
- {__LINE__, SHCNE_MKDIR, s_dir2, NULL, "000100000", DoAction1},
- {__LINE__, SHCNE_RENAMEFOLDER, s_dir2, s_dir3, "000000010", NULL},
- {__LINE__, SHCNE_RENAMEFOLDER, s_dir2, s_dir3, "000000010", DoAction3},
- {__LINE__, SHCNE_CREATE, s_file1, NULL, "010000000", NULL},
- {__LINE__, SHCNE_CREATE, s_file1, s_file2, "010000000", NULL},
- {__LINE__, SHCNE_CREATE, s_file1, NULL, "010000000", DoAction4},
- {__LINE__, SHCNE_RENAMEITEM, s_file1, s_file2, "100000000", NULL},
- {__LINE__, SHCNE_RENAMEITEM, s_file1, s_file2, "100000000", DoAction5},
- {__LINE__, SHCNE_RENAMEITEM, s_file1, s_file2, "100000000", NULL},
- {__LINE__, SHCNE_UPDATEITEM, s_file1, NULL, "000000100", NULL},
- {__LINE__, SHCNE_UPDATEITEM, s_file2, NULL, "000000100", NULL},
- {__LINE__, SHCNE_UPDATEITEM, s_file1, s_file2, "000000100", NULL},
- {__LINE__, SHCNE_UPDATEITEM, s_file2, s_file1, "000000100", NULL},
- {__LINE__, SHCNE_DELETE, s_file1, NULL, "001000000", NULL},
- {__LINE__, SHCNE_DELETE, s_file2, NULL, "001000000", NULL},
- {__LINE__, SHCNE_DELETE, s_file2, s_file1, "001000000", NULL},
- {__LINE__, SHCNE_DELETE, s_file1, s_file2, "001000000", NULL},
- {__LINE__, SHCNE_DELETE, s_file2, NULL, "001000000", DoAction6},
- {__LINE__, SHCNE_DELETE, s_file2, NULL, "001000000", NULL},
- {__LINE__, SHCNE_DELETE, s_file1, NULL, "001000000", NULL},
- {__LINE__, SHCNE_UPDATEDIR, s_file1, NULL, "000001000", NULL},
- {__LINE__, SHCNE_UPDATEDIR, s_file2, NULL, "000001000", NULL},
- {__LINE__, SHCNE_UPDATEDIR, s_file1, s_file2, "000001000", NULL},
- {__LINE__, SHCNE_UPDATEDIR, s_file2, s_file1, "000001000", NULL},
- {__LINE__, SHCNE_UPDATEDIR, s_dir1, NULL, "000001000", NULL},
- {__LINE__, SHCNE_UPDATEDIR, s_dir2, NULL, "000001000", NULL},
- {__LINE__, SHCNE_UPDATEDIR, s_dir1, s_dir2, "000001000", NULL},
- {__LINE__, SHCNE_UPDATEDIR, s_dir2, s_dir1, "000001000", NULL},
- {__LINE__, SHCNE_RMDIR, s_dir1, NULL, "000010000", NULL},
- {__LINE__, SHCNE_RMDIR, s_dir2, NULL, "000010000", NULL},
- {__LINE__, SHCNE_RMDIR, s_dir3, NULL, "000010000", NULL},
- {__LINE__, SHCNE_RMDIR, s_dir1, s_dir2, "000010000", NULL},
- {__LINE__, SHCNE_RMDIR, s_dir1, s_dir3, "000010000", NULL},
- {__LINE__, SHCNE_RMDIR, s_dir2, s_dir1, "000010000", NULL},
- {__LINE__, SHCNE_RMDIR, s_dir2, s_dir3, "000010000", NULL},
- {__LINE__, SHCNE_RMDIR, s_dir3, NULL, "000010000", NULL},
- {__LINE__, SHCNE_RMDIR, s_dir3, NULL, "000010000", DoAction7},
- {__LINE__, SHCNE_RMDIR, s_dir1, NULL, "000010000", NULL},
- {__LINE__, SHCNE_RMDIR, s_dir1, NULL, "000010000", DoAction8},
+ {__LINE__, SHCNE_MKDIR, s_dir1, NULL, "000100000", NULL, s_dir1,
L""},
+ {__LINE__, SHCNE_MKDIR, s_dir2, NULL, "000100000", NULL, s_dir2,
L""},
+ {__LINE__, SHCNE_RMDIR, s_dir2, NULL, "000010000", NULL, s_dir2,
L""},
+ {__LINE__, SHCNE_MKDIR, s_dir2, NULL, "000100000", DoAction1, s_dir2,
L""},
+ {__LINE__, SHCNE_RMDIR, s_dir2, NULL, "000010000", NULL, s_dir2,
L""},
+ {__LINE__, SHCNE_RMDIR, s_dir2, NULL, "000010000", DoAction2, s_dir2,
L""},
+ {__LINE__, SHCNE_MKDIR, s_dir2, NULL, "000100000", DoAction1, s_dir2,
L""},
+ {__LINE__, SHCNE_RENAMEFOLDER, s_dir2, s_dir3, "000000010", NULL, s_dir2,
s_dir3},
+ {__LINE__, SHCNE_RENAMEFOLDER, s_dir2, s_dir3, "000000010", DoAction3,
s_dir2, s_dir3},
+ {__LINE__, SHCNE_CREATE, s_file1, NULL, "010000000", NULL, s_file1,
L""},
+ {__LINE__, SHCNE_CREATE, s_file1, s_file2, "010000000", NULL, s_file1,
s_file2},
+ {__LINE__, SHCNE_CREATE, s_file1, NULL, "010000000", DoAction4, s_file1,
L""},
+ {__LINE__, SHCNE_RENAMEITEM, s_file1, s_file2, "100000000", NULL, s_file1,
s_file2},
+ {__LINE__, SHCNE_RENAMEITEM, s_file1, s_file2, "100000000", DoAction5,
s_file1, s_file2},
+ {__LINE__, SHCNE_RENAMEITEM, s_file1, s_file2, "100000000", NULL, s_file1,
s_file2},
+ {__LINE__, SHCNE_UPDATEITEM, s_file1, NULL, "000000100", NULL, s_file1,
L""},
+ {__LINE__, SHCNE_UPDATEITEM, s_file2, NULL, "000000100", NULL, s_file2,
L""},
+ {__LINE__, SHCNE_UPDATEITEM, s_file1, s_file2, "000000100", NULL, s_file1,
s_file2},
+ {__LINE__, SHCNE_UPDATEITEM, s_file2, s_file1, "000000100", NULL, s_file2,
s_file1},
+ {__LINE__, SHCNE_DELETE, s_file1, NULL, "001000000", NULL, s_file1,
L""},
+ {__LINE__, SHCNE_DELETE, s_file2, NULL, "001000000", NULL, s_file2,
L""},
+ {__LINE__, SHCNE_DELETE, s_file2, s_file1, "001000000", NULL, s_file2,
s_file1},
+ {__LINE__, SHCNE_DELETE, s_file1, s_file2, "001000000", NULL, s_file1,
s_file2},
+ {__LINE__, SHCNE_DELETE, s_file2, NULL, "001000000", DoAction6, s_file2,
L""},
+ {__LINE__, SHCNE_DELETE, s_file2, NULL, "001000000", NULL, s_file2,
L""},
+ {__LINE__, SHCNE_DELETE, s_file1, NULL, "001000000", NULL, s_file1,
L""},
+ {__LINE__, SHCNE_UPDATEDIR, s_file1, NULL, "000001000", NULL, s_file1,
L""},
+ {__LINE__, SHCNE_UPDATEDIR, s_file2, NULL, "000001000", NULL, s_file2,
L""},
+ {__LINE__, SHCNE_UPDATEDIR, s_file1, s_file2, "000001000", NULL, s_file1,
s_file2},
+ {__LINE__, SHCNE_UPDATEDIR, s_file2, s_file1, "000001000", NULL, s_file2,
s_file1},
+ {__LINE__, SHCNE_UPDATEDIR, s_dir1, NULL, "000001000", NULL, s_dir1,
L""},
+ {__LINE__, SHCNE_UPDATEDIR, s_dir2, NULL, "000001000", NULL, s_dir2,
L""},
+ {__LINE__, SHCNE_UPDATEDIR, s_dir1, s_dir2, "000001000", NULL, s_dir1,
s_dir2},
+ {__LINE__, SHCNE_UPDATEDIR, s_dir2, s_dir1, "000001000", NULL, s_dir2,
s_dir1},
+ {__LINE__, SHCNE_RMDIR, s_dir1, NULL, "000010000", NULL, s_dir1,
L""},
+ {__LINE__, SHCNE_RMDIR, s_dir2, NULL, "000010000", NULL, s_dir2,
L""},
+ {__LINE__, SHCNE_RMDIR, s_dir3, NULL, "000010000", NULL, s_dir3,
L""},
+ {__LINE__, SHCNE_RMDIR, s_dir1, s_dir2, "000010000", NULL, s_dir1,
s_dir2},
+ {__LINE__, SHCNE_RMDIR, s_dir1, s_dir3, "000010000", NULL, s_dir1,
s_dir3},
+ {__LINE__, SHCNE_RMDIR, s_dir2, s_dir1, "000010000", NULL, s_dir2,
s_dir1},
+ {__LINE__, SHCNE_RMDIR, s_dir2, s_dir3, "000010000", NULL, s_dir2,
s_dir3},
+ {__LINE__, SHCNE_RMDIR, s_dir3, NULL, "000010000", NULL, s_dir3,
L""},
+ {__LINE__, SHCNE_RMDIR, s_dir3, NULL, "000010000", DoAction7, s_dir3,
L""},
+ {__LINE__, SHCNE_RMDIR, s_dir1, NULL, "000010000", NULL, s_dir1,
L""},
+ {__LINE__, SHCNE_RMDIR, s_dir1, NULL, "000010000", DoAction8, s_dir1,
L""},
};
LPCSTR PatternFromFlags(DWORD flags)
@@ -165,6 +168,31 @@ LPCSTR PatternFromFlags(DWORD flags)
return s_buf;
}
+static BOOL
+DoGetClipText(LPWSTR pszPath1, LPWSTR pszPath2)
+{
+ pszPath1[0] = pszPath2[0] = 0;
+
+ if (!OpenClipboard(NULL) || !IsClipboardFormatAvailable(CF_UNICODETEXT))
+ return FALSE;
+
+ WCHAR szText[MAX_PATH * 2];
+ HGLOBAL hGlobal = GetClipboardData(CF_UNICODETEXT);
+ LPWSTR psz = (LPWSTR)GlobalLock(hGlobal);
+ lstrcpynW(szText, psz, _countof(szText));
+ GlobalUnlock(hGlobal);
+ CloseClipboard();
+
+ LPWSTR pch = wcschr(szText, L'|');
+ if (pch == NULL)
+ return FALSE;
+
+ *pch = 0;
+ lstrcpynW(pszPath1, szText, MAX_PATH);
+ lstrcpynW(pszPath2, pch + 1, MAX_PATH);
+ return TRUE;
+}
+
static void
DoTestEntry(const TEST_ENTRY *entry)
{
@@ -180,6 +208,17 @@ DoTestEntry(const TEST_ENTRY *entry)
ok(lstrcmpA(pattern, entry->pattern) == 0, "Line %d: pattern mismatch
'%s'\n", entry->line, pattern);
+ SendMessageW(s_hwnd, WM_SET_PATHS, 0, 0);
+
+ WCHAR szPath1[MAX_PATH], szPath2[MAX_PATH];
+ BOOL bOK = DoGetClipText(szPath1, szPath2);
+ if (entry->path1)
+ ok(bOK && lstrcmpiW(entry->path1, szPath1) == 0,
+ "Line %d: path1 mismatch '%S' (%d)\n", entry->line,
szPath1, bOK);
+ if (entry->path2)
+ ok(bOK && lstrcmpiW(entry->path2, szPath2) == 0,
+ "Line %d: path2 mismatch '%S' (%d)\n", entry->line,
szPath2, bOK);
+
SendMessageW(s_hwnd, WM_CLEAR_FLAGS, 0, 0);
}
@@ -266,13 +305,13 @@ START_TEST(SHChangeNotify)
return;
}
- for (int i = 0; i < 10; ++i)
+ for (int i = 0; i < 15; ++i)
{
s_hwnd = FindWindowW(s_szName, s_szName);
if (s_hwnd)
break;
- Sleep(100);
+ Sleep(50);
}
if (!s_hwnd)
diff --git a/modules/rostests/apitests/shell32/shell-notify.cpp
b/modules/rostests/apitests/shell32/shell-notify.cpp
index f6ac62e8a5d..bcf3770b3d2 100644
--- a/modules/rostests/apitests/shell32/shell-notify.cpp
+++ b/modules/rostests/apitests/shell32/shell-notify.cpp
@@ -12,6 +12,7 @@
#define WM_SHELL_NOTIFY (WM_USER + 100)
#define WM_GET_NOTIFY_FLAGS (WM_USER + 101)
#define WM_CLEAR_FLAGS (WM_USER + 102)
+#define WM_SET_PATHS (WM_USER + 103)
static HWND s_hwnd = NULL;
static const WCHAR s_szName[] = L"SHChangeNotify testcase";
@@ -31,7 +32,15 @@ typedef enum TYPE
static BYTE s_counters[TYPE_FREESPACE + 1];
static UINT s_uRegID = 0;
+
static WCHAR s_dir1[MAX_PATH]; // "%TEMP%\\WatchDir1"
+static WCHAR s_dir2[MAX_PATH]; // "%TEMP%\\WatchDir1\\Dir2"
+static WCHAR s_dir3[MAX_PATH]; // "%TEMP%\\WatchDir1\\Dir3"
+static WCHAR s_file1[MAX_PATH]; // "%TEMP%\\WatchDir1\\File1.txt"
+static WCHAR s_file2[MAX_PATH]; // "%TEMP%\\WatchDir1\\File2.txt"
+
+static WCHAR s_path1[MAX_PATH], s_path2[MAX_PATH];
+
static LPITEMIDLIST s_pidl = NULL;
static SHChangeNotifyEntry s_entry;
@@ -48,6 +57,18 @@ OnCreate(HWND hwnd)
lstrcpyW(s_dir1, szPath);
PathAppendW(s_dir1, L"WatchDir1");
+ lstrcpyW(s_dir2, s_dir1);
+ PathAppendW(s_dir2, L"Dir2");
+
+ lstrcpyW(s_dir3, s_dir1);
+ PathAppendW(s_dir3, L"Dir3");
+
+ lstrcpyW(s_file1, s_dir1);
+ PathAppendW(s_file1, L"File1.txt");
+
+ lstrcpyW(s_file2, s_dir1);
+ PathAppendW(s_file2, L"File2.txt");
+
s_pidl = ILCreateFromPathW(s_dir1);
s_entry.pidl = s_pidl;
@@ -86,17 +107,15 @@ OnDestroy(HWND hwnd)
static void
DoShellNotify(HWND hwnd, PIDLIST_ABSOLUTE pidl1, PIDLIST_ABSOLUTE pidl2, LONG lEvent)
{
- CHAR path1[MAX_PATH], path2[MAX_PATH];
-
if (pidl1)
- SHGetPathFromIDListA(pidl1, path1);
+ SHGetPathFromIDListW(pidl1, s_path1);
else
- path1[0] = 0;
+ s_path1[0] = 0;
if (pidl2)
- SHGetPathFromIDListA(pidl2, path2);
+ SHGetPathFromIDListW(pidl2, s_path2);
else
- path2[0] = 0;
+ s_path2[0] = 0;
switch (lEvent)
{
@@ -187,6 +206,37 @@ OnGetNotifyFlags(HWND hwnd)
return dwFlags;
}
+static void
+DoSetClipText(HWND hwnd)
+{
+ if (!OpenClipboard(hwnd))
+ return;
+
+ EmptyClipboard();
+
+ WCHAR szText[MAX_PATH * 2];
+ lstrcpyW(szText, s_path1);
+ lstrcatW(szText, L"|");
+ lstrcatW(szText, s_path2);
+
+ DWORD cbText = (lstrlenW(szText) + 1) * sizeof(WCHAR);
+ HGLOBAL hGlobal = GlobalAlloc(GHND | GMEM_SHARE, cbText);
+ if (hGlobal)
+ {
+ LPWSTR psz = (LPWSTR)GlobalLock(hGlobal);
+ if (psz)
+ {
+ CopyMemory(psz, szText, cbText);
+ GlobalUnlock(hGlobal);
+
+ SetClipboardData(CF_UNICODETEXT, hGlobal);
+ }
+ }
+
+ CloseClipboard();
+ Sleep(60);
+}
+
static LRESULT CALLBACK
WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
@@ -213,6 +263,10 @@ WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
ZeroMemory(&s_counters, sizeof(s_counters));
break;
+ case WM_SET_PATHS:
+ DoSetClipText(hwnd);
+ break;
+
default:
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}