Module: wine Branch: master Commit: ef224f1dd8033dc76fb8ac7b76ce50b3de70480a URL: https://gitlab.winehq.org/wine/wine/-/commit/ef224f1dd8033dc76fb8ac7b76ce50b...
Author: Rémi Bernon rbernon@codeweavers.com Date: Thu May 23 13:18:40 2024 +0200
win32u/tests: Introduce a new run_in_process helper.
---
dlls/win32u/tests/win32u.c | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-)
diff --git a/dlls/win32u/tests/win32u.c b/dlls/win32u/tests/win32u.c index f7fe74ed34c..78d2f21295c 100644 --- a/dlls/win32u/tests/win32u.c +++ b/dlls/win32u/tests/win32u.c @@ -29,6 +29,24 @@ #define check_member( val, exp, fmt, member ) \ check_member_( __FILE__, __LINE__, val, exp, fmt, member )
+#define run_in_process( a, b ) run_in_process_( __FILE__, __LINE__, a, b ) +static void run_in_process_( const char *file, int line, char **argv, const char *args ) +{ + STARTUPINFOA startup = {.cb = sizeof(STARTUPINFOA)}; + PROCESS_INFORMATION info = {0}; + char cmdline[MAX_PATH * 2]; + DWORD ret; + + sprintf( cmdline, "%s %s %s", argv[0], argv[1], args ); + ret = CreateProcessA( NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info ); + ok_(file, line)( ret, "CreateProcessA failed, error %lu\n", GetLastError() ); + if (!ret) return; + + wait_child_process( info.hProcess ); + CloseHandle( info.hThread ); + CloseHandle( info.hProcess ); +} + static void flush_events(void) { int min_timeout = 100, diff = 200; @@ -1305,7 +1323,7 @@ done: ok( ret, "UnregisterClassW failed: %lu\n", GetLastError() ); }
-static void test_NtUserEnableMouseInPointer_process( const char *arg ) +static void test_NtUserEnableMouseInPointer( const char *arg ) { DWORD enable = strtoul( arg, 0, 10 ); BOOL ret; @@ -1339,23 +1357,6 @@ static void test_NtUserEnableMouseInPointer_process( const char *arg ) test_NtUserGetPointerInfoList( enable ); }
-static void test_NtUserEnableMouseInPointer( char **argv, BOOL enable ) -{ - STARTUPINFOA startup = {.cb = sizeof(STARTUPINFOA)}; - PROCESS_INFORMATION info = {0}; - char cmdline[MAX_PATH * 2]; - BOOL ret; - - sprintf( cmdline, "%s %s NtUserEnableMouseInPointer %u", argv[0], argv[1], enable ); - ret = CreateProcessA( NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info ); - ok( ret, "CreateProcessA failed, error %lu\n", GetLastError() ); - if (!ret) return; - - wait_child_process( info.hProcess ); - CloseHandle( info.hThread ); - CloseHandle( info.hProcess ); -} - struct lparam_hook_test { const char *name; @@ -2060,7 +2061,7 @@ START_TEST(win32u) if (argc > 3 && !strcmp( argv[2], "NtUserEnableMouseInPointer" )) { winetest_push_context( "enable %s", argv[3] ); - test_NtUserEnableMouseInPointer_process( argv[3] ); + test_NtUserEnableMouseInPointer( argv[3] ); winetest_pop_context(); return; } @@ -2083,6 +2084,6 @@ START_TEST(win32u) test_NtUserCloseWindowStation(); test_NtUserDisplayConfigGetDeviceInfo();
- test_NtUserEnableMouseInPointer( argv, FALSE ); - test_NtUserEnableMouseInPointer( argv, TRUE ); + run_in_process( argv, "NtUserEnableMouseInPointer 0" ); + run_in_process( argv, "NtUserEnableMouseInPointer 1" ); }