user32/tests: Run tests on win95 again.

This commit is contained in:
Paul Vriens 2007-08-15 14:23:45 +02:00 committed by Alexandre Julliard
parent 22e48388d5
commit 5748f15826
4 changed files with 123 additions and 50 deletions

View File

@ -59,7 +59,7 @@
static HWND hWndTest;
static long timetag = 0x10000000;
static UINT (WINAPI *ptr_SendInput) (UINT, INPUT*, size_t);
static UINT (WINAPI *pSendInput) (UINT, INPUT*, size_t);
#define MAXKEYEVENTS 6
#define MAXKEYMESSAGES MAXKEYEVENTS /* assuming a key event generates one
@ -147,6 +147,20 @@ typedef union
unsigned long lp2;
} KEYLP;
static void init_function_pointers(void)
{
HMODULE hdll = GetModuleHandleA("user32");
#define GET_PROC(func) \
p ## func = (void*)GetProcAddress(hdll, #func); \
if(!p ## func) \
trace("GetProcAddress(%s) failed\n", #func);
GET_PROC(SendInput)
#undef GET_PROC
}
static int KbdMessage( KEV kev, WPARAM *pwParam, LPARAM *plParam )
{
UINT message;
@ -209,7 +223,6 @@ static int KbdMessage( KEV kev, WPARAM *pwParam, LPARAM *plParam )
*/
static void do_test( HWND hwnd, int seqnr, const KEV td[] )
{
HMODULE module;
INPUT inputs[MAXKEYEVENTS];
KMSG expmsg[MAXKEYEVENTS];
MSG msg;
@ -217,14 +230,6 @@ static void do_test( HWND hwnd, int seqnr, const KEV td[] )
UINT evtctr=0;
int kmctr, i;
module = GetModuleHandleA("user32");
ptr_SendInput = (void *)GetProcAddress(module, "SendInput");
if (!ptr_SendInput)
{
skip("skipping SendInput tests\n");
return;
}
buf[0]='\0';
TrackSysKey=0; /* see input.c */
for( i = 0; i < MAXKEYEVENTS; i++) {
@ -238,7 +243,7 @@ static void do_test( HWND hwnd, int seqnr, const KEV td[] )
for( kmctr = 0; kmctr < MAXKEYEVENTS && expmsg[kmctr].message; kmctr++)
;
assert( evtctr <= MAXKEYEVENTS );
assert( evtctr == ptr_SendInput(evtctr, &inputs[0], sizeof(INPUT)));
assert( evtctr == pSendInput(evtctr, &inputs[0], sizeof(INPUT)));
i = 0;
if (winetest_debug > 1)
trace("======== key stroke sequence #%d: %s =============\n",
@ -485,8 +490,14 @@ static void test_Input_blackbox(void)
int ii;
BYTE ks1[256], ks2[256];
LONG_PTR prevWndProc;
HWND window;
if (!pSendInput)
{
skip("SendInput is not available\n");
return;
}
window = CreateWindow("Static", NULL, WS_POPUP|WS_HSCROLL|WS_VSCROLL
|WS_VISIBLE, 0, 0, 200, 60, NULL, NULL,
NULL, NULL);
@ -510,7 +521,7 @@ static void test_Input_blackbox(void)
GetKeyboardState(ks1);
i.u.ki.dwFlags = sendinput_test[ii].dwFlags;
i.u.ki.wVk = sendinput_test[ii].wVk;
SendInput(1, (INPUT*)&i, sizeof(TEST_INPUT));
pSendInput(1, (INPUT*)&i, sizeof(TEST_INPUT));
empty_message_queue();
GetKeyboardState(ks2);
compare_and_check(ii, ks1, ks2,
@ -665,7 +676,13 @@ static void test_mouse_ll_hook(void)
START_TEST(input)
{
test_Input_whitebox();
init_function_pointers();
if (!pSendInput)
skip("SendInput is not available\n");
else
test_Input_whitebox();
test_Input_blackbox();
test_keynames();
test_mouse_ll_hook();

View File

@ -37,8 +37,25 @@
static ATOM atomMenuCheckClass;
static BOOL (WINAPI *pSetMenuInfo)(HMENU,LPCMENUINFO);
static BOOL (WINAPI *pGetMenuInfo)(HMENU,LPCMENUINFO);
static UINT (WINAPI *pSendInput)(UINT, INPUT*, size_t);
static BOOL (WINAPI *pSetMenuInfo)(HMENU,LPCMENUINFO);
static void init_function_pointers(void)
{
HMODULE hdll = GetModuleHandleA("user32");
#define GET_PROC(func) \
p ## func = (void*)GetProcAddress(hdll, #func); \
if(!p ## func) \
trace("GetProcAddress(%s) failed\n", #func);
GET_PROC(GetMenuInfo)
GET_PROC(SendInput)
GET_PROC(SetMenuInfo)
#undef GET_PROC
}
static LRESULT WINAPI menu_check_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
@ -471,7 +488,11 @@ static void test_menu_bmp_and_string(void)
HWND hwnd;
int count, szidx, txtidx, bmpidx, hassub, mnuopt, ispop;
if( !pGetMenuInfo) return;
if( !pGetMenuInfo)
{
skip("GetMenuInfo is not available\n");
return;
}
memset( bmfill, 0x55, sizeof( bmfill));
hwnd = CreateWindowEx(0, MAKEINTATOM(atomMenuCheckClass), NULL,
@ -1674,7 +1695,7 @@ static void send_key(WORD wVk)
i[0].type = i[1].type = INPUT_KEYBOARD;
i[0].u.ki.wVk = i[1].u.ki.wVk = wVk;
i[1].u.ki.dwFlags = KEYEVENTF_KEYUP;
SendInput(2, (INPUT *) i, sizeof(INPUT));
pSendInput(2, (INPUT *) i, sizeof(INPUT));
}
static void click_menu(HANDLE hWnd, struct menu_item_pair_s *mi)
@ -1699,7 +1720,7 @@ static void click_menu(HANDLE hWnd, struct menu_item_pair_s *mi)
i[0].u.mi.dwFlags |= MOUSEEVENTF_MOVE;
i[1].u.mi.dwFlags |= MOUSEEVENTF_LEFTDOWN;
i[2].u.mi.dwFlags |= MOUSEEVENTF_LEFTUP;
SendInput(3, (INPUT *) i, sizeof(INPUT));
pSendInput(3, (INPUT *) i, sizeof(INPUT));
/* hack to prevent mouse message buildup in Wine */
while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageA( &msg );
@ -2220,10 +2241,7 @@ static void test_InsertMenu(void)
START_TEST(menu)
{
pSetMenuInfo =
(void *)GetProcAddress( GetModuleHandleA("user32.dll"), "SetMenuInfo" );
pGetMenuInfo =
(void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetMenuInfo" );
init_function_pointers();
register_menu_check_class();
@ -2233,8 +2251,13 @@ START_TEST(menu)
test_menu_iteminfo();
test_menu_search_bycommand();
test_menu_bmp_and_string();
test_menu_input();
if( !pSendInput)
skip("SendInput is not available\n");
else
test_menu_input();
test_menu_flags();
test_menu_hilitemenuitem();
test_CheckMenuRadioItem();
test_menu_resource_layout();

View File

@ -24,6 +24,7 @@
#include "winuser.h"
static HMODULE hdll;
static LONG (WINAPI *pChangeDisplaySettingsExA)(LPCSTR, LPDEVMODEA, HWND, DWORD, LPVOID);
static BOOL (WINAPI *pEnumDisplayDevicesA)(LPCSTR,DWORD,LPDISPLAY_DEVICEA,DWORD);
static BOOL (WINAPI *pEnumDisplayMonitors)(HDC,LPRECT,MONITORENUMPROC,LPARAM);
static BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR,LPMONITORINFO);
@ -33,11 +34,20 @@ static HMONITOR (WINAPI *pMonitorFromWindow)(HWND,DWORD);
static void init_function_pointers(void)
{
hdll = GetModuleHandleA("user32.dll");
pEnumDisplayDevicesA = (void*)GetProcAddress(hdll, "EnumDisplayDevicesA");
pEnumDisplayMonitors = (void*)GetProcAddress(hdll, "EnumDisplayMonitors");
pGetMonitorInfoA = (void*)GetProcAddress(hdll, "GetMonitorInfoA");
pMonitorFromPoint = (void*)GetProcAddress(hdll, "MonitorFromPoint");
pMonitorFromWindow = (void*)GetProcAddress(hdll, "MonitorFromWindow");
#define GET_PROC(func) \
p ## func = (void*)GetProcAddress(hdll, #func); \
if(!p ## func) \
trace("GetProcAddress(%s) failed\n", #func);
GET_PROC(ChangeDisplaySettingsExA)
GET_PROC(EnumDisplayDevicesA)
GET_PROC(EnumDisplayMonitors)
GET_PROC(GetMonitorInfoA)
GET_PROC(MonitorFromPoint)
GET_PROC(MonitorFromWindow)
#undef GET_PROC
}
static BOOL CALLBACK monitor_enum_proc(HMONITOR hmon, HDC hdc, LPRECT lprc,
@ -129,6 +139,12 @@ static void test_ChangeDisplaySettingsEx(void)
LONG res;
int i;
if (!pChangeDisplaySettingsExA)
{
skip("ChangeDisplaySettingsExA is not available\n");
return;
}
memset(&dm, 0, sizeof(dm));
dm.dmSize = sizeof(dm);
@ -139,7 +155,7 @@ static void test_ChangeDisplaySettingsEx(void)
dm.dmBitsPerPel = vid_modes_test[i].bpp;
dm.dmDisplayFrequency = vid_modes_test[i].freq;
dm.dmFields = vid_modes_test[i].fields;
res = ChangeDisplaySettingsEx(NULL, &dm, NULL, CDS_FULLSCREEN, NULL);
res = pChangeDisplaySettingsExA(NULL, &dm, NULL, CDS_FULLSCREEN, NULL);
ok(vid_modes_test[i].success ?
(res == DISP_CHANGE_SUCCESSFUL) :
(res == DISP_CHANGE_BADMODE || res == DISP_CHANGE_BADPARAM),
@ -172,7 +188,7 @@ static void test_ChangeDisplaySettingsEx(void)
ok(EqualRect(&r, &virt), "Invalid clip rect: (%d %d) x (%d %d)\n", r.left, r.top, r.right, r.bottom);
}
}
res = ChangeDisplaySettingsEx(NULL, NULL, NULL, CDS_RESET, NULL);
res = pChangeDisplaySettingsExA(NULL, NULL, NULL, CDS_RESET, NULL);
ok(res == DISP_CHANGE_SUCCESSFUL, "Failed to reset default resolution: %d\n", res);
}
@ -202,4 +218,6 @@ START_TEST(monitor)
test_ChangeDisplaySettingsEx();
if (pMonitorFromPoint && pMonitorFromWindow)
test_monitors();
else
skip("MonitorFromPoint and/or MonitorFromWindow are not available\n");
}

View File

@ -54,11 +54,6 @@
static BOOL test_DestroyWindow_flag;
static HWINEVENTHOOK hEvent_hook;
static HWND (WINAPI *pGetAncestor)(HWND,UINT);
static void (WINAPI *pNotifyWinEvent)(DWORD, HWND, LONG, LONG);
static HWINEVENTHOOK (WINAPI *pSetWinEventHook)(DWORD, DWORD, HMODULE, WINEVENTPROC, DWORD, DWORD, DWORD);
static BOOL (WINAPI *pUnhookWinEvent)(HWINEVENTHOOK);
static void dump_winpos_flags(UINT flags);
static const WCHAR testWindowClassW[] =
@ -1407,22 +1402,35 @@ static int sequence_cnt, sequence_size;
static struct message* sequence;
static int log_all_parent_messages;
/* user32 functions */
static HWND (WINAPI *pGetAncestor)(HWND,UINT);
static void (WINAPI *pNotifyWinEvent)(DWORD, HWND, LONG, LONG);
static HWINEVENTHOOK (WINAPI *pSetWinEventHook)(DWORD, DWORD, HMODULE, WINEVENTPROC, DWORD, DWORD, DWORD);
static BOOL (WINAPI *pTrackMouseEvent)(TRACKMOUSEEVENT*);
static BOOL (WINAPI *pUnhookWinEvent)(HWINEVENTHOOK);
/* kernel32 functions */
static BOOL (WINAPI *pGetCPInfoExA)(UINT, DWORD, LPCPINFOEXA);
static void init_procs(void)
{
HMODULE user32 = GetModuleHandleA("user32.dll");
HMODULE kernel32 = GetModuleHandleA("kernel32.dll");
#define USER32_GET_PROC(func) \
p ## func = (void*)GetProcAddress(user32, #func); \
#define GET_PROC(dll, func) \
p ## func = (void*)GetProcAddress(dll, #func); \
if(!p ## func) { \
trace("GetProcAddress(%s) failed\n", #func); \
}
USER32_GET_PROC(GetAncestor)
USER32_GET_PROC(NotifyWinEvent)
USER32_GET_PROC(SetWinEventHook)
USER32_GET_PROC(UnhookWinEvent)
GET_PROC(user32, GetAncestor)
GET_PROC(user32, NotifyWinEvent)
GET_PROC(user32, SetWinEventHook)
GET_PROC(user32, TrackMouseEvent)
GET_PROC(user32, UnhookWinEvent)
#undef USER32_GET_PROC
GET_PROC(kernel32, GetCPInfoExA)
#undef GET_PROC
}
static void add_message(const struct message *msg)
@ -8478,7 +8486,7 @@ static void test_TrackMouseEvent(void)
tme.hwndTrack = track_hwnd; \
tme.dwHoverTime = track_hover_time; \
SetLastError(0xdeadbeef); \
ret = TrackMouseEvent(&tme); \
ret = pTrackMouseEvent(&tme); \
ok(ret, "TrackMouseEvent(TME_HOVER) error %d\n", GetLastError())
#define track_query(expected_track_flags, expected_track_hwnd, expected_hover_time) \
@ -8487,7 +8495,7 @@ static void test_TrackMouseEvent(void)
tme.hwndTrack = (HWND)0xdeadbeef; \
tme.dwHoverTime = 0xdeadbeef; \
SetLastError(0xdeadbeef); \
ret = TrackMouseEvent(&tme); \
ret = pTrackMouseEvent(&tme); \
ok(ret, "TrackMouseEvent(TME_QUERY) error %d\n", GetLastError());\
ok(tme.cbSize == sizeof(tme), "wrong tme.cbSize %u\n", tme.cbSize); \
ok(tme.dwFlags == (expected_track_flags), \
@ -8503,7 +8511,7 @@ static void test_TrackMouseEvent(void)
tme.hwndTrack = track_hwnd; \
tme.dwHoverTime = 0xdeadbeef; \
SetLastError(0xdeadbeef); \
ret = TrackMouseEvent(&tme); \
ret = pTrackMouseEvent(&tme); \
ok(ret, "TrackMouseEvent(TME_HOVER | TME_CANCEL) error %d\n", GetLastError())
default_hover_time = 0xdeadbeef;
@ -8543,7 +8551,7 @@ static void test_TrackMouseEvent(void)
tme.hwndTrack = (HWND)0xdeadbeef;
tme.dwHoverTime = 0xdeadbeef;
SetLastError(0xdeadbeef);
ret = TrackMouseEvent(&tme);
ret = pTrackMouseEvent(&tme);
ok(!ret, "TrackMouseEvent should fail\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER, "not expected error %d\n", GetLastError());
@ -8552,7 +8560,7 @@ static void test_TrackMouseEvent(void)
tme.hwndTrack = (HWND)0xdeadbeef;
tme.dwHoverTime = 0xdeadbeef;
SetLastError(0xdeadbeef);
ret = TrackMouseEvent(&tme);
ret = pTrackMouseEvent(&tme);
ok(!ret, "TrackMouseEvent should fail\n");
ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "not expected error %d\n", GetLastError());
@ -8561,7 +8569,7 @@ static void test_TrackMouseEvent(void)
tme.hwndTrack = (HWND)0xdeadbeef;
tme.dwHoverTime = 0xdeadbeef;
SetLastError(0xdeadbeef);
ret = TrackMouseEvent(&tme);
ret = pTrackMouseEvent(&tme);
ok(!ret, "TrackMouseEvent should fail\n");
ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "not expected error %d\n", GetLastError());
@ -9288,7 +9296,7 @@ static void test_dbcs_wm_char(void)
UINT i, j, k;
struct message wmCharSeq[2];
GetCPInfoExA( CP_ACP, 0, &cpinfo );
pGetCPInfoExA( CP_ACP, 0, &cpinfo );
if (cpinfo.MaxCharSize != 2)
{
skip( "Skipping DBCS WM_CHAR test in SBCS codepage '%s'\n", cpinfo.CodePageName );
@ -9616,7 +9624,12 @@ START_TEST(msg)
test_SendMessageTimeout();
test_edit_messages();
test_quit_message();
test_TrackMouseEvent();
if (!pTrackMouseEvent)
skip("TrackMouseEvent is not available\n");
else
test_TrackMouseEvent();
test_SetWindowRgn();
test_sys_menu();
test_dialog_messages();
@ -9635,4 +9648,6 @@ START_TEST(msg)
GetLastError() == 0xdeadbeef, /* Win9x */
"unexpected error %d\n", GetLastError());
}
else
skip("UnhookWinEvent is not available\n");
}