ReactOS  0.4.14-dev-49-gfb4591c
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
 

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
 

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),
62  m_FailQueryInterface(false),
63  m_AlwaysReturnOK(false)
64  {
66  Clear();
67  }
DWORD m_CoInit
void Clear()
$ULONG LowPart
Definition: ntbasedef.h:576
CUnknownBase(bool autoDelete=true, LONG initialRef=0)
Definition: unknownbase.h:13
ULARGE_INTEGER Cookie
bool m_FailQueryInterface
$ULONG HighPart
Definition: ntbasedef.h:577
const DWORD INVALID_VALUE
HRESULT m_hrCoInit
HRESULT hr
bool m_AlwaysReturnOK
DWORD m_CurAptRefs

◆ ~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 test_S_OK(hres, message)
ULARGE_INTEGER Cookie
#define ok(value,...)
Definition: atltest.h:57
pCoRevokeInitializeSpy_t pCoRevokeInitializeSpy
HRESULT hr
#define SUCCEEDED(hr)
Definition: intsafe.h:57

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_PostInitCalled
LONG m_PreUninitCalled
LONG m_PostUninitCalled
static void PostInit(void)
Definition: main.c:325
static void PreInit(void)
Definition: main.c:267
#define ok(value,...)
Definition: atltest.h:57
LONG m_PreInitCalled

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;
137  m_PostInitCalled = 0;
138  m_PreUninitCalled = 0;
139  m_PostUninitCalled = 0;
140  }
LONG m_PostInitCalled
LONG m_PreUninitCalled
LONG m_PostUninitCalled
LONG m_PreInitCalled

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  }
DWORD m_CoInit
HRESULT m_hrCoInit
DWORD m_CurAptRefs

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:2086

◆ 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);
113  if (m_AlwaysReturnOK)
114  return S_OK;
115  return hrCoInit;
116  }
DWORD m_CoInit
#define test_HRES(hres, hresExpected, message)
LONG m_PostInitCalled
static DWORD dwCoInit
Definition: compobj.c:68
HRESULT m_hrCoInit
#define S_OK
Definition: intsafe.h:59
#define InterlockedIncrement
Definition: armddk.h:53
#define ok(value,...)
Definition: atltest.h:57
LONG m_PreInitCalled
bool m_AlwaysReturnOK
DWORD m_CurAptRefs

◆ 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  }
LONG m_PreUninitCalled
LONG m_PostUninitCalled
unsigned long DWORD
Definition: ntddk_ex.h:95
#define S_OK
Definition: intsafe.h:59
#define InterlockedIncrement
Definition: armddk.h:53
#define ok(value,...)
Definition: atltest.h:57
DWORD m_CurAptRefs

◆ 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  }
DWORD m_CoInit
static DWORD dwCoInit
Definition: compobj.c:68
unsigned long DWORD
Definition: ntddk_ex.h:95
#define RPC_E_CHANGED_MODE
Definition: winerror.h:2482
HRESULT m_hrCoInit
#define S_OK
Definition: intsafe.h:59
#define InterlockedIncrement
Definition: armddk.h:53
#define ok(value,...)
Definition: atltest.h:57
LONG m_PreInitCalled
DWORD m_CurAptRefs

◆ 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  }
LONG m_PreUninitCalled
#define S_OK
Definition: intsafe.h:59
#define InterlockedIncrement
Definition: armddk.h:53
#define ok(value,...)
Definition: atltest.h:57
DWORD m_CurAptRefs

◆ 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  }
#define E_NOINTERFACE
Definition: winerror.h:2364
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39
bool m_FailQueryInterface
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppv)
Definition: unknownbase.h:34

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: