ReactOS  0.4.13-dev-1000-gbfea773
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 108 of file referenceclock.c.

109 {
111 
113 
114  CoUninitialize();
115 }
smooth NULL
Definition: ftsmooth.c:416
static void test_IReferenceClock_SystemClock(void)
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1897

◆ 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 */
60  hr = IReferenceClock_GetTime(pClock, NULL);
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;
89  ok (9940000 <= diff && diff <= 10240000, "%s - Expected difference around 10000000, got %u\n", clockdesc, diff);
90 
91 }
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
HRESULT hr
Definition: shlfolder.c:183
long LONG
Definition: pedump.c:60
#define S_FALSE
Definition: winerror.h:2357
smooth NULL
Definition: ftsmooth.c:416
LONGLONG REFERENCE_TIME
Definition: dmusicks.h:9
LONG HRESULT
Definition: typedefs.h:77
#define IReferenceClock_GetTime(p, a)
Definition: dmusicc.h:754
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
#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 }
#define IReferenceClock_QueryInterface(p, a, b)
Definition: dmusicc.h:750
#define E_NOINTERFACE
Definition: winerror.h:2364
HRESULT hr
Definition: shlfolder.c:183
smooth NULL
Definition: ftsmooth.c:416
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:59
#define ok(value,...)
Definition: atltest.h:57
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by test_IReferenceClock_SystemClock().

◆ test_IReferenceClock_SystemClock()

static void test_IReferenceClock_SystemClock ( void  )
static

Definition at line 93 of file referenceclock.c.

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

Referenced by START_TEST().