Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
8907220c
Commit
8907220c
authored
Mar 13, 2019
by
Zebediah Figura
Committed by
Alexandre Julliard
Mar 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
quartz/tests: Rewrite test_IReferenceClock_methods().
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
c3e4b3a3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
54 deletions
+33
-54
systemclock.c
dlls/quartz/tests/systemclock.c
+33
-54
No files found.
dlls/quartz/tests/systemclock.c
View file @
8907220c
...
...
@@ -22,6 +22,8 @@
#include "dshow.h"
#include "wine/test.h"
static
ULONGLONG
(
WINAPI
*
pGetTickCount64
)(
void
);
static
IReferenceClock
*
create_system_clock
(
void
)
{
IReferenceClock
*
filter
=
NULL
;
...
...
@@ -60,71 +62,48 @@ static void test_interfaces(void)
ok
(
!
ref
,
"Got outstanding refcount %d.
\n
"
,
ref
);
}
/* The following method expects a reference clock that will keep ticking for
* at least 5 seconds since its creation. This method assumes no other methods
* were called on the IReferenceClock interface since its creation.
*/
static
void
test_IReferenceClock_methods
(
const
char
*
clockdesc
,
IReferenceClock
*
pClock
)
static
void
test_get_time
(
void
)
{
IReferenceClock
*
clock
=
create_system_clock
();
REFERENCE_TIME
time1
,
time2
;
HRESULT
hr
;
REFERENCE_TIME
time1
;
REFERENCE_TIME
time2
;
LONG
diff
;
/* Test response from invalid (NULL) argument */
hr
=
IReferenceClock_GetTime
(
pClock
,
NULL
);
ok
(
hr
==
E_POINTER
,
"%s - Expected E_POINTER (0x%08x), got 0x%08x
\n
"
,
clockdesc
,
E_POINTER
,
hr
);
/* Test response for valid value - try 1 */
/* TODO: test whether Windows actually returns S_FALSE in its first invocation */
time1
=
(
REFERENCE_TIME
)
0xdeadbeef
;
hr
=
IReferenceClock_GetTime
(
pClock
,
&
time1
);
ok
(
hr
==
S_FALSE
||
hr
==
S_OK
,
"%s - Expected S_OK or S_FALSE, got 0x%08x
\n
"
,
clockdesc
,
hr
);
ok
(
time1
!=
0xdeadbeef
,
"%s - value was NOT changed on return!
\n
"
,
clockdesc
);
/* Test response for valid value - try 2 */
time2
=
(
REFERENCE_TIME
)
0xdeadbeef
;
hr
=
IReferenceClock_GetTime
(
pClock
,
&
time2
);
ok
(
hr
==
S_FALSE
||
hr
==
S_OK
,
"%s - Expected S_OK or S_FALSE, got 0x%08x
\n
"
,
clockdesc
,
hr
);
ok
(
time2
!=
0xdeadbeef
,
"%s - value was NOT changed on return!
\n
"
,
clockdesc
);
/* In case the second invocation managed to return S_FALSE, MSDN says the
returned time is the same as the previous one. */
ok
((
hr
!=
S_FALSE
||
time1
==
time2
),
"%s - returned S_FALSE, but values not equal!
\n
"
,
clockdesc
);
time1
=
time2
;
Sleep
(
1000
);
/* Sleep for at least 1 second */
hr
=
IReferenceClock_GetTime
(
pClock
,
&
time2
);
/* After a 1-second sleep, there is no excuse to get S_FALSE (see TODO above) */
ok
(
hr
==
S_OK
,
"%s - Expected S_OK, got 0x%08x
\n
"
,
clockdesc
,
hr
);
/* FIXME: How much deviation should be allowed after a sleep? */
/* 0.3% is common, and 0.4% is sometimes observed. */
diff
=
time2
-
time1
;
ok
(
9940000
<=
diff
&&
diff
<=
10240000
,
"%s - Expected difference around 10000000, got %u
\n
"
,
clockdesc
,
diff
);
}
ULONG
ref
;
static
void
test_IReferenceClock_SystemClock
(
void
)
{
IReferenceClock
*
pReferenceClock
;
HRESULT
hr
;
hr
=
IReferenceClock_GetTime
(
clock
,
NULL
);
ok
(
hr
==
E_POINTER
,
"Got hr %#x.
\n
"
,
hr
);
hr
=
IReferenceClock_GetTime
(
clock
,
&
time1
);
if
(
pGetTickCount64
)
time2
=
GetTickCount64
()
*
10000
;
else
time2
=
GetTickCount
()
*
10000
;
todo_wine
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
));
todo_wine
ok
(
abs
(
time1
-
time2
)
<
20
*
10000
,
"Expected about %s, got %s.
\n
"
,
wine_dbgstr_longlong
(
time2
),
wine_dbgstr_longlong
(
time1
));
hr
=
IReferenceClock_GetTime
(
clock
,
&
time2
);
ok
(
hr
==
(
time2
==
time1
?
S_FALSE
:
S_OK
),
"Got hr %#x.
\n
"
,
hr
);
Sleep
(
100
);
hr
=
IReferenceClock_GetTime
(
clock
,
&
time2
);
ok
(
hr
==
S_OK
,
"Got hr %#x.
\n
"
,
hr
);
ok
(
time2
-
time1
>
98
*
10000
,
"Expected about %s, but got %s.
\n
"
,
wine_dbgstr_longlong
(
time1
+
98
*
10000
),
wine_dbgstr_longlong
(
time2
));
hr
=
CoCreateInstance
(
&
CLSID_SystemClock
,
NULL
,
CLSCTX_INPROC_SERVER
,
&
IID_IReferenceClock
,
(
LPVOID
*
)
&
pReferenceClock
);
ok
(
hr
==
S_OK
,
"Unable to create reference clock from system clock %x
\n
"
,
hr
);
if
(
hr
==
S_OK
)
{
test_IReferenceClock_methods
(
"SystemClock"
,
pReferenceClock
);
IReferenceClock_Release
(
pReferenceClock
);
}
ref
=
IReferenceClock_Release
(
clock
);
ok
(
!
ref
,
"Got outstanding refcount %d.
\n
"
,
ref
);
}
START_TEST
(
systemclock
)
{
CoInitialize
(
NULL
);
pGetTickCount64
=
(
void
*
)
GetProcAddress
(
GetModuleHandleA
(
"kernel32.dll"
),
"GetTickCount64"
);
test_interfaces
();
test_
IReferenceClock_SystemClock
();
test_
get_time
();
CoUninitialize
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment