ReactOS 0.4.16-dev-297-gc569aee
referenceclock.c File Reference
#include "wine/test.h"
#include "uuids.h"
#include "dshow.h"
#include "control.h"
Include dependency graph for referenceclock.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 

Functions

static void test_IReferenceClock_query_interface (const char *clockdesc, IReferenceClock *pClock)
 
static void test_IReferenceClock_methods (const char *clockdesc, IReferenceClock *pClock)
 
static void test_IReferenceClock_SystemClock (void)
 
 START_TEST (referenceclock)
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file referenceclock.c.

Function Documentation

◆ START_TEST()

START_TEST ( referenceclock  )

Definition at line 109 of file referenceclock.c.

110{
112
114
116}
#define NULL
Definition: types.h:112
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
static void test_IReferenceClock_SystemClock(void)

◆ test_IReferenceClock_methods()

static void test_IReferenceClock_methods ( const char clockdesc,
IReferenceClock pClock 
)
static

Definition at line 52 of file referenceclock.c.

53{
54 HRESULT hr;
55 REFERENCE_TIME time1;
56 REFERENCE_TIME time2;
57 LONG diff;
58
59 /* Test response from invalid (NULL) argument */
61 ok (hr == E_POINTER, "%s - Expected E_POINTER (0x%08x), got 0x%08x\n", clockdesc, E_POINTER, hr);
62
63 /* Test response for valid value - try 1 */
64 /* TODO: test whether Windows actually returns S_FALSE in its first invocation */
65 time1 = (REFERENCE_TIME)0xdeadbeef;
66 hr = IReferenceClock_GetTime(pClock, &time1);
67 ok (hr == S_FALSE || hr == S_OK, "%s - Expected S_OK or S_FALSE, got 0x%08x\n", clockdesc, hr);
68 ok (time1 != 0xdeadbeef, "%s - value was NOT changed on return!\n", clockdesc);
69
70 /* Test response for valid value - try 2 */
71 time2 = (REFERENCE_TIME)0xdeadbeef;
72 hr = IReferenceClock_GetTime(pClock, &time2);
73 ok (hr == S_FALSE || hr == S_OK, "%s - Expected S_OK or S_FALSE, got 0x%08x\n", clockdesc, hr);
74 ok (time2 != 0xdeadbeef, "%s - value was NOT changed on return!\n", clockdesc);
75
76 /* In case the second invocation managed to return S_FALSE, MSDN says the
77 returned time is the same as the previous one. */
78 ok ((hr != S_FALSE || time1 == time2), "%s - returned S_FALSE, but values not equal!\n", clockdesc);
79
80 time1 = time2;
81 Sleep(1000); /* Sleep for at least 1 second */
82 hr = IReferenceClock_GetTime(pClock, &time2);
83 /* After a 1-second sleep, there is no excuse to get S_FALSE (see TODO above) */
84 ok (hr == S_OK, "%s - Expected S_OK, got 0x%08x\n", clockdesc, hr);
85
86 /* FIXME: How much deviation should be allowed after a sleep? */
87 /* 0.3% is common, and 0.4% is sometimes observed. */
88 diff = time2 - time1;
90 ok (9940000 <= diff && diff <= 10240000, "%s - Expected difference around 10000000, got %u\n", clockdesc, diff);
91
92}
#define ok(value,...)
Definition: atltest.h:57
#define IReferenceClock_GetTime(p, a)
Definition: dmusicc.h:754
LONGLONG REFERENCE_TIME
Definition: dmusicks.h:9
#define S_OK
Definition: intsafe.h:52
long LONG
Definition: pedump.c:60
#define ros_skip_flaky
Definition: test.h:180
HRESULT hr
Definition: shlfolder.c:183
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
#define S_FALSE
Definition: winerror.h:2357
#define E_POINTER
Definition: winerror.h:2365

Referenced by test_IReferenceClock_SystemClock().

◆ test_IReferenceClock_query_interface()

static void test_IReferenceClock_query_interface ( const char clockdesc,
IReferenceClock pClock 
)
static

Definition at line 28 of file referenceclock.c.

29{
30 HRESULT hr;
31 IUnknown *pF;
32
33 hr = IReferenceClock_QueryInterface(pClock, &IID_IUnknown, (void**)&pF);
34 ok(hr == S_OK, "IReferenceClock_QueryInterface returned %x\n", hr);
35 ok(pF != NULL, "pF is NULL\n");
36 if (SUCCEEDED(hr)) IUnknown_Release(pF);
37
38 hr = IReferenceClock_QueryInterface(pClock, &IID_IDirectDraw, (void**)&pF);
39 ok(hr == E_NOINTERFACE, "IReferenceClock_QueryInterface returned %x\n", hr);
40 ok(pF == NULL, "pF is not NULL\n");
41
42 hr = IReferenceClock_QueryInterface(pClock, &IID_IReferenceClock, (void**)&pF);
43 ok(hr == S_OK, "IReferenceClock_QueryInterface returned %x\n", hr);
44 ok(pF != NULL, "pF is NULL\n");
45 if (SUCCEEDED(hr)) IUnknown_Release(pF);
46}
const GUID IID_IUnknown
#define IReferenceClock_QueryInterface(p, a, b)
Definition: dmusicc.h:750
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define E_NOINTERFACE
Definition: winerror.h:2364

Referenced by test_IReferenceClock_SystemClock().

◆ test_IReferenceClock_SystemClock()

static void test_IReferenceClock_SystemClock ( void  )
static

Definition at line 94 of file referenceclock.c.

95{
96 IReferenceClock * pReferenceClock;
97 HRESULT hr;
98
99 hr = CoCreateInstance(&CLSID_SystemClock, NULL, CLSCTX_INPROC_SERVER, &IID_IReferenceClock, (LPVOID*)&pReferenceClock);
100 ok(hr == S_OK, "Unable to create reference clock from system clock %x\n", hr);
101 if (hr == S_OK)
102 {
103 test_IReferenceClock_query_interface("SystemClock", pReferenceClock);
104 test_IReferenceClock_methods("SystemClock", pReferenceClock);
105 IReferenceClock_Release(pReferenceClock);
106 }
107}
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
#define IReferenceClock_Release(p)
Definition: dmusicc.h:752
static void test_IReferenceClock_methods(const char *clockdesc, IReferenceClock *pClock)
static void test_IReferenceClock_query_interface(const char *clockdesc, IReferenceClock *pClock)

Referenced by START_TEST().