diff --git a/modules/rostests/apitests/atl/AtlObjMap.cpp b/modules/rostests/apitests/atl/AtlObjMap.cpp new file mode 100644 index 00000000000..12066534464 --- /dev/null +++ b/modules/rostests/apitests/atl/AtlObjMap.cpp @@ -0,0 +1,86 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later) + * PURPOSE: Test for OBJECT_ENTRY_AUTO + * COPYRIGHT: Copyright 2023 Mark Jansen + */ + +#ifdef HAVE_APITEST + #include +#else + #include "atltest.h" +#endif + +#include +#include + +class CAtlObjMapModule : public ATL::CAtlExeModuleT +{ + +} _Module; + +CLSID CLSID_ObjMapTestObject = {0xeae5616c, 0x1e7f, 0x4a00, {0x92, 0x27, 0x1a, 0xad, 0xad, 0x66, 0xbb, 0x85}}; + +static LONG g_Created = 0; +static LONG g_Destroyed = 0; + + +START_TEST(AtlObjMap) +{ + HRESULT hr = CoInitialize(NULL); + ok_hex(hr, S_OK); + + { + CComPtr spTestObject; + hr = CoCreateInstance(CLSID_ObjMapTestObject, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (LPVOID*)&spTestObject); + ok_hex(hr, REGDB_E_CLASSNOTREG); + } + + ok_int(g_Created, 0); + ok_int(g_Destroyed, 0); + + // Register the com objects added to the auto-map in _AtlComModule + hr = _Module.RegisterClassObjects(CLSCTX_INPROC_SERVER, REGCLS_MULTIPLEUSE); + ok_hex(hr, S_OK); + + ok_int(g_Created, 0); + ok_int(g_Destroyed, 0); + + { + CComPtr spTestObject; + hr = CoCreateInstance(CLSID_ObjMapTestObject, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (LPVOID *)&spTestObject); + ok_hex(hr, S_OK); + ok_int(g_Created, 1); + ok_int(g_Destroyed, 0); + } + ok_int(g_Created, 1); + ok_int(g_Destroyed, 1); +} + + + +struct CObjMapTestObject : public CComObjectRootEx, + public CComCoClass, + public IUnknown +{ + CObjMapTestObject() + { + InterlockedIncrement(&g_Created); + } + ~CObjMapTestObject() + { + InterlockedIncrement(&g_Destroyed); + } + + + DECLARE_PROTECT_FINAL_CONSTRUCT(); + DECLARE_NO_REGISTRY(); + DECLARE_NOT_AGGREGATABLE(CObjMapTestObject) + + BEGIN_COM_MAP(CObjMapTestObject) + COM_INTERFACE_ENTRY_IID(IID_IUnknown, IUnknown) + END_COM_MAP() +}; + +OBJECT_ENTRY_AUTO(CLSID_ObjMapTestObject, CObjMapTestObject) + diff --git a/modules/rostests/apitests/atl/CMakeLists.txt b/modules/rostests/apitests/atl/CMakeLists.txt index a414eb2d636..dfaddd62b61 100644 --- a/modules/rostests/apitests/atl/CMakeLists.txt +++ b/modules/rostests/apitests/atl/CMakeLists.txt @@ -2,6 +2,7 @@ add_definitions(-DINITGUID -DWINETEST_USE_DBGSTR_LONGLONG) list(APPEND SOURCE + AtlObjMap.cpp atltypes.cpp CAtlFileMapping.cpp CAtlArray.cpp diff --git a/modules/rostests/apitests/atl/devenv/ATLTest.sln b/modules/rostests/apitests/atl/devenv/ATLTest.sln index 2a923a69b57..5b3cc7d4247 100644 --- a/modules/rostests/apitests/atl/devenv/ATLTest.sln +++ b/modules/rostests/apitests/atl/devenv/ATLTest.sln @@ -29,6 +29,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SubclassWindow", "SubclassW EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CPath", "CPath.vcxproj", "{7119D446-43C1-425A-91D0-CDFA49B8B59A}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AtlObjMap", "AtlObjMap.vcxproj", "{B628C42A-A38E-488E-8512-2B997B75E95C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -141,6 +143,14 @@ Global {7119D446-43C1-425A-91D0-CDFA49B8B59A}.Release|x64.Build.0 = Release|x64 {7119D446-43C1-425A-91D0-CDFA49B8B59A}.Release|x86.ActiveCfg = Release|Win32 {7119D446-43C1-425A-91D0-CDFA49B8B59A}.Release|x86.Build.0 = Release|Win32 + {B628C42A-A38E-488E-8512-2B997B75E95C}.Debug|x64.ActiveCfg = Debug|x64 + {B628C42A-A38E-488E-8512-2B997B75E95C}.Debug|x64.Build.0 = Debug|x64 + {B628C42A-A38E-488E-8512-2B997B75E95C}.Debug|x86.ActiveCfg = Debug|Win32 + {B628C42A-A38E-488E-8512-2B997B75E95C}.Debug|x86.Build.0 = Debug|Win32 + {B628C42A-A38E-488E-8512-2B997B75E95C}.Release|x64.ActiveCfg = Release|x64 + {B628C42A-A38E-488E-8512-2B997B75E95C}.Release|x64.Build.0 = Release|x64 + {B628C42A-A38E-488E-8512-2B997B75E95C}.Release|x86.ActiveCfg = Release|Win32 + {B628C42A-A38E-488E-8512-2B997B75E95C}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/modules/rostests/apitests/atl/devenv/AtlObjMap.vcxproj b/modules/rostests/apitests/atl/devenv/AtlObjMap.vcxproj new file mode 100644 index 00000000000..586515bb052 --- /dev/null +++ b/modules/rostests/apitests/atl/devenv/AtlObjMap.vcxproj @@ -0,0 +1,180 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {B628C42A-A38E-488E-8512-2B997B75E95C} + 8.1 + AtlProj + + + + Application + true + v140_xp + Unicode + + + Application + false + v140_xp + Unicode + + + Application + true + v140_xp + Unicode + + + Application + false + v140_xp + Unicode + + + + + + + + + + + + + + + + + + + + + true + true + $(ProjectName)\$(Configuration)\ + + + true + true + $(ProjectName)\$(Platform)\$(Configuration)\ + + + true + false + $(ProjectName)\$(Configuration)\ + + + true + false + $(ProjectName)\$(Platform)\$(Configuration)\ + + + + NotUsing + Level3 + Disabled + WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions) + true + + + 0x0409 + $(IntDir);%(AdditionalIncludeDirectories) + _DEBUG;%(PreprocessorDefinitions) + + + Console + true + + + + + NotUsing + Level3 + Disabled + _WINDOWS;_DEBUG;%(PreprocessorDefinitions) + true + + + 0x0409 + $(IntDir);%(AdditionalIncludeDirectories) + _DEBUG;%(PreprocessorDefinitions) + + + Console + true + + + + + NotUsing + Level3 + MaxSpeed + WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions) + true + + + 0x0409 + $(IntDir);%(AdditionalIncludeDirectories) + NDEBUG;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + NotUsing + Level3 + MaxSpeed + _WINDOWS;NDEBUG;%(PreprocessorDefinitions) + true + + + 0x0409 + $(IntDir);%(AdditionalIncludeDirectories) + NDEBUG;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + MultiThreaded + MultiThreaded + MultiThreadedDebug + MultiThreadedDebug + NotUsing + NotUsing + NotUsing + NotUsing + + + + + + \ No newline at end of file diff --git a/modules/rostests/apitests/atl/testlist.c b/modules/rostests/apitests/atl/testlist.c index 510b5f4d834..2309a421512 100644 --- a/modules/rostests/apitests/atl/testlist.c +++ b/modules/rostests/apitests/atl/testlist.c @@ -1,6 +1,7 @@ #define STANDALONE #include +extern void func_AtlObjMap(void); extern void func_atltypes(void); extern void func_CAtlFileMapping(void); extern void func_CAtlArray(void); @@ -21,6 +22,7 @@ extern void func_SubclassWindow(void); const struct test winetest_testlist[] = { + { "AtlObjMap", func_AtlObjMap }, { "atltypes", func_atltypes }, { "CAtlFileMapping", func_CAtlFileMapping }, { "CAtlArray", func_CAtlArray },