https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d3feae51397c3fbc3b055…
commit d3feae51397c3fbc3b05574da6bf06e172136095
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Sat Apr 15 22:22:07 2023 +0200
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sat Apr 22 21:24:04 2023 +0200
[ATL_APITEST] Add test for OBJECT_ENTRY_AUTO
CORE-18936
---
modules/rostests/apitests/atl/AtlObjMap.cpp | 86 ++++++++++
modules/rostests/apitests/atl/CMakeLists.txt | 1 +
modules/rostests/apitests/atl/devenv/ATLTest.sln | 10 ++
.../rostests/apitests/atl/devenv/AtlObjMap.vcxproj | 180 +++++++++++++++++++++
modules/rostests/apitests/atl/testlist.c | 2 +
5 files changed, 279 insertions(+)
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 <mark.jansen(a)reactos.org>
+ */
+
+#ifdef HAVE_APITEST
+ #include <apitest.h>
+#else
+ #include "atltest.h"
+#endif
+
+#include <atlbase.h>
+#include <atlcom.h>
+
+class CAtlObjMapModule : public ATL::CAtlExeModuleT<CAtlObjMapModule>
+{
+
+} _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<IUnknown> 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<IUnknown> 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<CComSingleThreadModel>,
+ public CComCoClass<CObjMapTestObject,
&CLSID_ObjMapTestObject>,
+ 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 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="14.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{B628C42A-A38E-488E-8512-2B997B75E95C}</ProjectGuid>
+ <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
+ <Keyword>AtlProj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup
Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"
Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140_xp</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup
Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"
Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140_xp</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup
Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"
Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v140_xp</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup
Condition="'$(Configuration)|$(Platform)'=='Release|x64'"
Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v140_xp</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets"
Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets"
Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets"
Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets"
Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup
Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <IgnoreImportLibrary>true</IgnoreImportLibrary>
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(ProjectName)\$(Configuration)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup
Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <IgnoreImportLibrary>true</IgnoreImportLibrary>
+ <LinkIncremental>true</LinkIncremental>
+ <IntDir>$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup
Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <IgnoreImportLibrary>true</IgnoreImportLibrary>
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(ProjectName)\$(Configuration)\</IntDir>
+ </PropertyGroup>
+ <PropertyGroup
Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <IgnoreImportLibrary>true</IgnoreImportLibrary>
+ <LinkIncremental>false</LinkIncremental>
+ <IntDir>$(ProjectName)\$(Platform)\$(Configuration)\</IntDir>
+ </PropertyGroup>
+ <ItemDefinitionGroup
Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x0409</Culture>
+
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup
Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+
<PreprocessorDefinitions>_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x0409</Culture>
+
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup
Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x0409</Culture>
+
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup
Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+
<PreprocessorDefinitions>_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <SDLCheck>true</SDLCheck>
+ </ClCompile>
+ <ResourceCompile>
+ <Culture>0x0409</Culture>
+
<AdditionalIncludeDirectories>$(IntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ </ResourceCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="../AtlObjMap.cpp">
+ <RuntimeLibrary
Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MultiThreaded</RuntimeLibrary>
+ <RuntimeLibrary
Condition="'$(Configuration)|$(Platform)'=='Release|x64'">MultiThreaded</RuntimeLibrary>
+ <RuntimeLibrary
Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">MultiThreadedDebug</RuntimeLibrary>
+ <RuntimeLibrary
Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">MultiThreadedDebug</RuntimeLibrary>
+ <PrecompiledHeader
Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
+ <PrecompiledHeader
Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
+ <PrecompiledHeader
Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
+ <PrecompiledHeader
Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
+ </ClCompile>
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ 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 <apitest.h>
+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 },