reactos/modules/rostests/apitests/shell32/ShellExec_RunDLL.cpp
Katayama Hirofumi MZ f7c36c6d94
[SHELL32_APITEST] Certainly close newly-opened windows (#8171)
It's frustrating when windows open
during a test and remain after the test
is over.
JIRA issue: ROSTESTS-402
- Delete closewnd.cpp. Enhance
  closewnd.h.
- Modify ShellExecCmdLine,
  ShellExec_RunDLL, ShellExecuteEx,
  and ShellExecuteW testcases.
- Certainly close the newly-opened
  windows.
2025-06-26 18:20:49 +09:00

66 lines
1.6 KiB
C++

/*
* PROJECT: ReactOS API tests
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Test for ShellExec_RunDLL
* COPYRIGHT: Copyright 2025 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
#include "shelltest.h"
#include "closewnd.h"
#include <undocshell.h>
static WINDOW_LIST s_List1, s_List2;
static VOID TEST_ShellExec_RunDLL(VOID)
{
ShellExec_RunDLL(NULL, NULL, "?0?notepad.exe", SW_SHOWNORMAL);
}
static VOID TEST_ShellExec_RunDLLA(VOID)
{
ShellExec_RunDLLA(NULL, NULL, "?0?notepad.exe", SW_SHOWNORMAL);
}
static VOID TEST_ShellExec_RunDLLW(VOID)
{
ShellExec_RunDLLW(NULL, NULL, L"?0?notepad.exe", SW_SHOWNORMAL);
}
static BOOL CloseNotepad(VOID)
{
HWND hwndNew;
WCHAR szClass[64];
// Execution can be asynchronous; you have to wait for it to finish.
Sleep(1000);
// Close newly-opened window(s)
GetWindowList(&s_List2);
hwndNew = FindNewWindow(&s_List1, &s_List2);
if (!GetClassNameW(hwndNew, szClass, _countof(szClass)))
szClass[0] = UNICODE_NULL;
CloseNewWindows(&s_List1, &s_List2);
FreeWindowList(&s_List1);
FreeWindowList(&s_List2);
return lstrcmpiW(szClass, L"Notepad") == 0;
}
START_TEST(ShellExec_RunDLL)
{
BOOL ret;
GetWindowList(&s_List1);
TEST_ShellExec_RunDLL();
ret = CloseNotepad();
ok(ret, "Notepad not found\n");
GetWindowList(&s_List1);
TEST_ShellExec_RunDLLA();
ret = CloseNotepad();
ok(ret, "Notepad not found\n");
GetWindowList(&s_List1);
TEST_ShellExec_RunDLLW();
ret = CloseNotepad();
ok(ret, "Notepad not found\n");
}