user32/tests: Remove some workarounds for older Windows versions.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2020-01-09 09:22:25 +03:00 committed by Alexandre Julliard
parent 8a13cc6437
commit cb9f5e7d0e
2 changed files with 59 additions and 123 deletions

View File

@ -2010,15 +2010,10 @@ static int log_all_parent_messages;
static CRITICAL_SECTION sequence_cs;
/* user32 functions */
static HWND (WINAPI *pGetAncestor)(HWND,UINT);
static BOOL (WINAPI *pGetMenuInfo)(HMENU,LPCMENUINFO);
static void (WINAPI *pNotifyWinEvent)(DWORD, HWND, LONG, LONG);
static BOOL (WINAPI *pSetMenuInfo)(HMENU,LPCMENUINFO);
static HWINEVENTHOOK (WINAPI *pSetWinEventHook)(DWORD, DWORD, HMODULE, WINEVENTPROC, DWORD, DWORD, DWORD);
static BOOL (WINAPI *pTrackMouseEvent)(TRACKMOUSEEVENT*);
static BOOL (WINAPI *pUnhookWinEvent)(HWINEVENTHOOK);
static BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR,LPMONITORINFO);
static HMONITOR (WINAPI *pMonitorFromPoint)(POINT,DWORD);
static BOOL (WINAPI *pUpdateLayeredWindow)(HWND,HDC,POINT*,SIZE*,HDC,POINT*,COLORREF,BLENDFUNCTION*,DWORD);
static UINT_PTR (WINAPI *pSetSystemTimer)(HWND, UINT_PTR, UINT, TIMERPROC);
static UINT_PTR (WINAPI *pKillSystemTimer)(HWND, UINT_PTR);
@ -2037,15 +2032,10 @@ static void init_procs(void)
trace("GetProcAddress(%s) failed\n", #func); \
}
GET_PROC(user32, GetAncestor)
GET_PROC(user32, GetMenuInfo)
GET_PROC(user32, NotifyWinEvent)
GET_PROC(user32, SetMenuInfo)
GET_PROC(user32, SetWinEventHook)
GET_PROC(user32, TrackMouseEvent)
GET_PROC(user32, UnhookWinEvent)
GET_PROC(user32, GetMonitorInfoA)
GET_PROC(user32, MonitorFromPoint)
GET_PROC(user32, UpdateLayeredWindow)
GET_PROC(user32, SetSystemTimer)
GET_PROC(user32, KillSystemTimer)
@ -9469,8 +9459,7 @@ static LRESULT MsgCheckProc (BOOL unicode, HWND hwnd, UINT message,
}
/* fall through */
case WM_DESTROY:
if (pGetAncestor)
ok(pGetAncestor(hwnd, GA_PARENT) != 0, "parent should NOT be unlinked at this point\n");
ok(GetAncestor(hwnd, GA_PARENT) != 0, "parent should NOT be unlinked at this point\n");
if (test_DestroyWindow_flag)
{
DWORD style = GetWindowLongA(hwnd, GWL_STYLE);
@ -11172,10 +11161,8 @@ static void test_DestroyWindow(void)
test = GetParent(child2);
ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
ok(!IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
if(pGetAncestor) {
test = pGetAncestor(child2, GA_PARENT);
ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
}
test = GetAncestor(child2, GA_PARENT);
ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
test = GetWindow(child2, GW_OWNER);
ok(!test, "wrong owner %p\n", test);
@ -11186,10 +11173,8 @@ static void test_DestroyWindow(void)
test = GetParent(parent);
ok(!test, "wrong parent %p\n", test);
ok(!IsChild(GetDesktopWindow(), parent), "wrong parent/child %p/%p\n", GetDesktopWindow(), parent);
if(pGetAncestor) {
test = pGetAncestor(parent, GA_PARENT);
ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
}
test = GetAncestor(parent, GA_PARENT);
ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
test = GetWindow(parent, GW_OWNER);
ok(!test, "wrong owner %p\n", test);
@ -11197,10 +11182,8 @@ static void test_DestroyWindow(void)
test = GetParent(child1);
ok(test == parent, "wrong parent %p\n", test);
ok(IsChild(parent, child1), "wrong parent/child %p/%p\n", parent, child1);
if(pGetAncestor) {
test = pGetAncestor(child1, GA_PARENT);
ok(test == parent, "wrong parent %p\n", test);
}
test = GetAncestor(child1, GA_PARENT);
ok(test == parent, "wrong parent %p\n", test);
test = GetWindow(child1, GW_OWNER);
ok(!test, "wrong owner %p\n", test);
@ -11208,10 +11191,8 @@ static void test_DestroyWindow(void)
test = GetParent(child2);
ok(test == parent, "wrong parent %p\n", test);
ok(IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
if(pGetAncestor) {
test = pGetAncestor(child2, GA_PARENT);
ok(test == parent, "wrong parent %p\n", test);
}
test = GetAncestor(child2, GA_PARENT);
ok(test == parent, "wrong parent %p\n", test);
test = GetWindow(child2, GW_OWNER);
ok(!test, "wrong owner %p\n", test);
@ -11219,10 +11200,8 @@ static void test_DestroyWindow(void)
test = GetParent(child3);
ok(test == child1, "wrong parent %p\n", test);
ok(IsChild(parent, child3), "wrong parent/child %p/%p\n", parent, child3);
if(pGetAncestor) {
test = pGetAncestor(child3, GA_PARENT);
ok(test == child1, "wrong parent %p\n", test);
}
test = GetAncestor(child3, GA_PARENT);
ok(test == child1, "wrong parent %p\n", test);
test = GetWindow(child3, GW_OWNER);
ok(!test, "wrong owner %p\n", test);
@ -11230,10 +11209,8 @@ static void test_DestroyWindow(void)
test = GetParent(child4);
ok(test == parent, "wrong parent %p\n", test);
ok(!IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
if(pGetAncestor) {
test = pGetAncestor(child4, GA_PARENT);
ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
}
test = GetAncestor(child4, GA_PARENT);
ok(test == GetDesktopWindow(), "wrong parent %p\n", test);
test = GetWindow(child4, GW_OWNER);
ok(test == parent, "wrong owner %p\n", test);
@ -13440,6 +13417,9 @@ static void test_ShowWindow(void)
INT i;
WINDOWPLACEMENT wp;
RECT win_rc, work_rc = {0, 0, 0, 0};
HMONITOR hmon;
MONITORINFO mi;
POINT pt = {0, 0};
#define WS_BASE (WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_POPUP|WS_CLIPSIBLINGS)
hwnd = CreateWindowExA(0, "ShowWindowClass", NULL, WS_BASE,
@ -13453,24 +13433,17 @@ static void test_ShowWindow(void)
flush_events();
flush_sequence();
if (pGetMonitorInfoA && pMonitorFromPoint)
{
HMONITOR hmon;
MONITORINFO mi;
POINT pt = {0, 0};
SetLastError(0xdeadbeef);
hmon = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
ok(hmon != 0, "MonitorFromPoint error %u\n", GetLastError());
SetLastError(0xdeadbeef);
hmon = pMonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
ok(hmon != 0, "MonitorFromPoint error %u\n", GetLastError());
mi.cbSize = sizeof(mi);
SetLastError(0xdeadbeef);
ret = pGetMonitorInfoA(hmon, &mi);
ok(ret, "GetMonitorInfo error %u\n", GetLastError());
trace("monitor %s, work %s\n", wine_dbgstr_rect(&mi.rcMonitor),
wine_dbgstr_rect(&mi.rcWork));
work_rc = mi.rcWork;
}
mi.cbSize = sizeof(mi);
SetLastError(0xdeadbeef);
ret = GetMonitorInfoA(hmon, &mi);
ok(ret, "GetMonitorInfo error %u\n", GetLastError());
trace("monitor %s, work %s\n", wine_dbgstr_rect(&mi.rcMonitor),
wine_dbgstr_rect(&mi.rcWork));
work_rc = mi.rcWork;
GetWindowRect(hwnd, &win_rc);
OffsetRect(&win_rc, -work_rc.left, -work_rc.top);
@ -15258,7 +15231,7 @@ static void set_menu_style(HMENU hmenu, DWORD style)
mi.fMask = MIM_STYLE;
mi.dwStyle = style;
SetLastError(0xdeadbeef);
ret = pSetMenuInfo(hmenu, &mi);
ret = SetMenuInfo(hmenu, &mi);
ok(ret, "SetMenuInfo error %u\n", GetLastError());
}
@ -15271,7 +15244,7 @@ static DWORD get_menu_style(HMENU hmenu)
mi.fMask = MIM_STYLE;
mi.dwStyle = 0;
SetLastError(0xdeadbeef);
ret = pGetMenuInfo(hmenu, &mi);
ret = GetMenuInfo(hmenu, &mi);
ok(ret, "GetMenuInfo error %u\n", GetLastError());
return mi.dwStyle;
@ -15286,11 +15259,6 @@ static void test_menu_messages(void)
DWORD style;
BOOL us_kbd = (GetKeyboardLayout(0) == (HKL)(ULONG_PTR)0x04090409);
if (!pGetMenuInfo || !pSetMenuInfo)
{
win_skip("GetMenuInfo and/or SetMenuInfo are not available\n");
return;
}
cls.style = 0;
cls.lpfnWndProc = parent_menu_proc;
cls.cbClsExtra = 0;

View File

@ -50,15 +50,12 @@
void dump_region(HRGN hrgn);
static HWND (WINAPI *pGetAncestor)(HWND,UINT);
static BOOL (WINAPI *pGetWindowInfo)(HWND,WINDOWINFO*);
static UINT (WINAPI *pGetWindowModuleFileNameA)(HWND,LPSTR,UINT);
static BOOL (WINAPI *pGetLayeredWindowAttributes)(HWND,COLORREF*,BYTE*,DWORD*);
static BOOL (WINAPI *pSetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD);
static BOOL (WINAPI *pUpdateLayeredWindow)(HWND,HDC,POINT*,SIZE*,HDC,POINT*,COLORREF,BLENDFUNCTION*,DWORD);
static BOOL (WINAPI *pUpdateLayeredWindowIndirect)(HWND,const UPDATELAYEREDWINDOWINFO*);
static BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR,LPMONITORINFO);
static HMONITOR (WINAPI *pMonitorFromPoint)(POINT,DWORD);
static int (WINAPI *pGetWindowRgnBox)(HWND,LPRECT);
static BOOL (WINAPI *pGetGUIThreadInfo)(DWORD, GUITHREADINFO*);
static BOOL (WINAPI *pGetProcessDefaultLayout)( DWORD *layout );
@ -135,24 +132,18 @@ static void check_parents( HWND hwnd, HWND ga_parent, HWND gwl_parent, HWND get_
{
HWND res;
if (pGetAncestor)
{
res = pGetAncestor( hwnd, GA_PARENT );
ok( res == ga_parent, "Wrong result for GA_PARENT %p expected %p\n", res, ga_parent );
}
res = GetAncestor( hwnd, GA_PARENT );
ok( res == ga_parent, "Wrong result for GA_PARENT %p expected %p\n", res, ga_parent );
res = (HWND)GetWindowLongPtrA( hwnd, GWLP_HWNDPARENT );
ok( res == gwl_parent, "Wrong result for GWL_HWNDPARENT %p expected %p\n", res, gwl_parent );
res = GetParent( hwnd );
ok( res == get_parent, "Wrong result for GetParent %p expected %p\n", res, get_parent );
res = GetWindow( hwnd, GW_OWNER );
ok( res == gw_owner, "Wrong result for GW_OWNER %p expected %p\n", res, gw_owner );
if (pGetAncestor)
{
res = pGetAncestor( hwnd, GA_ROOT );
ok( res == ga_root, "Wrong result for GA_ROOT %p expected %p\n", res, ga_root );
res = pGetAncestor( hwnd, GA_ROOTOWNER );
ok( res == ga_root_owner, "Wrong result for GA_ROOTOWNER %p expected %p\n", res, ga_root_owner );
}
res = GetAncestor( hwnd, GA_ROOT );
ok( res == ga_root, "Wrong result for GA_ROOT %p expected %p\n", res, ga_root );
res = GetAncestor( hwnd, GA_ROOTOWNER );
ok( res == ga_root_owner, "Wrong result for GA_ROOTOWNER %p expected %p\n", res, ga_root_owner );
}
#define check_wnd_state(a,b,c,d) check_wnd_state_(__FILE__,__LINE__,a,b,c,d)
@ -1267,19 +1258,16 @@ static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
if (0)
{
/* Uncomment this once the test succeeds in all cases */
if (pGetAncestor)
{
ok(pGetAncestor(hwnd, GA_PARENT) == hwndMessage, "GA_PARENT should be set to hwndMessage at this point\n");
ok(pGetAncestor(hwnd, GA_ROOT) == hwnd,
"GA_ROOT is set to %p, expected %p\n", pGetAncestor(hwnd, GA_ROOT), hwnd);
ok(GetAncestor(hwnd, GA_PARENT) == hwndMessage, "GA_PARENT should be set to hwndMessage at this point\n");
ok(GetAncestor(hwnd, GA_ROOT) == hwnd,
"GA_ROOT is set to %p, expected %p\n", GetAncestor(hwnd, GA_ROOT), hwnd);
if ((style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
ok(pGetAncestor(hwnd, GA_ROOTOWNER) == hwndMessage,
ok(GetAncestor(hwnd, GA_ROOTOWNER) == hwndMessage,
"GA_ROOTOWNER should be set to hwndMessage at this point\n");
else
ok(pGetAncestor(hwnd, GA_ROOTOWNER) == hwnd,
"GA_ROOTOWNER is set to %p, expected %p\n", pGetAncestor(hwnd, GA_ROOTOWNER), hwnd);
}
ok(GetAncestor(hwnd, GA_ROOTOWNER) == hwnd,
"GA_ROOTOWNER is set to %p, expected %p\n", GetAncestor(hwnd, GA_ROOTOWNER), hwnd);
ok(GetWindowRect(hwnd, &rc), "GetWindowRect failed\n");
ok(EqualRect(&rc, &rc_null), "window rect should be set to 0 HCBT_CREATEWND\n");
@ -5265,17 +5253,9 @@ static void test_params(void)
ok(!IsWindow(HWND_TOPMOST), "IsWindow(HWND_TOPMOST)\n");
/* Just a param check */
if (pGetMonitorInfoA)
{
SetLastError(0xdeadbeef);
rc = GetWindowTextA(hwndMain2, NULL, 1024);
ok( rc==0, "GetWindowText: rc=%d err=%d\n",rc,GetLastError());
}
else
{
/* Skips actually on Win95 and NT4 */
win_skip("Test would crash on Win95\n");
}
SetLastError(0xdeadbeef);
rc = GetWindowTextA(hwndMain2, NULL, 1024);
ok(!rc, "GetWindowText: rc=%d err=%d\n",rc,GetLastError());
SetLastError(0xdeadbeef);
hwnd=CreateWindowA("LISTBOX", "TestList",
@ -8040,31 +8020,28 @@ static void test_hwnd_message(void)
{ GWLP_WNDPROC, 0, ERROR_ACCESS_DENIED },
{ DWLP_MSGRESULT, 0, ERROR_INVALID_INDEX }
};
HWND root, desktop = GetDesktopWindow();
DWORD_PTR result;
char buffer[100];
int i;
hwnd = CreateWindowExW(0, mainwindowclassW, message_windowW, WS_CAPTION | WS_VISIBLE,
100, 100, 200, 200, HWND_MESSAGE, 0, 0, NULL);
ok( hwnd != 0, "CreateWindowExW with parent HWND_MESSAGE failed\n" );
ok( !GetParent(hwnd), "GetParent should return 0 for message only windows\n" );
if (pGetAncestor)
{
char buffer[100];
HWND root, desktop = GetDesktopWindow();
parent = pGetAncestor(hwnd, GA_PARENT);
ok(parent != 0, "GetAncestor(GA_PARENT) should not return 0 for message windows\n");
ok(parent != desktop, "GetAncestor(GA_PARENT) should not return desktop for message windows\n");
root = pGetAncestor(hwnd, GA_ROOT);
ok(root == hwnd, "GetAncestor(GA_ROOT) should return hwnd for message windows\n");
ok( !pGetAncestor(parent, GA_PARENT),
"parent shouldn't have parent %p\n", pGetAncestor(parent, GA_PARENT) );
if (!GetClassNameA( parent, buffer, sizeof(buffer) )) buffer[0] = 0;
ok( !lstrcmpiA( buffer, "Message" ), "wrong parent class '%s'\n", buffer );
GetWindowRect( parent, &rect );
ok( rect.left == 0 && rect.right == 100 && rect.top == 0 && rect.bottom == 100,
"wrong parent rect %s\n", wine_dbgstr_rect( &rect ));
}
parent = GetAncestor(hwnd, GA_PARENT);
ok(parent != 0, "GetAncestor(GA_PARENT) should not return 0 for message windows\n");
ok(parent != desktop, "GetAncestor(GA_PARENT) should not return desktop for message windows\n");
root = GetAncestor(hwnd, GA_ROOT);
ok(root == hwnd, "GetAncestor(GA_ROOT) should return hwnd for message windows\n");
ok( !GetAncestor(parent, GA_PARENT),
"parent shouldn't have parent %p\n", GetAncestor(parent, GA_PARENT) );
if (!GetClassNameA( parent, buffer, sizeof(buffer) )) buffer[0] = 0;
ok( !lstrcmpiA( buffer, "Message" ), "wrong parent class '%s'\n", buffer );
GetWindowRect( parent, &rect );
ok( rect.left == 0 && rect.right == 100 && rect.top == 0 && rect.bottom == 100,
"wrong parent rect %s\n", wine_dbgstr_rect( &rect ));
GetWindowRect( hwnd, &rect );
ok( rect.left == 100 && rect.right == 300 && rect.top == 100 && rect.bottom == 300,
"wrong window rect %s\n", wine_dbgstr_rect( &rect ));
@ -8344,20 +8321,14 @@ static void test_fullscreen(void)
HMONITOR hmon;
LRESULT ret;
if (!pGetMonitorInfoA || !pMonitorFromPoint)
{
win_skip("GetMonitorInfoA or MonitorFromPoint are not available on this platform\n");
return;
}
pt.x = pt.y = 0;
SetLastError(0xdeadbeef);
hmon = pMonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
hmon = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
ok(hmon != 0, "MonitorFromPoint error %u\n", GetLastError());
mi.cbSize = sizeof(mi);
SetLastError(0xdeadbeef);
ret = pGetMonitorInfoA(hmon, &mi);
ret = GetMonitorInfoA(hmon, &mi);
ok(ret, "GetMonitorInfo error %u\n", GetLastError());
trace("monitor %s, work %s\n", wine_dbgstr_rect(&mi.rcMonitor), wine_dbgstr_rect(&mi.rcWork));
@ -11873,15 +11844,12 @@ START_TEST(win)
int argc = winetest_get_mainargs( &argv );
HMODULE user32 = GetModuleHandleA( "user32.dll" );
HMODULE gdi32 = GetModuleHandleA("gdi32.dll");
pGetAncestor = (void *)GetProcAddress( user32, "GetAncestor" );
pGetWindowInfo = (void *)GetProcAddress( user32, "GetWindowInfo" );
pGetWindowModuleFileNameA = (void *)GetProcAddress( user32, "GetWindowModuleFileNameA" );
pGetLayeredWindowAttributes = (void *)GetProcAddress( user32, "GetLayeredWindowAttributes" );
pSetLayeredWindowAttributes = (void *)GetProcAddress( user32, "SetLayeredWindowAttributes" );
pUpdateLayeredWindow = (void *)GetProcAddress( user32, "UpdateLayeredWindow" );
pUpdateLayeredWindowIndirect = (void *)GetProcAddress( user32, "UpdateLayeredWindowIndirect" );
pGetMonitorInfoA = (void *)GetProcAddress( user32, "GetMonitorInfoA" );
pMonitorFromPoint = (void *)GetProcAddress( user32, "MonitorFromPoint" );
pGetWindowRgnBox = (void *)GetProcAddress( user32, "GetWindowRgnBox" );
pGetGUIThreadInfo = (void *)GetProcAddress( user32, "GetGUIThreadInfo" );
pGetProcessDefaultLayout = (void *)GetProcAddress( user32, "GetProcessDefaultLayout" );