[USER32_APITEST] Improve GetMessageTime tests

This commit is contained in:
Katayama Hirofumi MZ 2019-01-17 09:31:35 +09:00
parent 87bfbb3ec7
commit b490084d38
3 changed files with 59 additions and 11 deletions

View file

@ -15,6 +15,7 @@ list(APPEND SOURCE
GetDCEx.c
GetIconInfo.c
GetKeyState.c
GetMessageTime.c
GetPeekMessage.c
GetSystemMetrics.c
GetUserObjectInformation.c
@ -22,7 +23,6 @@ list(APPEND SOURCE
InitializeLpkHooks.c
LoadImage.c
LookupIconIdFromDirectoryEx.c
MessageTime.c
NextDlgItem.c
PrivateExtractIcons.c
RealGetWindowClass.c

View file

@ -1,29 +1,48 @@
/*
* PROJECT: ReactOS api tests
* LICENSE: GPL - See COPYING in the top level directory
* PURPOSE: Test for message times
* PURPOSE: Test for GetMessageTime
* PROGRAMMERS: Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
*/
#include "precomp.h"
#define TIMER_ID 999
#define TIMER_INTERVAL 500 /* 500 milliseconds */
#define MOUSE_LOCATION_X(x) ((DWORD)(x) * 0xFFFF / GetSystemMetrics(SM_CXSCREEN))
#define MOUSE_LOCATION_Y(y) ((DWORD)(y) * 0xFFFF / GetSystemMetrics(SM_CYSCREEN))
#define WIN_X 50
#define WIN_Y 50
#define WIN_CX 100
#define WIN_CY 100
static INT s_nCount = 0;
static LONG s_nMsgTime = 0;
static LRESULT CALLBACK
WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static BOOL s_bReach_WM_MOUSEMOVE;
static BOOL s_bReach_WM_LBUTTONDOWN;
static BOOL s_bReach_WM_LBUTTONUP;
switch (uMsg)
{
case WM_CREATE:
s_nCount = 0;
s_nMsgTime = GetMessageTime();
SetTimer(hwnd, TIMER_ID, TIMER_INTERVAL, NULL);
s_bReach_WM_MOUSEMOVE = FALSE;
s_bReach_WM_LBUTTONDOWN = FALSE;
s_bReach_WM_LBUTTONUP = FALSE;
break;
case WM_TIMER:
if (s_nCount == 5)
{
KillTimer(hwnd, TIMER_ID);
DestroyWindow(hwnd);
break;
}
if (s_nCount != 0)
{
ok(GetMessageTime() - s_nMsgTime >= TIMER_INTERVAL / 2,
@ -32,13 +51,39 @@ WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
s_nMsgTime = GetMessageTime();
ok(s_nMsgTime != 0, "message time was zero.\n");
s_nCount++;
if (s_nCount >= 5)
if (s_nCount == 5)
{
KillTimer(hwnd, TIMER_ID);
DestroyWindow(hwnd);
mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE,
MOUSE_LOCATION_X(WIN_X + WIN_CX / 2),
MOUSE_LOCATION_Y(WIN_Y + WIN_CY / 2),
0, 0);
mouse_event(MOUSEEVENTF_MOVE, 1, 1, 0, 0);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
}
break;
case WM_MOUSEMOVE:
trace("WM_MOUSEMOVE\n");
ok_int(s_nCount, 5);
ok(GetMessageTime() - s_nMsgTime < TIMER_INTERVAL, "message time is wrong.\n");
s_bReach_WM_MOUSEMOVE = TRUE;
break;
case WM_LBUTTONDOWN:
trace("WM_LBUTTONDOWN\n");
ok_int(s_nCount, 5);
ok(GetMessageTime() - s_nMsgTime < TIMER_INTERVAL, "message time is wrong.\n");
s_bReach_WM_LBUTTONDOWN = TRUE;
break;
case WM_LBUTTONUP:
trace("WM_LBUTTONUP\n");
ok_int(s_nCount, 5);
ok(GetMessageTime() - s_nMsgTime < TIMER_INTERVAL, "message time is wrong.\n");
s_bReach_WM_LBUTTONUP = TRUE;
break;
case WM_DESTROY:
ok_int(s_bReach_WM_MOUSEMOVE, TRUE);
ok_int(s_bReach_WM_LBUTTONDOWN, TRUE);
ok_int(s_bReach_WM_LBUTTONUP, TRUE);
PostQuitMessage(0);
break;
default:
@ -47,7 +92,7 @@ WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
return 0;
}
START_TEST(MessageTime)
START_TEST(GetMessageTime)
{
static const WCHAR s_szName[] = L"MessageTimeTestWindow";
WNDCLASSW wc;
@ -56,6 +101,10 @@ START_TEST(MessageTime)
MSG msg;
BOOL bRet;
mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE,
MOUSE_LOCATION_X(1), MOUSE_LOCATION_Y(1),
0, 0);
ZeroMemory(&wc, sizeof(wc));
wc.lpfnWndProc = WindowProc;
wc.hInstance = GetModuleHandleW(NULL);
@ -68,8 +117,7 @@ START_TEST(MessageTime)
hwnd = CreateWindowW(s_szName, s_szName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0,
CW_USEDEFAULT, 0,
WIN_X, WIN_Y, WIN_CX, WIN_CY,
NULL, NULL, GetModuleHandleW(NULL), NULL);
ok(hwnd != NULL, "CreateWindowW\n");

View file

@ -17,6 +17,7 @@ extern void func_EnumDisplaySettings(void);
extern void func_GetDCEx(void);
extern void func_GetIconInfo(void);
extern void func_GetKeyState(void);
extern void func_GetMessageTime(void);
extern void func_GetPeekMessage(void);
extern void func_GetSystemMetrics(void);
extern void func_GetUserObjectInformation(void);
@ -24,7 +25,6 @@ extern void func_GetWindowPlacement(void);
extern void func_InitializeLpkHooks(void);
extern void func_LoadImage(void);
extern void func_LookupIconIdFromDirectoryEx(void);
extern void func_MessageTime(void);
extern void func_NextDlgItem(void);
extern void func_PrivateExtractIcons(void);
extern void func_RealGetWindowClass(void);
@ -62,6 +62,7 @@ const struct test winetest_testlist[] =
{ "GetDCEx", func_GetDCEx },
{ "GetIconInfo", func_GetIconInfo },
{ "GetKeyState", func_GetKeyState },
{ "GetMessageTime", func_GetMessageTime },
{ "GetPeekMessage", func_GetPeekMessage },
{ "GetSystemMetrics", func_GetSystemMetrics },
{ "GetUserObjectInformation", func_GetUserObjectInformation },
@ -69,7 +70,6 @@ const struct test winetest_testlist[] =
{ "InitializeLpkHooks", func_InitializeLpkHooks },
{ "LoadImage", func_LoadImage },
{ "LookupIconIdFromDirectoryEx", func_LookupIconIdFromDirectoryEx },
{ "MessageTime", func_MessageTime },
{ "NextDlgItem", func_NextDlgItem },
{ "PrivateExtractIcons", func_PrivateExtractIcons },
{ "RealGetWindowClass", func_RealGetWindowClass },