user32/tests: Remove unnecessary uses of CREATE_SUSPENDED.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2019-12-27 10:37:37 -06:00 committed by Alexandre Julliard
parent ddb6f150e1
commit 7473db002e
1 changed files with 46 additions and 56 deletions

View File

@ -43,6 +43,22 @@ static WNDPROC old_dde_client_wndproc;
static const DWORD default_timeout = 200; static const DWORD default_timeout = 200;
static HANDLE create_process(const char *arg)
{
STARTUPINFOA si = {.cb = sizeof(si)};
PROCESS_INFORMATION pi;
char cmdline[200];
char **argv;
BOOL ret;
winetest_get_mainargs(&argv);
sprintf(cmdline, "\"%s\" %s %s", argv[0], argv[1], arg);
ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
ok(ret, "CreateProcess failed: %u\n", GetLastError());
CloseHandle(pi.hThread);
return pi.hProcess;
}
static BOOL is_cjk(void) static BOOL is_cjk(void)
{ {
int lang_id = PRIMARYLANGID(GetUserDefaultLangID()); int lang_id = PRIMARYLANGID(GetUserDefaultLangID());
@ -253,23 +269,25 @@ static LRESULT WINAPI dde_server_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPA
return DefWindowProcA(hwnd, msg, wparam, lparam); return DefWindowProcA(hwnd, msg, wparam, lparam);
} }
static void test_msg_server(HANDLE hproc, HANDLE hthread) static void test_msg_server(void)
{ {
HANDLE client;
MSG msg; MSG msg;
HWND hwnd; HWND hwnd;
DWORD res; DWORD res;
create_dde_window(&hwnd, "dde_server", dde_server_wndproc); create_dde_window(&hwnd, "dde_server", dde_server_wndproc);
ResumeThread( hthread ); client = create_process("ddeml");
while (MsgWaitForMultipleObjects( 1, &hproc, FALSE, INFINITE, QS_ALLINPUT ) != 0) while (MsgWaitForMultipleObjects(1, &client, FALSE, INFINITE, QS_ALLINPUT) != 0)
{ {
while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
} }
destroy_dde_window(&hwnd, "dde_server"); destroy_dde_window(&hwnd, "dde_server");
GetExitCodeProcess( hproc, &res ); GetExitCodeProcess(client, &res);
ok( !res, "client failed with %u error(s)\n", res ); ok( !res, "client failed with %u error(s)\n", res );
CloseHandle(client);
} }
static HDDEDATA CALLBACK client_ddeml_callback(UINT uType, UINT uFmt, HCONV hconv, static HDDEDATA CALLBACK client_ddeml_callback(UINT uType, UINT uFmt, HCONV hconv,
@ -823,14 +841,17 @@ static HDDEDATA CALLBACK server_ddeml_callback(UINT uType, UINT uFmt, HCONV hcon
return 0; return 0;
} }
static void test_ddeml_server(HANDLE hproc) static void test_ddeml_server(void)
{ {
HANDLE client;
MSG msg; MSG msg;
UINT res; UINT res;
BOOL ret; BOOL ret;
HSZ server; HSZ server;
HDDEDATA hdata; HDDEDATA hdata;
client = create_process("msg");
/* set up DDE server */ /* set up DDE server */
server_pid = 0; server_pid = 0;
res = DdeInitializeA(&server_pid, server_ddeml_callback, APPCLASS_STANDARD, 0); res = DdeInitializeA(&server_pid, server_ddeml_callback, APPCLASS_STANDARD, 0);
@ -842,14 +863,15 @@ static void test_ddeml_server(HANDLE hproc)
hdata = DdeNameService(server_pid, server, 0, DNS_REGISTER); hdata = DdeNameService(server_pid, server, 0, DNS_REGISTER);
ok(hdata == (HDDEDATA)TRUE, "Expected TRUE, got %p\n", hdata); ok(hdata == (HDDEDATA)TRUE, "Expected TRUE, got %p\n", hdata);
while (MsgWaitForMultipleObjects( 1, &hproc, FALSE, INFINITE, QS_ALLINPUT ) != 0) while (MsgWaitForMultipleObjects(1, &client, FALSE, INFINITE, QS_ALLINPUT) != 0)
{ {
while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
} }
ret = DdeUninitialize(server_pid); ret = DdeUninitialize(server_pid);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret); ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
GetExitCodeProcess( hproc, &res ); GetExitCodeProcess(client, &res);
ok( !res, "client failed with %u error(s)\n", res ); ok( !res, "client failed with %u error(s)\n", res );
CloseHandle(client);
} }
static HWND client_hwnd, server_hwnd; static HWND client_hwnd, server_hwnd;
@ -2683,8 +2705,9 @@ static void test_end_to_end_client(BOOL type_a)
} }
static void test_end_to_end_server(HANDLE hproc, HANDLE hthread, BOOL type_a) static void test_end_to_end_server(BOOL client_unicode, BOOL server_unicode)
{ {
HANDLE client;
MSG msg; MSG msg;
HSZ server; HSZ server;
BOOL ret; BOOL ret;
@ -2692,13 +2715,14 @@ static void test_end_to_end_server(HANDLE hproc, HANDLE hthread, BOOL type_a)
HDDEDATA hdata; HDDEDATA hdata;
static const char test_service[] = "TestDDEService"; static const char test_service[] = "TestDDEService";
trace("start end to end server %s\n", type_a ? "ASCII" : "UNICODE"); trace("client %s, server %s\n", client_unicode ? "unicode" : "ascii",
server_unicode ? "unicode" : "ascii");
server_pid = 0; server_pid = 0;
if (type_a) if (server_unicode)
res = DdeInitializeA(&server_pid, server_end_to_end_callback, APPCLASS_STANDARD, 0);
else
res = DdeInitializeW(&server_pid, server_end_to_end_callback, APPCLASS_STANDARD, 0); res = DdeInitializeW(&server_pid, server_end_to_end_callback, APPCLASS_STANDARD, 0);
else
res = DdeInitializeA(&server_pid, server_end_to_end_callback, APPCLASS_STANDARD, 0);
ok(res == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", res); ok(res == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", res);
server = DdeCreateStringHandleA(server_pid, test_service, CP_WINANSI); server = DdeCreateStringHandleA(server_pid, test_service, CP_WINANSI);
@ -2706,27 +2730,25 @@ static void test_end_to_end_server(HANDLE hproc, HANDLE hthread, BOOL type_a)
hdata = DdeNameService(server_pid, server, 0, DNS_REGISTER); hdata = DdeNameService(server_pid, server, 0, DNS_REGISTER);
ok(hdata == (HDDEDATA)TRUE, "Expected TRUE, got %p\n", hdata); ok(hdata == (HDDEDATA)TRUE, "Expected TRUE, got %p\n", hdata);
ResumeThread( hthread );
client = create_process(client_unicode ? "endw" : "enda");
while (MsgWaitForMultipleObjects( 1, &hproc, FALSE, INFINITE, QS_ALLINPUT ) != 0) while (MsgWaitForMultipleObjects(1, &client, FALSE, INFINITE, QS_ALLINPUT) != 0)
{ {
while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg); while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
} }
ret = DdeUninitialize(server_pid); ret = DdeUninitialize(server_pid);
ok(ret == TRUE, "Expected TRUE, got %d\n", ret); ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
GetExitCodeProcess( hproc, &res ); GetExitCodeProcess(client, &res);
ok( !res, "client failed with %u error(s)\n", res ); ok( !res, "client failed with %u error(s)\n", res );
CloseHandle(client);
} }
START_TEST(dde) START_TEST(dde)
{ {
int argc; int argc;
char **argv; char **argv;
char buffer[MAX_PATH];
STARTUPINFOA startup;
PROCESS_INFORMATION proc;
DWORD dde_inst = 0xdeadbeef; DWORD dde_inst = 0xdeadbeef;
argc = winetest_get_mainargs(&argv); argc = winetest_get_mainargs(&argv);
@ -2754,30 +2776,12 @@ START_TEST(dde)
return; return;
} }
ZeroMemory(&startup, sizeof(STARTUPINFOA)); test_msg_server();
sprintf(buffer, "%s dde ddeml", argv[0]); test_ddeml_server();
startup.cb = sizeof(startup);
startup.dwFlags = STARTF_USESHOWWINDOW;
startup.wShowWindow = SW_SHOWNORMAL;
CreateProcessA(NULL, buffer, NULL, NULL, FALSE,
CREATE_SUSPENDED, NULL, NULL, &startup, &proc);
test_msg_server(proc.hProcess, proc.hThread);
sprintf(buffer, "%s dde msg", argv[0]);
CreateProcessA(NULL, buffer, NULL, NULL, FALSE,
0, NULL, NULL, &startup, &proc);
test_ddeml_server(proc.hProcess);
/* Test the combinations of A and W interfaces with A and W data /* Test the combinations of A and W interfaces with A and W data
end to end to ensure that data conversions are accurate */ end to end to ensure that data conversions are accurate */
sprintf(buffer, "%s dde enda", argv[0]); test_end_to_end_server(FALSE, FALSE);
CreateProcessA(NULL, buffer, NULL, NULL, FALSE,
CREATE_SUSPENDED, NULL, NULL, &startup, &proc);
test_end_to_end_server(proc.hProcess, proc.hThread, TRUE);
/* Don't bother testing W interfaces on Win9x/WinMe */ /* Don't bother testing W interfaces on Win9x/WinMe */
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
@ -2788,23 +2792,9 @@ START_TEST(dde)
} }
else else
{ {
sprintf(buffer, "%s dde endw", argv[0]); test_end_to_end_server(TRUE, TRUE);
CreateProcessA(NULL, buffer, NULL, NULL, FALSE, test_end_to_end_server(FALSE, TRUE);
CREATE_SUSPENDED, NULL, NULL, &startup, &proc); test_end_to_end_server(TRUE, FALSE);
test_end_to_end_server(proc.hProcess, proc.hThread, FALSE);
sprintf(buffer, "%s dde enda", argv[0]);
CreateProcessA(NULL, buffer, NULL, NULL, FALSE,
CREATE_SUSPENDED, NULL, NULL, &startup, &proc);
test_end_to_end_server(proc.hProcess, proc.hThread, FALSE);
sprintf(buffer, "%s dde endw", argv[0]);
CreateProcessA(NULL, buffer, NULL, NULL, FALSE,
CREATE_SUSPENDED, NULL, NULL, &startup, &proc);
test_end_to_end_server(proc.hProcess, proc.hThread, TRUE);
test_dde_aw_transaction( FALSE, TRUE ); test_dde_aw_transaction( FALSE, TRUE );
test_dde_aw_transaction( TRUE, FALSE ); test_dde_aw_transaction( TRUE, FALSE );