2004-09-08 01:28:32 +02:00
|
|
|
/*
|
2010-01-23 16:46:09 +01:00
|
|
|
* Unit test suite for timer functions
|
2004-09-08 01:28:32 +02:00
|
|
|
*
|
|
|
|
* Copyright 2004 Mike McCormack
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-09-08 01:28:32 +02:00
|
|
|
*/
|
|
|
|
|
2004-09-08 21:06:07 +02:00
|
|
|
#define _WIN32_WINNT 0x0501
|
|
|
|
|
2004-09-08 01:28:32 +02:00
|
|
|
#include "wine/test.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
|
|
|
|
|
2005-06-14 13:40:04 +02:00
|
|
|
static void test_timer(void)
|
2004-09-08 01:28:32 +02:00
|
|
|
{
|
2012-06-15 15:20:24 +02:00
|
|
|
HANDLE (WINAPI *pCreateWaitableTimerA)( SECURITY_ATTRIBUTES*, BOOL, LPSTR );
|
|
|
|
BOOL (WINAPI *pSetWaitableTimer)(HANDLE, LARGE_INTEGER*, LONG, PTIMERAPCROUTINE, LPVOID, BOOL);
|
2013-10-21 10:02:49 +02:00
|
|
|
HMODULE hker = GetModuleHandleA("kernel32.dll");
|
2004-09-08 01:28:32 +02:00
|
|
|
HANDLE handle;
|
|
|
|
BOOL r;
|
|
|
|
LARGE_INTEGER due;
|
|
|
|
|
2012-06-15 15:20:24 +02:00
|
|
|
pCreateWaitableTimerA = (void*)GetProcAddress( hker, "CreateWaitableTimerA");
|
2004-09-08 01:28:32 +02:00
|
|
|
if( !pCreateWaitableTimerA )
|
2008-06-08 14:09:37 +02:00
|
|
|
{
|
2009-02-24 00:03:07 +01:00
|
|
|
win_skip("CreateWaitableTimerA is not available\n");
|
2004-09-08 01:28:32 +02:00
|
|
|
return;
|
2008-06-08 14:09:37 +02:00
|
|
|
}
|
2004-09-08 01:28:32 +02:00
|
|
|
|
2012-06-15 15:20:24 +02:00
|
|
|
pSetWaitableTimer = (void*)GetProcAddress( hker, "SetWaitableTimer");
|
2004-09-08 01:28:32 +02:00
|
|
|
if( !pSetWaitableTimer )
|
2008-06-08 14:09:37 +02:00
|
|
|
{
|
2009-02-24 00:03:07 +01:00
|
|
|
win_skip("SetWaitableTimer is not available\n");
|
2004-09-08 01:28:32 +02:00
|
|
|
return;
|
2008-06-08 14:09:37 +02:00
|
|
|
}
|
2004-09-08 01:28:32 +02:00
|
|
|
|
|
|
|
/* try once with a positive number */
|
|
|
|
handle = pCreateWaitableTimerA( NULL, 0, NULL );
|
|
|
|
ok( handle != NULL, "failed to create waitable timer with no name\n" );
|
|
|
|
|
|
|
|
due.QuadPart = 10000;
|
|
|
|
r = pSetWaitableTimer( handle, &due, 0x1f4, NULL, NULL, FALSE );
|
|
|
|
ok( r, "failed to set timer\n");
|
|
|
|
|
|
|
|
CloseHandle( handle );
|
|
|
|
|
|
|
|
/* try once with a negative number */
|
|
|
|
handle = pCreateWaitableTimerA( NULL, 0, NULL );
|
|
|
|
ok( handle != NULL, "failed to create waitable timer with no name\n" );
|
|
|
|
|
|
|
|
due.QuadPart = -10000;
|
|
|
|
r = pSetWaitableTimer( handle, &due, 0x1f4, NULL, NULL, FALSE );
|
|
|
|
ok( r, "failed to set timer\n");
|
|
|
|
|
|
|
|
CloseHandle( handle );
|
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(timer)
|
|
|
|
{
|
|
|
|
test_timer();
|
|
|
|
}
|