https://git.reactos.org/?p=reactos.git;a=commitdiff;h=418edcd2bf95b5c9ca6fd3...
commit 418edcd2bf95b5c9ca6fd3710323e2b1e821aee4 Author: Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com AuthorDate: Tue Feb 15 20:15:36 2022 +0900 Commit: Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com CommitDate: Tue Feb 15 20:15:36 2022 +0900
[SHELL32_APITEST] ShellExecCmdLine: Close newly-opened windows
ROSTESTS-378 --- .../rostests/apitests/shell32/ShellExecCmdLine.cpp | 49 ++++++++++++++-------- 1 file changed, 31 insertions(+), 18 deletions(-)
diff --git a/modules/rostests/apitests/shell32/ShellExecCmdLine.cpp b/modules/rostests/apitests/shell32/ShellExecCmdLine.cpp index 699def5e114..e869e6deee5 100644 --- a/modules/rostests/apitests/shell32/ShellExecCmdLine.cpp +++ b/modules/rostests/apitests/shell32/ShellExecCmdLine.cpp @@ -594,6 +594,33 @@ static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam) 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) { 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", pEntry->lineno, pEntry->result, result);
- // close newly opened windows - 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)); + CleanupNewlyCreatedWindows(); }
START_TEST(ShellExecCmdLine) @@ -733,6 +743,9 @@ START_TEST(ShellExecCmdLine) DoEntry(&s_entries_2[i]); }
+ Sleep(2000); + CleanupNewlyCreatedWindows(); + // clean up 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");