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