quartz/tests: Check that system clock measurements are in sequence instead of comparing absolute time.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-07-19 22:25:26 -05:00 committed by Alexandre Julliard
parent 4df1a5831c
commit ff231dad75
1 changed files with 10 additions and 13 deletions

View File

@ -24,12 +24,6 @@
static ULONGLONG (WINAPI *pGetTickCount64)(void);
static BOOL compare_time(REFERENCE_TIME x, REFERENCE_TIME y, unsigned int max_diff)
{
REFERENCE_TIME diff = x > y ? x - y : y - x;
return diff <= max_diff;
}
static IReferenceClock *create_system_clock(void)
{
IReferenceClock *clock = NULL;
@ -172,7 +166,7 @@ static void test_aggregation(void)
static void test_get_time(void)
{
IReferenceClock *clock = create_system_clock();
REFERENCE_TIME time1, time2;
REFERENCE_TIME time1, ticks, time2;
HRESULT hr;
ULONG ref;
@ -180,18 +174,21 @@ static void test_get_time(void)
ok(hr == E_POINTER, "Got hr %#x.\n", hr);
hr = IReferenceClock_GetTime(clock, &time1);
if (pGetTickCount64)
time2 = pGetTickCount64() * 10000;
else
time2 = (REFERENCE_TIME)GetTickCount() * 10000;
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(time1 % 10000 == 0, "Expected no less than 1ms coarseness, but got time %s.\n",
wine_dbgstr_longlong(time1));
ok(compare_time(time1, time2, 20 * 10000), "Expected about %s, got %s.\n",
wine_dbgstr_longlong(time2), wine_dbgstr_longlong(time1));
if (pGetTickCount64)
ticks = pGetTickCount64() * 10000;
else
ticks = (REFERENCE_TIME)GetTickCount() * 10000;
hr = IReferenceClock_GetTime(clock, &time2);
ok(hr == (time2 == time1 ? S_FALSE : S_OK), "Got hr %#x.\n", hr);
ok(time2 % 10000 == 0, "Expected no less than 1ms coarseness, but got time %s.\n",
wine_dbgstr_longlong(time1));
ok(time2 >= ticks && ticks >= time1, "Got timestamps %I64d, %I64d, %I64d.\n", time1, ticks, time2);
Sleep(100);
hr = IReferenceClock_GetTime(clock, &time2);