https://git.reactos.org/?p=reactos.git;a=commitdiff;h=307ce1a5035412bafc37f2ef70a1f3502a2b10ad

commit 307ce1a5035412bafc37f2ef70a1f3502a2b10ad
Author:     Hermès Bélusca-Maïto <[email protected]>
AuthorDate: Thu May 5 22:20:59 2022 +0200
Commit:     Hermès Bélusca-Maïto <[email protected]>
CommitDate: Fri May 6 21:32:01 2022 +0200

    [SHELL32_APITEST] ShellExecuteEx: Introduce a CleanupNewlyCreatedWindows() 
helper similar to the one of the ShellExecCmdLine test.
---
 .../rostests/apitests/shell32/ShellExecuteEx.cpp   | 42 ++++++++++++----------
 1 file changed, 24 insertions(+), 18 deletions(-)

diff --git a/modules/rostests/apitests/shell32/ShellExecuteEx.cpp 
b/modules/rostests/apitests/shell32/ShellExecuteEx.cpp
index 70f33ca4021..d239467d859 100644
--- a/modules/rostests/apitests/shell32/ShellExecuteEx.cpp
+++ b/modules/rostests/apitests/shell32/ShellExecuteEx.cpp
@@ -67,6 +67,7 @@ TestShellExecuteEx(const WCHAR* Name, BOOL ExpectedResult)
 {
     SHELLEXECUTEINFOW ShellExecInfo;
     BOOL Result;
+
     ZeroMemory(&ShellExecInfo, sizeof(ShellExecInfo));
     ShellExecInfo.cbSize = sizeof(ShellExecInfo);
     ShellExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
@@ -74,6 +75,7 @@ TestShellExecuteEx(const WCHAR* Name, BOOL ExpectedResult)
     ShellExecInfo.nShow = SW_SHOWNORMAL;
     ShellExecInfo.lpFile = Name;
     ShellExecInfo.lpDirectory = NULL;
+
     Result = ShellExecuteExW(&ShellExecInfo);
     ok(Result == ExpectedResult, "ShellExecuteEx lpFile %s failed. Error: 
%lu\n", wine_dbgstr_w(Name), GetLastError());
     if (ShellExecInfo.hProcess)
@@ -209,6 +211,27 @@ 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)
+            PostMessageW(s_wi1.phwnd[i1], WM_CLOSE, 0, 0);
+    }
+    free(s_wi1.phwnd);
+    ZeroMemory(&s_wi1, sizeof(s_wi1));
+}
+
 static VOID DoTestEntry(const TEST_ENTRY *pEntry)
 {
     SHELLEXECUTEINFOA info = { sizeof(info) };
@@ -238,24 +261,7 @@ static VOID DoTestEntry(const TEST_ENTRY *pEntry)
 
     WaitForInputIdle(info.hProcess, INFINITE);
 
-    // 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();
 
     if (WaitForSingleObject(info.hProcess, 10 * 1000) == WAIT_TIMEOUT)
     {

Reply via email to