mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 12:26:09 +00:00
[SHELL32_APITEST] Add Regression Test for ShellExecuteW(). (#2166)
Add a testcase for ShellExecuteW regression. This test also shows the results of ShellExecuteW's return value. Addendum to PR#1854. CORE-12266
This commit is contained in:
parent
3fa95ab912
commit
76aaded77d
3 changed files with 188 additions and 0 deletions
|
@ -27,6 +27,7 @@ list(APPEND SOURCE
|
||||||
SHParseDisplayName.cpp
|
SHParseDisplayName.cpp
|
||||||
ShellExecCmdLine.cpp
|
ShellExecCmdLine.cpp
|
||||||
ShellExecuteEx.cpp
|
ShellExecuteEx.cpp
|
||||||
|
ShellExecuteW.cpp
|
||||||
ShellState.cpp
|
ShellState.cpp
|
||||||
SHLimitInputEdit.cpp
|
SHLimitInputEdit.cpp
|
||||||
menu.cpp
|
menu.cpp
|
||||||
|
|
185
modules/rostests/apitests/shell32/ShellExecuteW.cpp
Normal file
185
modules/rostests/apitests/shell32/ShellExecuteW.cpp
Normal file
|
@ -0,0 +1,185 @@
|
||||||
|
/*
|
||||||
|
* PROJECT: ReactOS api tests
|
||||||
|
* LICENSE: GPLv2+ - See COPYING in the top level directory
|
||||||
|
* PURPOSE: Testing ShellExecuteW
|
||||||
|
* PROGRAMMER: Doug Lyons <douglyons@douglyons.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "shelltest.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <winbase.h>
|
||||||
|
|
||||||
|
static
|
||||||
|
VOID
|
||||||
|
TestShellExecuteW()
|
||||||
|
{
|
||||||
|
HINSTANCE hInstance;
|
||||||
|
INT retval;
|
||||||
|
HWND hWnd;
|
||||||
|
const WCHAR *Name = L"ShellExecuteW";
|
||||||
|
WCHAR WindowsDirectory[MAX_PATH];
|
||||||
|
BOOL IsReactOS;
|
||||||
|
|
||||||
|
/* Check if we are running under ReactOS from the SystemRoot directory */
|
||||||
|
if(!GetWindowsDirectoryW(WindowsDirectory, MAX_PATH))
|
||||||
|
printf("GetWindowsDirectoryW failed\n");
|
||||||
|
|
||||||
|
IsReactOS = !_wcsnicmp(&WindowsDirectory[3], L"reactos", 7);
|
||||||
|
|
||||||
|
printf("OSVendor %s ReactOS.\n", IsReactOS ? "is" : "is not");
|
||||||
|
|
||||||
|
// ShellExecuteW(handle, "open", <fully_qualified_path_to_executable>, <parameters>, NULL, SW_SHOWNORMAL);
|
||||||
|
|
||||||
|
hInstance = ShellExecuteW(NULL, L"open", L"rundll32.exe", L"shell32.dll,Control_RunDLL desk.cpl",
|
||||||
|
NULL, SW_SHOWNORMAL);
|
||||||
|
retval = (UINT_PTR) hInstance;
|
||||||
|
|
||||||
|
printf("Return Value for Open Control Panel is '%d'.\n", retval);
|
||||||
|
|
||||||
|
ok(retval > 31, "ShellExecuteEx lpFile %s failed. Error: %lu\n",
|
||||||
|
wine_dbgstr_w(Name), GetLastError());
|
||||||
|
|
||||||
|
if (hInstance)
|
||||||
|
{
|
||||||
|
LPCWSTR lpWinTitle = L"Display Properties";
|
||||||
|
Sleep(1000);
|
||||||
|
hWnd = FindWindowW(NULL, lpWinTitle);
|
||||||
|
PostMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0); // Terminate Window
|
||||||
|
}
|
||||||
|
// End of test #1 - Open Control Panel
|
||||||
|
|
||||||
|
|
||||||
|
// ShellExecuteW(handle, "open", <fully_qualified_path_to_executable>, NULL, NULL, SW_SHOWNORMAL);
|
||||||
|
|
||||||
|
hInstance = ShellExecuteW(NULL, L"open", L"notepad.exe", NULL, NULL, SW_SHOWNORMAL);
|
||||||
|
retval = (UINT_PTR) hInstance;
|
||||||
|
|
||||||
|
printf("Return Value for Open notepad.exe is '%d'.\n", retval);
|
||||||
|
|
||||||
|
ok(retval > 31, "ShellExecuteEx lpFile %s failed. Error: %lu\n",
|
||||||
|
wine_dbgstr_w(Name), GetLastError());
|
||||||
|
|
||||||
|
if (hInstance)
|
||||||
|
{
|
||||||
|
LPCWSTR lpWinClass = L"Notepad";
|
||||||
|
LPCWSTR lpWinTitle = L"Untitled - Notepad";
|
||||||
|
Sleep(1000);
|
||||||
|
hWnd = FindWindowW(lpWinClass, lpWinTitle);
|
||||||
|
PostMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0); // Terminate Window
|
||||||
|
}
|
||||||
|
// End of test #2 - Open notepad.exe
|
||||||
|
|
||||||
|
|
||||||
|
// ShellExecuteW(handle, NULL, <fully_qualified_path_to_folder>, NULL, NULL, SW_SHOWNORMAL);
|
||||||
|
|
||||||
|
if(IsReactOS)
|
||||||
|
hInstance = ShellExecuteW(NULL, NULL, L"C:\\ReactOS", NULL,
|
||||||
|
NULL, SW_SHOWNORMAL);
|
||||||
|
else
|
||||||
|
hInstance = ShellExecuteW(NULL, NULL, L"C:\\Windows", NULL,
|
||||||
|
NULL, SW_SHOWNORMAL);
|
||||||
|
|
||||||
|
retval = (UINT_PTR) hInstance;
|
||||||
|
|
||||||
|
printf("Return Value for Open %s is '%d'.\n", IsReactOS ? "C:\\ReactOS" : "C:\\Windows", retval);
|
||||||
|
|
||||||
|
ok(retval > 31, "ShellExecuteEx lpFile %s failed. Error: %lu\n",
|
||||||
|
wine_dbgstr_w(Name), GetLastError());
|
||||||
|
|
||||||
|
if (hInstance)
|
||||||
|
{
|
||||||
|
LPCWSTR lpWinClass = L"CabinetWClass";
|
||||||
|
LPCWSTR lpWinTitleWindows = L"C:\\Windows";
|
||||||
|
LPCWSTR lpWinTitleReactOS = L"C:\\ReactOS";
|
||||||
|
|
||||||
|
Sleep(1000);
|
||||||
|
if (IsReactOS)
|
||||||
|
hWnd = FindWindowW(lpWinClass, lpWinTitleReactOS);
|
||||||
|
else
|
||||||
|
hWnd = FindWindowW(lpWinClass, lpWinTitleWindows);
|
||||||
|
PostMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0); // Terminate Window
|
||||||
|
}
|
||||||
|
// End of test #3 - Open C:\Windows
|
||||||
|
|
||||||
|
|
||||||
|
// ShellExecuteW(handle, "open", <fully_qualified_path_to_folder>, NULL, NULL, SW_SHOWNORMAL);
|
||||||
|
|
||||||
|
if(IsReactOS)
|
||||||
|
hInstance = ShellExecuteW(NULL, L"open", L"C:\\ReactOS\\system32", NULL,
|
||||||
|
NULL, SW_SHOWNORMAL);
|
||||||
|
else
|
||||||
|
hInstance = ShellExecuteW(NULL, L"open", L"C:\\Windows\\system32", NULL,
|
||||||
|
NULL, SW_SHOWNORMAL);
|
||||||
|
|
||||||
|
retval = (UINT_PTR) hInstance;
|
||||||
|
|
||||||
|
printf("Return Value for C:\\...\\system32 is '%d'.\n", retval);
|
||||||
|
|
||||||
|
ok(retval > 31, "ShellExecuteEx lpFile %s failed. Error: %lu\n",
|
||||||
|
wine_dbgstr_w(Name), GetLastError());
|
||||||
|
|
||||||
|
if (hInstance)
|
||||||
|
{
|
||||||
|
LPCWSTR lpWinClass = L"CabinetWClass";
|
||||||
|
LPCWSTR lpWinTitle = L"C:\\Windows\\system32";
|
||||||
|
Sleep(1000);
|
||||||
|
hWnd = FindWindowW(lpWinClass, lpWinTitle);
|
||||||
|
PostMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0); // Terminate Window
|
||||||
|
}
|
||||||
|
// End of test #4 - Open C:\Windows\system32
|
||||||
|
|
||||||
|
|
||||||
|
// ShellExecuteW(handle, "explore", <fully_qualified_path_to_folder>, NULL, NULL, SW_SHOWNORMAL);
|
||||||
|
|
||||||
|
hInstance = ShellExecuteW(NULL, L"explore", L"C:\\", NULL, NULL, SW_SHOWNORMAL);
|
||||||
|
retval = (UINT_PTR) hInstance;
|
||||||
|
|
||||||
|
printf("Return Value for explore c:\\ is '%d'.\n", retval);
|
||||||
|
|
||||||
|
ok(retval > 31, "ShellExecuteEx lpFile %s failed. Error: %lu\n",
|
||||||
|
wine_dbgstr_w(Name), GetLastError());
|
||||||
|
|
||||||
|
if (hInstance)
|
||||||
|
{
|
||||||
|
LPCWSTR lpWinClass = L"ExploreWClass";
|
||||||
|
LPCWSTR lpWinTitle = L"C:\\";
|
||||||
|
Sleep(1000);
|
||||||
|
hWnd = FindWindowW(lpWinClass, lpWinTitle);
|
||||||
|
PostMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0); // Terminate Window
|
||||||
|
}
|
||||||
|
// End of test #5 - explore C:
|
||||||
|
|
||||||
|
|
||||||
|
// ShellExecuteW(handle, "find", <fully_qualified_path_to_folder>, NULL, NULL, 0);
|
||||||
|
|
||||||
|
hInstance = ShellExecuteW(NULL, L"find", L"C:\\", NULL, NULL, SW_SHOWNORMAL);
|
||||||
|
retval = (UINT_PTR) hInstance;
|
||||||
|
|
||||||
|
printf("Return Value for find is '%d'.\n", retval);
|
||||||
|
|
||||||
|
ok(retval > 31, "ShellExecuteEx lpFile %s failed. Error: %lu\n",
|
||||||
|
wine_dbgstr_w(Name), GetLastError());
|
||||||
|
|
||||||
|
if (hInstance)
|
||||||
|
{
|
||||||
|
LPCWSTR lpWinClass = L"CabinetWClass";
|
||||||
|
LPCWSTR lpWinTitle = L"Search Results";
|
||||||
|
Sleep(1000);
|
||||||
|
hWnd = FindWindowW(lpWinClass, lpWinTitle);
|
||||||
|
PostMessage(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0); // Terminate Window
|
||||||
|
}
|
||||||
|
// End of test #6 - find
|
||||||
|
}
|
||||||
|
|
||||||
|
START_TEST(ShellExecuteW)
|
||||||
|
{
|
||||||
|
TestShellExecuteW();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Windows Server 2003 and Windows XP SP3 return values (Win 7 returns 42 in all cases)
|
||||||
|
// ShellExecuteW(NULL, L"open", L"rundll32.exe", L"shell32.dll,Control_RunDLL desk.cpl", NULL, SW_SHOWNORMAL) = 42
|
||||||
|
// ShellExecuteW(NULL, L"open", L"notepad.exe", NULL, NULL, SW_SHOWNORMAL) = 42
|
||||||
|
// ShellExecuteW(NULL, NULL, L"C:\\Windows", NULL, NULL, SW_SHOWNORMAL) = 33
|
||||||
|
// ShellExecuteW(NULL, L"open", L"C:\\Windows\\system32", NULL, NULL, SW_SHOWNORMAL) = 33
|
||||||
|
// ShellExecuteW(NULL, L"explore", L"C:\\", NULL, NULL, SW_SHOWNORMAL) = 33
|
||||||
|
// ShellExecuteW(NULL, L"find", L"C:\\", NULL, NULL, SW_SHOWNORMAL) = 33
|
|
@ -21,6 +21,7 @@ extern void func_SHCreateDataObject(void);
|
||||||
extern void func_SHCreateFileExtractIconW(void);
|
extern void func_SHCreateFileExtractIconW(void);
|
||||||
extern void func_ShellExecCmdLine(void);
|
extern void func_ShellExecCmdLine(void);
|
||||||
extern void func_ShellExecuteEx(void);
|
extern void func_ShellExecuteEx(void);
|
||||||
|
extern void func_ShellExecuteW(void);
|
||||||
extern void func_ShellState(void);
|
extern void func_ShellState(void);
|
||||||
extern void func_SHLimitInputEdit(void);
|
extern void func_SHLimitInputEdit(void);
|
||||||
extern void func_SHParseDisplayName(void);
|
extern void func_SHParseDisplayName(void);
|
||||||
|
@ -45,6 +46,7 @@ const struct test winetest_testlist[] =
|
||||||
{ "SHCreateFileExtractIconW", func_SHCreateFileExtractIconW },
|
{ "SHCreateFileExtractIconW", func_SHCreateFileExtractIconW },
|
||||||
{ "ShellExecCmdLine", func_ShellExecCmdLine },
|
{ "ShellExecCmdLine", func_ShellExecCmdLine },
|
||||||
{ "ShellExecuteEx", func_ShellExecuteEx },
|
{ "ShellExecuteEx", func_ShellExecuteEx },
|
||||||
|
{ "ShellExecuteW", func_ShellExecuteW },
|
||||||
{ "ShellState", func_ShellState },
|
{ "ShellState", func_ShellState },
|
||||||
{ "SHLimitInputEdit", func_SHLimitInputEdit },
|
{ "SHLimitInputEdit", func_SHLimitInputEdit },
|
||||||
{ "SHParseDisplayName", func_SHParseDisplayName },
|
{ "SHParseDisplayName", func_SHParseDisplayName },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue