ReactOS 0.4.15-dev-8058-ga7cbb60
timer.c
Go to the documentation of this file.
1/*
2 * Unit test suite for timer functions
3 *
4 * Copyright 2004 Mike McCormack
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21#include "wine/test.h"
22#include "winbase.h"
23
24
25static void test_timer(void)
26{
27 HANDLE (WINAPI *pCreateWaitableTimerA)( SECURITY_ATTRIBUTES*, BOOL, LPSTR );
28 BOOL (WINAPI *pSetWaitableTimer)(HANDLE, LARGE_INTEGER*, LONG, PTIMERAPCROUTINE, LPVOID, BOOL);
29 HMODULE hker = GetModuleHandleA("kernel32.dll");
31 BOOL r;
32 LARGE_INTEGER due;
33
34 pCreateWaitableTimerA = (void*)GetProcAddress( hker, "CreateWaitableTimerA");
35 if( !pCreateWaitableTimerA )
36 {
37 win_skip("CreateWaitableTimerA is not available\n");
38 return;
39 }
40
41 pSetWaitableTimer = (void*)GetProcAddress( hker, "SetWaitableTimer");
42 if( !pSetWaitableTimer )
43 {
44 win_skip("SetWaitableTimer is not available\n");
45 return;
46 }
47
48 /* try once with a positive number */
49 handle = pCreateWaitableTimerA( NULL, 0, NULL );
50 ok( handle != NULL, "failed to create waitable timer with no name\n" );
51
52 due.QuadPart = 10000;
53 r = pSetWaitableTimer( handle, &due, 0x1f4, NULL, NULL, FALSE );
54 ok( r, "failed to set timer\n");
55
57
58 /* try once with a negative number */
59 handle = pCreateWaitableTimerA( NULL, 0, NULL );
60 ok( handle != NULL, "failed to create waitable timer with no name\n" );
61
62 due.QuadPart = -10000;
63 r = pSetWaitableTimer( handle, &due, 0x1f4, NULL, NULL, FALSE );
64 ok( r, "failed to set timer\n");
65
67}
68
70{
71 test_timer();
72}
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
unsigned int BOOL
Definition: ntddk_ex.h:94
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static void test_timer(void)
Definition: timer.c:25
#define BOOL
Definition: nt_native.h:43
#define LPVOID
Definition: nt_native.h:45
long LONG
Definition: pedump.c:60
#define win_skip
Definition: test.h:163
PVOID HANDLE
Definition: typedefs.h:73
LONGLONG QuadPart
Definition: typedefs.h:114
void(CALLBACK * PTIMERAPCROUTINE)(PVOID, DWORD, DWORD)
Definition: winbase.h:1455
#define WINAPI
Definition: msvc.h:6
char * LPSTR
Definition: xmlstorage.h:182