https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f80de47c854f81bc8f3a1…
commit f80de47c854f81bc8f3a1d7e45905097dab2c286
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Tue Feb 1 23:22:44 2022 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Thu Feb 3 21:50:34 2022 +0100
[SHELL32_APITEST] ShellExecuteEx: Add test for 'properties' verb
CORE-18035
---
.../rostests/apitests/shell32/ShellExecuteEx.cpp | 99 +++++++++++++++++++++-
1 file changed, 98 insertions(+), 1 deletion(-)
diff --git a/modules/rostests/apitests/shell32/ShellExecuteEx.cpp
b/modules/rostests/apitests/shell32/ShellExecuteEx.cpp
index 6f32157e66b..3e33c075d10 100644
--- a/modules/rostests/apitests/shell32/ShellExecuteEx.cpp
+++ b/modules/rostests/apitests/shell32/ShellExecuteEx.cpp
@@ -256,7 +256,11 @@ static VOID DoTestEntry(const TEST_ENTRY *pEntry)
free(s_wi1.phwnd);
ZeroMemory(&s_wi1, sizeof(s_wi1));
- WaitForSingleObject(info.hProcess, INFINITE);
+ if (WaitForSingleObject(info.hProcess, 10 * 1000) == WAIT_TIMEOUT)
+ {
+ TerminateProcess(info.hProcess, 11);
+ ok(0, "Process %s did not quit!\n", pEntry->file);
+ }
CloseHandle(info.hProcess);
}
@@ -364,8 +368,101 @@ static void DoTestEntries(void)
free(s_wi0.phwnd);
}
+WCHAR* ExeName = NULL;
+
+BOOL CALLBACK EnumProc(_In_ HWND hwnd, _In_ LPARAM lParam)
+{
+ DWORD pid = 0;
+ GetWindowThreadProcessId(hwnd, &pid);
+ if (pid == GetCurrentProcessId() &&
+ IsWindowVisible(hwnd))
+ {
+ WCHAR Buffer[512] = {0};
+
+ GetWindowTextW(hwnd, Buffer, _countof(Buffer) - 1);
+ if (Buffer[0] && StrStrIW(Buffer, ExeName))
+ {
+ HWND* pHwnd = (HWND*)lParam;
+ *pHwnd = hwnd;
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+BOOL WaitAndCloseWindow()
+{
+ HWND hWnd = NULL;
+ for (int n = 0; n < 100; ++n)
+ {
+ Sleep(50);
+
+ EnumWindows(EnumProc, (LPARAM)&hWnd);
+
+ if (hWnd)
+ {
+ SendMessageW(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
+ return TRUE;
+ break;
+ }
+ }
+ return FALSE;
+}
+
+static void test_properties()
+{
+ WCHAR Buffer[MAX_PATH * 4];
+
+ CoInitialize(NULL);
+
+ GetModuleFileNameW(NULL, Buffer, _countof(Buffer));
+ SHELLEXECUTEINFOW info = { 0 };
+
+ info.cbSize = sizeof(SHELLEXECUTEINFOW);
+ info.fMask = SEE_MASK_INVOKEIDLIST | SEE_MASK_FLAG_NO_UI;
+ info.lpVerb = L"properties";
+ info.lpFile = Buffer;
+ info.lpParameters = L"";
+ info.nShow = SW_SHOW;
+
+ BOOL bRet = ShellExecuteExW(&info);
+ ok(bRet, "Failed! (GetLastError(): %d)\n", (int)GetLastError());
+ ok_ptr(info.hInstApp, (HINSTANCE)42);
+
+ ExeName = PathFindFileNameW(Buffer);
+ WCHAR* Extension = PathFindExtensionW(Buffer);
+ if (Extension)
+ {
+ // The inclusion of this depends on the file display settings!
+ *Extension = UNICODE_NULL;
+ }
+
+ if (bRet)
+ {
+ ok(WaitAndCloseWindow(), "Could not find properties window!\n");
+ }
+
+ // Now retry it with the extension cut off
+ bRet = ShellExecuteExW(&info);
+ ok(bRet, "Failed! (GetLastError(): %d)\n", (int)GetLastError());
+ ok_ptr(info.hInstApp, (HINSTANCE)42);
+
+ if (bRet)
+ {
+ ok(WaitAndCloseWindow(), "Could not find properties window!\n");
+ }
+
+ info.lpFile = L"complete garbage, cannot run this!";
+
+ // Now retry it with complete garabage
+ bRet = ShellExecuteExW(&info);
+ ok(bRet == 0, "Succeeded!\n");
+ ok_ptr(info.hInstApp, (HINSTANCE)2);
+}
+
START_TEST(ShellExecuteEx)
{
DoAppPathTest();
DoTestEntries();
+ test_properties();
}