mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
user32/tests: Add cross-process WindowFromPoint tests.
This commit is contained in:
parent
d137a95fda
commit
c86bd676c7
1 changed files with 96 additions and 2 deletions
|
@ -103,6 +103,22 @@ static void flush_events( BOOL remove_messages )
|
|||
}
|
||||
}
|
||||
|
||||
static BOOL wait_for_event(HANDLE event, int timeout)
|
||||
{
|
||||
DWORD end_time = GetTickCount() + timeout;
|
||||
MSG msg;
|
||||
|
||||
do {
|
||||
if(MsgWaitForMultipleObjects(1, &event, FALSE, timeout, QS_ALLINPUT) == WAIT_OBJECT_0)
|
||||
return TRUE;
|
||||
while(PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
|
||||
DispatchMessageA(&msg);
|
||||
timeout = end_time - GetTickCount();
|
||||
}while(timeout > 0);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* check the values returned by the various parent/owner functions on a given window */
|
||||
static void check_parents( HWND hwnd, HWND ga_parent, HWND gwl_parent, HWND get_parent,
|
||||
HWND gw_owner, HWND ga_root, HWND ga_root_owner )
|
||||
|
@ -7200,10 +7216,49 @@ todo_wine
|
|||
ok(ret, "UnregisterClass(my_window) failed\n");
|
||||
}
|
||||
|
||||
static void test_window_from_point(void)
|
||||
static void window_from_point_proc(HWND parent)
|
||||
{
|
||||
HANDLE start_event, end_event;
|
||||
HANDLE win, child_static, child_button;
|
||||
DWORD ret;
|
||||
POINT pt;
|
||||
|
||||
start_event = OpenEventA(EVENT_ALL_ACCESS, FALSE, "test_wfp_start");
|
||||
ok(start_event != 0, "OpenEvent failed\n");
|
||||
end_event = OpenEventA(EVENT_ALL_ACCESS, FALSE, "test_wfp_end");
|
||||
ok(end_event != 0, "OpenEvent failed\n");
|
||||
|
||||
child_static = CreateWindowExA(0, "static", "static", WS_CHILD | WS_VISIBLE,
|
||||
0, 0, 100, 100, parent, 0, NULL, NULL);
|
||||
ok(child_static != 0, "CreateWindowEx failed\n");
|
||||
pt.x = pt.y = 150;
|
||||
win = WindowFromPoint(pt);
|
||||
ok(win == parent, "WindowFromPoint returned %p, expected %p\n", win, parent);
|
||||
|
||||
child_button = CreateWindowExA(0, "button", "button", WS_CHILD | WS_VISIBLE,
|
||||
100, 0, 100, 100, parent, 0, NULL, NULL);
|
||||
ok(child_button != 0, "CreateWindowEx failed\n");
|
||||
pt.x = 250;
|
||||
win = WindowFromPoint(pt);
|
||||
ok(win == child_button, "WindowFromPoint returned %p, expected %p\n", win, child_button);
|
||||
|
||||
SetEvent(start_event);
|
||||
|
||||
ret = WaitForSingleObject(end_event, 5000);
|
||||
ok(ret == WAIT_OBJECT_0, "WaitForSingleObject returned %x\n", ret);
|
||||
|
||||
CloseHandle(start_event);
|
||||
CloseHandle(end_event);
|
||||
}
|
||||
|
||||
static void test_window_from_point(const char *argv0)
|
||||
{
|
||||
HWND hwnd, child, win;
|
||||
POINT pt;
|
||||
PROCESS_INFORMATION info;
|
||||
STARTUPINFOA startup;
|
||||
char cmd[MAX_PATH];
|
||||
HANDLE start_event, end_event;
|
||||
|
||||
hwnd = CreateWindowExA(0, "MainWindowClass", NULL, WS_POPUP | WS_VISIBLE,
|
||||
100, 100, 200, 100, 0, 0, NULL, NULL);
|
||||
|
@ -7235,6 +7290,34 @@ static void test_window_from_point(void)
|
|||
ok(win == child, "WindowFromPoint returned %p, expected %p\n", win, child);
|
||||
DestroyWindow(child);
|
||||
|
||||
start_event = CreateEventA(NULL, FALSE, FALSE, "test_wfp_start");
|
||||
ok(start_event != 0, "CreateEvent failed\n");
|
||||
end_event = CreateEventA(NULL, FALSE, FALSE, "test_wfp_end");
|
||||
ok(start_event != 0, "CreateEvent failed\n");
|
||||
|
||||
sprintf(cmd, "%s win create_children %p\n", argv0, hwnd);
|
||||
memset(&startup, 0, sizeof(startup));
|
||||
startup.cb = sizeof(startup);
|
||||
ok(CreateProcessA(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL,
|
||||
&startup, &info), "CreateProcess failed.\n");
|
||||
ok(wait_for_event(start_event, 1000), "didn't get start_event\n");
|
||||
|
||||
child = GetWindow(hwnd, GW_CHILD);
|
||||
win = WindowFromPoint(pt);
|
||||
ok(win == child, "WindowFromPoint returned %p, expected %p\n", win, child);
|
||||
|
||||
child = GetWindow(child, GW_HWNDNEXT);
|
||||
pt.x = 250;
|
||||
win = WindowFromPoint(pt);
|
||||
ok(win == child, "WindowFromPoint returned %p, expected %p\n", win, child);
|
||||
|
||||
SetEvent(end_event);
|
||||
winetest_wait_child_process(info.hProcess);
|
||||
CloseHandle(start_event);
|
||||
CloseHandle(end_event);
|
||||
CloseHandle(info.hProcess);
|
||||
CloseHandle(info.hThread);
|
||||
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
|
||||
|
@ -7713,6 +7796,8 @@ static void test_smresult(void)
|
|||
|
||||
START_TEST(win)
|
||||
{
|
||||
char **argv;
|
||||
int argc = winetest_get_mainargs( &argv );
|
||||
HMODULE user32 = GetModuleHandleA( "user32.dll" );
|
||||
HMODULE gdi32 = GetModuleHandleA("gdi32.dll");
|
||||
pGetAncestor = (void *)GetProcAddress( user32, "GetAncestor" );
|
||||
|
@ -7733,6 +7818,15 @@ START_TEST(win)
|
|||
pSetLayout = (void *)GetProcAddress( gdi32, "SetLayout" );
|
||||
pMirrorRgn = (void *)GetProcAddress( gdi32, "MirrorRgn" );
|
||||
|
||||
if (argc==4 && !strcmp(argv[2], "create_children"))
|
||||
{
|
||||
HWND hwnd;
|
||||
|
||||
sscanf(argv[3], "%p", &hwnd);
|
||||
window_from_point_proc(hwnd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!RegisterWindowClasses()) assert(0);
|
||||
|
||||
hwndMain = CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window",
|
||||
|
@ -7783,7 +7877,7 @@ START_TEST(win)
|
|||
|
||||
/* Add the tests below this line */
|
||||
test_child_window_from_point();
|
||||
test_window_from_point();
|
||||
test_window_from_point(argv[0]);
|
||||
test_thick_child_size(hwndMain);
|
||||
test_fullscreen();
|
||||
test_hwnd_message();
|
||||
|
|
Loading…
Reference in a new issue