ReactOS 0.4.16-dev-136-g52192f1
CTestSpy Class Reference
Inheritance diagram for CTestSpy:
Collaboration diagram for CTestSpy:

Public Member Functions

 CTestSpy ()
 
 ~CTestSpy ()
 
HRESULT STDMETHODCALLTYPE QueryInterface (REFIID riid, void **ppv)
 
const QITABGetQITab ()
 
HRESULT STDMETHODCALLTYPE PreInitialize (DWORD dwCoInit, DWORD dwCurThreadAptRefs)
 
HRESULT STDMETHODCALLTYPE PostInitialize (HRESULT hrCoInit, DWORD dwCoInit, DWORD dwNewThreadAptRefs)
 
HRESULT STDMETHODCALLTYPE PreUninitialize (DWORD dwCurThreadAptRefs)
 
HRESULT STDMETHODCALLTYPE PostUninitialize (DWORD dwNewThreadAptRefs)
 
void Clear ()
 
void Expect (HRESULT hrCoInit, DWORD CoInit, DWORD CurAptRefs)
 
void Check (LONG PreInit, LONG PostInit, LONG PreUninit, LONG PostUninit)
 
- Public Member Functions inherited from CUnknownBase< IInitializeSpy >
 CUnknownBase (bool autoDelete=true, LONG initialRef=0)
 
ULONG STDMETHODCALLTYPE AddRef ()
 
ULONG STDMETHODCALLTYPE Release ()
 
HRESULT STDMETHODCALLTYPE QueryInterface (REFIID riid, void **ppv)
 
virtual ~CUnknownBase ()
 
LONG GetRef () const
 
HRESULT PreInitialize ([in] DWORD dwCoInit, [in] DWORD dwCurThreadAptRefs)
 
HRESULT PostInitialize ([in] HRESULT hrCoInit, [in] DWORD dwCoInit, [in] DWORD dwNewThreadAptRefs)
 
HRESULT PreUninitialize ([in] DWORD dwCurThreadAptRefs)
 
HRESULT PostUninitialize ([in] DWORD dwNewThreadAptRefs)
 
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Public Attributes

HRESULT hr
 
ULARGE_INTEGER Cookie
 
HRESULT m_hrCoInit
 
DWORD m_CoInit
 
DWORD m_CurAptRefs
 
LONG m_PreInitCalled
 
LONG m_PostInitCalled
 
LONG m_PreUninitCalled
 
LONG m_PostUninitCalled
 
bool m_FailQueryInterface
 
bool m_AlwaysReturnOK
 

Additional Inherited Members

- Public Types inherited from IInitializeSpy
typedef IInitializeSpyLPINITIALIZESPY
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
virtual const QITABGetQITab ()=0
 

Detailed Description

Definition at line 35 of file initializespy.cpp.

Constructor & Destructor Documentation

◆ CTestSpy()

CTestSpy::CTestSpy ( )
inline

Definition at line 56 of file initializespy.cpp.

57 : CUnknownBase( false, 0 ),
58 hr(0),
59 m_hrCoInit(0),
60 m_CoInit(0),
61 m_CurAptRefs(0),
63 m_AlwaysReturnOK(false)
64 {
66 Clear();
67 }
DWORD m_CurAptRefs
HRESULT m_hrCoInit
bool m_AlwaysReturnOK
DWORD m_CoInit
bool m_FailQueryInterface
HRESULT hr
void Clear()
ULARGE_INTEGER Cookie
const DWORD INVALID_VALUE
$ULONG LowPart
Definition: ntbasedef.h:569
$ULONG HighPart
Definition: ntbasedef.h:570

◆ ~CTestSpy()

CTestSpy::~CTestSpy ( )
inline

Definition at line 69 of file initializespy.cpp.

70 {
71 // always try to revoke if we succeeded to register.
72 if (SUCCEEDED(hr))
73 {
75 test_S_OK(hr, "CoRevokeInitializeSpy");
76 }
77 // we should be done.
78 ok(GetRef() == 0, "Expected m_lRef to be 0, was: %ld\n", GetRef());
79 }
#define ok(value,...)
Definition: atltest.h:57
pCoRevokeInitializeSpy_t pCoRevokeInitializeSpy
#define test_S_OK(hres, message)
#define SUCCEEDED(hr)
Definition: intsafe.h:50

Member Function Documentation

◆ Check()

void CTestSpy::Check ( LONG  PreInit,
LONG  PostInit,
LONG  PreUninit,
LONG  PostUninit 
)
inline

Definition at line 149 of file initializespy.cpp.

150 {
151 ok(m_PreInitCalled == PreInit, "Expected PreInit to be %ld, was: %ld\n", PreInit, m_PreInitCalled);
152 ok(m_PostInitCalled == PostInit, "Expected PostInit to be %ld, was: %ld\n", PostInit, m_PostInitCalled);
153 ok(m_PreUninitCalled == PreUninit, "Expected PreUninit to be %ld, was: %ld\n", PreUninit, m_PreUninitCalled);
154 ok(m_PostUninitCalled == PostUninit, "Expected PostUninit to be %ld, was: %ld\n", PostUninit, m_PostUninitCalled);
155 }
LONG m_PreInitCalled
LONG m_PostInitCalled
LONG m_PostUninitCalled
LONG m_PreUninitCalled
static void PreInit(void)
Definition: main.c:267
static void PostInit(void)
Definition: main.c:325

Referenced by test_IInitializeSpy_register2(), and test_IInitializeSpy_switch_apt().

◆ Clear()

void CTestSpy::Clear ( )
inline

Definition at line 134 of file initializespy.cpp.

135 {
136 m_PreInitCalled = 0;
140 }

Referenced by CTestSpy().

◆ Expect()

void CTestSpy::Expect ( HRESULT  hrCoInit,
DWORD  CoInit,
DWORD  CurAptRefs 
)
inline

Definition at line 142 of file initializespy.cpp.

143 {
144 m_hrCoInit = hrCoInit;
145 m_CoInit = CoInit;
146 m_CurAptRefs = CurAptRefs;
147 }

Referenced by test_IInitializeSpy_register2(), and test_IInitializeSpy_switch_apt().

◆ GetQITab()

const QITAB * CTestSpy::GetQITab ( )
inlinevirtual

Implements CUnknownBase< IInitializeSpy >.

Definition at line 90 of file initializespy.cpp.

91 {
92 static const QITAB tab[] = { { &IID_IInitializeSpy, OFFSETOFCLASS(IInitializeSpy, CTestSpy) }, { 0 } };
93 return tab;
94 }
#define OFFSETOFCLASS(base, derived)
Definition: shlwapi.h:2118

◆ PostInitialize()

HRESULT STDMETHODCALLTYPE CTestSpy::PostInitialize ( HRESULT  hrCoInit,
DWORD  dwCoInit,
DWORD  dwNewThreadAptRefs 
)
inline

Implements IInitializeSpy.

Definition at line 106 of file initializespy.cpp.

107 {
109 ok(m_PreInitCalled == m_PostInitCalled, "Expected balanced pre/post: %ld / %ld\n", m_PreInitCalled, m_PostInitCalled);
110 test_HRES(hrCoInit, m_hrCoInit, "Unexpected hrCoInit in PostInitialize");
111 ok(m_CoInit == dwCoInit, "Unexpected dwCoInit: got %lx, expected %lx\n", dwCoInit, m_CoInit);
112 ok(m_CurAptRefs == dwNewThreadAptRefs, "Unexpected dwNewThreadAptRefs: got %lx, expected %lx\n", dwNewThreadAptRefs, m_CurAptRefs);
114 return S_OK;
115 return hrCoInit;
116 }
#define InterlockedIncrement
Definition: armddk.h:53
#define test_HRES(hres, hresExpected, message)
#define S_OK
Definition: intsafe.h:52
static DWORD dwCoInit
Definition: compobj.c:73

◆ PostUninitialize()

HRESULT STDMETHODCALLTYPE CTestSpy::PostUninitialize ( DWORD  dwNewThreadAptRefs)
inline

Implements IInitializeSpy.

Definition at line 125 of file initializespy.cpp.

126 {
128 ok(m_PreUninitCalled == m_PostUninitCalled, "Expected balanced pre/post: %ld / %ld\n", m_PreUninitCalled, m_PostUninitCalled);
129 DWORD apt = m_CurAptRefs ? (m_CurAptRefs-1) : 0;
130 ok(apt == dwNewThreadAptRefs, "Unexpected dwNewThreadAptRefs: got %lx, expected %lx\n", dwNewThreadAptRefs, apt);
131 return S_OK;
132 }
unsigned long DWORD
Definition: ntddk_ex.h:95

◆ PreInitialize()

HRESULT STDMETHODCALLTYPE CTestSpy::PreInitialize ( DWORD  dwCoInit,
DWORD  dwCurThreadAptRefs 
)
inline

Implements IInitializeSpy.

Definition at line 97 of file initializespy.cpp.

98 {
100 ok(m_CoInit == dwCoInit, "Unexpected dwCoInit: got %lx, expected %lx\n", dwCoInit, m_CoInit);
102 ok(expectApt == dwCurThreadAptRefs, "Unexpected dwCurThreadAptRefs: got %lx, expected %lx\n", dwCurThreadAptRefs, expectApt);
103 return S_OK;
104 }
#define RPC_E_CHANGED_MODE
Definition: winerror.h:2482

◆ PreUninitialize()

HRESULT STDMETHODCALLTYPE CTestSpy::PreUninitialize ( DWORD  dwCurThreadAptRefs)
inline

Implements IInitializeSpy.

Definition at line 118 of file initializespy.cpp.

119 {
121 ok(m_CurAptRefs == dwCurThreadAptRefs, "Unexpected dwCurThreadAptRefs: got %lx, expected %lx\n", dwCurThreadAptRefs, m_CurAptRefs);
122 return S_OK;
123 }

◆ QueryInterface()

HRESULT STDMETHODCALLTYPE CTestSpy::QueryInterface ( REFIID  riid,
void **  ppv 
)
inline

Implements IUnknown.

Definition at line 81 of file initializespy.cpp.

82 {
84 {
85 return E_NOINTERFACE;
86 }
88 }
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppv)
Definition: unknownbase.h:34
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define E_NOINTERFACE
Definition: winerror.h:2364

Member Data Documentation

◆ Cookie

◆ hr

◆ m_AlwaysReturnOK

bool CTestSpy::m_AlwaysReturnOK

Definition at line 54 of file initializespy.cpp.

Referenced by PostInitialize(), and test_IInitializeSpy_register2().

◆ m_CoInit

DWORD CTestSpy::m_CoInit

Definition at line 43 of file initializespy.cpp.

Referenced by Expect(), PostInitialize(), and PreInitialize().

◆ m_CurAptRefs

◆ m_FailQueryInterface

bool CTestSpy::m_FailQueryInterface

Definition at line 53 of file initializespy.cpp.

Referenced by QueryInterface(), and test_IInitializeSpy_fail().

◆ m_hrCoInit

HRESULT CTestSpy::m_hrCoInit

Definition at line 42 of file initializespy.cpp.

Referenced by Expect(), PostInitialize(), and PreInitialize().

◆ m_PostInitCalled

LONG CTestSpy::m_PostInitCalled

Definition at line 48 of file initializespy.cpp.

Referenced by Check(), Clear(), and PostInitialize().

◆ m_PostUninitCalled

LONG CTestSpy::m_PostUninitCalled

Definition at line 50 of file initializespy.cpp.

Referenced by Check(), Clear(), and PostUninitialize().

◆ m_PreInitCalled

LONG CTestSpy::m_PreInitCalled

Definition at line 47 of file initializespy.cpp.

Referenced by Check(), Clear(), PostInitialize(), and PreInitialize().

◆ m_PreUninitCalled

LONG CTestSpy::m_PreUninitCalled

Definition at line 49 of file initializespy.cpp.

Referenced by Check(), Clear(), PostUninitialize(), and PreUninitialize().


The documentation for this class was generated from the following file: