mirror of
https://github.com/reactos/reactos.git
synced 2025-06-20 07:36:05 +00:00
[SHELL32_APITEST] ShellExecCmdLine: Close newly-opened windows
ROSTESTS-378
This commit is contained in:
parent
2b2366ab90
commit
418edcd2bf
1 changed files with 31 additions and 18 deletions
|
@ -594,6 +594,33 @@ static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void CleanupNewlyCreatedWindows(void)
|
||||||
|
{
|
||||||
|
EnumWindows(EnumWindowsProc, (LPARAM)&s_wi1);
|
||||||
|
for (UINT i1 = 0; i1 < s_wi1.count; ++i1)
|
||||||
|
{
|
||||||
|
BOOL bFound = FALSE;
|
||||||
|
for (UINT i0 = 0; i0 < s_wi0.count; ++i0)
|
||||||
|
{
|
||||||
|
if (s_wi1.phwnd[i1] == s_wi0.phwnd[i0])
|
||||||
|
{
|
||||||
|
bFound = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!bFound)
|
||||||
|
{
|
||||||
|
DWORD dwPID;
|
||||||
|
GetWindowThreadProcessId(s_wi1.phwnd[i1], &dwPID);
|
||||||
|
HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, TRUE, dwPID);
|
||||||
|
TerminateProcess(hProcess, -1);
|
||||||
|
CloseHandle(hProcess);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(s_wi1.phwnd);
|
||||||
|
ZeroMemory(&s_wi1, sizeof(s_wi1));
|
||||||
|
}
|
||||||
|
|
||||||
static void DoEntry(const TEST_ENTRY *pEntry)
|
static void DoEntry(const TEST_ENTRY *pEntry)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
@ -632,24 +659,7 @@ static void DoEntry(const TEST_ENTRY *pEntry)
|
||||||
ok(result == pEntry->result, "Line %d: result expected %d, was %d\n",
|
ok(result == pEntry->result, "Line %d: result expected %d, was %d\n",
|
||||||
pEntry->lineno, pEntry->result, result);
|
pEntry->lineno, pEntry->result, result);
|
||||||
|
|
||||||
// close newly opened windows
|
CleanupNewlyCreatedWindows();
|
||||||
EnumWindows(EnumWindowsProc, (LPARAM)&s_wi1);
|
|
||||||
for (UINT i1 = 0; i1 < s_wi1.count; ++i1)
|
|
||||||
{
|
|
||||||
BOOL bFound = FALSE;
|
|
||||||
for (UINT i0 = 0; i0 < s_wi0.count; ++i0)
|
|
||||||
{
|
|
||||||
if (s_wi1.phwnd[i1] == s_wi0.phwnd[i0])
|
|
||||||
{
|
|
||||||
bFound = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!bFound)
|
|
||||||
PostMessageW(s_wi1.phwnd[i1], WM_CLOSE, 0, 0);
|
|
||||||
}
|
|
||||||
free(s_wi1.phwnd);
|
|
||||||
ZeroMemory(&s_wi1, sizeof(s_wi1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST(ShellExecCmdLine)
|
START_TEST(ShellExecCmdLine)
|
||||||
|
@ -733,6 +743,9 @@ START_TEST(ShellExecCmdLine)
|
||||||
DoEntry(&s_entries_2[i]);
|
DoEntry(&s_entries_2[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Sleep(2000);
|
||||||
|
CleanupNewlyCreatedWindows();
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
ok(DeleteFileW(s_win_test_exe), "failed to delete the test file\n");
|
ok(DeleteFileW(s_win_test_exe), "failed to delete the test file\n");
|
||||||
ok(DeleteFileW(s_sys_bat_file), "failed to delete the test file\n");
|
ok(DeleteFileW(s_sys_bat_file), "failed to delete the test file\n");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue