Piotr Caban : winmm: Add more timer tests.
Alexandre Julliard
julliard at winehq.org
Wed Sep 30 14:35:31 CDT 2020
Module: wine
Branch: master
Commit: bda21aa992c18b8e02dcbf4ba7f31138d465aa23
URL: https://source.winehq.org/git/wine.git/?a=commit;h=bda21aa992c18b8e02dcbf4ba7f31138d465aa23
Author: Piotr Caban <piotr at codeweavers.com>
Date: Wed Sep 30 14:38:01 2020 +0200
winmm: Add more timer tests.
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winmm/tests/timer.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/dlls/winmm/tests/timer.c b/dlls/winmm/tests/timer.c
index be63f6b032..9fba2ec055 100644
--- a/dlls/winmm/tests/timer.c
+++ b/dlls/winmm/tests/timer.c
@@ -193,6 +193,60 @@ static void test_priority(void)
timeKillEvent(id);
}
+static void CALLBACK kill_timer_callback(UINT id, UINT msg,
+ DWORD_PTR arg, DWORD_PTR dw1, DWORD_PTR dw2)
+{
+ HANDLE event = (HANDLE)arg;
+ MMRESULT res;
+
+ res = timeKillEvent(id);
+ ok(res == TIMERR_NOERROR, "timeKillEvent failed in callback\n");
+ SetEvent(event);
+}
+
+static void test_timer_lifetime(void)
+{
+ UINT timers[20], i;
+ HANDLE event;
+ MMRESULT res;
+
+ event = CreateEventW(NULL, FALSE, FALSE, NULL);
+ ok(event != NULL, "CreateEvent failed\n");
+
+ for (i = 0; i < 20; i++)
+ {
+ timers[i] = timeSetEvent(10000, 0, event, 0, TIME_CALLBACK_EVENT_SET);
+ if (i < 16)
+ ok(timers[i] != 0, "%d) timeSetEvent failed\n", i);
+ else
+ ok(!timers[i], "%d) timeSetEvent succeeded\n", i);
+ }
+
+ for (i = 0; i < 16; i++)
+ {
+ res = timeKillEvent(timers[i]);
+ ok(res == TIMERR_NOERROR, "%d) timeKillEvent failed\n", i);
+ }
+
+ timers[0] = timeSetEvent(10, 0, event, 0, TIME_CALLBACK_EVENT_SET);
+ ok(timers[0], "timeSetEvent failed\n");
+ WaitForSingleObject(event, 1000);
+ timers[1] = timeSetEvent(1000, 0, event, 0, TIME_CALLBACK_EVENT_SET);
+ ok(timers[1], "timeSetEvent failed\n");
+ ok(timers[0] != timers[1], "timer got the same id as just destroyed timer\n");
+ res = timeKillEvent(timers[0]);
+ ok(res == TIMERR_NOCANDO, "timeKillEvent returned %d\n", res);
+ res = timeKillEvent(timers[1]);
+ ok(res == TIMERR_NOERROR, "timeKillEvent returned %d\n", res);
+
+ timers[0] = timeSetEvent(10, 0, kill_timer_callback, (DWORD_PTR)event, TIME_ONESHOT);
+ WaitForSingleObject(event, 1000);
+ timers[0] = timeSetEvent(10, 0, kill_timer_callback, (DWORD_PTR)event, TIME_KILL_SYNCHRONOUS);
+ WaitForSingleObject(event, 1000);
+
+ CloseHandle(event);
+}
+
START_TEST(timer)
{
test_timeGetDevCaps();
@@ -216,4 +270,5 @@ START_TEST(timer)
}
test_priority();
+ test_timer_lifetime();
}
More information about the wine-cvs
mailing list