mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
[SHELL32_APITEST] Add SHRestricted testcase (#6558)
I have a plan to implement shell32!SHRestricted correctly. JIRA issue: CORE-11515 - Get SHRestricted and SHSettingsChanged procedures from shell32.dll. - Use them and check the results.
This commit is contained in:
parent
d0e29248e3
commit
b944563c7b
3 changed files with 112 additions and 0 deletions
|
@ -28,6 +28,7 @@ list(APPEND SOURCE
|
|||
SHCreateFileDataObject.cpp
|
||||
SHCreateFileExtractIconW.cpp
|
||||
SHParseDisplayName.cpp
|
||||
SHRestricted.cpp
|
||||
She.cpp
|
||||
ShellExecCmdLine.cpp
|
||||
ShellExecuteEx.cpp
|
||||
|
|
108
modules/rostests/apitests/shell32/SHRestricted.cpp
Normal file
108
modules/rostests/apitests/shell32/SHRestricted.cpp
Normal file
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* PROJECT: ReactOS API tests
|
||||
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
||||
* PURPOSE: Test for SHRestricted
|
||||
* COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
|
||||
*/
|
||||
|
||||
#include "shelltest.h"
|
||||
#include <versionhelpers.h>
|
||||
|
||||
#define REGKEY_POLICIES L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies"
|
||||
#define REGKEY_POLICIES_EXPLORER REGKEY_POLICIES L"\\Explorer"
|
||||
|
||||
typedef DWORD (WINAPI *FN_SHRestricted)(RESTRICTIONS rest);
|
||||
typedef BOOL (WINAPI *FN_SHSettingsChanged)(LPCVOID unused, LPCVOID inpRegKey);
|
||||
|
||||
#define DELETE_VALUE(hBaseKey) \
|
||||
SHDeleteValueW((hBaseKey), REGKEY_POLICIES_EXPLORER, L"NoRun")
|
||||
|
||||
#define SET_VALUE(hBaseKey, value) do { \
|
||||
dwValue = (value); \
|
||||
SHSetValueW((hBaseKey), REGKEY_POLICIES_EXPLORER, L"NoRun", \
|
||||
REG_DWORD, &dwValue, sizeof(dwValue)); \
|
||||
} while (0)
|
||||
|
||||
static VOID
|
||||
TEST_SHRestricted(FN_SHRestricted fnGetValue, FN_SHSettingsChanged fnRefresh)
|
||||
{
|
||||
DWORD dwValue;
|
||||
|
||||
DELETE_VALUE(HKEY_CURRENT_USER);
|
||||
DELETE_VALUE(HKEY_LOCAL_MACHINE);
|
||||
|
||||
fnRefresh(NULL, NULL);
|
||||
ok_long(fnGetValue(REST_NORUN), 0);
|
||||
|
||||
SET_VALUE(HKEY_CURRENT_USER, 0);
|
||||
DELETE_VALUE(HKEY_LOCAL_MACHINE);
|
||||
|
||||
ok_long(fnGetValue(REST_NORUN), 0);
|
||||
fnRefresh(NULL, NULL);
|
||||
ok_long(fnGetValue(REST_NORUN), 0);
|
||||
|
||||
SET_VALUE(HKEY_CURRENT_USER, 1);
|
||||
DELETE_VALUE(HKEY_LOCAL_MACHINE);
|
||||
|
||||
ok_long(fnGetValue(REST_NORUN), 0);
|
||||
fnRefresh(NULL, NULL);
|
||||
ok_long(fnGetValue(REST_NORUN), 1);
|
||||
|
||||
DELETE_VALUE(HKEY_CURRENT_USER);
|
||||
SET_VALUE(HKEY_LOCAL_MACHINE, 0);
|
||||
|
||||
ok_long(fnGetValue(REST_NORUN), 1);
|
||||
fnRefresh(NULL, NULL);
|
||||
ok_long(fnGetValue(REST_NORUN), 0);
|
||||
|
||||
DELETE_VALUE(HKEY_CURRENT_USER);
|
||||
SET_VALUE(HKEY_LOCAL_MACHINE, 1);
|
||||
|
||||
ok_long(fnGetValue(REST_NORUN), 0);
|
||||
fnRefresh(NULL, NULL);
|
||||
ok_long(fnGetValue(REST_NORUN), 1);
|
||||
|
||||
SET_VALUE(HKEY_CURRENT_USER, 2);
|
||||
SET_VALUE(HKEY_LOCAL_MACHINE, 1);
|
||||
|
||||
ok_long(fnGetValue(REST_NORUN), 1);
|
||||
fnRefresh(NULL, NULL);
|
||||
ok_long(fnGetValue(REST_NORUN), 1);
|
||||
|
||||
DELETE_VALUE(HKEY_CURRENT_USER);
|
||||
DELETE_VALUE(HKEY_LOCAL_MACHINE);
|
||||
|
||||
ok_long(fnGetValue(REST_NORUN), 1);
|
||||
fnRefresh(NULL, NULL);
|
||||
ok_long(fnGetValue(REST_NORUN), 0);
|
||||
}
|
||||
|
||||
START_TEST(SHRestricted)
|
||||
{
|
||||
if (IsWindowsVistaOrGreater())
|
||||
{
|
||||
skip("Vista+");
|
||||
return;
|
||||
}
|
||||
|
||||
HMODULE hSHELL32 = LoadLibraryW(L"shell32.dll");
|
||||
FN_SHRestricted fnGetValue;
|
||||
FN_SHSettingsChanged fnRefresh;
|
||||
|
||||
fnGetValue = (FN_SHRestricted)GetProcAddress(hSHELL32, MAKEINTRESOURCEA(100));
|
||||
fnRefresh = (FN_SHSettingsChanged)GetProcAddress(hSHELL32, MAKEINTRESOURCEA(244));
|
||||
|
||||
if (fnGetValue && fnRefresh)
|
||||
{
|
||||
TEST_SHRestricted(fnGetValue, fnRefresh);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!fnGetValue)
|
||||
skip("SHRestricted not found\n");
|
||||
if (!fnRefresh)
|
||||
skip("SHSettingsChanged not found\n");
|
||||
}
|
||||
|
||||
FreeLibrary(hSHELL32);
|
||||
}
|
|
@ -38,6 +38,7 @@ extern void func_ShellState(void);
|
|||
extern void func_SHGetAttributesFromDataObject(void);
|
||||
extern void func_SHLimitInputEdit(void);
|
||||
extern void func_SHParseDisplayName(void);
|
||||
extern void func_SHRestricted(void);
|
||||
|
||||
const struct test winetest_testlist[] =
|
||||
{
|
||||
|
@ -76,5 +77,7 @@ const struct test winetest_testlist[] =
|
|||
{ "SHGetAttributesFromDataObject", func_SHGetAttributesFromDataObject },
|
||||
{ "SHLimitInputEdit", func_SHLimitInputEdit },
|
||||
{ "SHParseDisplayName", func_SHParseDisplayName },
|
||||
{ "SHRestricted", func_SHRestricted },
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue