Author: mjansen
Date: Sun Dec 4 15:33:28 2016
New Revision: 73422
URL:
http://svn.reactos.org/svn/reactos?rev=73422&view=rev
Log:
[APPSHIM_APITEST] Add tests for the DisableThemes shim. CORE-11927
Modified:
trunk/rostests/apitests/appshim/dispmode.c
Modified: trunk/rostests/apitests/appshim/dispmode.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/appshim/dispmode…
==============================================================================
--- trunk/rostests/apitests/appshim/dispmode.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/appshim/dispmode.c [iso-8859-1] Sun Dec 4 15:33:28 2016
@@ -46,7 +46,7 @@
static DEVMODEA g_LastDevmode;
static DWORD g_LastFlags;
-LONG (WINAPI *pChangeDisplaySettingsA)(_In_opt_ PDEVMODEA lpDevMode, _In_ DWORD
dwflags);
+static LONG (WINAPI *pChangeDisplaySettingsA)(_In_opt_ PDEVMODEA lpDevMode, _In_ DWORD
dwflags);
LONG WINAPI mChangeDisplaySettingsA(_In_opt_ PDEVMODEA lpDevMode, _In_ DWORD dwflags)
{
g_Count++;
@@ -56,15 +56,33 @@
return DISP_CHANGE_FAILED;
}
-
-static void pre_8bit()
+static LONG g_ThemeCount;
+static DWORD g_LastThemeFlags;
+
+static void (WINAPI *pSetThemeAppProperties)(DWORD dwFlags);
+void WINAPI mSetThemeAppProperties(DWORD dwFlags)
+{
+ g_ThemeCount++;
+ g_LastThemeFlags = dwFlags;
+}
+
+
+static const WCHAR* shim_dll(const WCHAR* name)
+{
+ static WCHAR buf[MAX_PATH];
+ pSdbGetAppPatchDir(NULL, buf, MAX_PATH);
+ StringCchCatW(buf, _countof(buf), name);
+ return buf;
+}
+
+static void pre_8bit(void)
{
g_Count = 0;
memset(&g_LastDevmode, 0, sizeof(g_LastDevmode));
g_LastFlags = 0xffffffff;
}
-static void post_8bit()
+static void post_8bit(void)
{
ok_int(g_Count, 1);
ok_hex(g_LastDevmode.dmFields & DM_BITSPERPEL, DM_BITSPERPEL);
@@ -72,14 +90,14 @@
ok_hex(g_LastFlags, CDS_FULLSCREEN);
}
-static void pre_640()
+static void pre_640(void)
{
g_Count = 0;
memset(&g_LastDevmode, 0, sizeof(g_LastDevmode));
g_LastFlags = 0xffffffff;
}
-static void post_640()
+static void post_640(void)
{
ok_int(g_Count, 1);
ok_hex(g_LastDevmode.dmFields & (DM_PELSWIDTH | DM_PELSHEIGHT), (DM_PELSWIDTH |
DM_PELSHEIGHT));
@@ -88,8 +106,17 @@
ok_hex(g_LastFlags, CDS_FULLSCREEN);
}
-
-
+static void pre_theme(void)
+{
+ g_ThemeCount = 0;
+ g_LastThemeFlags = 0xffffffff;
+}
+
+static void post_theme(void)
+{
+ ok_int(g_ThemeCount, 1);
+ ok_hex(g_LastThemeFlags, 0);
+}
static PIMAGE_IMPORT_DESCRIPTOR FindImportDescriptor(PBYTE DllBase, PCSTR DllName)
{
@@ -144,6 +171,15 @@
return FALSE;
}
+static BOOL hook_disp(HMODULE dll)
+{
+ return RedirectIat(dll, "user32.dll", "ChangeDisplaySettingsA",
(ULONG_PTR)mChangeDisplaySettingsA, (ULONG_PTR*)&pChangeDisplaySettingsA);
+}
+
+static BOOL hook_theme(HMODULE dll)
+{
+ return RedirectIat(dll, "uxtheme.dll", "SetThemeAppProperties",
(ULONG_PTR)mSetThemeAppProperties, (ULONG_PTR*)&pSetThemeAppProperties);
+}
static void test_one(LPCSTR shim, DWORD dwReason, void(*pre)(), void(*post)())
@@ -178,28 +214,30 @@
static struct test_info
{
const char* name;
+ const WCHAR* dll;
DWORD winver;
DWORD reason;
- void(*pre)();
- void(*post)();
+ BOOL(*hook)(HMODULE);
+ void(*pre)(void);
+ void(*post)(void);
} tests[] =
{
- { "Force8BitColor", WINVER_ANY, 1, pre_8bit, post_8bit },
- { "Force8BitColor", WINVER_VISTA, 100, pre_8bit, post_8bit },
- { "Force640x480", WINVER_ANY, 1, pre_640, post_640 },
- { "Force640x480", WINVER_VISTA, 100, pre_640, post_640 },
- /* { "DisableThemes" }, AcGenral.dll */
+ { "Force8BitColor", L"\\aclayers.dll", WINVER_ANY, 1, hook_disp,
pre_8bit, post_8bit },
+ { "Force8BitColor", L"\\aclayers.dll", WINVER_VISTA, 100,
hook_disp, pre_8bit, post_8bit },
+ { "Force640x480", L"\\aclayers.dll", WINVER_ANY, 1, hook_disp,
pre_640, post_640 },
+ { "Force640x480", L"\\aclayers.dll", WINVER_VISTA, 100,
hook_disp, pre_640, post_640 },
+ { "DisableThemes", L"\\acgenral.dll", WINVER_ANY, 1, hook_theme,
pre_theme, post_theme },
+ { "DisableThemes", L"\\acgenral.dll", WINVER_VISTA, 100,
hook_theme, pre_theme, post_theme },
};
-static void run_test(size_t n, WCHAR* buf, BOOL unload)
+static void run_test(size_t n, BOOL unload)
{
BOOL ret;
HMODULE dll;
-
- trace("Running %d (%s)\n", n, tests[n].name);
-
- dll = LoadLibraryW(buf);
+ const WCHAR* buf = shim_dll(tests[n].dll);
+
+ dll = LoadLibraryW(shim_dll(tests[n].dll));
pGetHookAPIs = (void*)GetProcAddress(dll, "GetHookAPIs");
pNotifyShims = (void*)GetProcAddress(dll, "NotifyShims");
@@ -210,14 +248,14 @@
return;
}
- ret = RedirectIat(dll, "user32.dll", "ChangeDisplaySettingsA",
(ULONG_PTR)mChangeDisplaySettingsA, (ULONG_PTR*)&pChangeDisplaySettingsA);
+ ret = tests[n].hook(dll);
if (ret)
{
test_one(tests[n].name, tests[n].reason, tests[n].pre, tests[n].post);
}
else
{
- ok(0, "Unable to redirect ChangeDisplaySettingsA!\n");
+ ok(0, "Unable to redirect functions!\n");
}
FreeLibrary(dll);
if (unload)
@@ -231,8 +269,6 @@
START_TEST(dispmode)
{
HMODULE dll = LoadLibraryA("apphelp.dll");
- WCHAR buf[MAX_PATH];
- WCHAR aclayers[] = L"\\aclayers.dll";
size_t n;
int argc;
char **argv;
@@ -246,26 +282,27 @@
g_WinVersion = get_host_winver();
- pSdbGetAppPatchDir(NULL, buf, MAX_PATH);
- StringCchCatW(buf, _countof(buf), aclayers);
-
argc = winetest_get_mainargs(&argv);
if (argc < 3)
{
WCHAR path[MAX_PATH];
GetModuleFileNameW(NULL, path, _countof(path));
- dll = GetModuleHandleW(buf);
+ dll = GetModuleHandleW(shim_dll(L"\\aclayers.dll"));
+ if (!dll)
+ dll = GetModuleHandleW(shim_dll(L"\\acgenral.dll"));
if (dll != NULL)
trace("Loaded under a shim, running each test in it's own
process\n");
for (n = 0; n < _countof(tests); ++n)
{
+ LONG failures = winetest_get_failures();
+
if (g_WinVersion < tests[n].winver)
continue;
if (dll == NULL)
{
- run_test(n, buf, TRUE);
+ run_test(n, TRUE);
}
else
{
@@ -284,6 +321,11 @@
CloseHandle(pi.hProcess);
}
}
+
+ if (failures != winetest_get_failures())
+ {
+ trace("Failures from %d (%s)\n", n, tests[n].name);
+ }
}
}
else
@@ -291,7 +333,7 @@
n = (size_t)atoi(argv[2]);
if (n >= 0 && n < _countof(tests))
{
- run_test(n, buf, FALSE);
+ run_test(n, FALSE);
}
else
{