mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 18:13:03 +00:00
[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.
This commit is contained in:
parent
f1332c7722
commit
f7c36c6d94
8 changed files with 210 additions and 277 deletions
|
@ -10,18 +10,22 @@
|
|||
#include <stdio.h>
|
||||
#include <winbase.h>
|
||||
#include <shlwapi.h>
|
||||
#include "closewnd.h"
|
||||
|
||||
#define WAIT_SLEEP 700
|
||||
|
||||
// ShellExecuteW(handle, "open", <path_to_executable>, <parameters>, NULL, SW_SHOWNORMAL);
|
||||
|
||||
static WINDOW_LIST s_List1, s_List2;
|
||||
|
||||
START_TEST(ShellExecuteW)
|
||||
{
|
||||
INT ret;
|
||||
HINSTANCE hInstance;
|
||||
HWND hWnd;
|
||||
WCHAR WinDir[MAX_PATH], SysDir[MAX_PATH], SysDrive[MAX_PATH];
|
||||
|
||||
GetWindowList(&s_List1);
|
||||
|
||||
if (!GetWindowsDirectoryW(WinDir, _countof(WinDir)))
|
||||
{
|
||||
skip("GetWindowsDirectoryW failed\n");
|
||||
|
@ -47,104 +51,57 @@ START_TEST(ShellExecuteW)
|
|||
ret = (INT)(UINT_PTR)hInstance;
|
||||
ok(ret > 31, "TEST #1: ret:%d, LastError: %ld\n", ret, GetLastError());
|
||||
trace("TEST #1 ret: %d.\n", ret);
|
||||
if (hInstance)
|
||||
{
|
||||
Sleep(WAIT_SLEEP);
|
||||
// Terminate Window
|
||||
hWnd = FindWindowW(NULL, L"Display Properties");
|
||||
PostMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
|
||||
}
|
||||
|
||||
// TEST #2: Open Notepad
|
||||
hInstance = ShellExecuteW(NULL, L"open", L"notepad.exe", NULL, NULL, SW_SHOWNORMAL);
|
||||
ret = (INT)(UINT_PTR)hInstance;
|
||||
ok(ret > 31, "TEST #2: ret:%d, LastError: %ld\n", ret, GetLastError());
|
||||
trace("TEST #2 ret: %d.\n", ret);
|
||||
if (hInstance)
|
||||
{
|
||||
Sleep(WAIT_SLEEP);
|
||||
// Terminate Window
|
||||
hWnd = FindWindowW(L"Notepad", L"Untitled - Notepad");
|
||||
PostMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
|
||||
}
|
||||
|
||||
// TEST #3: Open Windows folder
|
||||
hInstance = ShellExecuteW(NULL, NULL, WinDir, NULL, NULL, SW_SHOWNORMAL);
|
||||
ret = (INT)(UINT_PTR)hInstance;
|
||||
ok(ret > 31, "TEST #3: ret:%d, LastError: %ld\n", ret, GetLastError());
|
||||
trace("TEST #3 ret: %d.\n", ret);
|
||||
if (hInstance)
|
||||
{
|
||||
Sleep(WAIT_SLEEP);
|
||||
// Terminate Window
|
||||
hWnd = FindWindowW(L"CabinetWClass", WinDir);
|
||||
PostMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
|
||||
}
|
||||
|
||||
// TEST #4: Open system32 folder
|
||||
hInstance = ShellExecuteW(NULL, L"open", SysDir, NULL, NULL, SW_SHOWNORMAL);
|
||||
ret = (INT)(UINT_PTR)hInstance;
|
||||
ok(ret > 31, "TEST #4: ret:%d, LastError: %ld\n", ret, GetLastError());
|
||||
trace("TEST #4 ret: %d.\n", ret);
|
||||
if (hInstance)
|
||||
{
|
||||
Sleep(WAIT_SLEEP);
|
||||
// Terminate Window
|
||||
hWnd = FindWindowW(L"CabinetWClass", SysDir);
|
||||
PostMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
|
||||
}
|
||||
|
||||
// TEST #5: Open %SystemDrive%
|
||||
hInstance = ShellExecuteW(NULL, L"explore", SysDrive, NULL, NULL, SW_SHOWNORMAL);
|
||||
ret = (INT)(UINT_PTR)hInstance;
|
||||
ok(ret > 31, "TEST #5: ret:%d, LastError: %ld\n", ret, GetLastError());
|
||||
trace("TEST #5 ret: %d.\n", ret);
|
||||
if (hInstance)
|
||||
{
|
||||
Sleep(WAIT_SLEEP);
|
||||
// Terminate Window
|
||||
hWnd = FindWindowW(L"ExploreWClass", SysDrive);
|
||||
PostMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
|
||||
}
|
||||
|
||||
// TEST #6: Open Explorer Search on %SYSTEMDRIVE%
|
||||
hInstance = ShellExecuteW(NULL, L"find", SysDrive, NULL, NULL, SW_SHOWNORMAL);
|
||||
ret = (INT)(UINT_PTR)hInstance;
|
||||
ok(ret > 31, "TEST #6: ret:%d, LastError: %ld\n", ret, GetLastError());
|
||||
trace("TEST #6 ret: %d.\n", ret);
|
||||
if (hInstance)
|
||||
{
|
||||
Sleep(WAIT_SLEEP);
|
||||
// Terminate Window
|
||||
hWnd = FindWindowW(L"CabinetWClass", L"Search Results");
|
||||
PostMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
|
||||
}
|
||||
|
||||
// TEST #7: Open My Documents ("::{450d8fba-ad25-11d0-98a8-0800361b1103}")
|
||||
hInstance = ShellExecuteW(NULL, NULL, L"::{450d8fba-ad25-11d0-98a8-0800361b1103}", NULL, NULL, SW_SHOWNORMAL);
|
||||
ret = (INT)(UINT_PTR)hInstance;
|
||||
ok(ret > 31, "TEST #7: ret:%d, LastError: %ld\n", ret, GetLastError());
|
||||
trace("TEST #7 ret: %d.\n", ret);
|
||||
if (hInstance)
|
||||
{
|
||||
Sleep(WAIT_SLEEP);
|
||||
// Terminate Window
|
||||
hWnd = FindWindowW(L"CabinetWClass", NULL);
|
||||
PostMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
|
||||
}
|
||||
|
||||
// TEST #8: Open My Documents ("shell:::{450d8fba-ad25-11d0-98a8-0800361b1103}")
|
||||
hInstance = ShellExecuteW(NULL, L"open", L"shell:::{450d8fba-ad25-11d0-98a8-0800361b1103}", NULL, NULL, SW_SHOWNORMAL);
|
||||
ret = (INT)(UINT_PTR)hInstance;
|
||||
ok(ret > 31, "TEST #8: ret:%d, LastError: %ld\n", ret, GetLastError());
|
||||
trace("TEST #8 ret: %d.\n", ret);
|
||||
if (hInstance)
|
||||
{
|
||||
Sleep(WAIT_SLEEP);
|
||||
// Terminate Window
|
||||
hWnd = FindWindowW(L"CabinetWClass", NULL);
|
||||
PostMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
|
||||
}
|
||||
|
||||
// Execution can be asynchronous; you have to wait for it to finish.
|
||||
Sleep(2000);
|
||||
|
||||
// Close newly-opened window(s)
|
||||
GetWindowList(&s_List2);
|
||||
CloseNewWindows(&s_List1, &s_List2);
|
||||
FreeWindowList(&s_List1);
|
||||
FreeWindowList(&s_List2);
|
||||
}
|
||||
|
||||
// Windows Server 2003 and Windows XP SP3 return values (Win 7 returns 42 in all cases)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue