[KERNEL32_WINETEST]
[reactos.git] / rostests / winetests / kernel32 / timer.c
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 #define _WIN32_WINNT 0x0501
22
23 #include "wine/test.h"
24 #include "winbase.h"
25
26 typedef HANDLE (WINAPI *fnCreateWaitableTimerA)( SECURITY_ATTRIBUTES*, BOOL, LPSTR );
27 typedef BOOL (WINAPI *fnSetWaitableTimer)(HANDLE, LARGE_INTEGER*, LONG, PTIMERAPCROUTINE, LPVOID, BOOL);
28
29
30 static void test_timer(void)
31 {
32 HMODULE hker = GetModuleHandle("kernel32");
33 fnCreateWaitableTimerA pCreateWaitableTimerA;
34 fnSetWaitableTimer pSetWaitableTimer;
35 HANDLE handle;
36 BOOL r;
37 LARGE_INTEGER due;
38
39 pCreateWaitableTimerA = (fnCreateWaitableTimerA) GetProcAddress( hker, "CreateWaitableTimerA");
40 if( !pCreateWaitableTimerA )
41 {
42 win_skip("CreateWaitableTimerA is not available\n");
43 return;
44 }
45
46 pSetWaitableTimer = (fnSetWaitableTimer) GetProcAddress( hker, "SetWaitableTimer");
47 if( !pSetWaitableTimer )
48 {
49 win_skip("SetWaitableTimer is not available\n");
50 return;
51 }
52
53 /* try once with a positive number */
54 handle = pCreateWaitableTimerA( NULL, 0, NULL );
55 ok( handle != NULL, "failed to create waitable timer with no name\n" );
56
57 due.QuadPart = 10000;
58 r = pSetWaitableTimer( handle, &due, 0x1f4, NULL, NULL, FALSE );
59 ok( r, "failed to set timer\n");
60
61 CloseHandle( handle );
62
63 /* try once with a negative number */
64 handle = pCreateWaitableTimerA( NULL, 0, NULL );
65 ok( handle != NULL, "failed to create waitable timer with no name\n" );
66
67 due.QuadPart = -10000;
68 r = pSetWaitableTimer( handle, &due, 0x1f4, NULL, NULL, FALSE );
69 ok( r, "failed to set timer\n");
70
71 CloseHandle( handle );
72 }
73
74 START_TEST(timer)
75 {
76 test_timer();
77 }