ReactOS 0.4.16-dev-433-g6363f78
NtUserSetTimer.c File Reference
#include "../win32nt.h"
Include dependency graph for NtUserSetTimer.c:

Go to the source code of this file.

Classes

struct  TIMER_MESSAGE_STATE1
 
struct  TIMER_MESSAGE_STATEW1
 

Macros

#define SLEEP_TIME   500
 
#define MIN_MESSAGES_TIME   1
 
#define MAX_MESSAGES_TIME   1000
 
#define TEST1_COUNT   20
 
#define TEST1_INTERVAL   10
 
#define TEST2_COUNT   40000
 
#define TEST2_INTERVAL   10
 
#define TESTW1_COUNT   20
 
#define TESTW1_INTERVAL   10
 
#define TESTW2_COUNT   40000
 
#define TESTW2_INTERVAL   10
 

Typedefs

typedef struct TIMER_MESSAGE_STATE1 TIMER_MESSAGE_STATE1
 
typedef struct TIMER_MESSAGE_STATEW1 TIMER_MESSAGE_STATEW1
 

Functions

static void CALLBACK TimerProc (HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
 
static LRESULT CALLBACK WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static BOOL test1 (void)
 
static BOOL test2 (void)
 
static BOOL test3 (void)
 
static BOOL testW1 (HWND hwnd)
 
static BOOL testW2 (HWND hwnd)
 
 START_TEST (NtUserSetTimer)
 

Variables

TIMER_MESSAGE_STATE1 timerId1 [TEST1_COUNT]
 
TIMER_MESSAGE_STATEW1 timerIdW1 [TESTW1_COUNT]
 

Macro Definition Documentation

◆ MAX_MESSAGES_TIME

#define MAX_MESSAGES_TIME   1000

Definition at line 13 of file NtUserSetTimer.c.

◆ MIN_MESSAGES_TIME

#define MIN_MESSAGES_TIME   1

Definition at line 12 of file NtUserSetTimer.c.

◆ SLEEP_TIME

#define SLEEP_TIME   500

Definition at line 11 of file NtUserSetTimer.c.

◆ TEST1_COUNT

#define TEST1_COUNT   20

Definition at line 15 of file NtUserSetTimer.c.

◆ TEST1_INTERVAL

#define TEST1_INTERVAL   10

Definition at line 16 of file NtUserSetTimer.c.

◆ TEST2_COUNT

#define TEST2_COUNT   40000

Definition at line 18 of file NtUserSetTimer.c.

◆ TEST2_INTERVAL

#define TEST2_INTERVAL   10

Definition at line 19 of file NtUserSetTimer.c.

◆ TESTW1_COUNT

#define TESTW1_COUNT   20

Definition at line 21 of file NtUserSetTimer.c.

◆ TESTW1_INTERVAL

#define TESTW1_INTERVAL   10

Definition at line 22 of file NtUserSetTimer.c.

◆ TESTW2_COUNT

#define TESTW2_COUNT   40000

Definition at line 24 of file NtUserSetTimer.c.

◆ TESTW2_INTERVAL

#define TESTW2_INTERVAL   10

Definition at line 25 of file NtUserSetTimer.c.

Typedef Documentation

◆ TIMER_MESSAGE_STATE1

◆ TIMER_MESSAGE_STATEW1

Function Documentation

◆ START_TEST()

START_TEST ( NtUserSetTimer  )

Definition at line 219 of file NtUserSetTimer.c.

220{
221 WNDCLASSW wc = { 0 };
222 HWND hwnd;
223
224 // TEST WITH MESSAGES WITHOUT WINDOW - test count of sent messages
225 TEST(test1());
226
227 // TEST WITH MESSAGES WITHOUT WINDOW - create many timers
228 TEST(test2());
229
230 // TEST WITH MESSAGES WITHOUT WINDOW - test different ids
231 TEST(test3());
232
235 wc.lpszClassName = L"TimerWindowClass";
236 RegisterClassW(&wc);
237
238 hwnd = CreateWindowExW(0, L"TimerWindowClass", L"Timer Window", 0,
241
242 // TEST WITH MESSAGES WITH WINDOW - test count of sent messages
243 TEST(testW1(hwnd));
244
245 // TEST WITH MESSAGES WITH WINDOW - create many timers
246 TEST(testW2(hwnd));
247
248 if (hwnd != NULL)
250 UnregisterClassW(L"TimerWindowClass", NULL);
251}
static BOOL testW1(HWND hwnd)
static BOOL test1(void)
static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
static BOOL testW2(HWND hwnd)
static BOOL test3(void)
static BOOL test2(void)
#define NULL
Definition: types.h:112
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define TEST(x)
Definition: precomp.h:20
#define L(x)
Definition: ntvdm.h:50
LPCWSTR lpszClassName
Definition: winuser.h:3188
HINSTANCE hInstance
Definition: winuser.h:3183
WNDPROC lpfnWndProc
Definition: winuser.h:3180
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define HWND_MESSAGE
Definition: winuser.h:1213
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define CW_USEDEFAULT
Definition: winuser.h:225
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
BOOL WINAPI DestroyWindow(_In_ HWND)

◆ test1()

static BOOL test1 ( void  )
static

Definition at line 69 of file NtUserSetTimer.c.

70{
71 UINT i, countErrors = 0;
73 MSG msg = { NULL };
74
76
77 for (i = 0; i < TEST1_COUNT; i++)
78 {
80 if (timerId1[i].index == 0)
81 countErrors++;
82 }
83
85
86 while (GetMessageW(&msg, NULL, 0, 0))
87 {
90
93 }
94
95 for (i = 0; i < TEST1_COUNT; i++)
96 {
98 countErrors++;
99 }
100
101 for (i = 0; i < TEST1_COUNT; i++)
102 {
103 if (KillTimer(NULL, timerId1[i].index) == 0)
104 countErrors++;
105 }
106
107 return (countErrors == 0);
108}
#define MIN_MESSAGES_TIME
#define TEST1_INTERVAL
TIMER_MESSAGE_STATE1 timerId1[TEST1_COUNT]
static void CALLBACK TimerProc(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
#define MAX_MESSAGES_TIME
#define SLEEP_TIME
#define TEST1_COUNT
#define msg(x)
Definition: auth_time.c:54
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
static ULONGLONG startTime
Definition: main.c:113
GLuint index
Definition: glext.h:6031
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
uint64_t ULONGLONG
Definition: typedefs.h:67
#define ZeroMemory
Definition: winbase.h:1737
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)

Referenced by START_TEST().

◆ test2()

static BOOL test2 ( void  )
static

Definition at line 111 of file NtUserSetTimer.c.

112{
113 UINT i, countErrors = 0;
114 UINT_PTR locIndex;
115
116 for (i = 0; i < TEST2_COUNT; i++)
117 {
118 locIndex = SetTimer(NULL, 0, TEST2_INTERVAL, TimerProc);
119
120 if (locIndex == 0)
121 countErrors++;
122 if (KillTimer(NULL, locIndex) == 0)
123 countErrors++;
124 }
125
126 return (countErrors == 0);
127}
#define TEST2_INTERVAL
#define TEST2_COUNT
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274

Referenced by START_TEST().

◆ test3()

static BOOL test3 ( void  )
static

Definition at line 130 of file NtUserSetTimer.c.

131{
132 UINT countErrors = 0;
133 UINT_PTR locIndex1;
134 UINT_PTR locIndex2;
135
136 locIndex1 = SetTimer(NULL, 0, TEST1_INTERVAL, TimerProc);
137 if (locIndex1 == 0)
138 countErrors++;
139 if (KillTimer(NULL, locIndex1) == 0)
140 countErrors++;
141 locIndex2 = SetTimer(NULL, 0, TEST1_INTERVAL, TimerProc);
142 if (locIndex2 == 0)
143 countErrors++;
144 if (KillTimer(NULL, locIndex2) == 0)
145 countErrors++;
146 if (locIndex1 == locIndex2)
147 countErrors++;
148
149 return (countErrors == 0);
150}

Referenced by START_TEST().

◆ testW1()

static BOOL testW1 ( HWND  hwnd)
static

Definition at line 153 of file NtUserSetTimer.c.

154{
155 UINT i, countErrors = 0;
156 UINT_PTR locIndex;
158 MSG msg = { NULL };
159
160 if (hwnd == NULL)
161 return FALSE;
162
164
165 for (i = 0; i < TESTW1_COUNT; i++)
166 {
167 locIndex = SetTimer(hwnd, i, TESTW1_INTERVAL, NULL);
168 if (locIndex == 0)
169 countErrors++;
170 }
171
173
174 while (GetMessageW(&msg, NULL, 0, 0))
175 {
178
181 }
182
183 for (i = 0; i < TESTW1_COUNT; i++)
184 {
186 countErrors++;
187 }
188
189 for (i = 0; i < TESTW1_COUNT; i++)
190 {
191 if (KillTimer(hwnd, i) == 0)
192 countErrors++;
193 }
194
195 return (countErrors == 0);
196}
#define TESTW1_INTERVAL
TIMER_MESSAGE_STATEW1 timerIdW1[TESTW1_COUNT]
#define TESTW1_COUNT
#define FALSE
Definition: types.h:117

Referenced by START_TEST().

◆ testW2()

static BOOL testW2 ( HWND  hwnd)
static

Definition at line 199 of file NtUserSetTimer.c.

200{
201 UINT i, countErrors = 0;
203
204 if (hwnd == NULL)
205 return FALSE;
206
207 for (i = 0; i < TESTW2_COUNT; i++)
208 {
210 if (result == 0)
211 countErrors++;
212 if (KillTimer(hwnd, 1) == 0)
213 countErrors++;
214 }
215
216 return (countErrors == 0);
217}
#define TESTW2_INTERVAL
#define TESTW2_COUNT
GLuint64EXT * result
Definition: glext.h:11304

Referenced by START_TEST().

◆ TimerProc()

static void CALLBACK TimerProc ( HWND  hWnd,
UINT  uMsg,
UINT_PTR  idEvent,
DWORD  dwTime 
)
static

Definition at line 44 of file NtUserSetTimer.c.

45{
46 UINT i;
47 for (i = 0; i < TEST1_COUNT; i++)
48 {
49 if (timerId1[i].index == idEvent)
51 }
52}

Referenced by test1(), test2(), and test3().

◆ WindowProc()

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

Definition at line 56 of file NtUserSetTimer.c.

57{
58 switch (uMsg)
59 {
60 case WM_TIMER:
62 return 0;
63 }
64
65 return DefWindowProcW(hwnd, uMsg, wParam, lParam);
66}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_TIMER
Definition: winuser.h:1745

Referenced by START_TEST().

Variable Documentation

◆ timerId1

Definition at line 33 of file NtUserSetTimer.c.

Referenced by test1(), and TimerProc().

◆ timerIdW1

Definition at line 40 of file NtUserSetTimer.c.

Referenced by testW1(), and WindowProc().