ReactOS 0.4.15-dev-7897-g78dc504
AtlObjMap.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS api tests
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: Test for OBJECT_ENTRY_AUTO
5 * COPYRIGHT: Copyright 2023 Mark Jansen <mark.jansen@reactos.org>
6 */
7
8#ifdef HAVE_APITEST
9 #include <apitest.h>
10#else
11 #include "atltest.h"
12#endif
13
14#include <atlbase.h>
15#include <atlcom.h>
16
17class CAtlObjMapModule : public ATL::CAtlExeModuleT<CAtlObjMapModule>
18{
19
21
22CLSID CLSID_ObjMapTestObject = {0xeae5616c, 0x1e7f, 0x4a00, {0x92, 0x27, 0x1a, 0xad, 0xad, 0x66, 0xbb, 0x85}};
23
24static LONG g_Created = 0;
25static LONG g_Destroyed = 0;
26
27
28START_TEST(AtlObjMap)
29{
31 ok_hex(hr, S_OK);
32
33 {
34 CComPtr<IUnknown> spTestObject;
35 hr = CoCreateInstance(CLSID_ObjMapTestObject, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (LPVOID*)&spTestObject);
37 }
38
39 ok_int(g_Created, 0);
41
42 // Register the com objects added to the auto-map in _AtlComModule
43 hr = _Module.RegisterClassObjects(CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE);
44 ok_hex(hr, S_OK);
45
46 ok_int(g_Created, 0);
48
49 {
50 CComPtr<IUnknown> spTestObject;
51 hr = CoCreateInstance(CLSID_ObjMapTestObject, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (LPVOID *)&spTestObject);
52 ok_hex(hr, S_OK);
53 ok_int(g_Created, 1);
55 }
56 ok_int(g_Created, 1);
58}
59
60
61
62struct CObjMapTestObject : public CComObjectRootEx<CComSingleThreadModel>,
63 public CComCoClass<CObjMapTestObject, &CLSID_ObjMapTestObject>,
64 public IUnknown
65{
67 {
69 }
71 {
73 }
74
75
79
83};
84
86
static LONG g_Created
Definition: AtlObjMap.cpp:24
CLSID CLSID_ObjMapTestObject
Definition: AtlObjMap.cpp:22
static LONG g_Destroyed
Definition: AtlObjMap.cpp:25
CAtlObjMapModule _Module
#define InterlockedIncrement
Definition: armddk.h:53
#define ok_hex(expression, result)
Definition: atltest.h:94
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
const GUID IID_IUnknown
HRESULT RegisterClassObjects(DWORD dwClsContext, DWORD dwFlags)
Definition: atlbase.h:840
#define NULL
Definition: types.h:112
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
#define S_OK
Definition: intsafe.h:52
#define BEGIN_COM_MAP(x)
Definition: atlcom.h:581
#define OBJECT_ENTRY_AUTO(clsid, class)
Definition: atlcom.h:707
#define COM_INTERFACE_ENTRY_IID(iid, x)
Definition: atlcom.h:601
#define DECLARE_NOT_AGGREGATABLE(x)
Definition: atlcom.h:651
#define END_COM_MAP()
Definition: atlcom.h:592
@ REGCLS_MULTIPLEUSE
Definition: objbase.h:393
long LONG
Definition: pedump.c:60
HRESULT hr
Definition: shlfolder.c:183
#define REGDB_E_CLASSNOTREG
Definition: winerror.h:2696