mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 08:53:02 +00:00
[SHELL32_APITEST] ShellExecuteEx: Add test for 'properties' verb
CORE-18035
This commit is contained in:
parent
d40d642f03
commit
f80de47c85
1 changed files with 98 additions and 1 deletions
|
@ -256,7 +256,11 @@ static VOID DoTestEntry(const TEST_ENTRY *pEntry)
|
||||||
free(s_wi1.phwnd);
|
free(s_wi1.phwnd);
|
||||||
ZeroMemory(&s_wi1, sizeof(s_wi1));
|
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);
|
CloseHandle(info.hProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,8 +368,101 @@ static void DoTestEntries(void)
|
||||||
free(s_wi0.phwnd);
|
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)
|
START_TEST(ShellExecuteEx)
|
||||||
{
|
{
|
||||||
DoAppPathTest();
|
DoAppPathTest();
|
||||||
DoTestEntries();
|
DoTestEntries();
|
||||||
|
test_properties();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue