mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[SHELL32_APITEST] Don't hardcode C:\ReactOS (#2344)
All tests successful. CORE-14747
This commit is contained in:
parent
f3b1185cdc
commit
e7a51a0ae0
1 changed files with 113 additions and 168 deletions
|
@ -2,184 +2,129 @@
|
|||
* PROJECT: ReactOS api tests
|
||||
* LICENSE: GPLv2+ - See COPYING in the top level directory
|
||||
* PURPOSE: Testing ShellExecuteW
|
||||
* PROGRAMMER: Doug Lyons <douglyons@douglyons.com>
|
||||
* PROGRAMMERS: Doug Lyons <douglyons@douglyons.com>
|
||||
* Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
||||
*/
|
||||
|
||||
#include "shelltest.h"
|
||||
#include <stdio.h>
|
||||
#include <winbase.h>
|
||||
#include <shlwapi.h>
|
||||
|
||||
static
|
||||
VOID
|
||||
TestShellExecuteW()
|
||||
{
|
||||
HINSTANCE hInstance;
|
||||
INT retval;
|
||||
HWND hWnd;
|
||||
const WCHAR *Name = L"ShellExecuteW";
|
||||
WCHAR WindowsDirectory[MAX_PATH];
|
||||
BOOL IsReactOS;
|
||||
#define WAIT_SLEEP 700
|
||||
|
||||
/* 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
|
||||
}
|
||||
// ShellExecuteW(handle, "open", <path_to_executable>, <parameters>, NULL, SW_SHOWNORMAL);
|
||||
|
||||
START_TEST(ShellExecuteW)
|
||||
{
|
||||
TestShellExecuteW();
|
||||
INT ret;
|
||||
HINSTANCE hInstance;
|
||||
HWND hWnd;
|
||||
WCHAR WinDir[MAX_PATH], SysDir[MAX_PATH], SysDrive[MAX_PATH];
|
||||
|
||||
if (!GetWindowsDirectoryW(WinDir, _countof(WinDir)))
|
||||
{
|
||||
skip("GetWindowsDirectoryW failed\n");
|
||||
return;
|
||||
}
|
||||
if (!GetSystemDirectoryW(SysDir, _countof(SysDir)))
|
||||
{
|
||||
skip("GetSystemDirectoryW failed\n");
|
||||
return;
|
||||
}
|
||||
if (!GetEnvironmentVariableW(L"SystemDrive", SysDrive, _countof(SysDrive)))
|
||||
{
|
||||
trace("GetEnvironmentVariableW('SystemDrive') failed\n");
|
||||
SysDrive[0] = SysDir[0];
|
||||
SysDrive[1] = L':';
|
||||
SysDrive[2] = 0;
|
||||
}
|
||||
PathAddBackslashW(SysDrive);
|
||||
|
||||
// TEST #1: Open Control Panel
|
||||
hInstance = ShellExecuteW(NULL, L"open", L"rundll32.exe", L"shell32.dll,Control_RunDLL desk.cpl",
|
||||
NULL, SW_SHOWNORMAL);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
// 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, WinDir, NULL, NULL, SW_SHOWNORMAL) = 33
|
||||
// ShellExecuteW(NULL, L"open", SysDir, NULL, NULL, SW_SHOWNORMAL) = 33
|
||||
// ShellExecuteW(NULL, L"explore", SysDrive, NULL, NULL, SW_SHOWNORMAL) = 33
|
||||
// ShellExecuteW(NULL, L"find", SysDrive, NULL, NULL, SW_SHOWNORMAL) = 33
|
||||
|
|
Loading…
Reference in a new issue