ReactOS 0.4.15-dev-8191-gbc6c731
GetMessageTime.c File Reference
#include "precomp.h"
Include dependency graph for GetMessageTime.c:

Go to the source code of this file.

Macros

#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
 

Functions

static LRESULT CALLBACK WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
 START_TEST (GetMessageTime)
 

Variables

static INT s_nCount = 0
 
static LONG s_nMsgTime = 0
 

Macro Definition Documentation

◆ MOUSE_LOCATION_X

#define MOUSE_LOCATION_X (   x)    ((DWORD)(x) * 0xFFFF / GetSystemMetrics(SM_CXSCREEN))

Definition at line 12 of file GetMessageTime.c.

◆ MOUSE_LOCATION_Y

#define MOUSE_LOCATION_Y (   y)    ((DWORD)(y) * 0xFFFF / GetSystemMetrics(SM_CYSCREEN))

Definition at line 13 of file GetMessageTime.c.

◆ TIMER_ID

#define TIMER_ID   999

Definition at line 9 of file GetMessageTime.c.

◆ TIMER_INTERVAL

#define TIMER_INTERVAL   500 /* 500 milliseconds */

Definition at line 10 of file GetMessageTime.c.

◆ WIN_CX

#define WIN_CX   100

Definition at line 17 of file GetMessageTime.c.

◆ WIN_CY

#define WIN_CY   100

Definition at line 18 of file GetMessageTime.c.

◆ WIN_X

#define WIN_X   50

Definition at line 15 of file GetMessageTime.c.

◆ WIN_Y

#define WIN_Y   50

Definition at line 16 of file GetMessageTime.c.

Function Documentation

◆ START_TEST()

START_TEST ( GetMessageTime  )

Definition at line 107 of file GetMessageTime.c.

108{
109 static const WCHAR s_szName[] = L"MessageTimeTestWindow";
110 WNDCLASSW wc;
111 ATOM atom;
112 HWND hwnd;
113 MSG msg;
114 BOOL bRet;
115
118 0, 0);
119
120 ZeroMemory(&wc, sizeof(wc));
125 wc.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1);
127 atom = RegisterClassW(&wc);
128 ok(atom != 0, "RegisterClassW\n");
129
134 ok(hwnd != NULL, "CreateWindowW\n");
135
136 if (hwnd)
137 {
140
141 while (GetMessageW(&msg, NULL, 0, 0))
142 {
145 }
146 }
147 else
148 {
149 skip("hwnd was NULL.\n");
150 }
151
153 ok_int(bRet, 1);
154
155 ok_int(s_nCount, 5);
156 ok(s_nMsgTime != 0, "message time was zero.\n");
157}
#define WIN_Y
static INT s_nCount
#define WIN_CX
static LONG s_nMsgTime
#define MOUSE_LOCATION_Y(y)
#define WIN_X
#define WIN_CY
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
#define MOUSE_LOCATION_X(x)
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define ok_int(expression, result)
Definition: atltest.h:134
#define msg(x)
Definition: auth_time.c:54
static WCHAR s_szName[MAX_PATH]
Definition: find.c:34
WORD ATOM
Definition: dimm.idl:113
#define NULL
Definition: types.h:112
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
unsigned int BOOL
Definition: ntddk_ex.h:94
#define L(x)
Definition: ntvdm.h:50
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
LPCWSTR lpszClassName
Definition: winuser.h:3185
HBRUSH hbrBackground
Definition: winuser.h:3183
HICON hIcon
Definition: winuser.h:3181
HINSTANCE hInstance
Definition: winuser.h:3180
WNDPROC lpfnWndProc
Definition: winuser.h:3177
HCURSOR hCursor
Definition: winuser.h:3182
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define ZeroMemory
Definition: winbase.h:1712
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define SW_SHOWNORMAL
Definition: winuser.h:770
#define MOUSEEVENTF_ABSOLUTE
Definition: winuser.h:1194
void WINAPI mouse_event(_In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ ULONG_PTR)
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define IDC_ARROW
Definition: winuser.h:687
#define IDI_APPLICATION
Definition: winuser.h:704
#define MOUSEEVENTF_MOVE
Definition: winuser.h:1183
#define LoadIcon
Definition: winuser.h:5822
BOOL WINAPI UpdateWindow(_In_ HWND)
#define LoadCursor
Definition: winuser.h:5821
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4316
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
#define COLOR_3DFACE
Definition: winuser.h:929
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ WindowProc()

static LRESULT CALLBACK WindowProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 24 of file GetMessageTime.c.

25{
26 static BOOL s_bReach_WM_MOUSEMOVE;
27 static BOOL s_bReach_WM_LBUTTONDOWN;
28 static BOOL s_bReach_WM_LBUTTONUP;
29 switch (uMsg)
30 {
31 case WM_CREATE:
32 s_nCount = 0;
35 s_bReach_WM_MOUSEMOVE = FALSE;
36 s_bReach_WM_LBUTTONDOWN = FALSE;
37 s_bReach_WM_LBUTTONUP = FALSE;
38 break;
39 case WM_TIMER:
40 if (s_nCount == 5)
41 {
44 break;
45 }
46 if (s_nCount != 0)
47 {
49 "GetMessageTime() is wrong, compared to previous one\n");
51 "GetMessageTime() is wrong, compared to GetTickCount()\n");
52 }
54 ok(s_nMsgTime != 0, "message time was zero.\n");
55 s_nCount++;
56 if (s_nCount == 5)
57 {
61 0, 0);
62 mouse_event(MOUSEEVENTF_MOVE, 1, 1, 0, 0);
65 }
66 break;
67 case WM_MOUSEMOVE:
68 trace("WM_MOUSEMOVE\n");
69 ok_int(s_nCount, 5);
70 // This test randomly fails on Windows 2003
71 //ok(GetMessageTime() - s_nMsgTime < TIMER_INTERVAL,
72 // "GetMessageTime() is wrong, compared to previous one\n");
74 "GetMessageTime() is wrong, compared to GetTickCount()\n");
75 s_bReach_WM_MOUSEMOVE = TRUE;
76 break;
77 case WM_LBUTTONDOWN:
78 trace("WM_LBUTTONDOWN\n");
79 ok_int(s_nCount, 5);
81 "GetMessageTime() is wrong, compared to previous one\n");
83 "GetMessageTime() is wrong, compared to GetTickCount()\n");
84 s_bReach_WM_LBUTTONDOWN = TRUE;
85 break;
86 case WM_LBUTTONUP:
87 trace("WM_LBUTTONUP\n");
88 ok_int(s_nCount, 5);
90 "GetMessageTime() is wrong, compared to previous one\n");
92 "GetMessageTime() is wrong, compared to GetTickCount()\n");
93 s_bReach_WM_LBUTTONUP = TRUE;
94 break;
95 case WM_DESTROY:
96 ok_int(s_bReach_WM_MOUSEMOVE, TRUE);
97 ok_int(s_bReach_WM_LBUTTONDOWN, TRUE);
98 ok_int(s_bReach_WM_LBUTTONUP, TRUE);
100 break;
101 default:
102 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
103 }
104 return 0;
105}
#define TIMER_INTERVAL
#define TIMER_ID
Definition: GetMessageTime.c:9
#define trace
Definition: atltest.h:70
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
unsigned long DWORD
Definition: ntddk_ex.h:95
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MOUSEEVENTF_LEFTUP
Definition: winuser.h:1185
#define WM_CREATE
Definition: winuser.h:1608
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_MOUSEMOVE
Definition: winuser.h:1775
#define WM_LBUTTONDOWN
Definition: winuser.h:1776
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define MOUSEEVENTF_LEFTDOWN
Definition: winuser.h:1184
#define WM_TIMER
Definition: winuser.h:1742
#define WM_LBUTTONUP
Definition: winuser.h:1777
LONG WINAPI GetMessageTime(void)
Definition: message.c:1361
#define WM_DESTROY
Definition: winuser.h:1609
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by START_TEST().

Variable Documentation

◆ s_nCount

INT s_nCount = 0
static

Definition at line 20 of file GetMessageTime.c.

Referenced by START_TEST(), and WindowProc().

◆ s_nMsgTime

LONG s_nMsgTime = 0
static

Definition at line 21 of file GetMessageTime.c.

Referenced by START_TEST(), and WindowProc().