mirror of
https://github.com/reactos/reactos.git
synced 2024-12-31 19:42:51 +00:00
[USER32_APITEST] Improve GetMessageTime tests
This commit is contained in:
parent
87bfbb3ec7
commit
b490084d38
3 changed files with 59 additions and 11 deletions
|
@ -15,6 +15,7 @@ list(APPEND SOURCE
|
||||||
GetDCEx.c
|
GetDCEx.c
|
||||||
GetIconInfo.c
|
GetIconInfo.c
|
||||||
GetKeyState.c
|
GetKeyState.c
|
||||||
|
GetMessageTime.c
|
||||||
GetPeekMessage.c
|
GetPeekMessage.c
|
||||||
GetSystemMetrics.c
|
GetSystemMetrics.c
|
||||||
GetUserObjectInformation.c
|
GetUserObjectInformation.c
|
||||||
|
@ -22,7 +23,6 @@ list(APPEND SOURCE
|
||||||
InitializeLpkHooks.c
|
InitializeLpkHooks.c
|
||||||
LoadImage.c
|
LoadImage.c
|
||||||
LookupIconIdFromDirectoryEx.c
|
LookupIconIdFromDirectoryEx.c
|
||||||
MessageTime.c
|
|
||||||
NextDlgItem.c
|
NextDlgItem.c
|
||||||
PrivateExtractIcons.c
|
PrivateExtractIcons.c
|
||||||
RealGetWindowClass.c
|
RealGetWindowClass.c
|
||||||
|
|
|
@ -1,29 +1,48 @@
|
||||||
/*
|
/*
|
||||||
* PROJECT: ReactOS api tests
|
* PROJECT: ReactOS api tests
|
||||||
* LICENSE: GPL - See COPYING in the top level directory
|
* 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>
|
* PROGRAMMERS: Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "precomp.h"
|
#include "precomp.h"
|
||||||
|
|
||||||
#define TIMER_ID 999
|
#define TIMER_ID 999
|
||||||
#define TIMER_INTERVAL 500 /* 500 milliseconds */
|
#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 INT s_nCount = 0;
|
||||||
static LONG s_nMsgTime = 0;
|
static LONG s_nMsgTime = 0;
|
||||||
|
|
||||||
static LRESULT CALLBACK
|
static LRESULT CALLBACK
|
||||||
WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
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)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
s_nCount = 0;
|
s_nCount = 0;
|
||||||
s_nMsgTime = GetMessageTime();
|
s_nMsgTime = GetMessageTime();
|
||||||
SetTimer(hwnd, TIMER_ID, TIMER_INTERVAL, NULL);
|
SetTimer(hwnd, TIMER_ID, TIMER_INTERVAL, NULL);
|
||||||
|
s_bReach_WM_MOUSEMOVE = FALSE;
|
||||||
|
s_bReach_WM_LBUTTONDOWN = FALSE;
|
||||||
|
s_bReach_WM_LBUTTONUP = FALSE;
|
||||||
break;
|
break;
|
||||||
case WM_TIMER:
|
case WM_TIMER:
|
||||||
|
if (s_nCount == 5)
|
||||||
|
{
|
||||||
|
KillTimer(hwnd, TIMER_ID);
|
||||||
|
DestroyWindow(hwnd);
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (s_nCount != 0)
|
if (s_nCount != 0)
|
||||||
{
|
{
|
||||||
ok(GetMessageTime() - s_nMsgTime >= TIMER_INTERVAL / 2,
|
ok(GetMessageTime() - s_nMsgTime >= TIMER_INTERVAL / 2,
|
||||||
|
@ -32,13 +51,39 @@ WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
s_nMsgTime = GetMessageTime();
|
s_nMsgTime = GetMessageTime();
|
||||||
ok(s_nMsgTime != 0, "message time was zero.\n");
|
ok(s_nMsgTime != 0, "message time was zero.\n");
|
||||||
s_nCount++;
|
s_nCount++;
|
||||||
if (s_nCount >= 5)
|
if (s_nCount == 5)
|
||||||
{
|
{
|
||||||
KillTimer(hwnd, TIMER_ID);
|
mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE,
|
||||||
DestroyWindow(hwnd);
|
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;
|
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:
|
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);
|
PostQuitMessage(0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -47,7 +92,7 @@ WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
START_TEST(MessageTime)
|
START_TEST(GetMessageTime)
|
||||||
{
|
{
|
||||||
static const WCHAR s_szName[] = L"MessageTimeTestWindow";
|
static const WCHAR s_szName[] = L"MessageTimeTestWindow";
|
||||||
WNDCLASSW wc;
|
WNDCLASSW wc;
|
||||||
|
@ -56,6 +101,10 @@ START_TEST(MessageTime)
|
||||||
MSG msg;
|
MSG msg;
|
||||||
BOOL bRet;
|
BOOL bRet;
|
||||||
|
|
||||||
|
mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE,
|
||||||
|
MOUSE_LOCATION_X(1), MOUSE_LOCATION_Y(1),
|
||||||
|
0, 0);
|
||||||
|
|
||||||
ZeroMemory(&wc, sizeof(wc));
|
ZeroMemory(&wc, sizeof(wc));
|
||||||
wc.lpfnWndProc = WindowProc;
|
wc.lpfnWndProc = WindowProc;
|
||||||
wc.hInstance = GetModuleHandleW(NULL);
|
wc.hInstance = GetModuleHandleW(NULL);
|
||||||
|
@ -68,8 +117,7 @@ START_TEST(MessageTime)
|
||||||
|
|
||||||
hwnd = CreateWindowW(s_szName, s_szName,
|
hwnd = CreateWindowW(s_szName, s_szName,
|
||||||
WS_OVERLAPPEDWINDOW,
|
WS_OVERLAPPEDWINDOW,
|
||||||
CW_USEDEFAULT, 0,
|
WIN_X, WIN_Y, WIN_CX, WIN_CY,
|
||||||
CW_USEDEFAULT, 0,
|
|
||||||
NULL, NULL, GetModuleHandleW(NULL), NULL);
|
NULL, NULL, GetModuleHandleW(NULL), NULL);
|
||||||
ok(hwnd != NULL, "CreateWindowW\n");
|
ok(hwnd != NULL, "CreateWindowW\n");
|
||||||
|
|
|
@ -17,6 +17,7 @@ extern void func_EnumDisplaySettings(void);
|
||||||
extern void func_GetDCEx(void);
|
extern void func_GetDCEx(void);
|
||||||
extern void func_GetIconInfo(void);
|
extern void func_GetIconInfo(void);
|
||||||
extern void func_GetKeyState(void);
|
extern void func_GetKeyState(void);
|
||||||
|
extern void func_GetMessageTime(void);
|
||||||
extern void func_GetPeekMessage(void);
|
extern void func_GetPeekMessage(void);
|
||||||
extern void func_GetSystemMetrics(void);
|
extern void func_GetSystemMetrics(void);
|
||||||
extern void func_GetUserObjectInformation(void);
|
extern void func_GetUserObjectInformation(void);
|
||||||
|
@ -24,7 +25,6 @@ extern void func_GetWindowPlacement(void);
|
||||||
extern void func_InitializeLpkHooks(void);
|
extern void func_InitializeLpkHooks(void);
|
||||||
extern void func_LoadImage(void);
|
extern void func_LoadImage(void);
|
||||||
extern void func_LookupIconIdFromDirectoryEx(void);
|
extern void func_LookupIconIdFromDirectoryEx(void);
|
||||||
extern void func_MessageTime(void);
|
|
||||||
extern void func_NextDlgItem(void);
|
extern void func_NextDlgItem(void);
|
||||||
extern void func_PrivateExtractIcons(void);
|
extern void func_PrivateExtractIcons(void);
|
||||||
extern void func_RealGetWindowClass(void);
|
extern void func_RealGetWindowClass(void);
|
||||||
|
@ -62,6 +62,7 @@ const struct test winetest_testlist[] =
|
||||||
{ "GetDCEx", func_GetDCEx },
|
{ "GetDCEx", func_GetDCEx },
|
||||||
{ "GetIconInfo", func_GetIconInfo },
|
{ "GetIconInfo", func_GetIconInfo },
|
||||||
{ "GetKeyState", func_GetKeyState },
|
{ "GetKeyState", func_GetKeyState },
|
||||||
|
{ "GetMessageTime", func_GetMessageTime },
|
||||||
{ "GetPeekMessage", func_GetPeekMessage },
|
{ "GetPeekMessage", func_GetPeekMessage },
|
||||||
{ "GetSystemMetrics", func_GetSystemMetrics },
|
{ "GetSystemMetrics", func_GetSystemMetrics },
|
||||||
{ "GetUserObjectInformation", func_GetUserObjectInformation },
|
{ "GetUserObjectInformation", func_GetUserObjectInformation },
|
||||||
|
@ -69,7 +70,6 @@ const struct test winetest_testlist[] =
|
||||||
{ "InitializeLpkHooks", func_InitializeLpkHooks },
|
{ "InitializeLpkHooks", func_InitializeLpkHooks },
|
||||||
{ "LoadImage", func_LoadImage },
|
{ "LoadImage", func_LoadImage },
|
||||||
{ "LookupIconIdFromDirectoryEx", func_LookupIconIdFromDirectoryEx },
|
{ "LookupIconIdFromDirectoryEx", func_LookupIconIdFromDirectoryEx },
|
||||||
{ "MessageTime", func_MessageTime },
|
|
||||||
{ "NextDlgItem", func_NextDlgItem },
|
{ "NextDlgItem", func_NextDlgItem },
|
||||||
{ "PrivateExtractIcons", func_PrivateExtractIcons },
|
{ "PrivateExtractIcons", func_PrivateExtractIcons },
|
||||||
{ "RealGetWindowClass", func_RealGetWindowClass },
|
{ "RealGetWindowClass", func_RealGetWindowClass },
|
||||||
|
|
Loading…
Reference in a new issue