ReactOS 0.4.17-dev-966-gf06eace
passthrough.c File Reference
#include "dshow.h"
#include "wine/test.h"
Include dependency graph for passthrough.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 

Functions

static ULONG get_refcount (void *iface)
 
static HRESULT WINAPI outer_QueryInterface (IUnknown *iface, REFIID iid, void **out)
 
static ULONG WINAPI outer_AddRef (IUnknown *iface)
 
static ULONG WINAPI outer_Release (IUnknown *iface)
 
static void test_aggregation (void)
 
 START_TEST (passthrough)
 

Variables

static const GUID test_iid = {0x33333333}
 
static LONG outer_ref = 1
 
static const IUnknownVtbl outer_vtbl
 
static IUnknown test_outer = {&outer_vtbl}
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file passthrough.c.

Function Documentation

◆ get_refcount()

static ULONG get_refcount ( void *  iface)
static

Definition at line 25 of file passthrough.c.

26{
27 IUnknown *unknown = iface;
28 IUnknown_AddRef(unknown);
29 return IUnknown_Release(unknown);
30}
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1674

Referenced by test_aggregation().

◆ outer_AddRef()

static ULONG WINAPI outer_AddRef ( IUnknown *  iface)
static

Definition at line 48 of file passthrough.c.

49{
51}
#define InterlockedIncrement
Definition: armddk.h:53
static LONG outer_ref
Definition: passthrough.c:33

◆ outer_QueryInterface()

static HRESULT WINAPI outer_QueryInterface ( IUnknown *  iface,
REFIID  iid,
void **  out 
)
static

Definition at line 35 of file passthrough.c.

36{
37 if (IsEqualGUID(iid, &IID_IUnknown)
38 || IsEqualGUID(iid, &IID_ISeekingPassThru)
39 || IsEqualGUID(iid, &test_iid))
40 {
41 *out = (IUnknown *)0xdeadbeef;
42 return S_OK;
43 }
44 ok(0, "unexpected call %s\n", wine_dbgstr_guid(iid));
45 return E_NOINTERFACE;
46}
#define ok(value,...)
Definition: atltest.h:57
const GUID IID_IUnknown
#define S_OK
Definition: intsafe.h:52
static const GUID test_iid
Definition: passthrough.c:32
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:181
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ outer_Release()

static ULONG WINAPI outer_Release ( IUnknown *  iface)
static

Definition at line 53 of file passthrough.c.

54{
56}
#define InterlockedDecrement
Definition: armddk.h:52

◆ START_TEST()

START_TEST ( passthrough  )

Definition at line 126 of file passthrough.c.

127{
129
131
133}
#define NULL
Definition: types.h:112
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:531
static void test_aggregation(void)
Definition: passthrough.c:67

◆ test_aggregation()

static void test_aggregation ( void  )
static

Definition at line 67 of file passthrough.c.

68{
69 ISeekingPassThru *passthrough, *passthrough2;
70 IUnknown *unk, *unk2;
71 HRESULT hr;
72 ULONG ref;
73
74 passthrough = (ISeekingPassThru *)0xdeadbeef;
75 hr = CoCreateInstance(&CLSID_SeekingPassThru, &test_outer, CLSCTX_INPROC_SERVER,
76 &IID_ISeekingPassThru, (void **)&passthrough);
77 ok(hr == E_NOINTERFACE, "Got hr %#lx.\n", hr);
78 ok(!passthrough, "Got interface %p.\n", passthrough);
79
80 hr = CoCreateInstance(&CLSID_SeekingPassThru, &test_outer, CLSCTX_INPROC_SERVER,
81 &IID_IUnknown, (void **)&unk);
82 ok(hr == S_OK, "Got hr %#lx.\n", hr);
83 ok(outer_ref == 1, "Got unexpected refcount %ld.\n", outer_ref);
84 ok(unk != &test_outer, "Returned IUnknown should not be outer IUnknown.\n");
85 ref = get_refcount(unk);
86 ok(ref == 1, "Got unexpected refcount %ld.\n", ref);
87
88 ref = IUnknown_AddRef(unk);
89 ok(ref == 2, "Got unexpected refcount %ld.\n", ref);
90 ok(outer_ref == 1, "Got unexpected refcount %ld.\n", outer_ref);
91
92 ref = IUnknown_Release(unk);
93 ok(ref == 1, "Got unexpected refcount %ld.\n", ref);
94 ok(outer_ref == 1, "Got unexpected refcount %ld.\n", outer_ref);
95
96 hr = IUnknown_QueryInterface(unk, &IID_IUnknown, (void **)&unk2);
97 ok(hr == S_OK, "Got hr %#lx.\n", hr);
98 ok(unk2 == unk, "Got unexpected IUnknown %p.\n", unk2);
99 IUnknown_Release(unk2);
100
101 hr = IUnknown_QueryInterface(unk, &IID_ISeekingPassThru, (void **)&passthrough);
102 ok(hr == S_OK, "Got hr %#lx.\n", hr);
103
104 hr = ISeekingPassThru_QueryInterface(passthrough, &IID_IUnknown, (void **)&unk2);
105 ok(hr == S_OK, "Got hr %#lx.\n", hr);
106 ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
107
108 hr = ISeekingPassThru_QueryInterface(passthrough, &IID_ISeekingPassThru, (void **)&passthrough2);
109 ok(hr == S_OK, "Got hr %#lx.\n", hr);
110 ok(passthrough2 == (ISeekingPassThru *)0xdeadbeef, "Got unexpected ISeekingPassThru %p.\n", passthrough2);
111
112 hr = IUnknown_QueryInterface(unk, &test_iid, (void **)&unk2);
113 ok(hr == E_NOINTERFACE, "Got hr %#lx.\n", hr);
114 ok(!unk2, "Got unexpected IUnknown %p.\n", unk2);
115
116 hr = ISeekingPassThru_QueryInterface(passthrough, &test_iid, (void **)&unk2);
117 ok(hr == S_OK, "Got hr %#lx.\n", hr);
118 ok(unk2 == (IUnknown *)0xdeadbeef, "Got unexpected IUnknown %p.\n", unk2);
119
120 ISeekingPassThru_Release(passthrough);
121 ref = IUnknown_Release(unk);
122 ok(!ref, "Got unexpected refcount %ld.\n", ref);
123 ok(outer_ref == 1, "Got unexpected refcount %ld.\n", outer_ref);
124}
HRESULT hr
Definition: delayimp.cpp:582
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
static ULONG get_refcount(void *iface)
Definition: passthrough.c:25
static IUnknown test_outer
Definition: passthrough.c:65
Definition: send.c:48
uint32_t ULONG
Definition: typedefs.h:59

Referenced by START_TEST().

Variable Documentation

◆ outer_ref

LONG outer_ref = 1
static

Definition at line 33 of file passthrough.c.

Referenced by outer_AddRef(), outer_Release(), and test_aggregation().

◆ outer_vtbl

const IUnknownVtbl outer_vtbl
static
Initial value:
=
{
}
static ULONG WINAPI outer_AddRef(IUnknown *iface)
Definition: passthrough.c:48
static HRESULT WINAPI outer_QueryInterface(IUnknown *iface, REFIID iid, void **out)
Definition: passthrough.c:35
static ULONG WINAPI outer_Release(IUnknown *iface)
Definition: passthrough.c:53

Definition at line 58 of file passthrough.c.

◆ test_iid

const GUID test_iid = {0x33333333}
static

Definition at line 32 of file passthrough.c.

Referenced by outer_QueryInterface(), and test_aggregation().

◆ test_outer

IUnknown test_outer = {&outer_vtbl}
static

Definition at line 65 of file passthrough.c.

Referenced by test_aggregation().