diff options
author | Stefan Laner <laner@itestra.de> | 2014-02-24 09:57:40 +0100 |
---|---|---|
committer | Stefan Laner <laner@itestra.de> | 2014-02-26 11:34:55 +0100 |
commit | 356ad3559a386865673aed7738c877206a73e390 (patch) | |
tree | 140e2c5a1f05babdcb9e739ef4604390bd7c26d5 | |
parent | ea1f26308a75266087251b0cf7780699f5e125cf (diff) | |
download | genivi-common-api-dbus-runtime-356ad3559a386865673aed7738c877206a73e390.tar.gz |
Windows support, fixed attribute handling with inherited interfaces
Change-Id: I8c0248d25f267333878166dbab790e4ffa353e54
78 files changed, 1649 insertions, 442 deletions
diff --git a/CommonAPI-DBus.sln b/CommonAPI-DBus.sln new file mode 100644 index 0000000..4df764f --- /dev/null +++ b/CommonAPI-DBus.sln @@ -0,0 +1,28 @@ +
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2013
+VisualStudioVersion = 12.0.21005.1
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CommonAPI-DBus", "CommonAPI-DBus.vcxproj", "{D3B0744D-2A3E-4C36-9AA0-534D6BD5A44C}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTests", "UnitTests.vcxproj", "{A437B05C-A664-493D-B60A-822A3A7A1CED}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {D3B0744D-2A3E-4C36-9AA0-534D6BD5A44C}.Debug|Win32.ActiveCfg = Debug|Win32
+ {D3B0744D-2A3E-4C36-9AA0-534D6BD5A44C}.Debug|Win32.Build.0 = Debug|Win32
+ {D3B0744D-2A3E-4C36-9AA0-534D6BD5A44C}.Release|Win32.ActiveCfg = Release|Win32
+ {D3B0744D-2A3E-4C36-9AA0-534D6BD5A44C}.Release|Win32.Build.0 = Release|Win32
+ {A437B05C-A664-493D-B60A-822A3A7A1CED}.Debug|Win32.ActiveCfg = Debug|Win32
+ {A437B05C-A664-493D-B60A-822A3A7A1CED}.Debug|Win32.Build.0 = Debug|Win32
+ {A437B05C-A664-493D-B60A-822A3A7A1CED}.Release|Win32.ActiveCfg = Release|Win32
+ {A437B05C-A664-493D-B60A-822A3A7A1CED}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/CommonAPI-DBus.vcxproj b/CommonAPI-DBus.vcxproj new file mode 100644 index 0000000..a4432cd --- /dev/null +++ b/CommonAPI-DBus.vcxproj @@ -0,0 +1,148 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.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>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{D3B0744D-2A3E-4C36-9AA0-534D6BD5A44C}</ProjectGuid>
+ <RootNamespace>CommonAPIDBus</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>StaticLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v120</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v120</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </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>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <IncludePath>$(ProjectDir)\src;C:\work\bmw\2.0\dbus;C:\work\bmw\vs21\Common-API\src\;$(IncludePath)</IncludePath>
+ <LibraryPath>C:\work\bmw\vs21\Common-API\Debug;$(LibraryPath)</LibraryPath>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ <PreprocessorDefinitions>WIN32;COMMONAPI_INTERNAL_COMPILATION;COMMONAPI_DBUS_VERSION_MAJOR=2;COMMONAPI_DBUS_VERSION_MINOR=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ <DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalDependencies>CommonAPI.dll;dbus-1d.dll;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalLibraryDirectories>$(ProgramFiles)\dbus\bin\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalOptions>/VERBOSE %(AdditionalOptions)</AdditionalOptions>
+ </Link>
+ <Lib>
+ <AdditionalDependencies>CommonAPI.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Lib>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ </ClCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="src\CommonAPI\DBus\DBusAddressTranslator.cpp" />
+ <ClCompile Include="src\CommonAPI\DBus\DBusClientId.cpp" />
+ <ClCompile Include="src\CommonAPI\DBus\DBusConfiguration.cpp" />
+ <ClCompile Include="src\CommonAPI\DBus\DBusConnection.cpp" />
+ <ClCompile Include="src\CommonAPI\DBus\DBusDaemonProxy.cpp" />
+ <ClCompile Include="src\CommonAPI\DBus\DBusError.cpp" />
+ <ClCompile Include="src\CommonAPI\DBus\DBusFactory.cpp" />
+ <ClCompile Include="src\CommonAPI\DBus\DBusFunctionalHash.cpp" />
+ <ClCompile Include="src\CommonAPI\DBus\DBusInputStream.cpp" />
+ <ClCompile Include="src\CommonAPI\DBus\DBusMainLoopContext.cpp" />
+ <ClCompile Include="src\CommonAPI\DBus\DBusMessage.cpp" />
+ <ClCompile Include="src\CommonAPI\DBus\DBusObjectManager.cpp" />
+ <ClCompile Include="src\CommonAPI\DBus\DBusObjectManagerStub.cpp" />
+ <ClCompile Include="src\CommonAPI\DBus\DBusOutputStream.cpp" />
+ <ClCompile Include="src\CommonAPI\DBus\DBusProxy.cpp" />
+ <ClCompile Include="src\CommonAPI\DBus\DBusProxyBase.cpp" />
+ <ClCompile Include="src\CommonAPI\DBus\DBusProxyManager.cpp" />
+ <ClCompile Include="src\CommonAPI\DBus\DBusRuntime.cpp" />
+ <ClCompile Include="src\CommonAPI\DBus\DBusServicePublisher.cpp" />
+ <ClCompile Include="src\CommonAPI\DBus\DBusServiceRegistry.cpp" />
+ <ClCompile Include="src\CommonAPI\DBus\DBusStubAdapter.cpp" />
+ <ClCompile Include="src\murmurhash\MurmurHash3.cpp" />
+ <ClCompile Include="src\pugixml\pugixml.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\CommonAPI\DBus\DBusAddressTranslator.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusAttribute.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusClientId.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusConfiguration.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusConnection.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusConnectionBusType.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusDaemonProxy.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusError.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusEvent.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusFactory.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusFunctionalHash.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusHelper.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusInputStream.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusInstanceAvailabilityStatusChangedEvent.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusInterfaceHandler.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusLegacyVariant.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusMainLoopContext.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusMessage.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusMultiEvent.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusObjectManager.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusObjectManagerStub.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusOutputStream.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusProxy.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusProxyAsyncCallbackHandler.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusProxyBase.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusProxyConnection.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusProxyHelper.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusProxyManager.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusRuntime.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusSelectiveEvent.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusSerializableArguments.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusServicePublisher.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusServiceRegistry.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusStubAdapter.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusStubAdapterHelper.h" />
+ <ClInclude Include="src\CommonAPI\DBus\DBusUtils.h" />
+ <ClInclude Include="src\murmurhash\MurmurHash3.h" />
+ <ClInclude Include="src\pugixml\pugiconfig.hpp" />
+ <ClInclude Include="src\pugixml\pugixml.hpp" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file @@ -81,6 +81,8 @@ Use autotools to build this package withthe above requirements available through # make # sudo make install (or alternative install process, eg. checkinstall on debian-based distributions, such as Ubuntu) ---- +To build the Windows version with Visual Studio, you can use the solution file CommonAPI-DBus.sln. It is configured to build CommonAPI-DBus as a static library. +Add the path of CommonAPI.lib to "Additional Library Directories" == Linking against CommonAPI-D-Bus @@ -184,6 +186,14 @@ All "dbus_*"-values are optional. For each such omitted value the default value # dbus_bustype may be set to "session" or "system" for communication on the user's session bus or on the system wide bus. The default value is "session" +== Remarks on Windows version + +On Windows systems there are some drawbacks: +# Calling disconnect and later connect on the same DBusConnection somehow damages the libdbus connection. On Linux +implementation this all works fine. +# The DBusLoadTest revealed that a number of more than about 50 proxies slows down the dbus communication +significantly. That's why we run the DBusLoadTest on windows with just 50 instead of 100 proxies. + == Working on the code & contribution .First get the code from the git: diff --git a/UnitTests.vcxproj b/UnitTests.vcxproj new file mode 100644 index 0000000..ac46eca --- /dev/null +++ b/UnitTests.vcxproj @@ -0,0 +1,186 @@ +<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="12.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>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="src\test\commonapi\tests\DerivedTypeCollection.cpp" />
+ <ClCompile Include="src\test\commonapi\tests\ExtendedInterfaceDBusProxy.cpp" />
+ <ClCompile Include="src\test\commonapi\tests\ExtendedInterfaceDBusStubAdapter.cpp" />
+ <ClCompile Include="src\test\commonapi\tests\ExtendedInterfaceStubDefault.cpp" />
+ <ClCompile Include="src\test\commonapi\tests\managed\BranchInterfaceDBusProxy.cpp" />
+ <ClCompile Include="src\test\commonapi\tests\managed\BranchInterfaceDBusStubAdapter.cpp" />
+ <ClCompile Include="src\test\commonapi\tests\managed\BranchInterfaceStubDefault.cpp" />
+ <ClCompile Include="src\test\commonapi\tests\managed\LeafInterfaceDBusProxy.cpp" />
+ <ClCompile Include="src\test\commonapi\tests\managed\LeafInterfaceDBusStubAdapter.cpp" />
+ <ClCompile Include="src\test\commonapi\tests\managed\LeafInterfaceStubDefault.cpp" />
+ <ClCompile Include="src\test\commonapi\tests\managed\RootInterfaceDBusProxy.cpp" />
+ <ClCompile Include="src\test\commonapi\tests\managed\RootInterfaceDBusStubAdapter.cpp" />
+ <ClCompile Include="src\test\commonapi\tests\managed\RootInterfaceStubDefault.cpp" />
+ <ClCompile Include="src\test\commonapi\tests\managed\SecondRootDBusProxy.cpp" />
+ <ClCompile Include="src\test\commonapi\tests\managed\SecondRootDBusStubAdapter.cpp" />
+ <ClCompile Include="src\test\commonapi\tests\managed\SecondRootStubDefault.cpp" />
+ <ClCompile Include="src\test\commonapi\tests\TestInterfaceDBusProxy.cpp" />
+ <ClCompile Include="src\test\commonapi\tests\TestInterfaceDBusStubAdapter.cpp" />
+ <ClCompile Include="src\test\commonapi\tests\TestInterfaceStubDefault.cpp" />
+ <ClCompile Include="src\test\DBusAddressTranslatorTest.cpp" />
+ <ClCompile Include="src\test\DBusClientIdTest.cpp" />
+ <ClCompile Include="src\test\DBusCommunicationTest.cpp" />
+ <ClCompile Include="src\test\DBusConnectionTest.cpp" />
+ <ClCompile Include="src\test\DBusDaemonProxyTest.cpp" />
+ <ClCompile Include="src\test\DBusFactoryTest.cpp" />
+ <ClCompile Include="src\test\DBusInputStreamTest.cpp" />
+ <ClCompile Include="src\test\DBusMainLoopIntegrationTest.cpp" />
+ <ClCompile Include="src\test\DBusManagedTest.cpp" />
+ <ClCompile Include="src\test\DBusMultipleConnectionTest.cpp" />
+ <ClCompile Include="src\test\DBusObjectManagerStubTest.cpp" />
+ <ClCompile Include="src\test\DBusOutputStreamTest.cpp" />
+ <ClCompile Include="src\test\DBusPolymorphicTest.cpp" />
+ <ClCompile Include="src\test\DBusProxyTest.cpp" />
+ <ClCompile Include="src\test\DBusRuntimeTest.cpp" />
+ <ClCompile Include="src\test\DBusSelectiveBroadcastTest.cpp" />
+ <ClCompile Include="src\test\DBusServicePublisherTest.cpp" />
+ <ClCompile Include="src\test\DBusServiceRegistryTest.cpp" />
+ <ClCompile Include="src\test\DBusTypeStreamTest.cpp" />
+ <ClCompile Include="src\test\DBusVariantOutputStreamTest.cpp" />
+ <ClCompile Include="src\test\DBusVariantTest.cpp" />
+ <ClCompile Include="src\test\DemoPoll.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="src\test\commonapi\tests\DerivedTypeCollection.h" />
+ <ClInclude Include="src\test\commonapi\tests\ExtendedInterface.h" />
+ <ClInclude Include="src\test\commonapi\tests\ExtendedInterfaceDBusProxy.h" />
+ <ClInclude Include="src\test\commonapi\tests\ExtendedInterfaceDBusStubAdapter.h" />
+ <ClInclude Include="src\test\commonapi\tests\ExtendedInterfaceProxy.h" />
+ <ClInclude Include="src\test\commonapi\tests\ExtendedInterfaceProxyBase.h" />
+ <ClInclude Include="src\test\commonapi\tests\ExtendedInterfaceStub.h" />
+ <ClInclude Include="src\test\commonapi\tests\ExtendedInterfaceStubDefault.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\BranchInterface.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\BranchInterfaceDBusProxy.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\BranchInterfaceDBusStubAdapter.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\BranchInterfaceProxy.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\BranchInterfaceProxyBase.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\BranchInterfaceStub.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\BranchInterfaceStubDefault.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\LeafInterface.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\LeafInterfaceDBusProxy.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\LeafInterfaceDBusStubAdapter.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\LeafInterfaceProxy.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\LeafInterfaceProxyBase.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\LeafInterfaceStub.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\LeafInterfaceStubDefault.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\RootInterface.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\RootInterfaceDBusProxy.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\RootInterfaceDBusStubAdapter.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\RootInterfaceProxy.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\RootInterfaceProxyBase.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\RootInterfaceStub.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\RootInterfaceStubDefault.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\SecondRoot.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\SecondRootDBusProxy.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\SecondRootDBusStubAdapter.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\SecondRootProxy.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\SecondRootProxyBase.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\SecondRootStub.h" />
+ <ClInclude Include="src\test\commonapi\tests\managed\SecondRootStubDefault.h" />
+ <ClInclude Include="src\test\commonapi\tests\PredefinedTypeCollection.h" />
+ <ClInclude Include="src\test\commonapi\tests\TestInterface.h" />
+ <ClInclude Include="src\test\commonapi\tests\TestInterfaceDBusProxy.h" />
+ <ClInclude Include="src\test\commonapi\tests\TestInterfaceDBusStubAdapter.h" />
+ <ClInclude Include="src\test\commonapi\tests\TestInterfaceProxy.h" />
+ <ClInclude Include="src\test\commonapi\tests\TestInterfaceProxyBase.h" />
+ <ClInclude Include="src\test\commonapi\tests\TestInterfaceStub.h" />
+ <ClInclude Include="src\test\commonapi\tests\TestInterfaceStubDefault.h" />
+ <ClInclude Include="src\test\DBusTestUtils.h" />
+ <ClInclude Include="src\test\DemoPoll.h" />
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{A437B05C-A664-493D-B60A-822A3A7A1CED}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>UnitTests</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v120</PlatformToolset>
+ <CharacterSet>Unicode</CharacterSet>
+ <UseOfMfc>false</UseOfMfc>
+ <CLRSupport>false</CLRSupport>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v120</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ <UseOfMfc>false</UseOfMfc>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </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>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <LibraryPath>C:\work\bmw\2.0\dbus\cmake\bin\Debug;C:\work\bmw\2.0\gtest-1.7.0\msvc\gtest\Debug;C:\work\bmw\vs21\Common-API\Debug;$(SolutionDir)\Debug;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86)</LibraryPath>
+ <IncludePath>C:\work\bmw\2.0\dbus;$(ProjectDir);$(SolutionDir)\src\test;$(SolutionDir)\src;C:\work\bmw\vs21\Common-API\src;C:\work\bmw\2.0\gtest-1.7.0\include;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
+ <SourcePath>$(SourcePath)</SourcePath>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ENABLE_ATTRIBUTE_EXTENSIONS;WIN32;COMMONAPI_INTERNAL_COMPILATION;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <UseFullPaths>true</UseFullPaths>
+ <ShowIncludes>true</ShowIncludes>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ </ClCompile>
+ <Link>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>CommonAPI-DBus.lib;gtestd.lib;gtest_maind.lib;dbus-1d.lib;Ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalOptions>/VERBOSE /VERBOSE:LIB %(AdditionalOptions)</AdditionalOptions>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>Use</PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <AdditionalIncludeDirectories>$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <UseFullPaths>true</UseFullPaths>
+ </ClCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <AdditionalLibraryDirectories>$(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ </Link>
+ </ItemDefinitionGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
\ No newline at end of file diff --git a/src/CommonAPI/DBus/DBusAddressTranslator.cpp b/src/CommonAPI/DBus/DBusAddressTranslator.cpp index 8d89330..92f432c 100644 --- a/src/CommonAPI/DBus/DBusAddressTranslator.cpp +++ b/src/CommonAPI/DBus/DBusAddressTranslator.cpp @@ -50,13 +50,13 @@ DBusAddressTranslator& DBusAddressTranslator::getInstance() { void DBusAddressTranslator::searchForDBusAddress(const std::string& domain, - const std::string& interface, + const std::string& interf, const std::string& instance, std::string& interfaceName, std::string& connectionName, std::string& objectPath) { std::stringstream ss; - ss << domain << ":" << interface << ":" << instance; + ss << domain << ":" << interf << ":" << instance; searchForDBusAddress(ss.str(), interfaceName, connectionName, objectPath); } diff --git a/src/CommonAPI/DBus/DBusAddressTranslator.h b/src/CommonAPI/DBus/DBusAddressTranslator.h index f55b6df..c1b29df 100644 --- a/src/CommonAPI/DBus/DBusAddressTranslator.h +++ b/src/CommonAPI/DBus/DBusAddressTranslator.h @@ -33,7 +33,7 @@ public: static DBusAddressTranslator& getInstance(); void searchForDBusAddress(const std::string& domain, - const std::string& interface, + const std::string& interf, const std::string& instance, std::string& interfaceName, std::string& connectionName, diff --git a/src/CommonAPI/DBus/DBusAttribute.h b/src/CommonAPI/DBus/DBusAttribute.h index 4967702..adac105 100644 --- a/src/CommonAPI/DBus/DBusAttribute.h +++ b/src/CommonAPI/DBus/DBusAttribute.h @@ -389,10 +389,10 @@ public: } protected: - void onInternalEvent(const std::string& interface, + void onInternalEvent(const std::string& interfaceName, const std::unordered_map<std::string, DBusLegacyVariantWrapper<Variant<_Types> > >& props, const std::vector<std::string>& invalid) { - if (std::string(interfaceName_) == interface) { + if (std::string(interfaceName_) == interfaceName) { auto mapIter = props.find(std::string(propertyName_)); if (mapIter != props.end()) { notifyListeners(mapIter->second.contained_.template get<ValueType>()); @@ -481,10 +481,10 @@ public: } protected: - void onInternalEvent(const std::string& interface, + void onInternalEvent(const std::string& interfaceName, const std::unordered_map<std::string, DBusLegacyVariantWrapper<ValueType> >& props, const std::vector<std::string>& invalid) { - if (std::string(interfaceName_) == interface) { + if (std::string(interfaceName_) == interfaceName) { auto mapIter = props.find(std::string(propertyName_)); if (mapIter != props.end()) { notifyListeners(mapIter->second.contained_); diff --git a/src/CommonAPI/DBus/DBusConnection.cpp b/src/CommonAPI/DBus/DBusConnection.cpp index 1d95989..8f0bd86 100644 --- a/src/CommonAPI/DBus/DBusConnection.cpp +++ b/src/CommonAPI/DBus/DBusConnection.cpp @@ -43,10 +43,11 @@ const DBusObjectPathVTable* DBusConnection::getDBusObjectPathVTable() { } + //std::bind used to start the dispatch thread holds one reference, and the selfReference //created within the thread is the second. If only those two remain, no one but the //dispatch thread references the connection, which therefore can be finished. -constexpr uint32_t ownUseCount = 2; +const uint32_t ownUseCount = 2; void DBusConnection::dispatch() { std::shared_ptr<DBusConnection> selfReference = this->shared_from_this(); diff --git a/src/CommonAPI/DBus/DBusEvent.h b/src/CommonAPI/DBus/DBusEvent.h index 587ccfc..ecd8735 100644 --- a/src/CommonAPI/DBus/DBusEvent.h +++ b/src/CommonAPI/DBus/DBusEvent.h @@ -66,16 +66,20 @@ class DBusEvent: public _EventType, public DBusProxyConnection::DBusSignalHandle } protected: virtual void onFirstListenerAdded(const CancellableListener&) { - subscription_ = dbusProxy_.addSignalMemberHandler(objectPath_, interfaceName_, - eventName_, eventSignature_, this); - } + subscription_ = dbusProxy_.addSignalMemberHandler(objectPath_, + interfaceName_, + eventName_, + eventSignature_, + this); + } virtual void onLastListenerRemoved(const CancellableListener&) { dbusProxy_.removeSignalMemberHandler(subscription_); } - template <typename ... _Arguments> - inline SubscriptionStatus unpackArgumentsAndHandleSignalDBusMessage(const DBusMessage& dbusMessage, std::tuple<_Arguments...> argTuple) { + template<typename ... _Arguments> + inline SubscriptionStatus unpackArgumentsAndHandleSignalDBusMessage(const DBusMessage& dbusMessage, + std::tuple<_Arguments...> argTuple) { return handleSignalDBusMessage(dbusMessage, std::move(argTuple), typename make_sequence<sizeof...(_Arguments)>::type()); } diff --git a/src/CommonAPI/DBus/DBusFactory.h b/src/CommonAPI/DBus/DBusFactory.h index ec40ff9..8b290fe 100644 --- a/src/CommonAPI/DBus/DBusFactory.h +++ b/src/CommonAPI/DBus/DBusFactory.h @@ -16,7 +16,7 @@ #include <CommonAPI/Factory.h> -#include "CommonAPI/DBus/DBusStubAdapter.h" +#include "DBusStubAdapter.h" #include "DBusConnection.h" #include "DBusProxy.h" diff --git a/src/CommonAPI/DBus/DBusInstanceAvailabilityStatusChangedEvent.h b/src/CommonAPI/DBus/DBusInstanceAvailabilityStatusChangedEvent.h index 456ed8d..f9e5a1e 100644 --- a/src/CommonAPI/DBus/DBusInstanceAvailabilityStatusChangedEvent.h +++ b/src/CommonAPI/DBus/DBusInstanceAvailabilityStatusChangedEvent.h @@ -47,6 +47,11 @@ class DBusInstanceAvailabilityStatusChangedEvent: return CommonAPI::SubscriptionStatus::RETAIN; } + virtual ~DBusInstanceAvailabilityStatusChangedEvent() { + dbusProxy_.removeSignalMemberHandler(interfacesAddedSubscription_); + dbusProxy_.removeSignalMemberHandler(interfacesRemovedSubscription_); + } + protected: virtual void onFirstListenerAdded(const CancellableListener&) { interfacesAddedSubscription_ = dbusProxy_.addSignalMemberHandler( diff --git a/src/CommonAPI/DBus/DBusMainLoopContext.cpp b/src/CommonAPI/DBus/DBusMainLoopContext.cpp index 4f114b4..c1a581f 100644 --- a/src/CommonAPI/DBus/DBusMainLoopContext.cpp +++ b/src/CommonAPI/DBus/DBusMainLoopContext.cpp @@ -9,7 +9,11 @@ #include "DBusMainLoopContext.h" #include "DBusConnection.h" +#ifdef WIN32 +#include <WinSock2.h> +#else #include <poll.h> +#endif #include <chrono> diff --git a/src/CommonAPI/DBus/DBusMainLoopContext.h b/src/CommonAPI/DBus/DBusMainLoopContext.h index 7e59535..439d530 100644 --- a/src/CommonAPI/DBus/DBusMainLoopContext.h +++ b/src/CommonAPI/DBus/DBusMainLoopContext.h @@ -14,11 +14,10 @@ #include <list> #include <memory> -#include <poll.h> +#include <CommonAPI/MainLoopContext.h> #include <dbus/dbus.h> -#include <CommonAPI/MainLoopContext.h> namespace CommonAPI { @@ -55,7 +54,6 @@ class DBusWatch: public Watch { const std::vector<DispatchSource*>& getDependentDispatchSources(); void addDependentDispatchSource(DispatchSource* dispatchSource); - private: bool isReady(); @@ -79,7 +77,6 @@ class DBusTimeout: public Timeout { int64_t getTimeoutInterval() const; int64_t getReadyTime() const; - private: void recalculateDueTime(); diff --git a/src/CommonAPI/DBus/DBusProxyHelper.h b/src/CommonAPI/DBus/DBusProxyHelper.h index da8896f..0a316be 100644 --- a/src/CommonAPI/DBus/DBusProxyHelper.h +++ b/src/CommonAPI/DBus/DBusProxyHelper.h @@ -200,7 +200,7 @@ template< const _InArgs&... inArgs, _AsyncCallback asyncCallback) { - callMethodAsync( + return callMethodAsync( dbusProxy, dbusProxy.getDBusBusName().c_str(), dbusProxy.getDBusObjectPath().c_str(), diff --git a/src/CommonAPI/DBus/DBusRuntime.cpp b/src/CommonAPI/DBus/DBusRuntime.cpp index 9da7bea..bddd91b 100644 --- a/src/CommonAPI/DBus/DBusRuntime.cpp +++ b/src/CommonAPI/DBus/DBusRuntime.cpp @@ -13,28 +13,34 @@ const char middlewareIdentifier[] = "DBus"; -const CommonAPI::MiddlewareInfo middlewareInfo(middlewareIdentifier, - &CommonAPI::DBus::DBusRuntime::getInstance, - {COMMONAPI_DBUS_VERSION_MAJOR, COMMONAPI_DBUS_VERSION_MINOR} ); - - namespace CommonAPI { namespace DBus { -__attribute__((constructor)) void registerDBusMiddleware(void) { +INITIALIZER(registerDBusMiddleware) { Runtime::registerRuntimeLoader(middlewareIdentifier, &DBusRuntime::getInstance); } +const CommonAPI::MiddlewareInfo DBusRuntime::middlewareInfo_(middlewareIdentifier, + &CommonAPI::DBus::DBusRuntime::getInstance, + {COMMONAPI_DBUS_VERSION_MAJOR, + COMMONAPI_DBUS_VERSION_MINOR} +); + + + + std::shared_ptr<Runtime> DBusRuntime::getInstance() { static std::shared_ptr<Runtime> dbusRuntimeSingleton_; if (!dbusRuntimeSingleton_) { dbusRuntimeSingleton_ = std::make_shared<DBusRuntime>(); - for (const auto& genericLibraryPath: Configuration::getInstance().getGenericLibraryPaths(middlewareIdentifier)) { +#ifndef WIN32 + for (const auto& genericLibraryPath : Configuration::getInstance().getGenericLibraryPaths(middlewareIdentifier)) { if (!loadGenericLibrary(middlewareIdentifier, genericLibraryPath, false)) { return std::shared_ptr<Runtime>(NULL); } } findAndLoadGenericLibraries(middlewareIdentifier, Configuration::getInstance().getLibrarySearchPaths()); +#endif } return dbusRuntimeSingleton_; } @@ -46,7 +52,7 @@ std::shared_ptr<Factory> DBusRuntime::doCreateFactory(std::shared_ptr<MainLoopCo auto factory = std::shared_ptr<DBusFactory>(NULL); if (factoryName == "") { - factory = std::make_shared<DBusFactory>(this->shared_from_this(), &middlewareInfo, mainLoopContext); + factory = std::make_shared<DBusFactory>(this->shared_from_this(), &middlewareInfo_, mainLoopContext); } else { const DBusFactoryConfig* dbusFactoryConfig = DBusConfiguration::getInstance().getFactoryConfiguration(factoryName); @@ -60,7 +66,7 @@ std::shared_ptr<Factory> DBusRuntime::doCreateFactory(std::shared_ptr<MainLoopCo factory = std::make_shared<DBusFactory>( this->shared_from_this(), - &middlewareInfo, + &middlewareInfo_, mainLoopContext, *dbusFactoryConfig); } @@ -74,3 +80,7 @@ std::shared_ptr<ServicePublisher> DBusRuntime::getServicePublisher() { } // namespace DBus } // namespace CommonAPI + +extern "C" { + CommonAPI::MiddlewareInfo middlewareInfo = CommonAPI::DBus::DBusRuntime::middlewareInfo_; +} diff --git a/src/CommonAPI/DBus/DBusRuntime.h b/src/CommonAPI/DBus/DBusRuntime.h index 725863e..ee7e689 100644 --- a/src/CommonAPI/DBus/DBusRuntime.h +++ b/src/CommonAPI/DBus/DBusRuntime.h @@ -21,23 +21,19 @@ namespace CommonAPI { namespace DBus { class DBusRuntime: public Runtime, public std::enable_shared_from_this<DBusRuntime> { - public: +public: static std::shared_ptr<Runtime> getInstance(); std::shared_ptr<ServicePublisher> getServicePublisher(); - - protected: + static const MiddlewareInfo middlewareInfo_; +protected: std::shared_ptr<Factory> doCreateFactory(std::shared_ptr<MainLoopContext> mainLoopContext, const std::string& factoryName, const bool nullOnInvalidName); - - private: +private: static std::unordered_map<std::string, DBusRuntime> registeredRuntimes; }; } // namespace DBus } // namespace CommonAPI - -extern "C" const CommonAPI::MiddlewareInfo middlewareInfo; - #endif // COMMONAPI_DBUS_DBUS_RUNTIME_H_ diff --git a/src/CommonAPI/DBus/DBusServiceRegistry.h b/src/CommonAPI/DBus/DBusServiceRegistry.h index 49480b1..9d59cf1 100644 --- a/src/CommonAPI/DBus/DBusServiceRegistry.h +++ b/src/CommonAPI/DBus/DBusServiceRegistry.h @@ -265,7 +265,7 @@ class DBusServiceRegistry: public std::enable_shared_from_this<DBusServiceRegist const std::string& rootObjectPath, const std::string& dbusServiceUniqueName); - void processIntrospectionInterface(const pugi::xml_node& interface, + void processIntrospectionInterface(const pugi::xml_node& node, const std::string& rootObjectPath, const std::string& fullObjectPath, const std::string& dbusServiceUniqueName); diff --git a/src/CommonAPI/DBus/DBusStubAdapterHelper.h b/src/CommonAPI/DBus/DBusStubAdapterHelper.h index 4448f32..d4c9f5e 100644 --- a/src/CommonAPI/DBus/DBusStubAdapterHelper.h +++ b/src/CommonAPI/DBus/DBusStubAdapterHelper.h @@ -40,7 +40,9 @@ class DBusStubAdapterHelper: public virtual DBusStubAdapter { class StubDispatcher: public StubDispatcherBase { public: - virtual bool dispatchDBusMessage(const DBusMessage& dbusMessage, const std::shared_ptr<_StubClass>& stub, DBusStubAdapterHelper<_StubClass>& dbusStubAdapterHelper) = 0; + virtual bool dispatchDBusMessage(const DBusMessage& dbusMessage, + const std::shared_ptr<_StubClass>& stub, + DBusStubAdapterHelper<_StubClass>& dbusStubAdapterHelper) = 0; }; // interfaceMemberName, interfaceMemberSignature typedef std::pair<const char*, const char*> DBusInterfaceMemberPath; @@ -188,7 +190,7 @@ class DBusMethodStubDispatcher<_StubClass, _In<_InArgs...> >: public DBusStubAda } private: - template <int... _InArgIndices, int... _OutArgIndices> + template <int... _InArgIndices> inline bool handleDBusMessage(const DBusMessage& dbusMessage, const std::shared_ptr<_StubClass>& stub, DBusStubAdapterHelperType& dbusStubAdapterHelper, @@ -239,7 +241,6 @@ class DBusMethodWithReplyStubDispatcher<_StubClass, _In<_InArgs...>, _Out<_OutAr typename make_sequence_range<sizeof...(_InArgs), 0>::type(), typename make_sequence_range<sizeof...(_OutArgs), sizeof...(_InArgs)>::type()); } - private: template <int... _InArgIndices, int... _OutArgIndices> inline bool handleDBusMessage(const DBusMessage& dbusMessage, @@ -291,6 +292,7 @@ class DBusMethodWithReplyAdapterDispatcher<_StubClass, _StubAdapterClass, _In<_I public: typedef DBusStubAdapterHelper<_StubClass> DBusStubAdapterHelperType; typedef void (_StubAdapterClass::*_StubFunctor)(std::shared_ptr<CommonAPI::ClientId>, _InArgs..., _OutArgs&...); + typedef typename CommonAPI::Stub<typename DBusStubAdapterHelperType::StubAdapterType, typename _StubClass::RemoteEventType> StubType; DBusMethodWithReplyAdapterDispatcher(_StubFunctor stubFunctor, const char* dbusReplySignature): stubFunctor_(stubFunctor), @@ -324,7 +326,7 @@ class DBusMethodWithReplyAdapterDispatcher<_StubClass, _StubAdapterClass, _In<_I std::shared_ptr<DBusClientId> clientId = std::make_shared<DBusClientId>(std::string(dbusMessage.getSenderName())); - (stub->getStubAdapter().get()->*stubFunctor_)(clientId, std::move(std::get<_InArgIndices>(argTuple))..., std::get<_OutArgIndices>(argTuple)...); + (stub->StubType::getStubAdapter().get()->*stubFunctor_)(clientId, std::move(std::get<_InArgIndices>(argTuple))..., std::get<_OutArgIndices>(argTuple)...); DBusMessage dbusMessageReply = dbusMessage.createMethodReturn(dbusReplySignature_); if (sizeof...(_OutArgs) > 0) { @@ -444,10 +446,10 @@ class DBusSetObservableAttributeStubDispatcher: public DBusSetAttributeStubDispa public: typedef typename DBusSetAttributeStubDispatcher<_StubClass, _AttributeType>::DBusStubAdapterHelperType DBusStubAdapterHelperType; typedef typename DBusStubAdapterHelperType::StubAdapterType StubAdapterType; - typedef typename DBusSetAttributeStubDispatcher<_StubClass, _AttributeType>::GetStubFunctor GetStubFunctor; typedef typename DBusSetAttributeStubDispatcher<_StubClass, _AttributeType>::OnRemoteSetFunctor OnRemoteSetFunctor; typedef typename DBusSetAttributeStubDispatcher<_StubClass, _AttributeType>::OnRemoteChangedFunctor OnRemoteChangedFunctor; + typedef typename CommonAPI::Stub<StubAdapterType, typename _StubClass::RemoteEventType> StubType; typedef void (StubAdapterType::*FireChangedFunctor)(const _AttributeType&); DBusSetObservableAttributeStubDispatcher(GetStubFunctor getStubFunctor, @@ -477,7 +479,7 @@ class DBusSetObservableAttributeStubDispatcher: public DBusSetAttributeStubDispa private: inline void fireAttributeValueChanged(std::shared_ptr<CommonAPI::ClientId> clientId, DBusStubAdapterHelperType& dbusStubAdapterHelper, const std::shared_ptr<_StubClass> stub) { - (stub->getStubAdapter().get()->*fireChangedFunctor_)(this->getAttributeValue(clientId, stub)); + (stub->StubType::getStubAdapter().get()->*fireChangedFunctor_)(this->getAttributeValue(clientId, stub)); } const FireChangedFunctor fireChangedFunctor_; diff --git a/src/test/DBusAddressTranslatorTest.cpp b/src/test/DBusAddressTranslatorTest.cpp index ef5d828..218cd5c 100644 --- a/src/test/DBusAddressTranslatorTest.cpp +++ b/src/test/DBusAddressTranslatorTest.cpp @@ -9,12 +9,13 @@ #include <gtest/gtest.h> #include <fstream> #include <thread> -#include <unistd.h> #include <CommonAPI/CommonAPI.h> + #define COMMONAPI_INTERNAL_COMPILATION +#include <CommonAPI/types.h> #include <CommonAPI/DBus/DBusAddressTranslator.h> #include <CommonAPI/DBus/DBusUtils.h> #include <CommonAPI/DBus/DBusConnection.h> @@ -86,7 +87,30 @@ static const std::string fileString = "dbus_connection=fake.legacy.service.connection\n" "dbus_object=/some/legacy/path/6259504\n" "dbus_interface=fake.legacy.service.LegacyInterface\n" -"dbus_predefined=true\n"; +"dbus_predefined=true\n" +// all tests run within the same binary under windows, meaning the config file will only be read once. That's why we already have to add the factory configuration used by DBusFactoryTest and the predifined instances for DBusServiceRegistryTest here. +#ifdef WIN32 +"[local:Interface1:predefined.Instance1]\n" +"dbus_connection=DBusServiceRegistryTest.Predefined.Service\n" +"dbus_object=/tests/predefined/Object1\n" +"dbus_interface=tests.Interface1\n" +"dbus_predefined=true\n" +"[local:Interface1:predefined.Instance2]\n" +"dbus_connection=DBusServiceRegistryTest.Predefined.Service\n" +"dbus_object=/tests/predefined/Object2\n" +"dbus_interface=tests.Interface1\n" +"dbus_predefined=true\n" +"[local:Interface2:predefined.Instance]\n" +"dbus_connection=DBusServiceRegistryTest.Predefined.Service\n" +"dbus_object=/tests/predefined/Object1\n" +"dbus_interface=tests.Interface2\n" +"dbus_predefined=true\n" +"[factory$session]\n" +"dbus_bustype=session\n" +"[factory$system]\n" +"dbus_bustype=system\n" +#endif +; typedef std::vector<CommonAPI::DBus::DBusServiceAddress>::value_type vt; static const std::vector<CommonAPI::DBus::DBusServiceAddress> dbusAddresses = { @@ -101,13 +125,9 @@ static const std::vector<CommonAPI::DBus::DBusServiceAddress> dbusAddresses = { vt("fake.legacy.service.connection", "/some/legacy/path/6259504", "fake.legacy.service.LegacyInterface") }; - -class Environment: public ::testing::Environment { -public: - virtual ~Environment() { - } - - virtual void SetUp() { +class AddressTranslatorTest: public ::testing::Test { +protected: + void SetUp() { configFileName_ = CommonAPI::getCurrentBinaryFileFQN(); configFileName_ += CommonAPI::DBus::DBUS_CONFIG_SUFFIX; std::ofstream configFile(configFileName_); @@ -117,29 +137,16 @@ public: } virtual void TearDown() { + usleep(30000); std::remove(configFileName_.c_str()); } - std::string configFileName_; }; - -class AddressTranslatorTest: public ::testing::Test { -protected: - void SetUp() { - } - - virtual void TearDown() { - usleep(30000); - } -}; - - TEST_F(AddressTranslatorTest, InstanceCanBeRetrieved) { CommonAPI::DBus::DBusAddressTranslator& translator = CommonAPI::DBus::DBusAddressTranslator::getInstance(); } - TEST_F(AddressTranslatorTest, ParsesDBusAddresses) { CommonAPI::DBus::DBusAddressTranslator& translator = CommonAPI::DBus::DBusAddressTranslator::getInstance(); @@ -152,7 +159,6 @@ TEST_F(AddressTranslatorTest, ParsesDBusAddresses) { } } - TEST_F(AddressTranslatorTest, ParsesCommonAPIAddresses) { CommonAPI::DBus::DBusAddressTranslator& translator = CommonAPI::DBus::DBusAddressTranslator::getInstance(); @@ -167,7 +173,6 @@ TEST_F(AddressTranslatorTest, ParsesCommonAPIAddresses) { } } - TEST_F(AddressTranslatorTest, ServicesUsingPredefinedAddressesCanCommunicate) { std::shared_ptr<CommonAPI::Runtime> runtime = CommonAPI::Runtime::load(); ASSERT_TRUE((bool)runtime); @@ -208,7 +213,7 @@ TEST_F(AddressTranslatorTest, ServicesUsingPredefinedAddressesCanCommunicate) { servicePublisher->unregisterService(commonApiAddresses[0]); } - +#ifndef WIN32 const std::string addressOfFakeLegacyService = commonApiAddresses[8]; const std::string domainOfFakeLegacyService = "local"; @@ -281,9 +286,8 @@ TEST_F(AddressTranslatorTest, FakeLegacyServiceCanBeAddressed) { fakeServiceThread.join(); } - int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); - ::testing::AddGlobalTestEnvironment(new Environment()); return RUN_ALL_TESTS(); } +#endif // !WIN32 diff --git a/src/test/DBusClientIdTest.cpp b/src/test/DBusClientIdTest.cpp index e0aa72f..eeb52b0 100644 --- a/src/test/DBusClientIdTest.cpp +++ b/src/test/DBusClientIdTest.cpp @@ -6,6 +6,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include <gtest/gtest.h> + +#define COMMONAPI_INTERNAL_COMPILATION + #include "CommonAPI/DBus/DBusClientId.h" #include "CommonAPI/types.h" diff --git a/src/test/DBusCommunicationTest.cpp b/src/test/DBusCommunicationTest.cpp index 2534154..3a06910 100644 --- a/src/test/DBusCommunicationTest.cpp +++ b/src/test/DBusCommunicationTest.cpp @@ -23,6 +23,7 @@ #include <CommonAPI/CommonAPI.h> #define COMMONAPI_INTERNAL_COMPILATION +#include <CommonAPI/types.h> #include <CommonAPI/DBus/DBusConnection.h> #include <CommonAPI/DBus/DBusProxy.h> @@ -36,7 +37,6 @@ #include "commonapi/tests/TestInterfaceDBusProxy.h" - class DBusCommunicationTest: public ::testing::Test { protected: virtual void SetUp() { @@ -55,6 +55,11 @@ class DBusCommunicationTest: public ::testing::Test { } virtual void TearDown() { + servicePublisher_->unregisterService(serviceAddress_); + servicePublisher_->unregisterService(serviceAddress2_); + servicePublisher_->unregisterService(serviceAddress3_); + servicePublisher_->unregisterService(serviceAddress4_); + servicePublisher_->unregisterService(serviceAddress5_); usleep(30000); } @@ -433,17 +438,18 @@ const std::string DBusLowLevelCommunicationTest::lowLevelAddress2_ = "local:Comm const std::string DBusLowLevelCommunicationTest::lowLevelAddress3_ = "local:CommonAPI.DBus.tests.DBusProxyTestInterface:CommonAPI.DBus.tests.DBusProxyLowLevelService3"; const std::string DBusLowLevelCommunicationTest::lowLevelAddress4_ = "local:CommonAPI.DBus.tests.DBusProxyTestInterface:CommonAPI.DBus.tests.DBusProxyLowLevelService4"; +namespace DBusCommunicationTestNamespace { ::DBusHandlerResult onLibdbusObjectPathMessageThunk(::DBusConnection* libdbusConnection, ::DBusMessage* libdbusMessage, void* userData) { - return ::DBusHandlerResult::DBUS_HANDLER_RESULT_HANDLED; + return ::DBusHandlerResult::DBUS_HANDLER_RESULT_HANDLED; } DBusObjectPathVTable libdbusObjectPathVTable = { - NULL, - &onLibdbusObjectPathMessageThunk + NULL, + &onLibdbusObjectPathMessageThunk }; - +} TEST_F(DBusLowLevelCommunicationTest, AgressiveNameClaimingOfServicesIsHandledCorrectly) { std::shared_ptr<CommonAPI::DBus::DBusConnection> connection1 = CommonAPI::DBus::DBusConnection::getSessionBus(); @@ -461,7 +467,7 @@ TEST_F(DBusLowLevelCommunicationTest, AgressiveNameClaimingOfServicesIsHandledCo status = stat; }); - sleep(1); + usleep(1000000); EXPECT_EQ(1, counter); EXPECT_EQ(CommonAPI::AvailabilityStatus::NOT_AVAILABLE, status); @@ -501,11 +507,11 @@ TEST_F(DBusLowLevelCommunicationTest, AgressiveNameClaimingOfServicesIsHandledCo dbus_connection_try_register_object_path(libdbusConnection1, "/", - &libdbusObjectPathVTable, + &DBusCommunicationTestNamespace::libdbusObjectPathVTable, NULL, NULL); - sleep(1); + usleep(1000000); EXPECT_EQ(DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER, libdbusStatus); EXPECT_EQ(2, counter); @@ -523,11 +529,11 @@ TEST_F(DBusLowLevelCommunicationTest, AgressiveNameClaimingOfServicesIsHandledCo dbus_connection_try_register_object_path(libdbusConnection2, "/", - &libdbusObjectPathVTable, + &DBusCommunicationTestNamespace::libdbusObjectPathVTable, NULL, NULL); - sleep(1); + usleep(1000000); EXPECT_EQ(DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER, libdbusStatus); @@ -540,8 +546,9 @@ TEST_F(DBusLowLevelCommunicationTest, AgressiveNameClaimingOfServicesIsHandledCo ASSERT_TRUE(hasEnded.get()); } - +#ifndef WIN32 int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } +#endif diff --git a/src/test/DBusConnectionTest.cpp b/src/test/DBusConnectionTest.cpp index c16f32c..ce1c893 100644 --- a/src/test/DBusConnectionTest.cpp +++ b/src/test/DBusConnectionTest.cpp @@ -362,8 +362,9 @@ TEST_F(DBusConnectionTest, DISABLED_TimeoutForNonexistingServices) { dispatchThread.join(); } +#ifndef WIN32 int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } - +#endif diff --git a/src/test/DBusDaemonProxyTest.cpp b/src/test/DBusDaemonProxyTest.cpp index 16338f5..8f47b6d 100644 --- a/src/test/DBusDaemonProxyTest.cpp +++ b/src/test/DBusDaemonProxyTest.cpp @@ -16,124 +16,125 @@ namespace { class DBusDaemonProxyTest: public ::testing::Test { - protected: - - virtual void SetUp() { - dbusConnection_ = CommonAPI::DBus::DBusConnection::getSessionBus(); - ASSERT_TRUE(dbusConnection_->connect()); - dbusDaemonProxy_ = std::make_shared<CommonAPI::DBus::DBusDaemonProxy>(dbusConnection_); - } - - virtual void TearDown() { - } - - std::shared_ptr<CommonAPI::DBus::DBusConnection> dbusConnection_; - std::shared_ptr<CommonAPI::DBus::DBusDaemonProxy> dbusDaemonProxy_; +protected: + virtual void SetUp() { + dbusConnection_ = CommonAPI::DBus::DBusConnection::getSessionBus(); + ASSERT_TRUE(dbusConnection_->connect()); + dbusDaemonProxy_ = std::make_shared<CommonAPI::DBus::DBusDaemonProxy>(dbusConnection_); + } + + virtual void TearDown() { + } + + std::shared_ptr<CommonAPI::DBus::DBusConnection> dbusConnection_; + std::shared_ptr<CommonAPI::DBus::DBusDaemonProxy> dbusDaemonProxy_; }; TEST_F(DBusDaemonProxyTest, ListNames) { - std::vector<std::string> busNames; - CommonAPI::CallStatus callStatus; + std::vector<std::string> busNames; + CommonAPI::CallStatus callStatus; - dbusDaemonProxy_->listNames(callStatus, busNames); - ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + dbusDaemonProxy_->listNames(callStatus, busNames); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); - ASSERT_GT(busNames.size(), 0); - for (const std::string& busName : busNames) { - ASSERT_FALSE(busName.empty()); - ASSERT_GT(busName.length(), 1); - } + ASSERT_GT(busNames.size(), 0); + for (const std::string& busName : busNames) { + ASSERT_FALSE(busName.empty()); + ASSERT_GT(busName.length(), 1); + } } TEST_F(DBusDaemonProxyTest, ListNamesAsync) { - std::promise<std::tuple<CommonAPI::CallStatus, std::vector<std::string>>> promise; - auto future = promise.get_future(); + std::promise<std::tuple<CommonAPI::CallStatus, std::vector<std::string>>>promise; + auto future = promise.get_future(); - auto callStatusFuture = dbusDaemonProxy_->listNamesAsync( - [&](const CommonAPI::CallStatus& callStatus, std::vector<std::string> busNames) { - promise.set_value(std::tuple<CommonAPI::CallStatus, std::vector<std::string>>(callStatus, std::move(busNames))); - }); + auto callStatusFuture = dbusDaemonProxy_->listNamesAsync( + [&](const CommonAPI::CallStatus& callStatus, std::vector<std::string> busNames) { + promise.set_value(std::tuple<CommonAPI::CallStatus, std::vector<std::string>>(callStatus, std::move(busNames))); + }); - auto status = future.wait_for(std::chrono::milliseconds(500)); - bool waitResult = CommonAPI::DBus::checkReady(status); + auto status = future.wait_for(std::chrono::milliseconds(500)); + bool waitResult = CommonAPI::DBus::checkReady(status); ASSERT_EQ(waitResult, true); - ASSERT_EQ(callStatusFuture.get(), CommonAPI::CallStatus::SUCCESS); + ASSERT_EQ(callStatusFuture.get(), CommonAPI::CallStatus::SUCCESS); - auto futureResult = future.get(); - const CommonAPI::CallStatus& callStatus = std::get<0>(futureResult); - const std::vector<std::string>& busNames = std::get<1>(futureResult); + auto futureResult = future.get(); + const CommonAPI::CallStatus& callStatus = std::get<0>(futureResult); + const std::vector<std::string>& busNames = std::get<1>(futureResult); - ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); - ASSERT_GT(busNames.size(), 0); - for (const std::string& busName : busNames) { - ASSERT_FALSE(busName.empty()); - ASSERT_GT(busName.length(), 1); - } + ASSERT_GT(busNames.size(), 0); + for (const std::string& busName : busNames) { + ASSERT_FALSE(busName.empty()); + ASSERT_GT(busName.length(), 1); + } } TEST_F(DBusDaemonProxyTest, NameHasOwner) { - bool nameHasOwner; - CommonAPI::CallStatus callStatus; + bool nameHasOwner; + CommonAPI::CallStatus callStatus; - dbusDaemonProxy_->nameHasOwner("org.freedesktop.DBus", callStatus, nameHasOwner); - ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); - ASSERT_TRUE(nameHasOwner); + dbusDaemonProxy_->nameHasOwner("org.freedesktop.DBus", callStatus, nameHasOwner); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + ASSERT_TRUE(nameHasOwner); - dbusDaemonProxy_->nameHasOwner("org.freedesktop.DBus.InvalidName.XXYYZZ", callStatus, nameHasOwner); - ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); - ASSERT_FALSE(nameHasOwner); + dbusDaemonProxy_->nameHasOwner("org.freedesktop.DBus.InvalidName.XXYYZZ", callStatus, nameHasOwner); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + ASSERT_FALSE(nameHasOwner); } TEST_F(DBusDaemonProxyTest, NameHasOwnerAsync) { - std::promise<std::tuple<CommonAPI::CallStatus, bool>> promise; - auto future = promise.get_future(); + std::promise<std::tuple<CommonAPI::CallStatus, bool>> promise; + auto future = promise.get_future(); - auto callStatusFuture = dbusDaemonProxy_->nameHasOwnerAsync( - "org.freedesktop.DBus", - [&](const CommonAPI::CallStatus& callStatus, bool nameHasOwner) { - promise.set_value(std::tuple<CommonAPI::CallStatus, bool>(callStatus, std::move(nameHasOwner))); - }); + auto callStatusFuture = dbusDaemonProxy_->nameHasOwnerAsync( + "org.freedesktop.DBus", + [&](const CommonAPI::CallStatus& callStatus, bool nameHasOwner) { + promise.set_value(std::tuple<CommonAPI::CallStatus, bool>(callStatus, std::move(nameHasOwner))); + }); - auto status = future.wait_for(std::chrono::milliseconds(100)); - const bool waitResult = CommonAPI::DBus::checkReady(status); + auto status = future.wait_for(std::chrono::milliseconds(100)); + const bool waitResult = CommonAPI::DBus::checkReady(status); ASSERT_EQ(waitResult, true); - ASSERT_EQ(callStatusFuture.get(), CommonAPI::CallStatus::SUCCESS); + ASSERT_EQ(callStatusFuture.get(), CommonAPI::CallStatus::SUCCESS); - auto futureResult = future.get(); - const CommonAPI::CallStatus& callStatus = std::get<0>(futureResult); - const bool& nameHasOwner = std::get<1>(futureResult); + auto futureResult = future.get(); + const CommonAPI::CallStatus& callStatus = std::get<0>(futureResult); + const bool& nameHasOwner = std::get<1>(futureResult); - ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); - ASSERT_TRUE(nameHasOwner); + ASSERT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + ASSERT_TRUE(nameHasOwner); } TEST_F(DBusDaemonProxyTest, NameOwnerChangedEvent) { - std::promise<bool> promise; - auto future = promise.get_future(); + std::promise<bool> promise; + auto future = promise.get_future(); - auto subscription = dbusDaemonProxy_->getNameOwnerChangedEvent().subscribe( - [&](const std::string& name, const std::string& oldOwner, const std::string& newOwner) { - static bool promiseIsSet = false; - if(!promiseIsSet) { - promiseIsSet = true; - promise.set_value(!name.empty() && (!oldOwner.empty() || !newOwner.empty())); - } - }); + auto subscription = dbusDaemonProxy_->getNameOwnerChangedEvent().subscribe( + [&](const std::string& name, const std::string& oldOwner, const std::string& newOwner) { + static bool promiseIsSet = false; + if(!promiseIsSet) { + promiseIsSet = true; + promise.set_value(!name.empty() && (!oldOwner.empty() || !newOwner.empty())); + } + }); - // Trigger NameOwnerChanged using a new DBusConnection - ASSERT_TRUE(CommonAPI::DBus::DBusConnection::getSessionBus()->connect()); + // Trigger NameOwnerChanged using a new DBusConnection + ASSERT_TRUE(CommonAPI::DBus::DBusConnection::getSessionBus()->connect()); - ASSERT_TRUE(future.get()); + ASSERT_TRUE(future.get()); - dbusDaemonProxy_->getNameOwnerChangedEvent().unsubscribe(subscription); + dbusDaemonProxy_->getNameOwnerChangedEvent().unsubscribe(subscription); } } // namespace +#ifndef WIN32 int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } +#endif diff --git a/src/test/DBusFactoryTest.cpp b/src/test/DBusFactoryTest.cpp index fc68d1f..0b7a313 100644 --- a/src/test/DBusFactoryTest.cpp +++ b/src/test/DBusFactoryTest.cpp @@ -164,8 +164,9 @@ TEST_F(DBusProxyFactoryTest, CreateNamedFactory) { ASSERT_TRUE(nullFactory == NULL); } - +#ifndef WIN32 int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } +#endif
\ No newline at end of file diff --git a/src/test/DBusInputStreamTest.cpp b/src/test/DBusInputStreamTest.cpp index 71409ca..dcfdc64 100644 --- a/src/test/DBusInputStreamTest.cpp +++ b/src/test/DBusInputStreamTest.cpp @@ -12,7 +12,6 @@ #include "DBusTestUtils.h" #include <unordered_map> -#include <bits/functional_hash.h> #include <gtest/gtest.h> @@ -21,8 +20,7 @@ #include <chrono> #include <cstdint> #include <vector> -#include <unordered_map> -#include <bits/functional_hash.h> + class InputStreamTest: public ::testing::Test { @@ -220,10 +218,10 @@ TEST_F(InputStreamTest, ReadsDoubles) { } TEST_F(InputStreamTest, ReadsStrings) { - std::string val = "hai"; for (unsigned int i = 0; i < numOfElements; i += 1) { - dbus_message_iter_append_basic(&libdbusMessageWriteIter, DBUS_TYPE_STRING, &val); + const char* valPtr = val.c_str(); + dbus_message_iter_append_basic(&libdbusMessageWriteIter, DBUS_TYPE_STRING, &valPtr); } CommonAPI::DBus::DBusMessage scopedMessage(libdbusMessage); @@ -237,8 +235,6 @@ TEST_F(InputStreamTest, ReadsStrings) { } } - - namespace bmw { namespace test { @@ -291,7 +287,8 @@ TEST_F(InputStreamTest, ReadsStructs) { dbus_message_iter_append_basic(&subIter, DBUS_TYPE_INT16, &testStruct.b); dbus_bool_t dbusBool = static_cast<dbus_bool_t>(testStruct.c); dbus_message_iter_append_basic(&subIter, DBUS_TYPE_BOOLEAN, &dbusBool); - dbus_message_iter_append_basic(&subIter, DBUS_TYPE_STRING, &testStruct.d); + const char* dPtr = testStruct.d.c_str(); + dbus_message_iter_append_basic(&subIter, DBUS_TYPE_STRING, &dPtr); dbus_message_iter_append_basic(&subIter, DBUS_TYPE_DOUBLE, &testStruct.e); dbus_message_iter_close_container(&libdbusMessageWriteIter, &subIter); @@ -445,7 +442,8 @@ TEST_F(InputStreamTest, ReadsStringVariants) { dbus_message_iter_append_basic(&subIter, DBUS_TYPE_BYTE, &variantTypeIndex); DBusMessageIter subSubIter; dbus_message_iter_open_container(&subIter, DBUS_TYPE_VARIANT, "s", &subSubIter); - dbus_message_iter_append_basic(&subSubIter, DBUS_TYPE_STRING, &fromString); + const char* fromStringPtr = fromString.c_str(); + dbus_message_iter_append_basic(&subSubIter, DBUS_TYPE_STRING, &fromStringPtr); dbus_message_iter_close_container(&subIter, &subSubIter); dbus_message_iter_close_container(&libdbusMessageWriteIter, &subIter); } @@ -495,7 +493,8 @@ TEST_F(InputStreamTest, ReadsVariantsWithAnArrayOfStrings) { DBusMessageIter innerArrayIter; dbus_message_iter_open_container(&subSubIter, DBUS_TYPE_ARRAY, "s", &innerArrayIter); for (unsigned int i = 0; i < numOfElements; i++) { - dbus_message_iter_append_basic(&innerArrayIter, DBUS_TYPE_STRING, &testInnerVector[i]); + const char* testPtr = testInnerVector[i].c_str(); + dbus_message_iter_append_basic(&innerArrayIter, DBUS_TYPE_STRING, &testPtr); } dbus_message_iter_close_container(&subSubIter, &innerArrayIter); @@ -661,7 +660,6 @@ TEST_F(InputStreamTest, ReadsVariantsWithStructs) { DBusMessageIter variantActualIter; DBusMessageIter innerStructIter; - //begin variant dbus_message_iter_open_container(&libdbusMessageWriteIter, DBUS_TYPE_STRUCT, NULL, &variantStructIter); dbus_message_iter_append_basic(&variantStructIter, DBUS_TYPE_BYTE, &variantTypeIndex); @@ -674,7 +672,8 @@ TEST_F(InputStreamTest, ReadsVariantsWithStructs) { dbus_message_iter_append_basic(&innerStructIter, DBUS_TYPE_UINT32, &testStruct.a); dbus_message_iter_append_basic(&innerStructIter, DBUS_TYPE_INT16, &testStruct.b); dbus_message_iter_append_basic(&innerStructIter, DBUS_TYPE_BOOLEAN, &dbusBool); - dbus_message_iter_append_basic(&innerStructIter, DBUS_TYPE_STRING, &testStruct.d); + const char* dPtr = testStruct.d.c_str(); + dbus_message_iter_append_basic(&innerStructIter, DBUS_TYPE_STRING, &dPtr); dbus_message_iter_append_basic(&innerStructIter, DBUS_TYPE_DOUBLE, &testStruct.e); dbus_message_iter_close_container(&variantActualIter, &innerStructIter); @@ -738,7 +737,8 @@ TEST_F(InputStreamTest, ReadsVariantsWithAnArrayOfStructs) { dbus_message_iter_append_basic(&innerStructIter, DBUS_TYPE_UINT32, &testStruct.a); dbus_message_iter_append_basic(&innerStructIter, DBUS_TYPE_INT16, &testStruct.b); dbus_message_iter_append_basic(&innerStructIter, DBUS_TYPE_BOOLEAN, &dbusBool); - dbus_message_iter_append_basic(&innerStructIter, DBUS_TYPE_STRING, &testStruct.d); + const char* dPtr = testStruct.d.c_str(); + dbus_message_iter_append_basic(&innerStructIter, DBUS_TYPE_STRING, &dPtr); dbus_message_iter_append_basic(&innerStructIter, DBUS_TYPE_DOUBLE, &testStruct.e); dbus_message_iter_close_container(&innerArrayIter, &innerStructIter); @@ -778,8 +778,9 @@ TEST_F(InputStreamTest, ReadsVariantsWithAnArrayOfStructs) { EXPECT_EQ(referenceVariant, readVariant); } - +#ifndef WIN32 int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } +#endif diff --git a/src/test/DBusLoadTest.cpp b/src/test/DBusLoadTest.cpp index 8dc3707..c75590c 100644 --- a/src/test/DBusLoadTest.cpp +++ b/src/test/DBusLoadTest.cpp @@ -68,7 +68,7 @@ protected: } virtual void TearDown() { - sleep(3); + usleep(1000000); } public: @@ -102,7 +102,13 @@ public: const std::string DBusLoadTest::serviceAddress_ = "local:CommonAPI.DBus.tests.DBusProxyTestInterface:CommonAPI.DBus.tests.DBusProxyTestService"; const uint32_t DBusLoadTest::numCallsPerProxy_ = 100; + +#ifdef WIN32 +// test with just 50 proxies under windows as it becomes very slow with more ones +const uint32_t DBusLoadTest::numProxies_ = 50; +#else const uint32_t DBusLoadTest::numProxies_ = 100; +#endif // Multiple proxies in one thread, one stub TEST_F(DBusLoadTest, SingleClientMultipleProxiesSingleStubCallsSucceed) { @@ -261,7 +267,7 @@ TEST_F(DBusLoadTest, MultipleClientsMultipleServersCallsSucceed) { allProxiesAvailable = allProxiesAvailable && testProxies[j]->isAvailable(); } if (!allProxiesAvailable) - sleep(1); + usleep(1000000); } ASSERT_TRUE(allProxiesAvailable); @@ -298,7 +304,9 @@ TEST_F(DBusLoadTest, MultipleClientsMultipleServersCallsSucceed) { } } +#ifndef WIN32 int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } +#endif diff --git a/src/test/DBusMainLoopIntegrationTest.cpp b/src/test/DBusMainLoopIntegrationTest.cpp index 71295ae..f3bc0ae 100644 --- a/src/test/DBusMainLoopIntegrationTest.cpp +++ b/src/test/DBusMainLoopIntegrationTest.cpp @@ -17,8 +17,9 @@ #include <utility> #include <tuple> #include <type_traits> +#ifndef WIN32 #include <glib.h> - +#endif #include <CommonAPI/CommonAPI.h> #define COMMONAPI_INTERNAL_COMPILATION @@ -312,7 +313,7 @@ TEST_F(DBusMainLoopTest, DemoMainloopClientsHandleNonavailableServices) { } //################################################################################################## - +#ifndef WIN32 class GDispatchWrapper: public GSource { public: GDispatchWrapper(CommonAPI::DispatchSource* dispatchSource): dispatchSource_(dispatchSource) {} @@ -574,9 +575,11 @@ TEST_F(DBusInGLibMainLoopTest, ProxyAndServiceInSameGlibMainloopCanCommunicate) servicePublisher_->unregisterService(testAddress7); } +#endif - +#ifndef WIN32 int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } +#endif
\ No newline at end of file diff --git a/src/test/DBusManagedTest.cpp b/src/test/DBusManagedTest.cpp index 4e9e45f..0b01016 100644 --- a/src/test/DBusManagedTest.cpp +++ b/src/test/DBusManagedTest.cpp @@ -226,7 +226,7 @@ TEST_F(DBusManagedTest, RegisterLeafManagedAndCreateProxyForLeaf) { success = rootStub->registerManagedStubLeafInterface(leafStub, leafInstance); ASSERT_TRUE(success); - sleep(2); + usleep(2000000); auto leafProxy = proxyManagerLeafInterface.buildProxy<commonapi::tests::managed::LeafInterfaceProxy>(leafInstance); for (uint32_t i = 0; !leafProxy->isAvailable() && i < 500; ++i) { @@ -290,7 +290,7 @@ TEST_F(DBusManagedTest, PropagateTeardown) { bool reg = rootStub->registerManagedStubLeafInterface(leafStub, leafInstance); ASSERT_TRUE(reg); - sleep(2); + usleep(2000000); auto leafProxy = proxyManagerLeafInterface.buildProxy<commonapi::tests::managed::LeafInterfaceProxy>(leafInstance); @@ -377,12 +377,11 @@ protected: bool waitForAllProxiesToBeAvailable(const std::vector<_ProxyType>& dbusProxies) { bool allAreAvailable = false; for (size_t i = 0; i < 500 && !allAreAvailable; i++) { - allAreAvailable = std::all_of( - dbusProxies.begin(), - dbusProxies.end(), - [](const _ProxyType& proxy) { - return proxy->isAvailable(); - }); + allAreAvailable = std::all_of(dbusProxies.begin(), + dbusProxies.end(), + [](const _ProxyType& proxy) { + return proxy->isAvailable(); + }); usleep(10 * 1000); } return allAreAvailable; @@ -413,15 +412,15 @@ protected: } void createXLeafProxiesForAllExistingLeafs() { - for (auto rootProxyIterator: rootProxies_) { - std::vector<std::shared_ptr<commonapi::tests::managed::LeafInterfaceProxy<>>> leafProxiesForRootX; + for (auto rootProxyIterator : rootProxies_) { + std::vector<std::shared_ptr<commonapi::tests::managed::LeafInterfaceProxyDefault>> leafProxiesForRootX; CommonAPI::ProxyManager& leafProxyManager = rootProxyIterator->getProxyManagerLeafInterface(); std::vector<std::string> availableInstances; CommonAPI::CallStatus status; leafProxyManager.getAvailableInstances(status, availableInstances); - for (const std::string& availableInstance: availableInstances) { + for (const std::string& availableInstance : availableInstances) { auto newLeafProxy = leafProxyManager.buildProxy<commonapi::tests::managed::LeafInterfaceProxy>(availableInstance); leafProxiesForRootX.push_back(newLeafProxy); } @@ -429,7 +428,6 @@ protected: } } - std::shared_ptr<CommonAPI::DBus::DBusRuntime> runtime_; std::shared_ptr<CommonAPI::Factory> serviceFactory_; std::shared_ptr<CommonAPI::Factory> clientFactory_; @@ -437,12 +435,11 @@ protected: std::shared_ptr<CommonAPI::DBus::DBusConnection> manualTestDBusConnection_; std::unordered_map<std::string, std::shared_ptr<commonapi::tests::managed::RootInterfaceStubDefault>> rootStubs_; - std::vector<std::shared_ptr<commonapi::tests::managed::RootInterfaceProxy<>>> rootProxies_; - std::vector<std::vector<std::shared_ptr<commonapi::tests::managed::LeafInterfaceProxy<>>>> leafProxies_; + std::vector<std::shared_ptr<commonapi::tests::managed::RootInterfaceProxyDefault>> rootProxies_; + std::vector<std::vector<std::shared_ptr<commonapi::tests::managed::LeafInterfaceProxyDefault>>>leafProxies_; CommonAPI::AvailabilityStatus leafInstanceAvailability; CommonAPI::AvailabilityStatus branchInstanceAvailability; - public: void onLeafInstanceAvailabilityStatusChanged(const std::string instanceName, CommonAPI::AvailabilityStatus availabilityStatus) { leafInstanceAvailability = availabilityStatus; @@ -451,10 +448,8 @@ public: void onBranchInstanceAvailabilityStatusChanged(const std::string instanceName, CommonAPI::AvailabilityStatus availabilityStatus) { branchInstanceAvailability = availabilityStatus; } - }; - TEST_F(DBusManagedTestExtended, RegisterSeveralRootsOnSameObjectPath) { ASSERT_TRUE(registerRootStubForSuffix("One")); ASSERT_TRUE(registerRootStubForSuffix("Two")); @@ -485,13 +480,12 @@ TEST_F(DBusManagedTestExtended, RegisterSeveralRootsOnSameObjectPathAndCommunica std::string outString; for (size_t i = 0; i < rootProxies_.size(); ++i) { - rootProxies_[i]->testRootMethod( - -5, - std::string("More Cars"), - callStatus, - applicationError, - outInt, - outString); + rootProxies_[i]->testRootMethod(-5, + std::string("More Cars"), + callStatus, + applicationError, + outInt, + outString); EXPECT_EQ(CommonAPI::CallStatus::SUCCESS, callStatus); } } @@ -537,8 +531,8 @@ TEST_F(DBusManagedTestExtended, RegisterSeveralRootsAndSeveralLeafsForEachOnSame ASSERT_EQ(3, leafProxies_.size()); uint32_t runNr = 1; - for (const auto& leafProxiesForCurrentRoot: leafProxies_) { - ASSERT_EQ(5, leafProxiesForCurrentRoot.size()) << "in run #" << runNr++; + for (const auto& leafProxiesForCurrentRoot : leafProxies_) { + ASSERT_EQ(5, leafProxiesForCurrentRoot.size())<< "in run #" << runNr++; bool allLeafProxiesForCurrentRootAreAvailable = waitForAllProxiesToBeAvailable(leafProxiesForCurrentRoot); EXPECT_TRUE(allLeafProxiesForCurrentRootAreAvailable); @@ -591,9 +585,8 @@ TEST_F(DBusManagedTestExtended, RegisterTwoRootsForSameLeafInterface) { std::shared_ptr<commonapi::tests::managed::SecondRootStubDefault> secondRootStub = std::make_shared< commonapi::tests::managed::SecondRootStubDefault>(); - const std::string rootAddress = getSuffixedRootAddress("Two"); - runtime_->getServicePublisher()->registerService(secondRootStub, rootAddress, serviceFactory_); - + const std::string rootAddressLocal = getSuffixedRootAddress("Two"); + runtime_->getServicePublisher()->registerService(secondRootStub, rootAddressLocal, serviceFactory_); auto leafStub1 = std::make_shared<commonapi::tests::managed::LeafInterfaceStubDefault>(); auto leafStub2 = std::make_shared<commonapi::tests::managed::LeafInterfaceStubDefault>(); @@ -604,7 +597,7 @@ TEST_F(DBusManagedTestExtended, RegisterTwoRootsForSameLeafInterface) { bool leafStub2Registered = secondRootStub->registerManagedStubLeafInterface(leafStub2, secondLeafInstance); ASSERT_TRUE(leafStub2Registered); - runtime_->getServicePublisher()->unregisterService(rootAddress); + runtime_->getServicePublisher()->unregisterService(rootAddressLocal); } TEST_F(DBusManagedTestExtended, RegisterLeafsWithDistinctInterfacesOnSameRootManaged) { @@ -612,11 +605,21 @@ TEST_F(DBusManagedTestExtended, RegisterLeafsWithDistinctInterfacesOnSameRootMan createRootProxyForSuffix("One"); auto rootProxy = *(rootProxies_.begin()); - CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& leafInstanceAvailabilityStatusEvent = rootProxy->getProxyManagerLeafInterface().getInstanceAvailabilityStatusChangedEvent(); - CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& branchInstanceAvailabilityStatusEvent = rootProxy->getProxyManagerBranchInterface().getInstanceAvailabilityStatusChangedEvent(); - - leafInstanceAvailabilityStatusEvent.subscribe(std::bind(&DBusManagedTestExtended::onLeafInstanceAvailabilityStatusChanged, this, std::placeholders::_1, std::placeholders::_2)); - branchInstanceAvailabilityStatusEvent.subscribe(std::bind(&DBusManagedTestExtended::onBranchInstanceAvailabilityStatusChanged, this, std::placeholders::_1, std::placeholders::_2)); + CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& leafInstanceAvailabilityStatusEvent = + rootProxy->getProxyManagerLeafInterface().getInstanceAvailabilityStatusChangedEvent(); + CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& branchInstanceAvailabilityStatusEvent = + rootProxy->getProxyManagerBranchInterface().getInstanceAvailabilityStatusChangedEvent(); + + leafInstanceAvailabilityStatusEvent.subscribe( + std::bind(&DBusManagedTestExtended::onLeafInstanceAvailabilityStatusChanged, + this, + std::placeholders::_1, + std::placeholders::_2)); + branchInstanceAvailabilityStatusEvent.subscribe( + std::bind(&DBusManagedTestExtended::onBranchInstanceAvailabilityStatusChanged, + this, + std::placeholders::_1, + std::placeholders::_2)); auto leafStub1 = std::make_shared<commonapi::tests::managed::LeafInterfaceStubDefault>(); auto leafStub2 = std::make_shared<commonapi::tests::managed::BranchInterfaceStubDefault>(); @@ -630,8 +633,9 @@ TEST_F(DBusManagedTestExtended, RegisterLeafsWithDistinctInterfacesOnSameRootMan // check that event for branch instances is not triggered by leaf instances ASSERT_NE(CommonAPI::AvailabilityStatus::AVAILABLE, branchInstanceAvailability); - - bool leafStub2Registered = rootStubs_.begin()->second->registerManagedStubBranchInterface(leafStub2, branchInstance); + bool leafStub2Registered = rootStubs_.begin()->second->registerManagedStubBranchInterface( + leafStub2, + branchInstance); ASSERT_TRUE(leafStub2Registered); usleep(50000); @@ -643,11 +647,21 @@ TEST_F(DBusManagedTestExtended, RegisterLeafsWithDistinctInterfacesOnSameRootUnm createRootProxyForSuffix("One"); auto rootProxy = *(rootProxies_.begin()); - CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& leafInstanceAvailabilityStatusEvent = rootProxy->getProxyManagerLeafInterface().getInstanceAvailabilityStatusChangedEvent(); - CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& branchInstanceAvailabilityStatusEvent = rootProxy->getProxyManagerBranchInterface().getInstanceAvailabilityStatusChangedEvent(); - - leafInstanceAvailabilityStatusEvent.subscribe(std::bind(&DBusManagedTestExtended::onLeafInstanceAvailabilityStatusChanged, this, std::placeholders::_1, std::placeholders::_2)); - branchInstanceAvailabilityStatusEvent.subscribe(std::bind(&DBusManagedTestExtended::onBranchInstanceAvailabilityStatusChanged, this, std::placeholders::_1, std::placeholders::_2)); + CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& leafInstanceAvailabilityStatusEvent = + rootProxy->getProxyManagerLeafInterface().getInstanceAvailabilityStatusChangedEvent(); + CommonAPI::ProxyManager::InstanceAvailabilityStatusChangedEvent& branchInstanceAvailabilityStatusEvent = + rootProxy->getProxyManagerBranchInterface().getInstanceAvailabilityStatusChangedEvent(); + + leafInstanceAvailabilityStatusEvent.subscribe( + std::bind(&DBusManagedTestExtended::onLeafInstanceAvailabilityStatusChanged, + this, + std::placeholders::_1, + std::placeholders::_2)); + branchInstanceAvailabilityStatusEvent.subscribe( + std::bind(&DBusManagedTestExtended::onBranchInstanceAvailabilityStatusChanged, + this, + std::placeholders::_1, + std::placeholders::_2)); auto leafStub1 = std::make_shared<commonapi::tests::managed::LeafInterfaceStubDefault>(); runtime_->getServicePublisher()->registerService(leafStub1, leafAddress, serviceFactory_); @@ -660,14 +674,18 @@ TEST_F(DBusManagedTestExtended, RegisterLeafsWithDistinctInterfacesOnSameRootUnm // check, that events do not get triggered by unmanaged registration ASSERT_EQ(CommonAPI::AvailabilityStatus::UNKNOWN, leafInstanceAvailability); ASSERT_EQ(CommonAPI::AvailabilityStatus::UNKNOWN, branchInstanceAvailability); + + runtime_->getServicePublisher()->unregisterService(leafAddress); + runtime_->getServicePublisher()->unregisterService(branchAddress); } //XXX: Needs tests for invalid instances for the children. //XXX: Also later on need auto generated instance ID test and //XXX: If stub cannot manage, ensure the objectManager interface does not appear on dbus //XXX: Tests if configuration file is present - +#ifndef WIN32 int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } +#endif diff --git a/src/test/DBusMultipleConnectionTest.cpp b/src/test/DBusMultipleConnectionTest.cpp index c061d2f..d14d17b 100644 --- a/src/test/DBusMultipleConnectionTest.cpp +++ b/src/test/DBusMultipleConnectionTest.cpp @@ -55,15 +55,14 @@ class DBusMultipleConnectionTest: public ::testing::Test { virtual void TearDown() { servicePublisher->unregisterService(serviceAddress); - usleep(30000); + usleep(30000); } std::shared_ptr<CommonAPI::Factory> proxyFactory; std::shared_ptr<CommonAPI::Factory> stubFactory; std::shared_ptr<CommonAPI::ServicePublisher> servicePublisher; std::shared_ptr<commonapi::tests::TestInterfaceStubDefault> stub; - std::shared_ptr<commonapi::tests::TestInterfaceProxy<> > proxy; - + std::shared_ptr<commonapi::tests::TestInterfaceProxyDefault> proxy; }; @@ -139,9 +138,9 @@ TEST_F(DBusMultipleConnectionTest, GetAttribute) { ASSERT_EQ(CommonAPI::CallStatus::SUCCESS, status); } - +#ifndef WIN32 int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } - +#endif diff --git a/src/test/DBusObjectManagerStubTest.cpp b/src/test/DBusObjectManagerStubTest.cpp index 28b44c7..1c94a9b 100644 --- a/src/test/DBusObjectManagerStubTest.cpp +++ b/src/test/DBusObjectManagerStubTest.cpp @@ -184,6 +184,8 @@ protected: } virtual void TearDown() { + stubDBusConnection_->releaseServiceName(dbusServiceName); + stubDBusConnection_->disconnect(); stubDBusConnection_.reset(); @@ -492,7 +494,9 @@ TEST_F(DBusObjectManagerStubTest, DestructorUnpublishingWorks) { ASSERT_TRUE(wasServiceDeregistrationSuccessful); } +#ifndef WIN32 int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } +#endif diff --git a/src/test/DBusOutputStreamTest.cpp b/src/test/DBusOutputStreamTest.cpp index 72cc6e9..1549101 100644 --- a/src/test/DBusOutputStreamTest.cpp +++ b/src/test/DBusOutputStreamTest.cpp @@ -798,7 +798,9 @@ TEST_F(OutputStreamTest, WritesEnumKeyedMaps) { } } +#ifndef WIN32 int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } +#endif
\ No newline at end of file diff --git a/src/test/DBusPolymorphicTest.cpp b/src/test/DBusPolymorphicTest.cpp index 79a1bb6..0c0dd98 100644 --- a/src/test/DBusPolymorphicTest.cpp +++ b/src/test/DBusPolymorphicTest.cpp @@ -250,8 +250,9 @@ TEST_F(PolymorphicTest, SendStructWithMapWithEnumKeyMember) { ASSERT_EQ(stat, CommonAPI::CallStatus::SUCCESS); } - +#ifndef WIN32 int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } +#endif
\ No newline at end of file diff --git a/src/test/DBusProxyTest.cpp b/src/test/DBusProxyTest.cpp index e767913..5668abb 100644 --- a/src/test/DBusProxyTest.cpp +++ b/src/test/DBusProxyTest.cpp @@ -199,6 +199,11 @@ TEST_F(ProxyTest, DBusProxyStatusEventBeforeServiceIsRegistered) { proxyDeregisterForAvailabilityStatus(); } +/* +This test fails in Windows. Calling disconnect and then connect again somehow +damages the connection in libdbus. In Linux this all works fine. +*/ +#ifndef WIN32 TEST_F(ProxyTest, DBusProxyStatusEventAfterServiceIsRegistered) { proxyDBusConnection_->disconnect(); @@ -217,6 +222,7 @@ TEST_F(ProxyTest, DBusProxyStatusEventAfterServiceIsRegistered) { proxyDeregisterForAvailabilityStatus(); } +#endif TEST_F(ProxyTest, ServiceStatus) { registerTestStub(); @@ -348,6 +354,70 @@ TEST_F(ProxyTest, CallMethodFromParentInterface) { deregisterExtendedStub(); } +TEST_F(ProxyTest, CanHandleRemoteAttribute) { + registerTestStub(); + + for (uint32_t i = 0; !proxy_->isAvailable() && i < 200; ++i) { + usleep(20 * 1000); + } + ASSERT_TRUE(proxy_->isAvailable()); + + CommonAPI::CallStatus callStatus(CommonAPI::CallStatus::REMOTE_ERROR); + uint32_t value; + + auto& testAttribute = proxy_->getTestPredefinedTypeAttributeAttribute(); + + testAttribute.getValue(callStatus, value); + + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + + value = 7; + uint32_t responseValue; + testAttribute.setValue(value, callStatus, responseValue); + + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(value, responseValue); + + usleep(50000); + deregisterTestStub(); +} + + +TEST_F(ProxyTest, CanHandleRemoteAttributeFromParentInterface) { + registerExtendedStub(); + + std::shared_ptr<CommonAPI::DBus::DBusFactory> proxyFactory_ = std::dynamic_pointer_cast<CommonAPI::DBus::DBusFactory>(runtime_->createFactory()); + + auto extendedProxy = proxyFactory_->buildProxy<commonapi::tests::ExtendedInterfaceProxy>(commonApiAddressExtended); + + + for (uint32_t i = 0; !extendedProxy->isAvailable() && i < 200; ++i) { + usleep(20 * 1000); + } + ASSERT_TRUE(extendedProxy->isAvailable()); + + CommonAPI::CallStatus callStatus(CommonAPI::CallStatus::REMOTE_ERROR); + uint32_t value; + + //usleep(200000000); + + auto& testAttribute = extendedProxy->getTestPredefinedTypeAttributeAttribute(); + + testAttribute.getValue(callStatus, value); + + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + + value = 7; + uint32_t responseValue; + testAttribute.setValue(value, callStatus, responseValue); + + EXPECT_EQ(callStatus, CommonAPI::CallStatus::SUCCESS); + EXPECT_EQ(value, responseValue); + + usleep(50000); + deregisterExtendedStub(); +} + TEST_F(ProxyTest, ProxyCanFetchVersionAttributeFromInheritedInterfaceStub) { registerExtendedStub(); @@ -379,7 +449,102 @@ TEST_F(ProxyTest, ProxyCanFetchVersionAttributeFromInheritedInterfaceStub) { deregisterExtendedStub(); } +// this test does not build its proxies within SetUp +class ProxyTest2: public ::testing::Test { +protected: + virtual void SetUp() { + runtime_ = std::dynamic_pointer_cast<CommonAPI::DBus::DBusRuntime>(CommonAPI::Runtime::load()); + serviceFactory_ = std::dynamic_pointer_cast<CommonAPI::DBus::DBusFactory>(runtime_->createFactory()); + } + + virtual void TearDown() { + std::this_thread::sleep_for(std::chrono::milliseconds(300)); + } + + void registerTestStub() { + stubDefault_ = std::make_shared<commonapi::tests::TestInterfaceStubDefault>(); + bool isTestStubAdapterRegistered_ = runtime_->getServicePublisher()->registerService< + commonapi::tests::TestInterfaceStub>(stubDefault_, commonApiAddress, serviceFactory_); + ASSERT_TRUE(isTestStubAdapterRegistered_); + + usleep(100000); + } + + void deregisterTestStub() { + const bool isStubAdapterUnregistered = CommonAPI::DBus::DBusServicePublisher::getInstance()->unregisterService( + commonApiAddress); + ASSERT_TRUE(isStubAdapterUnregistered); + stubDefault_.reset(); + isTestStubAdapterRegistered_ = false; + } + + void proxyRegisterForAvailabilityStatus() { + proxyAvailabilityStatus_ = CommonAPI::AvailabilityStatus::UNKNOWN; + + proxyStatusSubscription_ = proxy_->getProxyStatusEvent().subscribe( + [&](const CommonAPI::AvailabilityStatus& availabilityStatus) { + proxyAvailabilityStatus_ = availabilityStatus; + }); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + + void proxyDeregisterForAvailabilityStatus() { + proxy_->getProxyStatusEvent().unsubscribe(proxyStatusSubscription_); + } + + bool proxyWaitForAvailabilityStatus(const CommonAPI::AvailabilityStatus& availabilityStatus) const { + for (int i = 0; i < 100; i++) { + if (proxyAvailabilityStatus_ == availabilityStatus) + return true; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + + return false; + } + + bool isTestStubAdapterRegistered_; + std::shared_ptr<CommonAPI::DBus::DBusRuntime> runtime_; + std::shared_ptr<CommonAPI::DBus::DBusFactory> serviceFactory_; + + std::shared_ptr<CommonAPI::DBus::DBusConnection> proxyDBusConnection_; + std::shared_ptr<commonapi::tests::TestInterfaceDBusProxy> proxy_; + CommonAPI::AvailabilityStatus proxyAvailabilityStatus_; + + CommonAPI::ProxyStatusEvent::Subscription proxyStatusSubscription_; + + std::shared_ptr<commonapi::tests::TestInterfaceStubDefault> stubDefault_; +}; + +TEST_F(ProxyTest2, DBusProxyStatusEventAfterServiceIsRegistered) { + registerTestStub(); + + proxyDBusConnection_ = CommonAPI::DBus::DBusConnection::getSessionBus(); + ASSERT_TRUE(proxyDBusConnection_->connect()); + + proxy_ = std::make_shared<commonapi::tests::TestInterfaceDBusProxy>( + serviceFactory_, + commonApiAddress, + interfaceName, + busName, + objectPath, + proxyDBusConnection_); + proxy_->init(); + + proxyRegisterForAvailabilityStatus(); + + EXPECT_TRUE(proxyWaitForAvailabilityStatus(CommonAPI::AvailabilityStatus::AVAILABLE)); + + deregisterTestStub(); + usleep(100000); + + EXPECT_TRUE(proxyWaitForAvailabilityStatus(CommonAPI::AvailabilityStatus::NOT_AVAILABLE)); + + proxyDeregisterForAvailabilityStatus(); +} + +#ifndef WIN32 int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } +#endif diff --git a/src/test/DBusRuntimeTest.cpp b/src/test/DBusRuntimeTest.cpp index 231fd23..f2ea9b7 100644 --- a/src/test/DBusRuntimeTest.cpp +++ b/src/test/DBusRuntimeTest.cpp @@ -39,6 +39,12 @@ TEST_F(DBusRuntimeTest, LoadsSpecifiedStaticallyLinkedDBusLibrary) { TEST_F(DBusRuntimeTest, LoadsDBusLibraryAsSingleton) { +#ifdef WIN32 + /* + access the middlewareInfo in order to get a call to DBusRuntime. This forces the windows linker not to remove DBusRuntime from resulting binary + */ + ASSERT_TRUE(CommonAPI::DBus::DBusRuntime::middlewareInfo_.middlewareName_); +#endif std::shared_ptr<CommonAPI::Runtime> runtime1 = CommonAPI::Runtime::load("DBus"); std::shared_ptr<CommonAPI::Runtime> runtime2 = CommonAPI::Runtime::load("DBus"); ASSERT_TRUE((bool)runtime1); @@ -84,8 +90,9 @@ TEST_F(DBusRuntimeTest, DBusRuntimeLoadsDBusServicePublisher) { ASSERT_TRUE(dbusServicePublisher != NULL); } - +#ifndef WIN32 int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } +#endif diff --git a/src/test/DBusSelectiveBroadcastTest.cpp b/src/test/DBusSelectiveBroadcastTest.cpp index 6585aab..870568c 100644 --- a/src/test/DBusSelectiveBroadcastTest.cpp +++ b/src/test/DBusSelectiveBroadcastTest.cpp @@ -135,19 +135,16 @@ protected: int selectiveBroadcastArrivedAtProxyFromSameFactory2; int selectiveBroadcastArrivedAtProxyFromOtherFactory; public: - CommonAPI::SubscriptionStatus selectiveBroadcastCallbackForProxyFromSameFactory1() { + void selectiveBroadcastCallbackForProxyFromSameFactory1() { selectiveBroadcastArrivedAtProxyFromSameFactory1++; - return CommonAPI::SubscriptionStatus::RETAIN; } - CommonAPI::SubscriptionStatus selectiveBroadcastCallbackForProxyFromSameFactory2() { + void selectiveBroadcastCallbackForProxyFromSameFactory2() { selectiveBroadcastArrivedAtProxyFromSameFactory2++; - return CommonAPI::SubscriptionStatus::RETAIN; } - CommonAPI::SubscriptionStatus selectiveBroadcastCallbackForProxyFromOtherFactory() { + void selectiveBroadcastCallbackForProxyFromOtherFactory() { selectiveBroadcastArrivedAtProxyFromOtherFactory++; - return CommonAPI::SubscriptionStatus::RETAIN; } }; @@ -266,7 +263,9 @@ TEST_F(DBusSelectiveBroadcastTest, ProxysCanBeRejected) { ASSERT_EQ(selectiveBroadcastArrivedAtProxyFromOtherFactory, 0); } +#ifndef WIN32 int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } +#endif
\ No newline at end of file diff --git a/src/test/DBusServicePublisherTest.cpp b/src/test/DBusServicePublisherTest.cpp index 0124a43..b265e71 100644 --- a/src/test/DBusServicePublisherTest.cpp +++ b/src/test/DBusServicePublisherTest.cpp @@ -109,8 +109,9 @@ TEST_F(DBusServicePublisherTest, GracefullyHandlesWrongAddresses) { EXPECT_FALSE(servicePublisher->registerService(myStub, "too:much:stuff:here", proxyFactory)); } - +#ifndef WIN32 int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } +#endif
\ No newline at end of file diff --git a/src/test/DBusServiceRegistryTest.cpp b/src/test/DBusServiceRegistryTest.cpp index 855d5ff..9135ff5 100644 --- a/src/test/DBusServiceRegistryTest.cpp +++ b/src/test/DBusServiceRegistryTest.cpp @@ -138,20 +138,25 @@ struct TestDBusServiceListener { }; -class TestDBusStubAdapter: public CommonAPI::DBus::DBusStubAdapter { - public: - TestDBusStubAdapter(const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, - const std::string& commonApiAddress, - const std::string& dbusInterfaceName, - const std::string& dbusBusName, - const std::string& dbusObjectPath, - const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusConnection): - DBusStubAdapter(factory, commonApiAddress, dbusInterfaceName, dbusBusName, dbusObjectPath, dbusConnection, false), - introspectionCount(0) { +class DBusServiceRegistryTestDBusStubAdapter: public CommonAPI::DBus::DBusStubAdapter { +public: + DBusServiceRegistryTestDBusStubAdapter(const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, + const std::string& commonApiAddress, + const std::string& dbusInterfaceName, + const std::string& dbusBusName, + const std::string& dbusObjectPath, + const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusConnection) : + DBusStubAdapter(factory, + commonApiAddress, + dbusInterfaceName, + dbusBusName, + dbusObjectPath, + dbusConnection, + false), + introspectionCount(0) { } void deactivateManagedInstances() { - } virtual const char* getMethodsDBusIntrospectionXmlData() const { @@ -233,19 +238,19 @@ TEST_F(DBusServiceRegistryTest, SubscribeBeforeConnectWorks) { ASSERT_TRUE(serviceDBusConnection->connect()); ASSERT_TRUE(serviceDBusConnection->requestServiceNameAndBlock(dbusServiceName)); - auto testDBusStubAdapter = std::make_shared<TestDBusStubAdapter>( - serviceFactory, - "local:Interface1:predefined.Instance1", - "tests.Interface1", - dbusServiceName, - "/tests/predefined/Object1", - serviceDBusConnection); + auto testDBusStubAdapter = std::make_shared<DBusServiceRegistryTestDBusStubAdapter>( + serviceFactory, + "local:Interface1:predefined.Instance1", + "tests.Interface1", + dbusServiceName, + "/tests/predefined/Object1", + serviceDBusConnection); CommonAPI::DBus::DBusServicePublisher::getInstance()->registerService(testDBusStubAdapter); EXPECT_TRUE(waitForAvailabilityStatusChanged( testDBusServiceListener, CommonAPI::AvailabilityStatus::AVAILABLE)); - sleep(2); + usleep(2000000); EXPECT_LE(testDBusServiceListener.availabilityStatusCount, 3); EXPECT_EQ(testDBusStubAdapter->introspectionCount, 1); @@ -259,13 +264,13 @@ TEST_F(DBusServiceRegistryTest, SubscribeBeforeConnectWorks) { TEST_F(DBusServiceRegistryTest, SubscribeBeforeConnectWithServiceWorks) { ASSERT_TRUE(serviceDBusConnection->connect()); - auto testDBusStubAdapter = std::make_shared<TestDBusStubAdapter>( + auto testDBusStubAdapter = std::make_shared<DBusServiceRegistryTestDBusStubAdapter>( serviceFactory, - "local:Interface1:predefined.Instance1", - "tests.Interface1", - dbusServiceName, - "/tests/predefined/Object1", - serviceDBusConnection); + "local:Interface1:predefined.Instance1", + "tests.Interface1", + dbusServiceName, + "/tests/predefined/Object1", + serviceDBusConnection); CommonAPI::DBus::DBusServicePublisher::getInstance()->registerService(testDBusStubAdapter); TestDBusServiceListener testDBusServiceListener("local:Interface1:predefined.Instance1", clientDBusConnection); @@ -291,13 +296,13 @@ TEST_F(DBusServiceRegistryTest, SubscribeBeforeConnectWithServiceWorks) { TEST_F(DBusServiceRegistryTest, SubscribeAfterConnectWithServiceWorks) { ASSERT_TRUE(serviceDBusConnection->connect()); - auto testDBusStubAdapter = std::make_shared<TestDBusStubAdapter>( + auto testDBusStubAdapter = std::make_shared<DBusServiceRegistryTestDBusStubAdapter>( serviceFactory, - "local:Interface1:predefined.Instance1", - "tests.Interface1", - dbusServiceName, - "/tests/predefined/Object1", - serviceDBusConnection); + "local:Interface1:predefined.Instance1", + "tests.Interface1", + dbusServiceName, + "/tests/predefined/Object1", + serviceDBusConnection); CommonAPI::DBus::DBusServicePublisher::getInstance()->registerService(testDBusStubAdapter); ASSERT_TRUE(clientDBusConnection->connect()); @@ -607,24 +612,31 @@ TEST_F(DBusServiceDiscoveryTestWithPredefinedRemote, FindsNoInstancesOfNonexisti EXPECT_EQ(0, futureResult.get().size()); } +// disable that test, because vs2013's "high_resolution_clock" is not accurate enough to measure that +// see the microsoft bug report there: https://connect.microsoft.com/VisualStudio/feedback/details/719443/ +#ifndef WIN32 TEST_F(DBusServiceDiscoveryTestWithPredefinedRemote, ServiceRegistryUsesCacheForResolvingOneService) { - std::chrono::system_clock::time_point startTimeWithColdCache = std::chrono::system_clock::now(); + std::chrono::system_clock::time_point startTimeWithColdCache = std::chrono::high_resolution_clock::now(); ASSERT_TRUE(clientFactory_->isServiceInstanceAlive(serviceAddress_)); - std::chrono::system_clock::time_point endTimeWithColdCache = std::chrono::system_clock::now(); + std::chrono::system_clock::time_point endTimeWithColdCache = std::chrono::high_resolution_clock::now(); - long durationWithColdCache = std::chrono::duration_cast<std::chrono::microseconds>(endTimeWithColdCache - startTimeWithColdCache).count(); + unsigned long durationWithColdCache = std::chrono::duration_cast<std::chrono::nanoseconds>( + endTimeWithColdCache - startTimeWithColdCache).count(); - std::chrono::system_clock::time_point startTimeWithHotCache = std::chrono::system_clock::now(); + std::chrono::system_clock::time_point startTimeWithHotCache = std::chrono::high_resolution_clock::now(); ASSERT_TRUE(clientFactory_->isServiceInstanceAlive(serviceAddress_)); - std::chrono::system_clock::time_point endTimeWithHotCache = std::chrono::system_clock::now(); + std::chrono::system_clock::time_point endTimeWithHotCache = std::chrono::high_resolution_clock::now(); - long durationWithHotCache = std::chrono::duration_cast<std::chrono::microseconds>(endTimeWithHotCache - startTimeWithHotCache).count(); + unsigned long durationWithHotCache = std::chrono::duration_cast<std::chrono::nanoseconds>( + endTimeWithHotCache - startTimeWithHotCache).count(); + + ASSERT_GT(durationWithHotCache, 0); double speedRatio = durationWithColdCache / durationWithHotCache; EXPECT_GE(speedRatio, 100); } - +#endif TEST_F(DBusServiceDiscoveryTestWithPredefinedRemote, DISABLED_ServiceRegistryUsesCacheForResolvingWholeBus) { std::chrono::system_clock::time_point startTimeWithColdCache = std::chrono::system_clock::now(); @@ -645,9 +657,10 @@ TEST_F(DBusServiceDiscoveryTestWithPredefinedRemote, DISABLED_ServiceRegistryUse } - +#ifndef WIN32 int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); ::testing::AddGlobalTestEnvironment(new Environment()); return RUN_ALL_TESTS(); } +#endif diff --git a/src/test/DBusTypeStreamTest.cpp b/src/test/DBusTypeStreamTest.cpp index 4431bf1..52dee1b 100644 --- a/src/test/DBusTypeStreamTest.cpp +++ b/src/test/DBusTypeStreamTest.cpp @@ -325,8 +325,9 @@ TEST_F(TypeOutputStreamTest, ParsesSignatureOfGenericTestStructTypeVariantsCorre ASSERT_TRUE(signature.compare("(qs(yv))") == 0); } - +#ifndef WIN32 int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } +#endif
\ No newline at end of file diff --git a/src/test/DBusVariantOutputStreamTest.cpp b/src/test/DBusVariantOutputStreamTest.cpp index 47789e9..ad02d66 100644 --- a/src/test/DBusVariantOutputStreamTest.cpp +++ b/src/test/DBusVariantOutputStreamTest.cpp @@ -292,7 +292,9 @@ TEST_F(VariantOutputStreamTest, CanWriteVariantInArrayInVariant) { EXPECT_TRUE(inVariant == outVariant); } +#ifndef WIN32 int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } +#endif
\ No newline at end of file diff --git a/src/test/DBusVariantTest.cpp b/src/test/DBusVariantTest.cpp index c027a3f..a05ae03 100644 --- a/src/test/DBusVariantTest.cpp +++ b/src/test/DBusVariantTest.cpp @@ -166,7 +166,9 @@ TEST_F(VariantTest, VariantStringArray) { delete vectorVariant; } +#ifndef WIN32 int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } +#endif
\ No newline at end of file diff --git a/src/test/DemoMainLoop.h b/src/test/DemoMainLoop.h index 8b013e1..41b51eb 100644 --- a/src/test/DemoMainLoop.h +++ b/src/test/DemoMainLoop.h @@ -18,14 +18,27 @@ #include <vector> #include <set> #include <map> +#ifdef WIN32 +#include <WinSock2.h> +#include "DemoPoll.h" +#else #include <poll.h> -#include <unistd.h> #include <sys/eventfd.h> +#include <unistd.h> +#endif + + #include <cassert> namespace CommonAPI { +#ifdef WIN32 +typedef ::DemoPollFd DemoMainLoopPollFd; +#else +typedef pollfd DemoMainLoopPollFd; +#endif + class MainLoop { public: MainLoop() = delete; @@ -36,7 +49,18 @@ class MainLoop { explicit MainLoop(std::shared_ptr<MainLoopContext> context) : context_(context), currentMinimalTimeoutInterval_(TIMEOUT_INFINITE), running_(false), breakLoop_(false) { + +#ifdef WIN32 + WSAEVENT wsaEvent = WSACreateEvent(); + + if (wsaEvent != WSA_INVALID_EVENT) { + wakeFd_.fd = PtrToInt(wsaEvent); + } + + wakeFd_.isWsaEvent = true; +#else wakeFd_.fd = eventfd(0, EFD_SEMAPHORE | EFD_NONBLOCK); +#endif wakeFd_.events = POLLIN; assert(wakeFd_.fd != -1); @@ -63,7 +87,11 @@ class MainLoop { context_->unsubscribeForTimeouts(timeoutSourceListenerSubscription_); context_->unsubscribeForWakeupEvents(wakeupListenerSubscription_); +#ifdef WIN32 + WSACloseEvent(IntToPtr(wakeFd_.fd)); +#else close(wakeFd_.fd); +#endif } /** @@ -227,16 +255,21 @@ class MainLoop { } void wakeup() { +#ifdef WIN32 + HANDLE h = IntToPtr(wakeFd_.fd); + SetEvent(h); +#else int64_t wake = 1; ::write(wakeFd_.fd, &wake, sizeof(int64_t)); +#endif } private: - void registerFileDescriptor(const pollfd& fileDescriptor) { + void registerFileDescriptor(const DemoMainLoopPollFd& fileDescriptor) { managedFileDescriptors_.push_back(fileDescriptor); } - void deregisterFileDescriptor(const pollfd& fileDescriptor) { + void deregisterFileDescriptor(const DemoMainLoopPollFd& fileDescriptor) { for (auto it = managedFileDescriptors_.begin(); it != managedFileDescriptors_.end(); it++) { if ((*it).fd == fileDescriptor.fd) { managedFileDescriptors_.erase(it); @@ -263,8 +296,15 @@ class MainLoop { } void registerWatch(Watch* watch, const DispatchPriority dispatchPriority) { - registerFileDescriptor(watch->getAssociatedFileDescriptor()); - registeredWatches_.insert( { dispatchPriority, {watch->getAssociatedFileDescriptor().fd, watch} } ); +#ifdef WIN32 + DemoMainLoopPollFd fdToRegister = watch->getAssociatedFileDescriptor(); + fdToRegister.isWsaEvent = false; +#else + DemoMainLoopPollFd fdToRegister = watch->getAssociatedFileDescriptor(); +#endif + + registerFileDescriptor(fdToRegister); + registeredWatches_.insert( {dispatchPriority, {watch->getAssociatedFileDescriptor().fd, watch}}); } void deregisterWatch(Watch* watch) { @@ -298,13 +338,19 @@ class MainLoop { } void acknowledgeWakeup() { +#ifdef WIN32 + HANDLE h = IntToPtr(wakeFd_.fd); + ResetEvent(h); +#else int64_t buffer; - while (::read(wakeFd_.fd, &buffer, sizeof(int64_t)) == sizeof(buffer)); + while (::read(wakeFd_.fd, &buffer, sizeof(int64_t)) == sizeof(buffer)) + ; +#endif } std::shared_ptr<MainLoopContext> context_; - std::vector<pollfd> managedFileDescriptors_; + std::vector<DemoMainLoopPollFd> managedFileDescriptors_; std::multimap<DispatchPriority, DispatchSource*> registeredDispatchSources_; std::multimap<DispatchPriority, std::pair<int, Watch*>> registeredWatches_; @@ -323,7 +369,7 @@ class MainLoop { bool breakLoop_; bool running_; - pollfd wakeFd_; + DemoMainLoopPollFd wakeFd_; }; diff --git a/src/test/commonapi/tests/ExtendedInterfaceDBusProxy.cpp b/src/test/commonapi/tests/ExtendedInterfaceDBusProxy.cpp index 0e81757..d46c5e1 100644 --- a/src/test/commonapi/tests/ExtendedInterfaceDBusProxy.cpp +++ b/src/test/commonapi/tests/ExtendedInterfaceDBusProxy.cpp @@ -22,7 +22,7 @@ std::shared_ptr<CommonAPI::DBus::DBusProxy> createExtendedInterfaceDBusProxy( return std::make_shared<ExtendedInterfaceDBusProxy>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection); } -__attribute__((constructor)) void registerExtendedInterfaceDBusProxy(void) { +INITIALIZER(registerExtendedInterfaceDBusProxy) { CommonAPI::DBus::DBusFactory::registerProxyFactoryMethod(ExtendedInterface::getInterfaceId(), &createExtendedInterfaceDBusProxy); } diff --git a/src/test/commonapi/tests/ExtendedInterfaceDBusStubAdapter.cpp b/src/test/commonapi/tests/ExtendedInterfaceDBusStubAdapter.cpp index a2303a4..59cf9cd 100644 --- a/src/test/commonapi/tests/ExtendedInterfaceDBusStubAdapter.cpp +++ b/src/test/commonapi/tests/ExtendedInterfaceDBusStubAdapter.cpp @@ -24,7 +24,7 @@ std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> createExtendedInterfaceDBusStu return std::make_shared<ExtendedInterfaceDBusStubAdapter>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection, stubBase); } -__attribute__((constructor)) void registerExtendedInterfaceDBusStubAdapter(void) { +INITIALIZER(registerExtendedInterfaceDBusStubAdapter) { CommonAPI::DBus::DBusFactory::registerAdapterFactoryMethod(ExtendedInterface::getInterfaceId(), &createExtendedInterfaceDBusStubAdapter); } @@ -37,6 +37,7 @@ ExtendedInterfaceDBusStubAdapterInternal::~ExtendedInterfaceDBusStubAdapterInter } void ExtendedInterfaceDBusStubAdapterInternal::deactivateManagedInstances() { + } const char* ExtendedInterfaceDBusStubAdapterInternal::getMethodsDBusIntrospectionXmlData() const { @@ -50,19 +51,138 @@ const char* ExtendedInterfaceDBusStubAdapterInternal::getMethodsDBusIntrospectio return introspectionData.c_str(); } -static CommonAPI::DBus::DBusGetAttributeStubDispatcher< +CommonAPI::DBus::DBusGetAttributeStubDispatcher< ExtendedInterfaceStub, CommonAPI::Version - > getExtendedInterfaceInterfaceVersionStubDispatcher(&ExtendedInterfaceStub::getInterfaceVersion, "uu"); + > ExtendedInterfaceDBusStubAdapterInternal::getExtendedInterfaceInterfaceVersionStubDispatcher(&ExtendedInterfaceStub::getInterfaceVersion, "uu"); -static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< +#ifdef WIN32 +CommonAPI::DBus::DBusGetAttributeStubDispatcher< + ExtendedInterfaceStub, + uint32_t + > ExtendedInterfaceDBusStubAdapterInternal::getTestPredefinedTypeAttributeAttributeStubDispatcher(&ExtendedInterfaceStub::getTestPredefinedTypeAttributeAttribute, "u"); +CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< + ExtendedInterfaceStub, + uint32_t + > ExtendedInterfaceDBusStubAdapterInternal::setTestPredefinedTypeAttributeAttributeStubDispatcher( + &ExtendedInterfaceStub::getTestPredefinedTypeAttributeAttribute, + &ExtendedInterfaceStubRemoteEvent::onRemoteSetTestPredefinedTypeAttributeAttribute, + &ExtendedInterfaceStubRemoteEvent::onRemoteTestPredefinedTypeAttributeAttributeChanged, + &ExtendedInterfaceStubAdapter::fireTestPredefinedTypeAttributeAttributeChanged, + "u"); +CommonAPI::DBus::DBusGetAttributeStubDispatcher< + ExtendedInterfaceStub, + DerivedTypeCollection::TestStructExtended + > ExtendedInterfaceDBusStubAdapterInternal::getTestDerivedStructAttributeAttributeStubDispatcher(&ExtendedInterfaceStub::getTestDerivedStructAttributeAttribute, "(sqi)"); +CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< + ExtendedInterfaceStub, + DerivedTypeCollection::TestStructExtended + > ExtendedInterfaceDBusStubAdapterInternal::setTestDerivedStructAttributeAttributeStubDispatcher( + &ExtendedInterfaceStub::getTestDerivedStructAttributeAttribute, + &ExtendedInterfaceStubRemoteEvent::onRemoteSetTestDerivedStructAttributeAttribute, + &ExtendedInterfaceStubRemoteEvent::onRemoteTestDerivedStructAttributeAttributeChanged, + &ExtendedInterfaceStubAdapter::fireTestDerivedStructAttributeAttributeChanged, + "(sqi)"); +CommonAPI::DBus::DBusGetAttributeStubDispatcher< + ExtendedInterfaceStub, + DerivedTypeCollection::TestArrayUInt64 + > ExtendedInterfaceDBusStubAdapterInternal::getTestDerivedArrayAttributeAttributeStubDispatcher(&ExtendedInterfaceStub::getTestDerivedArrayAttributeAttribute, "at"); +CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< + ExtendedInterfaceStub, + DerivedTypeCollection::TestArrayUInt64 + > ExtendedInterfaceDBusStubAdapterInternal::setTestDerivedArrayAttributeAttributeStubDispatcher( + &ExtendedInterfaceStub::getTestDerivedArrayAttributeAttribute, + &ExtendedInterfaceStubRemoteEvent::onRemoteSetTestDerivedArrayAttributeAttribute, + &ExtendedInterfaceStubRemoteEvent::onRemoteTestDerivedArrayAttributeAttributeChanged, + &ExtendedInterfaceStubAdapter::fireTestDerivedArrayAttributeAttributeChanged, + "at"); +#endif + +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< ExtendedInterfaceStub, std::tuple<uint32_t>, std::tuple<> - > testIntMethodExtendedStubDispatcher(&ExtendedInterfaceStub::TestIntMethodExtended, ""); + > ExtendedInterfaceDBusStubAdapterInternal::testIntMethodExtendedStubDispatcher(&ExtendedInterfaceStub::TestIntMethodExtended, ""); + +#ifdef WIN32 +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + ExtendedInterfaceStub, + std::tuple<>, + std::tuple<> + > ExtendedInterfaceDBusStubAdapterInternal::testEmptyMethodStubDispatcher(&ExtendedInterfaceStub::testEmptyMethod, ""); +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + ExtendedInterfaceStub, + std::tuple<uint32_t, std::string>, + std::tuple<> + > ExtendedInterfaceDBusStubAdapterInternal::testVoidPredefinedTypeMethodStubDispatcher(&ExtendedInterfaceStub::testVoidPredefinedTypeMethod, ""); +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + ExtendedInterfaceStub, + std::tuple<uint32_t, std::string>, + std::tuple<uint32_t, std::string> + > ExtendedInterfaceDBusStubAdapterInternal::testPredefinedTypeMethodStubDispatcher(&ExtendedInterfaceStub::testPredefinedTypeMethod, "us"); +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + ExtendedInterfaceStub, + std::tuple<DerivedTypeCollection::TestEnumExtended2, DerivedTypeCollection::TestMap>, + std::tuple<> + > ExtendedInterfaceDBusStubAdapterInternal::testVoidDerivedTypeMethodStubDispatcher(&ExtendedInterfaceStub::testVoidDerivedTypeMethod, ""); +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + ExtendedInterfaceStub, + std::tuple<DerivedTypeCollection::TestEnumExtended2, DerivedTypeCollection::TestMap>, + std::tuple<DerivedTypeCollection::TestEnumExtended2, DerivedTypeCollection::TestMap> + > ExtendedInterfaceDBusStubAdapterInternal::testDerivedTypeMethodStubDispatcher(&ExtendedInterfaceStub::testDerivedTypeMethod, "ia{ua(sq)}"); +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + ExtendedInterfaceStub, + std::tuple<std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>>>, + std::tuple<> + > ExtendedInterfaceDBusStubAdapterInternal::testArrayOfPolymorphicStructMethodStubDispatcher(&ExtendedInterfaceStub::TestArrayOfPolymorphicStructMethod, ""); +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + ExtendedInterfaceStub, + std::tuple<DerivedTypeCollection::MapIntToPolymorphic>, + std::tuple<> + > ExtendedInterfaceDBusStubAdapterInternal::testMapOfPolymorphicStructMethodStubDispatcher(&ExtendedInterfaceStub::TestMapOfPolymorphicStructMethod, ""); +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + ExtendedInterfaceStub, + std::tuple<DerivedTypeCollection::StructWithPolymorphicMember>, + std::tuple<> + > ExtendedInterfaceDBusStubAdapterInternal::testStructWithPolymorphicMemberMethodStubDispatcher(&ExtendedInterfaceStub::TestStructWithPolymorphicMemberMethod, ""); +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + ExtendedInterfaceStub, + std::tuple<DerivedTypeCollection::StructWithEnumKeyMap>, + std::tuple<> + > ExtendedInterfaceDBusStubAdapterInternal::testStructWithEnumKeyMapMemberStubDispatcher(&ExtendedInterfaceStub::TestStructWithEnumKeyMapMember, ""); +#endif + +#ifdef WIN32 +CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< + ExtendedInterfaceStub, + ExtendedInterfaceStubAdapter, + std::tuple<>, + std::tuple<bool> + > ExtendedInterfaceDBusStubAdapterInternal::subscribeTestSelectiveBroadcastSelectiveStubDispatcher(&ExtendedInterfaceStubAdapter::subscribeForTestSelectiveBroadcastSelective, "b"); + +CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< + ExtendedInterfaceStub, + ExtendedInterfaceStubAdapter, + std::tuple<>, + std::tuple<> + > ExtendedInterfaceDBusStubAdapterInternal::unsubscribeTestSelectiveBroadcastSelectiveStubDispatcher(&ExtendedInterfaceStubAdapter::unsubscribeFromTestSelectiveBroadcastSelective, ""); +CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< + ExtendedInterfaceStub, + ExtendedInterfaceStubAdapter, + std::tuple<>, + std::tuple<bool> + > ExtendedInterfaceDBusStubAdapterInternal::subscribeTestBroadcastWithOutArgsSelectiveStubDispatcher(&ExtendedInterfaceStubAdapter::subscribeForTestBroadcastWithOutArgsSelective, "b"); + +CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< + ExtendedInterfaceStub, + ExtendedInterfaceStubAdapter, + std::tuple<>, + std::tuple<> + > ExtendedInterfaceDBusStubAdapterInternal::unsubscribeTestBroadcastWithOutArgsSelectiveStubDispatcher(&ExtendedInterfaceStubAdapter::unsubscribeFromTestBroadcastWithOutArgsSelective, ""); +#endif const ExtendedInterfaceDBusStubAdapterHelper::StubDispatcherTable& ExtendedInterfaceDBusStubAdapterInternal::getStubDispatcherTable() { return stubDispatcherTable_; @@ -103,18 +223,48 @@ ExtendedInterfaceDBusStubAdapterInternal::ExtendedInterfaceDBusStubAdapterIntern dbusConnection, stub), stubDispatcherTable_({ - { { "TestIntMethodExtended", "u" }, &commonapi::tests::testIntMethodExtendedStubDispatcher } + { { "TestIntMethodExtended", "u" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::testIntMethodExtendedStubDispatcher } + #ifdef WIN32 + , + { { "getTestPredefinedTypeAttributeAttribute", "" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::getTestPredefinedTypeAttributeAttributeStubDispatcher } + , { { "setTestPredefinedTypeAttributeAttribute", "u" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::setTestPredefinedTypeAttributeAttributeStubDispatcher }, + { { "getTestDerivedStructAttributeAttribute", "" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::getTestDerivedStructAttributeAttributeStubDispatcher } + , { { "setTestDerivedStructAttributeAttribute", "(sqi)" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::setTestDerivedStructAttributeAttributeStubDispatcher }, + { { "getTestDerivedArrayAttributeAttribute", "" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::getTestDerivedArrayAttributeAttributeStubDispatcher } + , { { "setTestDerivedArrayAttributeAttribute", "at" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::setTestDerivedArrayAttributeAttributeStubDispatcher } + , + { { "testEmptyMethod", "" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::testEmptyMethodStubDispatcher }, + { { "testVoidPredefinedTypeMethod", "us" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::testVoidPredefinedTypeMethodStubDispatcher }, + { { "testPredefinedTypeMethod", "us" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::testPredefinedTypeMethodStubDispatcher }, + { { "testVoidDerivedTypeMethod", "ia{ua(sq)}" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::testVoidDerivedTypeMethodStubDispatcher }, + { { "testDerivedTypeMethod", "ia{ua(sq)}" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::testDerivedTypeMethodStubDispatcher }, + { { "TestArrayOfPolymorphicStructMethod", "a(uv)" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::testArrayOfPolymorphicStructMethodStubDispatcher }, + { { "TestMapOfPolymorphicStructMethod", "a{y(uv)}" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::testMapOfPolymorphicStructMethodStubDispatcher }, + { { "TestStructWithPolymorphicMemberMethod", "(u(uv))" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::testStructWithPolymorphicMemberMethodStubDispatcher }, + { { "TestStructWithEnumKeyMapMember", "(a{is})" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::testStructWithEnumKeyMapMemberStubDispatcher } + , + { { "subscribeForTestSelectiveBroadcastSelective", "" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::subscribeTestSelectiveBroadcastSelectiveStubDispatcher } + , + { { "unsubscribeFromTestSelectiveBroadcastSelective", "" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::unsubscribeTestSelectiveBroadcastSelectiveStubDispatcher }, + { { "subscribeForTestBroadcastWithOutArgsSelective", "" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::subscribeTestBroadcastWithOutArgsSelectiveStubDispatcher } + , + { { "unsubscribeFromTestBroadcastWithOutArgsSelective", "" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::unsubscribeTestBroadcastWithOutArgsSelectiveStubDispatcher } + #endif }) { + #ifdef WIN32 + stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::getExtendedInterfaceInterfaceVersionStubDispatcher }); + #else auto parentDispatcherTable = TestInterfaceDBusStubAdapterInternal::getStubDispatcherTable(); stubDispatcherTable_.insert(parentDispatcherTable.begin(), parentDispatcherTable.end()); auto interfaceVersionGetter = stubDispatcherTable_.find({ "getInterfaceVersion", "" }); if(interfaceVersionGetter != stubDispatcherTable_.end()) { - interfaceVersionGetter->second = &commonapi::tests::getExtendedInterfaceInterfaceVersionStubDispatcher; + interfaceVersionGetter->second = &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::getExtendedInterfaceInterfaceVersionStubDispatcher; } else { - stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::getExtendedInterfaceInterfaceVersionStubDispatcher }); + stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::ExtendedInterfaceDBusStubAdapterInternal::getExtendedInterfaceInterfaceVersionStubDispatcher }); } + #endif } } // namespace tests diff --git a/src/test/commonapi/tests/ExtendedInterfaceDBusStubAdapter.h b/src/test/commonapi/tests/ExtendedInterfaceDBusStubAdapter.h index b713f45..3d2f23e 100644 --- a/src/test/commonapi/tests/ExtendedInterfaceDBusStubAdapter.h +++ b/src/test/commonapi/tests/ExtendedInterfaceDBusStubAdapter.h @@ -29,7 +29,7 @@ namespace tests { typedef CommonAPI::DBus::DBusStubAdapterHelper<ExtendedInterfaceStub> ExtendedInterfaceDBusStubAdapterHelper; -class ExtendedInterfaceDBusStubAdapterInternal: public ExtendedInterfaceStubAdapter, public ExtendedInterfaceDBusStubAdapterHelper, public TestInterfaceDBusStubAdapterInternal { +class ExtendedInterfaceDBusStubAdapterInternal: public virtual ExtendedInterfaceStubAdapter, public ExtendedInterfaceDBusStubAdapterHelper, public TestInterfaceDBusStubAdapterInternal { public: ExtendedInterfaceDBusStubAdapterInternal( const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, @@ -66,17 +66,134 @@ class ExtendedInterfaceDBusStubAdapterInternal: public ExtendedInterfaceStubAdap } virtual void init(std::shared_ptr<DBusStubAdapter> instance) { - return DBusStubAdapter::init(instance); + return ExtendedInterfaceDBusStubAdapterHelper::init(instance); } virtual void deinit() { - return DBusStubAdapter::deinit(); + return ExtendedInterfaceDBusStubAdapterHelper::deinit(); } virtual bool onInterfaceDBusMessage(const CommonAPI::DBus::DBusMessage& dbusMessage) { return ExtendedInterfaceDBusStubAdapterHelper::onInterfaceDBusMessage(dbusMessage); } +static CommonAPI::DBus::DBusGetAttributeStubDispatcher< + ExtendedInterfaceStub, + CommonAPI::Version + > getExtendedInterfaceInterfaceVersionStubDispatcher; + + +#ifdef WIN32 +static CommonAPI::DBus::DBusGetAttributeStubDispatcher< + ExtendedInterfaceStub, + uint32_t + > getTestPredefinedTypeAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< + ExtendedInterfaceStub, + uint32_t + > setTestPredefinedTypeAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusGetAttributeStubDispatcher< + ExtendedInterfaceStub, + DerivedTypeCollection::TestStructExtended + > getTestDerivedStructAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< + ExtendedInterfaceStub, + DerivedTypeCollection::TestStructExtended + > setTestDerivedStructAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusGetAttributeStubDispatcher< + ExtendedInterfaceStub, + DerivedTypeCollection::TestArrayUInt64 + > getTestDerivedArrayAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< + ExtendedInterfaceStub, + DerivedTypeCollection::TestArrayUInt64 + > setTestDerivedArrayAttributeAttributeStubDispatcher; +#endif + +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + ExtendedInterfaceStub, + std::tuple<uint32_t>, + std::tuple<> + > testIntMethodExtendedStubDispatcher; + +#ifdef WIN32 +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + ExtendedInterfaceStub, + std::tuple<>, + std::tuple<> + > testEmptyMethodStubDispatcher; +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + ExtendedInterfaceStub, + std::tuple<uint32_t, std::string>, + std::tuple<> + > testVoidPredefinedTypeMethodStubDispatcher; +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + ExtendedInterfaceStub, + std::tuple<uint32_t, std::string>, + std::tuple<uint32_t, std::string> + > testPredefinedTypeMethodStubDispatcher; +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + ExtendedInterfaceStub, + std::tuple<DerivedTypeCollection::TestEnumExtended2, DerivedTypeCollection::TestMap>, + std::tuple<> + > testVoidDerivedTypeMethodStubDispatcher; +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + ExtendedInterfaceStub, + std::tuple<DerivedTypeCollection::TestEnumExtended2, DerivedTypeCollection::TestMap>, + std::tuple<DerivedTypeCollection::TestEnumExtended2, DerivedTypeCollection::TestMap> + > testDerivedTypeMethodStubDispatcher; +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + ExtendedInterfaceStub, + std::tuple<std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>>>, + std::tuple<> + > testArrayOfPolymorphicStructMethodStubDispatcher; +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + ExtendedInterfaceStub, + std::tuple<DerivedTypeCollection::MapIntToPolymorphic>, + std::tuple<> + > testMapOfPolymorphicStructMethodStubDispatcher; +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + ExtendedInterfaceStub, + std::tuple<DerivedTypeCollection::StructWithPolymorphicMember>, + std::tuple<> + > testStructWithPolymorphicMemberMethodStubDispatcher; +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + ExtendedInterfaceStub, + std::tuple<DerivedTypeCollection::StructWithEnumKeyMap>, + std::tuple<> + > testStructWithEnumKeyMapMemberStubDispatcher; +#endif + + +#ifdef WIN32 +static CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< + ExtendedInterfaceStub, + ExtendedInterfaceStubAdapter, + std::tuple<>, + std::tuple<bool> + > subscribeTestSelectiveBroadcastSelectiveStubDispatcher; + +static CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< + ExtendedInterfaceStub, + ExtendedInterfaceStubAdapter, + std::tuple<>, + std::tuple<> + > unsubscribeTestSelectiveBroadcastSelectiveStubDispatcher; +static CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< + ExtendedInterfaceStub, + ExtendedInterfaceStubAdapter, + std::tuple<>, + std::tuple<bool> + > subscribeTestBroadcastWithOutArgsSelectiveStubDispatcher; + +static CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< + ExtendedInterfaceStub, + ExtendedInterfaceStubAdapter, + std::tuple<>, + std::tuple<> + > unsubscribeTestBroadcastWithOutArgsSelectiveStubDispatcher; +#endif + protected: virtual const char* getMethodsDBusIntrospectionXmlData() const; diff --git a/src/test/commonapi/tests/ExtendedInterfaceProxy.h b/src/test/commonapi/tests/ExtendedInterfaceProxy.h index af09b7f..18bae29 100644 --- a/src/test/commonapi/tests/ExtendedInterfaceProxy.h +++ b/src/test/commonapi/tests/ExtendedInterfaceProxy.h @@ -108,6 +108,12 @@ public: std::shared_ptr<ExtendedInterfaceProxyBase> delegate_; }; +#ifdef WIN32 + typedef ExtendedInterfaceProxy<CommonAPI::WINDummyAttributeExtension<CommonAPI::WINDummyAttribute>> ExtendedInterfaceProxyDefault; +#else + typedef ExtendedInterfaceProxy<> ExtendedInterfaceProxyDefault; +#endif + // // ExtendedInterfaceProxy Implementation diff --git a/src/test/commonapi/tests/ExtendedInterfaceStub.h b/src/test/commonapi/tests/ExtendedInterfaceStub.h index b8b42d0..7e253ac 100644 --- a/src/test/commonapi/tests/ExtendedInterfaceStub.h +++ b/src/test/commonapi/tests/ExtendedInterfaceStub.h @@ -35,7 +35,7 @@ namespace tests { * and attribute-changed-notifications of observable attributes as defined by this service. * An application developer should not need to bother with this class. */ -class ExtendedInterfaceStubAdapter: virtual public CommonAPI::StubAdapter, public ExtendedInterface { +class ExtendedInterfaceStubAdapter: virtual public CommonAPI::StubAdapter, public ExtendedInterface, public virtual TestInterfaceStubAdapter { public: @@ -61,7 +61,7 @@ protected: * This class and the one below are the ones an application developer needs to have * a look at if he wants to implement a service. */ -class ExtendedInterfaceStubRemoteEvent { +class ExtendedInterfaceStubRemoteEvent: public virtual TestInterfaceStubRemoteEvent { public: virtual ~ExtendedInterfaceStubRemoteEvent() { } @@ -74,7 +74,7 @@ class ExtendedInterfaceStubRemoteEvent { * This class and the one above are the ones an application developer needs to have * a look at if he wants to implement a service. */ -class ExtendedInterfaceStub : public virtual CommonAPI::Stub<ExtendedInterfaceStubAdapter, ExtendedInterfaceStubRemoteEvent>, public virtual TestInterfaceStub { +class ExtendedInterfaceStub: public virtual CommonAPI::Stub<ExtendedInterfaceStubAdapter, ExtendedInterfaceStubRemoteEvent>, public virtual TestInterfaceStub { public: virtual ~ExtendedInterfaceStub() { } virtual const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) = 0; @@ -86,6 +86,8 @@ public: using CommonAPI::Stub<ExtendedInterfaceStubAdapter, ExtendedInterfaceStubRemoteEvent>::initStubAdapter; typedef CommonAPI::Stub<ExtendedInterfaceStubAdapter, ExtendedInterfaceStubRemoteEvent>::StubAdapterType StubAdapterType; typedef CommonAPI::Stub<ExtendedInterfaceStubAdapter, ExtendedInterfaceStubRemoteEvent>::RemoteEventHandlerType RemoteEventHandlerType; + typedef ExtendedInterfaceStubRemoteEvent RemoteEventType; + typedef ExtendedInterface StubInterface; }; } // namespace tests diff --git a/src/test/commonapi/tests/ExtendedInterfaceStubDefault.cpp b/src/test/commonapi/tests/ExtendedInterfaceStubDefault.cpp index d5d4f62..468a5e7 100644 --- a/src/test/commonapi/tests/ExtendedInterfaceStubDefault.cpp +++ b/src/test/commonapi/tests/ExtendedInterfaceStubDefault.cpp @@ -22,6 +22,7 @@ const CommonAPI::Version& ExtendedInterfaceStubDefault::getInterfaceVersion(std: } ExtendedInterfaceStubRemoteEvent* ExtendedInterfaceStubDefault::initStubAdapter(const std::shared_ptr<ExtendedInterfaceStubAdapter>& stubAdapter) { + TestInterfaceStubDefault::initStubAdapter(stubAdapter); CommonAPI::Stub<ExtendedInterfaceStubAdapter, ExtendedInterfaceStubRemoteEvent>::stubAdapter_ = stubAdapter; return &remoteEventHandler_; } @@ -39,6 +40,7 @@ void ExtendedInterfaceStubDefault::TestIntMethodExtended(uint32_t inInt) { ExtendedInterfaceStubDefault::RemoteEventHandler::RemoteEventHandler(ExtendedInterfaceStubDefault* defaultStub): + TestInterfaceStubDefault::RemoteEventHandler(defaultStub), defaultStub_(defaultStub) { } diff --git a/src/test/commonapi/tests/ExtendedInterfaceStubDefault.h b/src/test/commonapi/tests/ExtendedInterfaceStubDefault.h index d7601f3..7117532 100644 --- a/src/test/commonapi/tests/ExtendedInterfaceStubDefault.h +++ b/src/test/commonapi/tests/ExtendedInterfaceStubDefault.h @@ -44,8 +44,7 @@ public: protected: -private: - class RemoteEventHandler: public ExtendedInterfaceStubRemoteEvent { + class RemoteEventHandler: public virtual ExtendedInterfaceStubRemoteEvent, public virtual TestInterfaceStubDefault::RemoteEventHandler { public: RemoteEventHandler(ExtendedInterfaceStubDefault* defaultStub); @@ -53,8 +52,8 @@ private: private: ExtendedInterfaceStubDefault* defaultStub_; }; - - RemoteEventHandler remoteEventHandler_; +private: + ExtendedInterfaceStubDefault::RemoteEventHandler remoteEventHandler_; CommonAPI::Version interfaceVersion_; diff --git a/src/test/commonapi/tests/TestInterfaceDBusProxy.cpp b/src/test/commonapi/tests/TestInterfaceDBusProxy.cpp index c04c828..bb0d482 100644 --- a/src/test/commonapi/tests/TestInterfaceDBusProxy.cpp +++ b/src/test/commonapi/tests/TestInterfaceDBusProxy.cpp @@ -22,7 +22,7 @@ std::shared_ptr<CommonAPI::DBus::DBusProxy> createTestInterfaceDBusProxy( return std::make_shared<TestInterfaceDBusProxy>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection); } -__attribute__((constructor)) void registerTestInterfaceDBusProxy(void) { +INITIALIZER(registerTestInterfaceDBusProxy) { CommonAPI::DBus::DBusFactory::registerProxyFactoryMethod(TestInterface::getInterfaceId(), &createTestInterfaceDBusProxy); } diff --git a/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp b/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp index ed057ba..32d2294 100644 --- a/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp +++ b/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp @@ -24,7 +24,7 @@ std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> createTestInterfaceDBusStubAda return std::make_shared<TestInterfaceDBusStubAdapter>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection, stubBase); } -__attribute__((constructor)) void registerTestInterfaceDBusStubAdapter(void) { +INITIALIZER(registerTestInterfaceDBusStubAdapter) { CommonAPI::DBus::DBusFactory::registerAdapterFactoryMethod(TestInterface::getInterfaceId(), &createTestInterfaceDBusStubAdapter); } @@ -37,6 +37,7 @@ TestInterfaceDBusStubAdapterInternal::~TestInterfaceDBusStubAdapterInternal() { } void TestInterfaceDBusStubAdapterInternal::deactivateManagedInstances() { + } const char* TestInterfaceDBusStubAdapterInternal::getMethodsDBusIntrospectionXmlData() const { @@ -123,47 +124,45 @@ const char* TestInterfaceDBusStubAdapterInternal::getMethodsDBusIntrospectionXml return introspectionData.c_str(); } -static CommonAPI::DBus::DBusGetAttributeStubDispatcher< +CommonAPI::DBus::DBusGetAttributeStubDispatcher< TestInterfaceStub, CommonAPI::Version - > getTestInterfaceInterfaceVersionStubDispatcher(&TestInterfaceStub::getInterfaceVersion, "uu"); + > TestInterfaceDBusStubAdapterInternal::getTestInterfaceInterfaceVersionStubDispatcher(&TestInterfaceStub::getInterfaceVersion, "uu"); -static CommonAPI::DBus::DBusGetAttributeStubDispatcher< +CommonAPI::DBus::DBusGetAttributeStubDispatcher< TestInterfaceStub, uint32_t - > getTestPredefinedTypeAttributeAttributeStubDispatcher(&TestInterfaceStub::getTestPredefinedTypeAttributeAttribute, "u"); -static CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< + > TestInterfaceDBusStubAdapterInternal::getTestPredefinedTypeAttributeAttributeStubDispatcher(&TestInterfaceStub::getTestPredefinedTypeAttributeAttribute, "u"); +CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< TestInterfaceStub, uint32_t - > setTestPredefinedTypeAttributeAttributeStubDispatcher( + > TestInterfaceDBusStubAdapterInternal::setTestPredefinedTypeAttributeAttributeStubDispatcher( &TestInterfaceStub::getTestPredefinedTypeAttributeAttribute, &TestInterfaceStubRemoteEvent::onRemoteSetTestPredefinedTypeAttributeAttribute, &TestInterfaceStubRemoteEvent::onRemoteTestPredefinedTypeAttributeAttributeChanged, &TestInterfaceStubAdapter::fireTestPredefinedTypeAttributeAttributeChanged, "u"); - -static CommonAPI::DBus::DBusGetAttributeStubDispatcher< +CommonAPI::DBus::DBusGetAttributeStubDispatcher< TestInterfaceStub, DerivedTypeCollection::TestStructExtended - > getTestDerivedStructAttributeAttributeStubDispatcher(&TestInterfaceStub::getTestDerivedStructAttributeAttribute, "(sqi)"); -static CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< + > TestInterfaceDBusStubAdapterInternal::getTestDerivedStructAttributeAttributeStubDispatcher(&TestInterfaceStub::getTestDerivedStructAttributeAttribute, "(sqi)"); +CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< TestInterfaceStub, DerivedTypeCollection::TestStructExtended - > setTestDerivedStructAttributeAttributeStubDispatcher( + > TestInterfaceDBusStubAdapterInternal::setTestDerivedStructAttributeAttributeStubDispatcher( &TestInterfaceStub::getTestDerivedStructAttributeAttribute, &TestInterfaceStubRemoteEvent::onRemoteSetTestDerivedStructAttributeAttribute, &TestInterfaceStubRemoteEvent::onRemoteTestDerivedStructAttributeAttributeChanged, &TestInterfaceStubAdapter::fireTestDerivedStructAttributeAttributeChanged, "(sqi)"); - -static CommonAPI::DBus::DBusGetAttributeStubDispatcher< +CommonAPI::DBus::DBusGetAttributeStubDispatcher< TestInterfaceStub, DerivedTypeCollection::TestArrayUInt64 - > getTestDerivedArrayAttributeAttributeStubDispatcher(&TestInterfaceStub::getTestDerivedArrayAttributeAttribute, "at"); -static CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< + > TestInterfaceDBusStubAdapterInternal::getTestDerivedArrayAttributeAttributeStubDispatcher(&TestInterfaceStub::getTestDerivedArrayAttributeAttribute, "at"); +CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< TestInterfaceStub, DerivedTypeCollection::TestArrayUInt64 - > setTestDerivedArrayAttributeAttributeStubDispatcher( + > TestInterfaceDBusStubAdapterInternal::setTestDerivedArrayAttributeAttributeStubDispatcher( &TestInterfaceStub::getTestDerivedArrayAttributeAttribute, &TestInterfaceStubRemoteEvent::onRemoteSetTestDerivedArrayAttributeAttribute, &TestInterfaceStubRemoteEvent::onRemoteTestDerivedArrayAttributeAttributeChanged, @@ -171,51 +170,52 @@ static CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< "at"); -static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< TestInterfaceStub, std::tuple<>, std::tuple<> - > testEmptyMethodStubDispatcher(&TestInterfaceStub::testEmptyMethod, ""); -static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + > TestInterfaceDBusStubAdapterInternal::testEmptyMethodStubDispatcher(&TestInterfaceStub::testEmptyMethod, ""); +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< TestInterfaceStub, std::tuple<uint32_t, std::string>, std::tuple<> - > testVoidPredefinedTypeMethodStubDispatcher(&TestInterfaceStub::testVoidPredefinedTypeMethod, ""); -static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + > TestInterfaceDBusStubAdapterInternal::testVoidPredefinedTypeMethodStubDispatcher(&TestInterfaceStub::testVoidPredefinedTypeMethod, ""); +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< TestInterfaceStub, std::tuple<uint32_t, std::string>, std::tuple<uint32_t, std::string> - > testPredefinedTypeMethodStubDispatcher(&TestInterfaceStub::testPredefinedTypeMethod, "us"); -static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + > TestInterfaceDBusStubAdapterInternal::testPredefinedTypeMethodStubDispatcher(&TestInterfaceStub::testPredefinedTypeMethod, "us"); +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< TestInterfaceStub, std::tuple<DerivedTypeCollection::TestEnumExtended2, DerivedTypeCollection::TestMap>, std::tuple<> - > testVoidDerivedTypeMethodStubDispatcher(&TestInterfaceStub::testVoidDerivedTypeMethod, ""); -static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + > TestInterfaceDBusStubAdapterInternal::testVoidDerivedTypeMethodStubDispatcher(&TestInterfaceStub::testVoidDerivedTypeMethod, ""); +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< TestInterfaceStub, std::tuple<DerivedTypeCollection::TestEnumExtended2, DerivedTypeCollection::TestMap>, std::tuple<DerivedTypeCollection::TestEnumExtended2, DerivedTypeCollection::TestMap> - > testDerivedTypeMethodStubDispatcher(&TestInterfaceStub::testDerivedTypeMethod, "ia{ua(sq)}"); -static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + > TestInterfaceDBusStubAdapterInternal::testDerivedTypeMethodStubDispatcher(&TestInterfaceStub::testDerivedTypeMethod, "ia{ua(sq)}"); +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< TestInterfaceStub, std::tuple<std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>>>, std::tuple<> - > testArrayOfPolymorphicStructMethodStubDispatcher(&TestInterfaceStub::TestArrayOfPolymorphicStructMethod, ""); -static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + > TestInterfaceDBusStubAdapterInternal::testArrayOfPolymorphicStructMethodStubDispatcher(&TestInterfaceStub::TestArrayOfPolymorphicStructMethod, ""); +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< TestInterfaceStub, std::tuple<DerivedTypeCollection::MapIntToPolymorphic>, std::tuple<> - > testMapOfPolymorphicStructMethodStubDispatcher(&TestInterfaceStub::TestMapOfPolymorphicStructMethod, ""); -static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + > TestInterfaceDBusStubAdapterInternal::testMapOfPolymorphicStructMethodStubDispatcher(&TestInterfaceStub::TestMapOfPolymorphicStructMethod, ""); +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< TestInterfaceStub, std::tuple<DerivedTypeCollection::StructWithPolymorphicMember>, std::tuple<> - > testStructWithPolymorphicMemberMethodStubDispatcher(&TestInterfaceStub::TestStructWithPolymorphicMemberMethod, ""); -static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + > TestInterfaceDBusStubAdapterInternal::testStructWithPolymorphicMemberMethodStubDispatcher(&TestInterfaceStub::TestStructWithPolymorphicMemberMethod, ""); +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< TestInterfaceStub, std::tuple<DerivedTypeCollection::StructWithEnumKeyMap>, std::tuple<> - > testStructWithEnumKeyMapMemberStubDispatcher(&TestInterfaceStub::TestStructWithEnumKeyMapMember, ""); + > TestInterfaceDBusStubAdapterInternal::testStructWithEnumKeyMapMemberStubDispatcher(&TestInterfaceStub::TestStructWithEnumKeyMapMember, ""); + void TestInterfaceDBusStubAdapterInternal::fireTestPredefinedTypeAttributeAttributeChanged(const uint32_t& value) { CommonAPI::DBus::DBusStubSignalHelper<CommonAPI::DBus::DBusSerializableArguments<uint32_t>> @@ -254,20 +254,19 @@ void TestInterfaceDBusStubAdapterInternal::fireTestPredefinedTypeBroadcastEvent( uint32Value, stringValue ); } -static CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< +CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< TestInterfaceStub, TestInterfaceStubAdapter, std::tuple<>, std::tuple<bool> - > subscribeTestSelectiveBroadcastSelectiveStubDispatcher(&TestInterfaceStubAdapter::subscribeForTestSelectiveBroadcastSelective, "b"); + > TestInterfaceDBusStubAdapterInternal::subscribeTestSelectiveBroadcastSelectiveStubDispatcher(&TestInterfaceStubAdapter::subscribeForTestSelectiveBroadcastSelective, "b"); -static CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< +CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< TestInterfaceStub, TestInterfaceStubAdapter, std::tuple<>, std::tuple<> - > unsubscribeTestSelectiveBroadcastSelectiveStubDispatcher(&TestInterfaceStubAdapter::unsubscribeFromTestSelectiveBroadcastSelective, ""); - + > TestInterfaceDBusStubAdapterInternal::unsubscribeTestSelectiveBroadcastSelectiveStubDispatcher(&TestInterfaceStubAdapter::unsubscribeFromTestSelectiveBroadcastSelective, ""); void TestInterfaceDBusStubAdapterInternal::fireTestSelectiveBroadcastSelective(const std::shared_ptr<CommonAPI::ClientId> clientId) { std::shared_ptr<CommonAPI::DBus::DBusClientId> dbusClientId = std::dynamic_pointer_cast<CommonAPI::DBus::DBusClientId, CommonAPI::ClientId>(clientId); @@ -323,20 +322,19 @@ std::shared_ptr<CommonAPI::ClientIdList> const TestInterfaceDBusStubAdapterInter return subscribersForTestSelectiveBroadcastSelective_; } -static CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< +CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< TestInterfaceStub, TestInterfaceStubAdapter, std::tuple<>, std::tuple<bool> - > subscribeTestBroadcastWithOutArgsSelectiveStubDispatcher(&TestInterfaceStubAdapter::subscribeForTestBroadcastWithOutArgsSelective, "b"); + > TestInterfaceDBusStubAdapterInternal::subscribeTestBroadcastWithOutArgsSelectiveStubDispatcher(&TestInterfaceStubAdapter::subscribeForTestBroadcastWithOutArgsSelective, "b"); -static CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< +CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< TestInterfaceStub, TestInterfaceStubAdapter, std::tuple<>, std::tuple<> - > unsubscribeTestBroadcastWithOutArgsSelectiveStubDispatcher(&TestInterfaceStubAdapter::unsubscribeFromTestBroadcastWithOutArgsSelective, ""); - + > TestInterfaceDBusStubAdapterInternal::unsubscribeTestBroadcastWithOutArgsSelectiveStubDispatcher(&TestInterfaceStubAdapter::unsubscribeFromTestBroadcastWithOutArgsSelective, ""); void TestInterfaceDBusStubAdapterInternal::fireTestBroadcastWithOutArgsSelective(const std::shared_ptr<CommonAPI::ClientId> clientId, const uint32_t& uint32Value, const std::string& stringValue) { std::shared_ptr<CommonAPI::DBus::DBusClientId> dbusClientId = std::dynamic_pointer_cast<CommonAPI::DBus::DBusClientId, CommonAPI::ClientId>(clientId); @@ -394,6 +392,7 @@ std::shared_ptr<CommonAPI::ClientIdList> const TestInterfaceDBusStubAdapterInter } + const TestInterfaceDBusStubAdapterHelper::StubDispatcherTable& TestInterfaceDBusStubAdapterInternal::getStubDispatcherTable() { return stubDispatcherTable_; } @@ -425,32 +424,34 @@ TestInterfaceDBusStubAdapterInternal::TestInterfaceDBusStubAdapterInternal( std::dynamic_pointer_cast<TestInterfaceStub>(stub), false), stubDispatcherTable_({ - { { "getTestPredefinedTypeAttributeAttribute", "" }, &commonapi::tests::getTestPredefinedTypeAttributeAttributeStubDispatcher } - , { { "setTestPredefinedTypeAttributeAttribute", "u" }, &commonapi::tests::setTestPredefinedTypeAttributeAttributeStubDispatcher }, - { { "getTestDerivedStructAttributeAttribute", "" }, &commonapi::tests::getTestDerivedStructAttributeAttributeStubDispatcher } - , { { "setTestDerivedStructAttributeAttribute", "(sqi)" }, &commonapi::tests::setTestDerivedStructAttributeAttributeStubDispatcher }, - { { "getTestDerivedArrayAttributeAttribute", "" }, &commonapi::tests::getTestDerivedArrayAttributeAttributeStubDispatcher } - , { { "setTestDerivedArrayAttributeAttribute", "at" }, &commonapi::tests::setTestDerivedArrayAttributeAttributeStubDispatcher } + { { "getTestPredefinedTypeAttributeAttribute", "" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::getTestPredefinedTypeAttributeAttributeStubDispatcher } + , { { "setTestPredefinedTypeAttributeAttribute", "u" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::setTestPredefinedTypeAttributeAttributeStubDispatcher }, + { { "getTestDerivedStructAttributeAttribute", "" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::getTestDerivedStructAttributeAttributeStubDispatcher } + , { { "setTestDerivedStructAttributeAttribute", "(sqi)" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::setTestDerivedStructAttributeAttributeStubDispatcher }, + { { "getTestDerivedArrayAttributeAttribute", "" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::getTestDerivedArrayAttributeAttributeStubDispatcher } + , { { "setTestDerivedArrayAttributeAttribute", "at" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::setTestDerivedArrayAttributeAttributeStubDispatcher } + , + { { "testEmptyMethod", "" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::testEmptyMethodStubDispatcher }, + { { "testVoidPredefinedTypeMethod", "us" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::testVoidPredefinedTypeMethodStubDispatcher }, + { { "testPredefinedTypeMethod", "us" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::testPredefinedTypeMethodStubDispatcher }, + { { "testVoidDerivedTypeMethod", "ia{ua(sq)}" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::testVoidDerivedTypeMethodStubDispatcher }, + { { "testDerivedTypeMethod", "ia{ua(sq)}" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::testDerivedTypeMethodStubDispatcher }, + { { "TestArrayOfPolymorphicStructMethod", "a(uv)" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::testArrayOfPolymorphicStructMethodStubDispatcher }, + { { "TestMapOfPolymorphicStructMethod", "a{y(uv)}" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::testMapOfPolymorphicStructMethodStubDispatcher }, + { { "TestStructWithPolymorphicMemberMethod", "(u(uv))" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::testStructWithPolymorphicMemberMethodStubDispatcher }, + { { "TestStructWithEnumKeyMapMember", "(a{is})" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::testStructWithEnumKeyMapMemberStubDispatcher } + , + { { "subscribeForTestSelectiveBroadcastSelective", "" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::subscribeTestSelectiveBroadcastSelectiveStubDispatcher } , - { { "testEmptyMethod", "" }, &commonapi::tests::testEmptyMethodStubDispatcher }, - { { "testVoidPredefinedTypeMethod", "us" }, &commonapi::tests::testVoidPredefinedTypeMethodStubDispatcher }, - { { "testPredefinedTypeMethod", "us" }, &commonapi::tests::testPredefinedTypeMethodStubDispatcher }, - { { "testVoidDerivedTypeMethod", "ia{ua(sq)}" }, &commonapi::tests::testVoidDerivedTypeMethodStubDispatcher }, - { { "testDerivedTypeMethod", "ia{ua(sq)}" }, &commonapi::tests::testDerivedTypeMethodStubDispatcher }, - { { "TestArrayOfPolymorphicStructMethod", "a(uv)" }, &commonapi::tests::testArrayOfPolymorphicStructMethodStubDispatcher }, - { { "TestMapOfPolymorphicStructMethod", "a{y(uv)}" }, &commonapi::tests::testMapOfPolymorphicStructMethodStubDispatcher }, - { { "TestStructWithPolymorphicMemberMethod", "(u(uv))" }, &commonapi::tests::testStructWithPolymorphicMemberMethodStubDispatcher }, - { { "TestStructWithEnumKeyMapMember", "(a{is})" }, &commonapi::tests::testStructWithEnumKeyMapMemberStubDispatcher } + { { "unsubscribeFromTestSelectiveBroadcastSelective", "" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::unsubscribeTestSelectiveBroadcastSelectiveStubDispatcher }, + { { "subscribeForTestBroadcastWithOutArgsSelective", "" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::subscribeTestBroadcastWithOutArgsSelectiveStubDispatcher } , - { { "subscribeForTestSelectiveBroadcastSelective", "" }, &commonapi::tests::subscribeTestSelectiveBroadcastSelectiveStubDispatcher }, - { { "unsubscribeFromTestSelectiveBroadcastSelective", "" }, &commonapi::tests::unsubscribeTestSelectiveBroadcastSelectiveStubDispatcher }, - { { "subscribeForTestBroadcastWithOutArgsSelective", "" }, &commonapi::tests::subscribeTestBroadcastWithOutArgsSelectiveStubDispatcher }, - { { "unsubscribeFromTestBroadcastWithOutArgsSelective", "" }, &commonapi::tests::unsubscribeTestBroadcastWithOutArgsSelectiveStubDispatcher } + { { "unsubscribeFromTestBroadcastWithOutArgsSelective", "" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::unsubscribeTestBroadcastWithOutArgsSelectiveStubDispatcher } }) { subscribersForTestSelectiveBroadcastSelective_ = std::make_shared<CommonAPI::ClientIdList>(); subscribersForTestBroadcastWithOutArgsSelective_ = std::make_shared<CommonAPI::ClientIdList>(); - stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::getTestInterfaceInterfaceVersionStubDispatcher }); + stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::TestInterfaceDBusStubAdapterInternal::getTestInterfaceInterfaceVersionStubDispatcher }); } } // namespace tests diff --git a/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.h b/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.h index 2596cfe..f0f31ff 100644 --- a/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.h +++ b/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.h @@ -28,7 +28,7 @@ namespace tests { typedef CommonAPI::DBus::DBusStubAdapterHelper<TestInterfaceStub> TestInterfaceDBusStubAdapterHelper; -class TestInterfaceDBusStubAdapterInternal: public TestInterfaceStubAdapter, public TestInterfaceDBusStubAdapterHelper { +class TestInterfaceDBusStubAdapterInternal: public virtual TestInterfaceStubAdapter, public TestInterfaceDBusStubAdapterHelper { public: TestInterfaceDBusStubAdapterInternal( const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, @@ -63,6 +63,112 @@ class TestInterfaceDBusStubAdapterInternal: public TestInterfaceStubAdapter, pub void deactivateManagedInstances(); +static CommonAPI::DBus::DBusGetAttributeStubDispatcher< + TestInterfaceStub, + CommonAPI::Version + > getTestInterfaceInterfaceVersionStubDispatcher; + +static CommonAPI::DBus::DBusGetAttributeStubDispatcher< + TestInterfaceStub, + uint32_t + > getTestPredefinedTypeAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< + TestInterfaceStub, + uint32_t + > setTestPredefinedTypeAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusGetAttributeStubDispatcher< + TestInterfaceStub, + DerivedTypeCollection::TestStructExtended + > getTestDerivedStructAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< + TestInterfaceStub, + DerivedTypeCollection::TestStructExtended + > setTestDerivedStructAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusGetAttributeStubDispatcher< + TestInterfaceStub, + DerivedTypeCollection::TestArrayUInt64 + > getTestDerivedArrayAttributeAttributeStubDispatcher; +static CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< + TestInterfaceStub, + DerivedTypeCollection::TestArrayUInt64 + > setTestDerivedArrayAttributeAttributeStubDispatcher; + + +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + TestInterfaceStub, + std::tuple<>, + std::tuple<> + > testEmptyMethodStubDispatcher; +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + TestInterfaceStub, + std::tuple<uint32_t, std::string>, + std::tuple<> + > testVoidPredefinedTypeMethodStubDispatcher; +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + TestInterfaceStub, + std::tuple<uint32_t, std::string>, + std::tuple<uint32_t, std::string> + > testPredefinedTypeMethodStubDispatcher; +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + TestInterfaceStub, + std::tuple<DerivedTypeCollection::TestEnumExtended2, DerivedTypeCollection::TestMap>, + std::tuple<> + > testVoidDerivedTypeMethodStubDispatcher; +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + TestInterfaceStub, + std::tuple<DerivedTypeCollection::TestEnumExtended2, DerivedTypeCollection::TestMap>, + std::tuple<DerivedTypeCollection::TestEnumExtended2, DerivedTypeCollection::TestMap> + > testDerivedTypeMethodStubDispatcher; +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + TestInterfaceStub, + std::tuple<std::vector<std::shared_ptr<DerivedTypeCollection::TestPolymorphicStruct>>>, + std::tuple<> + > testArrayOfPolymorphicStructMethodStubDispatcher; +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + TestInterfaceStub, + std::tuple<DerivedTypeCollection::MapIntToPolymorphic>, + std::tuple<> + > testMapOfPolymorphicStructMethodStubDispatcher; +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + TestInterfaceStub, + std::tuple<DerivedTypeCollection::StructWithPolymorphicMember>, + std::tuple<> + > testStructWithPolymorphicMemberMethodStubDispatcher; +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + TestInterfaceStub, + std::tuple<DerivedTypeCollection::StructWithEnumKeyMap>, + std::tuple<> + > testStructWithEnumKeyMapMemberStubDispatcher; + + +static CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< + TestInterfaceStub, + TestInterfaceStubAdapter, + std::tuple<>, + std::tuple<bool> + > subscribeTestSelectiveBroadcastSelectiveStubDispatcher; + +static CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< + TestInterfaceStub, + TestInterfaceStubAdapter, + std::tuple<>, + std::tuple<> + > unsubscribeTestSelectiveBroadcastSelectiveStubDispatcher; +static CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< + TestInterfaceStub, + TestInterfaceStubAdapter, + std::tuple<>, + std::tuple<bool> + > subscribeTestBroadcastWithOutArgsSelectiveStubDispatcher; + +static CommonAPI::DBus::DBusMethodWithReplyAdapterDispatcher< + TestInterfaceStub, + TestInterfaceStubAdapter, + std::tuple<>, + std::tuple<> + > unsubscribeTestBroadcastWithOutArgsSelectiveStubDispatcher; + + protected: virtual const char* getMethodsDBusIntrospectionXmlData() const; diff --git a/src/test/commonapi/tests/TestInterfaceProxy.h b/src/test/commonapi/tests/TestInterfaceProxy.h index 13ac60c..52491e2 100644 --- a/src/test/commonapi/tests/TestInterfaceProxy.h +++ b/src/test/commonapi/tests/TestInterfaceProxy.h @@ -302,6 +302,12 @@ public: std::shared_ptr<TestInterfaceProxyBase> delegate_; }; +#ifdef WIN32 + typedef TestInterfaceProxy<CommonAPI::WINDummyAttributeExtension<CommonAPI::WINDummyAttribute>> TestInterfaceProxyDefault; +#else + typedef TestInterfaceProxy<> TestInterfaceProxyDefault; +#endif + namespace TestInterfaceExtensions { template <template <typename > class _ExtensionType> class TestPredefinedTypeAttributeAttributeExtension { @@ -310,6 +316,9 @@ namespace TestInterfaceExtensions { static_assert(std::is_base_of<typename CommonAPI::AttributeExtension<TestInterfaceProxyBase::TestPredefinedTypeAttributeAttribute>, extension_type>::value, "Not CommonAPI Attribute Extension!"); + #ifdef WIN32 + TestPredefinedTypeAttributeAttributeExtension() {} + #endif TestPredefinedTypeAttributeAttributeExtension(TestInterfaceProxyBase& proxy): attributeExtension_(proxy.getTestPredefinedTypeAttributeAttribute()) { } @@ -329,6 +338,9 @@ namespace TestInterfaceExtensions { static_assert(std::is_base_of<typename CommonAPI::AttributeExtension<TestInterfaceProxyBase::TestDerivedStructAttributeAttribute>, extension_type>::value, "Not CommonAPI Attribute Extension!"); + #ifdef WIN32 + TestDerivedStructAttributeAttributeExtension() {} + #endif TestDerivedStructAttributeAttributeExtension(TestInterfaceProxyBase& proxy): attributeExtension_(proxy.getTestDerivedStructAttributeAttribute()) { } @@ -348,6 +360,9 @@ namespace TestInterfaceExtensions { static_assert(std::is_base_of<typename CommonAPI::AttributeExtension<TestInterfaceProxyBase::TestDerivedArrayAttributeAttribute>, extension_type>::value, "Not CommonAPI Attribute Extension!"); + #ifdef WIN32 + TestDerivedArrayAttributeAttributeExtension() {} + #endif TestDerivedArrayAttributeAttributeExtension(TestInterfaceProxyBase& proxy): attributeExtension_(proxy.getTestDerivedArrayAttributeAttribute()) { } diff --git a/src/test/commonapi/tests/TestInterfaceStub.h b/src/test/commonapi/tests/TestInterfaceStub.h index 77b72cf..d45ad3b 100644 --- a/src/test/commonapi/tests/TestInterfaceStub.h +++ b/src/test/commonapi/tests/TestInterfaceStub.h @@ -127,7 +127,7 @@ class TestInterfaceStubRemoteEvent { * This class and the one above are the ones an application developer needs to have * a look at if he wants to implement a service. */ -class TestInterfaceStub : public virtual CommonAPI::Stub<TestInterfaceStubAdapter, TestInterfaceStubRemoteEvent> { +class TestInterfaceStub: public virtual CommonAPI::Stub<TestInterfaceStubAdapter, TestInterfaceStubRemoteEvent> { public: virtual ~TestInterfaceStub() { } virtual const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) = 0; @@ -187,6 +187,8 @@ public: using CommonAPI::Stub<TestInterfaceStubAdapter, TestInterfaceStubRemoteEvent>::initStubAdapter; typedef CommonAPI::Stub<TestInterfaceStubAdapter, TestInterfaceStubRemoteEvent>::StubAdapterType StubAdapterType; typedef CommonAPI::Stub<TestInterfaceStubAdapter, TestInterfaceStubRemoteEvent>::RemoteEventHandlerType RemoteEventHandlerType; + typedef TestInterfaceStubRemoteEvent RemoteEventType; + typedef TestInterface StubInterface; }; } // namespace tests diff --git a/src/test/commonapi/tests/TestInterfaceStubDefault.h b/src/test/commonapi/tests/TestInterfaceStubDefault.h index 8eb7f93..e24ecdb 100644 --- a/src/test/commonapi/tests/TestInterfaceStubDefault.h +++ b/src/test/commonapi/tests/TestInterfaceStubDefault.h @@ -101,8 +101,7 @@ protected: virtual bool trySetTestDerivedArrayAttributeAttribute(DerivedTypeCollection::TestArrayUInt64 value); virtual bool validateTestDerivedArrayAttributeAttributeRequestedValue(const DerivedTypeCollection::TestArrayUInt64& value); virtual void onRemoteTestDerivedArrayAttributeAttributeChanged(); -private: - class RemoteEventHandler: public TestInterfaceStubRemoteEvent { + class RemoteEventHandler: public virtual TestInterfaceStubRemoteEvent { public: RemoteEventHandler(TestInterfaceStubDefault* defaultStub); @@ -122,8 +121,8 @@ private: private: TestInterfaceStubDefault* defaultStub_; }; - - RemoteEventHandler remoteEventHandler_; +private: + TestInterfaceStubDefault::RemoteEventHandler remoteEventHandler_; uint32_t testPredefinedTypeAttributeAttributeValue_; DerivedTypeCollection::TestStructExtended testDerivedStructAttributeAttributeValue_; diff --git a/src/test/commonapi/tests/managed/BranchInterfaceDBusProxy.cpp b/src/test/commonapi/tests/managed/BranchInterfaceDBusProxy.cpp index 1b62005..4757c27 100644 --- a/src/test/commonapi/tests/managed/BranchInterfaceDBusProxy.cpp +++ b/src/test/commonapi/tests/managed/BranchInterfaceDBusProxy.cpp @@ -23,7 +23,7 @@ std::shared_ptr<CommonAPI::DBus::DBusProxy> createBranchInterfaceDBusProxy( return std::make_shared<BranchInterfaceDBusProxy>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection); } -__attribute__((constructor)) void registerBranchInterfaceDBusProxy(void) { +INITIALIZER(registerBranchInterfaceDBusProxy) { CommonAPI::DBus::DBusFactory::registerProxyFactoryMethod(BranchInterface::getInterfaceId(), &createBranchInterfaceDBusProxy); } diff --git a/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.cpp b/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.cpp index 70f9b51..9411f53 100644 --- a/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.cpp +++ b/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.cpp @@ -25,7 +25,7 @@ std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> createBranchInterfaceDBusStubA return std::make_shared<BranchInterfaceDBusStubAdapter>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection, stubBase); } -__attribute__((constructor)) void registerBranchInterfaceDBusStubAdapter(void) { +INITIALIZER(registerBranchInterfaceDBusStubAdapter) { CommonAPI::DBus::DBusFactory::registerAdapterFactoryMethod(BranchInterface::getInterfaceId(), &createBranchInterfaceDBusStubAdapter); } @@ -38,6 +38,7 @@ BranchInterfaceDBusStubAdapterInternal::~BranchInterfaceDBusStubAdapterInternal( } void BranchInterfaceDBusStubAdapterInternal::deactivateManagedInstances() { + } const char* BranchInterfaceDBusStubAdapterInternal::getMethodsDBusIntrospectionXmlData() const { @@ -57,17 +58,20 @@ const char* BranchInterfaceDBusStubAdapterInternal::getMethodsDBusIntrospectionX return introspectionData.c_str(); } -static CommonAPI::DBus::DBusGetAttributeStubDispatcher< +CommonAPI::DBus::DBusGetAttributeStubDispatcher< BranchInterfaceStub, CommonAPI::Version - > getBranchInterfaceInterfaceVersionStubDispatcher(&BranchInterfaceStub::getInterfaceVersion, "uu"); + > BranchInterfaceDBusStubAdapterInternal::getBranchInterfaceInterfaceVersionStubDispatcher(&BranchInterfaceStub::getInterfaceVersion, "uu"); + -static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< BranchInterfaceStub, std::tuple<int32_t, std::string>, std::tuple<BranchInterface::testBranchMethodError, int32_t, std::string> - > testBranchMethodStubDispatcher(&BranchInterfaceStub::testBranchMethod, "iis"); + > BranchInterfaceDBusStubAdapterInternal::testBranchMethodStubDispatcher(&BranchInterfaceStub::testBranchMethod, "iis"); + + @@ -102,10 +106,10 @@ BranchInterfaceDBusStubAdapterInternal::BranchInterfaceDBusStubAdapterInternal( std::dynamic_pointer_cast<BranchInterfaceStub>(stub), false), stubDispatcherTable_({ - { { "testBranchMethod", "is" }, &commonapi::tests::managed::testBranchMethodStubDispatcher } + { { "testBranchMethod", "is" }, &commonapi::tests::managed::BranchInterfaceDBusStubAdapterInternal::testBranchMethodStubDispatcher } }) { - stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::managed::getBranchInterfaceInterfaceVersionStubDispatcher }); + stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::managed::BranchInterfaceDBusStubAdapterInternal::getBranchInterfaceInterfaceVersionStubDispatcher }); } } // namespace managed diff --git a/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.h b/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.h index bc9cfc8..730a0e5 100644 --- a/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.h +++ b/src/test/commonapi/tests/managed/BranchInterfaceDBusStubAdapter.h @@ -29,7 +29,7 @@ namespace managed { typedef CommonAPI::DBus::DBusStubAdapterHelper<BranchInterfaceStub> BranchInterfaceDBusStubAdapterHelper; -class BranchInterfaceDBusStubAdapterInternal: public BranchInterfaceStubAdapter, public BranchInterfaceDBusStubAdapterHelper { +class BranchInterfaceDBusStubAdapterInternal: public virtual BranchInterfaceStubAdapter, public BranchInterfaceDBusStubAdapterHelper { public: BranchInterfaceDBusStubAdapterInternal( const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, @@ -50,6 +50,22 @@ class BranchInterfaceDBusStubAdapterInternal: public BranchInterfaceStubAdapter, void deactivateManagedInstances(); +static CommonAPI::DBus::DBusGetAttributeStubDispatcher< + BranchInterfaceStub, + CommonAPI::Version + > getBranchInterfaceInterfaceVersionStubDispatcher; + + + +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + BranchInterfaceStub, + std::tuple<int32_t, std::string>, + std::tuple<BranchInterface::testBranchMethodError, int32_t, std::string> + > testBranchMethodStubDispatcher; + + + + protected: virtual const char* getMethodsDBusIntrospectionXmlData() const; diff --git a/src/test/commonapi/tests/managed/BranchInterfaceProxy.h b/src/test/commonapi/tests/managed/BranchInterfaceProxy.h index 35ab437..c543d36 100644 --- a/src/test/commonapi/tests/managed/BranchInterfaceProxy.h +++ b/src/test/commonapi/tests/managed/BranchInterfaceProxy.h @@ -105,6 +105,12 @@ public: std::shared_ptr<BranchInterfaceProxyBase> delegate_; }; +#ifdef WIN32 + typedef BranchInterfaceProxy<CommonAPI::WINDummyAttributeExtension<CommonAPI::WINDummyAttribute>> BranchInterfaceProxyDefault; +#else + typedef BranchInterfaceProxy<> BranchInterfaceProxyDefault; +#endif + // // BranchInterfaceProxy Implementation diff --git a/src/test/commonapi/tests/managed/BranchInterfaceStub.h b/src/test/commonapi/tests/managed/BranchInterfaceStub.h index 034316b..e94b775 100644 --- a/src/test/commonapi/tests/managed/BranchInterfaceStub.h +++ b/src/test/commonapi/tests/managed/BranchInterfaceStub.h @@ -74,7 +74,7 @@ class BranchInterfaceStubRemoteEvent { * This class and the one above are the ones an application developer needs to have * a look at if he wants to implement a service. */ -class BranchInterfaceStub : public virtual CommonAPI::Stub<BranchInterfaceStubAdapter, BranchInterfaceStubRemoteEvent> { +class BranchInterfaceStub: public virtual CommonAPI::Stub<BranchInterfaceStubAdapter, BranchInterfaceStubRemoteEvent> { public: virtual ~BranchInterfaceStub() { } virtual const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) = 0; @@ -86,6 +86,8 @@ public: using CommonAPI::Stub<BranchInterfaceStubAdapter, BranchInterfaceStubRemoteEvent>::initStubAdapter; typedef CommonAPI::Stub<BranchInterfaceStubAdapter, BranchInterfaceStubRemoteEvent>::StubAdapterType StubAdapterType; typedef CommonAPI::Stub<BranchInterfaceStubAdapter, BranchInterfaceStubRemoteEvent>::RemoteEventHandlerType RemoteEventHandlerType; + typedef BranchInterfaceStubRemoteEvent RemoteEventType; + typedef BranchInterface StubInterface; }; } // namespace managed diff --git a/src/test/commonapi/tests/managed/BranchInterfaceStubDefault.h b/src/test/commonapi/tests/managed/BranchInterfaceStubDefault.h index 7d992c9..bb1459b 100644 --- a/src/test/commonapi/tests/managed/BranchInterfaceStubDefault.h +++ b/src/test/commonapi/tests/managed/BranchInterfaceStubDefault.h @@ -44,8 +44,7 @@ public: protected: -private: - class RemoteEventHandler: public BranchInterfaceStubRemoteEvent { + class RemoteEventHandler: public virtual BranchInterfaceStubRemoteEvent { public: RemoteEventHandler(BranchInterfaceStubDefault* defaultStub); @@ -53,8 +52,8 @@ private: private: BranchInterfaceStubDefault* defaultStub_; }; - - RemoteEventHandler remoteEventHandler_; +private: + BranchInterfaceStubDefault::RemoteEventHandler remoteEventHandler_; CommonAPI::Version interfaceVersion_; diff --git a/src/test/commonapi/tests/managed/LeafInterfaceDBusProxy.cpp b/src/test/commonapi/tests/managed/LeafInterfaceDBusProxy.cpp index 0a6eb8a..4616c17 100644 --- a/src/test/commonapi/tests/managed/LeafInterfaceDBusProxy.cpp +++ b/src/test/commonapi/tests/managed/LeafInterfaceDBusProxy.cpp @@ -23,7 +23,7 @@ std::shared_ptr<CommonAPI::DBus::DBusProxy> createLeafInterfaceDBusProxy( return std::make_shared<LeafInterfaceDBusProxy>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection); } -__attribute__((constructor)) void registerLeafInterfaceDBusProxy(void) { +INITIALIZER(registerLeafInterfaceDBusProxy) { CommonAPI::DBus::DBusFactory::registerProxyFactoryMethod(LeafInterface::getInterfaceId(), &createLeafInterfaceDBusProxy); } diff --git a/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.cpp b/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.cpp index 1a43690..5411efa 100644 --- a/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.cpp +++ b/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.cpp @@ -25,7 +25,7 @@ std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> createLeafInterfaceDBusStubAda return std::make_shared<LeafInterfaceDBusStubAdapter>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection, stubBase); } -__attribute__((constructor)) void registerLeafInterfaceDBusStubAdapter(void) { +INITIALIZER(registerLeafInterfaceDBusStubAdapter) { CommonAPI::DBus::DBusFactory::registerAdapterFactoryMethod(LeafInterface::getInterfaceId(), &createLeafInterfaceDBusStubAdapter); } @@ -38,6 +38,7 @@ LeafInterfaceDBusStubAdapterInternal::~LeafInterfaceDBusStubAdapterInternal() { } void LeafInterfaceDBusStubAdapterInternal::deactivateManagedInstances() { + } const char* LeafInterfaceDBusStubAdapterInternal::getMethodsDBusIntrospectionXmlData() const { @@ -57,17 +58,20 @@ const char* LeafInterfaceDBusStubAdapterInternal::getMethodsDBusIntrospectionXml return introspectionData.c_str(); } -static CommonAPI::DBus::DBusGetAttributeStubDispatcher< +CommonAPI::DBus::DBusGetAttributeStubDispatcher< LeafInterfaceStub, CommonAPI::Version - > getLeafInterfaceInterfaceVersionStubDispatcher(&LeafInterfaceStub::getInterfaceVersion, "uu"); + > LeafInterfaceDBusStubAdapterInternal::getLeafInterfaceInterfaceVersionStubDispatcher(&LeafInterfaceStub::getInterfaceVersion, "uu"); + -static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< LeafInterfaceStub, std::tuple<int32_t, std::string>, std::tuple<LeafInterface::testLeafMethodError, int32_t, std::string> - > testLeafMethodStubDispatcher(&LeafInterfaceStub::testLeafMethod, "iis"); + > LeafInterfaceDBusStubAdapterInternal::testLeafMethodStubDispatcher(&LeafInterfaceStub::testLeafMethod, "iis"); + + @@ -102,10 +106,10 @@ LeafInterfaceDBusStubAdapterInternal::LeafInterfaceDBusStubAdapterInternal( std::dynamic_pointer_cast<LeafInterfaceStub>(stub), false), stubDispatcherTable_({ - { { "testLeafMethod", "is" }, &commonapi::tests::managed::testLeafMethodStubDispatcher } + { { "testLeafMethod", "is" }, &commonapi::tests::managed::LeafInterfaceDBusStubAdapterInternal::testLeafMethodStubDispatcher } }) { - stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::managed::getLeafInterfaceInterfaceVersionStubDispatcher }); + stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::managed::LeafInterfaceDBusStubAdapterInternal::getLeafInterfaceInterfaceVersionStubDispatcher }); } } // namespace managed diff --git a/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.h b/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.h index 1dc3d81..4819095 100644 --- a/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.h +++ b/src/test/commonapi/tests/managed/LeafInterfaceDBusStubAdapter.h @@ -29,7 +29,7 @@ namespace managed { typedef CommonAPI::DBus::DBusStubAdapterHelper<LeafInterfaceStub> LeafInterfaceDBusStubAdapterHelper; -class LeafInterfaceDBusStubAdapterInternal: public LeafInterfaceStubAdapter, public LeafInterfaceDBusStubAdapterHelper { +class LeafInterfaceDBusStubAdapterInternal: public virtual LeafInterfaceStubAdapter, public LeafInterfaceDBusStubAdapterHelper { public: LeafInterfaceDBusStubAdapterInternal( const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, @@ -50,6 +50,22 @@ class LeafInterfaceDBusStubAdapterInternal: public LeafInterfaceStubAdapter, pub void deactivateManagedInstances(); +static CommonAPI::DBus::DBusGetAttributeStubDispatcher< + LeafInterfaceStub, + CommonAPI::Version + > getLeafInterfaceInterfaceVersionStubDispatcher; + + + +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + LeafInterfaceStub, + std::tuple<int32_t, std::string>, + std::tuple<LeafInterface::testLeafMethodError, int32_t, std::string> + > testLeafMethodStubDispatcher; + + + + protected: virtual const char* getMethodsDBusIntrospectionXmlData() const; diff --git a/src/test/commonapi/tests/managed/LeafInterfaceProxy.h b/src/test/commonapi/tests/managed/LeafInterfaceProxy.h index f83f6e6..289e3c3 100644 --- a/src/test/commonapi/tests/managed/LeafInterfaceProxy.h +++ b/src/test/commonapi/tests/managed/LeafInterfaceProxy.h @@ -105,6 +105,12 @@ public: std::shared_ptr<LeafInterfaceProxyBase> delegate_; }; +#ifdef WIN32 + typedef LeafInterfaceProxy<CommonAPI::WINDummyAttributeExtension<CommonAPI::WINDummyAttribute>> LeafInterfaceProxyDefault; +#else + typedef LeafInterfaceProxy<> LeafInterfaceProxyDefault; +#endif + // // LeafInterfaceProxy Implementation diff --git a/src/test/commonapi/tests/managed/LeafInterfaceStub.h b/src/test/commonapi/tests/managed/LeafInterfaceStub.h index 2224922..e93cdf0 100644 --- a/src/test/commonapi/tests/managed/LeafInterfaceStub.h +++ b/src/test/commonapi/tests/managed/LeafInterfaceStub.h @@ -74,7 +74,7 @@ class LeafInterfaceStubRemoteEvent { * This class and the one above are the ones an application developer needs to have * a look at if he wants to implement a service. */ -class LeafInterfaceStub : public virtual CommonAPI::Stub<LeafInterfaceStubAdapter, LeafInterfaceStubRemoteEvent> { +class LeafInterfaceStub: public virtual CommonAPI::Stub<LeafInterfaceStubAdapter, LeafInterfaceStubRemoteEvent> { public: virtual ~LeafInterfaceStub() { } virtual const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) = 0; @@ -86,6 +86,8 @@ public: using CommonAPI::Stub<LeafInterfaceStubAdapter, LeafInterfaceStubRemoteEvent>::initStubAdapter; typedef CommonAPI::Stub<LeafInterfaceStubAdapter, LeafInterfaceStubRemoteEvent>::StubAdapterType StubAdapterType; typedef CommonAPI::Stub<LeafInterfaceStubAdapter, LeafInterfaceStubRemoteEvent>::RemoteEventHandlerType RemoteEventHandlerType; + typedef LeafInterfaceStubRemoteEvent RemoteEventType; + typedef LeafInterface StubInterface; }; } // namespace managed diff --git a/src/test/commonapi/tests/managed/LeafInterfaceStubDefault.h b/src/test/commonapi/tests/managed/LeafInterfaceStubDefault.h index dfaadb2..c0bd5b1 100644 --- a/src/test/commonapi/tests/managed/LeafInterfaceStubDefault.h +++ b/src/test/commonapi/tests/managed/LeafInterfaceStubDefault.h @@ -44,8 +44,7 @@ public: protected: -private: - class RemoteEventHandler: public LeafInterfaceStubRemoteEvent { + class RemoteEventHandler: public virtual LeafInterfaceStubRemoteEvent { public: RemoteEventHandler(LeafInterfaceStubDefault* defaultStub); @@ -53,8 +52,8 @@ private: private: LeafInterfaceStubDefault* defaultStub_; }; - - RemoteEventHandler remoteEventHandler_; +private: + LeafInterfaceStubDefault::RemoteEventHandler remoteEventHandler_; CommonAPI::Version interfaceVersion_; diff --git a/src/test/commonapi/tests/managed/RootInterfaceDBusProxy.cpp b/src/test/commonapi/tests/managed/RootInterfaceDBusProxy.cpp index ddfe44c..1c4e8c8 100644 --- a/src/test/commonapi/tests/managed/RootInterfaceDBusProxy.cpp +++ b/src/test/commonapi/tests/managed/RootInterfaceDBusProxy.cpp @@ -23,7 +23,7 @@ std::shared_ptr<CommonAPI::DBus::DBusProxy> createRootInterfaceDBusProxy( return std::make_shared<RootInterfaceDBusProxy>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection); } -__attribute__((constructor)) void registerRootInterfaceDBusProxy(void) { +INITIALIZER(registerRootInterfaceDBusProxy) { CommonAPI::DBus::DBusFactory::registerProxyFactoryMethod(RootInterface::getInterfaceId(), &createRootInterfaceDBusProxy); } diff --git a/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.cpp b/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.cpp index 5f56fe5..7fa1c1b 100644 --- a/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.cpp +++ b/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.cpp @@ -25,7 +25,7 @@ std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> createRootInterfaceDBusStubAda return std::make_shared<RootInterfaceDBusStubAdapter>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection, stubBase); } -__attribute__((constructor)) void registerRootInterfaceDBusStubAdapter(void) { +INITIALIZER(registerRootInterfaceDBusStubAdapter) { CommonAPI::DBus::DBusFactory::registerAdapterFactoryMethod(RootInterface::getInterfaceId(), &createRootInterfaceDBusStubAdapter); } @@ -38,13 +38,30 @@ RootInterfaceDBusStubAdapterInternal::~RootInterfaceDBusStubAdapterInternal() { } void RootInterfaceDBusStubAdapterInternal::deactivateManagedInstances() { - for(std::set<std::string>::iterator iter = registeredLeafInterfaceInstances.begin(); - iter != registeredLeafInterfaceInstances.end(); ++iter) { - deregisterManagedStubLeafInterface(*iter); + std::set<std::string>::iterator iter; + std::set<std::string>::iterator iterNext; + + iter = registeredLeafInterfaceInstances.begin(); + while (iter != registeredLeafInterfaceInstances.end()) { + iterNext = std::next(iter); + + if (deregisterManagedStubLeafInterface(*iter)) { + iter = iterNext; + } + else { + iter++; + } } - for(std::set<std::string>::iterator iter = registeredBranchInterfaceInstances.begin(); - iter != registeredBranchInterfaceInstances.end(); ++iter) { - deregisterManagedStubBranchInterface(*iter); + iter = registeredBranchInterfaceInstances.begin(); + while (iter != registeredBranchInterfaceInstances.end()) { + iterNext = std::next(iter); + + if (deregisterManagedStubBranchInterface(*iter)) { + iter = iterNext; + } + else { + iter++; + } } } @@ -65,17 +82,20 @@ const char* RootInterfaceDBusStubAdapterInternal::getMethodsDBusIntrospectionXml return introspectionData.c_str(); } -static CommonAPI::DBus::DBusGetAttributeStubDispatcher< +CommonAPI::DBus::DBusGetAttributeStubDispatcher< RootInterfaceStub, CommonAPI::Version - > getRootInterfaceInterfaceVersionStubDispatcher(&RootInterfaceStub::getInterfaceVersion, "uu"); + > RootInterfaceDBusStubAdapterInternal::getRootInterfaceInterfaceVersionStubDispatcher(&RootInterfaceStub::getInterfaceVersion, "uu"); + -static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< +CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< RootInterfaceStub, std::tuple<int32_t, std::string>, std::tuple<RootInterface::testRootMethodError, int32_t, std::string> - > testRootMethodStubDispatcher(&RootInterfaceStub::testRootMethod, "iis"); + > RootInterfaceDBusStubAdapterInternal::testRootMethodStubDispatcher(&RootInterfaceStub::testRootMethod, "iis"); + + @@ -218,10 +238,10 @@ RootInterfaceDBusStubAdapterInternal::RootInterfaceDBusStubAdapterInternal( std::dynamic_pointer_cast<RootInterfaceStub>(stub), true), stubDispatcherTable_({ - { { "testRootMethod", "is" }, &commonapi::tests::managed::testRootMethodStubDispatcher } + { { "testRootMethod", "is" }, &commonapi::tests::managed::RootInterfaceDBusStubAdapterInternal::testRootMethodStubDispatcher } }) { - stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::managed::getRootInterfaceInterfaceVersionStubDispatcher }); + stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::managed::RootInterfaceDBusStubAdapterInternal::getRootInterfaceInterfaceVersionStubDispatcher }); } } // namespace managed diff --git a/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.h b/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.h index fadd1d3..929e6c5 100644 --- a/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.h +++ b/src/test/commonapi/tests/managed/RootInterfaceDBusStubAdapter.h @@ -29,7 +29,7 @@ namespace managed { typedef CommonAPI::DBus::DBusStubAdapterHelper<RootInterfaceStub> RootInterfaceDBusStubAdapterHelper; -class RootInterfaceDBusStubAdapterInternal: public RootInterfaceStubAdapter, public RootInterfaceDBusStubAdapterHelper { +class RootInterfaceDBusStubAdapterInternal: public virtual RootInterfaceStubAdapter, public RootInterfaceDBusStubAdapterHelper { public: RootInterfaceDBusStubAdapterInternal( const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, @@ -56,6 +56,22 @@ class RootInterfaceDBusStubAdapterInternal: public RootInterfaceStubAdapter, pub void deactivateManagedInstances(); +static CommonAPI::DBus::DBusGetAttributeStubDispatcher< + RootInterfaceStub, + CommonAPI::Version + > getRootInterfaceInterfaceVersionStubDispatcher; + + + +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + RootInterfaceStub, + std::tuple<int32_t, std::string>, + std::tuple<RootInterface::testRootMethodError, int32_t, std::string> + > testRootMethodStubDispatcher; + + + + protected: virtual const char* getMethodsDBusIntrospectionXmlData() const; diff --git a/src/test/commonapi/tests/managed/RootInterfaceProxy.h b/src/test/commonapi/tests/managed/RootInterfaceProxy.h index 511090f..e128995 100644 --- a/src/test/commonapi/tests/managed/RootInterfaceProxy.h +++ b/src/test/commonapi/tests/managed/RootInterfaceProxy.h @@ -107,6 +107,12 @@ public: std::shared_ptr<RootInterfaceProxyBase> delegate_; }; +#ifdef WIN32 + typedef RootInterfaceProxy<CommonAPI::WINDummyAttributeExtension<CommonAPI::WINDummyAttribute>> RootInterfaceProxyDefault; +#else + typedef RootInterfaceProxy<> RootInterfaceProxyDefault; +#endif + // // RootInterfaceProxy Implementation diff --git a/src/test/commonapi/tests/managed/RootInterfaceStub.h b/src/test/commonapi/tests/managed/RootInterfaceStub.h index 2e1f878..de224f6 100644 --- a/src/test/commonapi/tests/managed/RootInterfaceStub.h +++ b/src/test/commonapi/tests/managed/RootInterfaceStub.h @@ -82,7 +82,7 @@ class RootInterfaceStubRemoteEvent { * This class and the one above are the ones an application developer needs to have * a look at if he wants to implement a service. */ -class RootInterfaceStub : public virtual CommonAPI::Stub<RootInterfaceStubAdapter, RootInterfaceStubRemoteEvent> { +class RootInterfaceStub: public virtual CommonAPI::Stub<RootInterfaceStubAdapter, RootInterfaceStubRemoteEvent> { public: virtual ~RootInterfaceStub() { } virtual const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) = 0; @@ -100,6 +100,8 @@ public: using CommonAPI::Stub<RootInterfaceStubAdapter, RootInterfaceStubRemoteEvent>::initStubAdapter; typedef CommonAPI::Stub<RootInterfaceStubAdapter, RootInterfaceStubRemoteEvent>::StubAdapterType StubAdapterType; typedef CommonAPI::Stub<RootInterfaceStubAdapter, RootInterfaceStubRemoteEvent>::RemoteEventHandlerType RemoteEventHandlerType; + typedef RootInterfaceStubRemoteEvent RemoteEventType; + typedef RootInterface StubInterface; }; } // namespace managed diff --git a/src/test/commonapi/tests/managed/RootInterfaceStubDefault.h b/src/test/commonapi/tests/managed/RootInterfaceStubDefault.h index 3bcb0f5..a68bde3 100644 --- a/src/test/commonapi/tests/managed/RootInterfaceStubDefault.h +++ b/src/test/commonapi/tests/managed/RootInterfaceStubDefault.h @@ -52,8 +52,7 @@ public: std::set<std::string>& getBranchInterfaceInstances(); protected: -private: - class RemoteEventHandler: public RootInterfaceStubRemoteEvent { + class RemoteEventHandler: public virtual RootInterfaceStubRemoteEvent { public: RemoteEventHandler(RootInterfaceStubDefault* defaultStub); @@ -61,8 +60,8 @@ private: private: RootInterfaceStubDefault* defaultStub_; }; - - RemoteEventHandler remoteEventHandler_; +private: + RootInterfaceStubDefault::RemoteEventHandler remoteEventHandler_; uint32_t autoInstanceCounter_; diff --git a/src/test/commonapi/tests/managed/SecondRootDBusProxy.cpp b/src/test/commonapi/tests/managed/SecondRootDBusProxy.cpp index dbb2bd1..25e0588 100644 --- a/src/test/commonapi/tests/managed/SecondRootDBusProxy.cpp +++ b/src/test/commonapi/tests/managed/SecondRootDBusProxy.cpp @@ -23,7 +23,7 @@ std::shared_ptr<CommonAPI::DBus::DBusProxy> createSecondRootDBusProxy( return std::make_shared<SecondRootDBusProxy>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection); } -__attribute__((constructor)) void registerSecondRootDBusProxy(void) { +INITIALIZER(registerSecondRootDBusProxy) { CommonAPI::DBus::DBusFactory::registerProxyFactoryMethod(SecondRoot::getInterfaceId(), &createSecondRootDBusProxy); } diff --git a/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.cpp b/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.cpp index 2664ca2..20ccd2b 100644 --- a/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.cpp +++ b/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.cpp @@ -25,7 +25,7 @@ std::shared_ptr<CommonAPI::DBus::DBusStubAdapter> createSecondRootDBusStubAdapte return std::make_shared<SecondRootDBusStubAdapter>(factory, commonApiAddress, interfaceName, busName, objectPath, dbusProxyConnection, stubBase); } -__attribute__((constructor)) void registerSecondRootDBusStubAdapter(void) { +INITIALIZER(registerSecondRootDBusStubAdapter) { CommonAPI::DBus::DBusFactory::registerAdapterFactoryMethod(SecondRoot::getInterfaceId(), &createSecondRootDBusStubAdapter); } @@ -38,9 +38,19 @@ SecondRootDBusStubAdapterInternal::~SecondRootDBusStubAdapterInternal() { } void SecondRootDBusStubAdapterInternal::deactivateManagedInstances() { - for(std::set<std::string>::iterator iter = registeredLeafInterfaceInstances.begin(); - iter != registeredLeafInterfaceInstances.end(); ++iter) { - deregisterManagedStubLeafInterface(*iter); + std::set<std::string>::iterator iter; + std::set<std::string>::iterator iterNext; + + iter = registeredLeafInterfaceInstances.begin(); + while (iter != registeredLeafInterfaceInstances.end()) { + iterNext = std::next(iter); + + if (deregisterManagedStubLeafInterface(*iter)) { + iter = iterNext; + } + else { + iter++; + } } } @@ -55,10 +65,13 @@ const char* SecondRootDBusStubAdapterInternal::getMethodsDBusIntrospectionXmlDat return introspectionData.c_str(); } -static CommonAPI::DBus::DBusGetAttributeStubDispatcher< +CommonAPI::DBus::DBusGetAttributeStubDispatcher< SecondRootStub, CommonAPI::Version - > getSecondRootInterfaceVersionStubDispatcher(&SecondRootStub::getInterfaceVersion, "uu"); + > SecondRootDBusStubAdapterInternal::getSecondRootInterfaceVersionStubDispatcher(&SecondRootStub::getInterfaceVersion, "uu"); + + + @@ -151,7 +164,7 @@ SecondRootDBusStubAdapterInternal::SecondRootDBusStubAdapterInternal( stubDispatcherTable_({ }) { - stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::managed::getSecondRootInterfaceVersionStubDispatcher }); + stubDispatcherTable_.insert({ { "getInterfaceVersion", "" }, &commonapi::tests::managed::SecondRootDBusStubAdapterInternal::getSecondRootInterfaceVersionStubDispatcher }); } } // namespace managed diff --git a/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.h b/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.h index 70ef6eb..4a2afde 100644 --- a/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.h +++ b/src/test/commonapi/tests/managed/SecondRootDBusStubAdapter.h @@ -29,7 +29,7 @@ namespace managed { typedef CommonAPI::DBus::DBusStubAdapterHelper<SecondRootStub> SecondRootDBusStubAdapterHelper; -class SecondRootDBusStubAdapterInternal: public SecondRootStubAdapter, public SecondRootDBusStubAdapterHelper { +class SecondRootDBusStubAdapterInternal: public virtual SecondRootStubAdapter, public SecondRootDBusStubAdapterHelper { public: SecondRootDBusStubAdapterInternal( const std::shared_ptr<CommonAPI::DBus::DBusFactory>& factory, @@ -53,6 +53,17 @@ class SecondRootDBusStubAdapterInternal: public SecondRootStubAdapter, public Se void deactivateManagedInstances(); +static CommonAPI::DBus::DBusGetAttributeStubDispatcher< + SecondRootStub, + CommonAPI::Version + > getSecondRootInterfaceVersionStubDispatcher; + + + + + + + protected: virtual const char* getMethodsDBusIntrospectionXmlData() const; diff --git a/src/test/commonapi/tests/managed/SecondRootProxy.h b/src/test/commonapi/tests/managed/SecondRootProxy.h index 4926155..0ce5699 100644 --- a/src/test/commonapi/tests/managed/SecondRootProxy.h +++ b/src/test/commonapi/tests/managed/SecondRootProxy.h @@ -85,6 +85,12 @@ public: std::shared_ptr<SecondRootProxyBase> delegate_; }; +#ifdef WIN32 + typedef SecondRootProxy<CommonAPI::WINDummyAttributeExtension<CommonAPI::WINDummyAttribute>> SecondRootProxyDefault; +#else + typedef SecondRootProxy<> SecondRootProxyDefault; +#endif + // // SecondRootProxy Implementation diff --git a/src/test/commonapi/tests/managed/SecondRootStub.h b/src/test/commonapi/tests/managed/SecondRootStub.h index b155f04..3eeb974 100644 --- a/src/test/commonapi/tests/managed/SecondRootStub.h +++ b/src/test/commonapi/tests/managed/SecondRootStub.h @@ -77,7 +77,7 @@ class SecondRootStubRemoteEvent { * This class and the one above are the ones an application developer needs to have * a look at if he wants to implement a service. */ -class SecondRootStub : public virtual CommonAPI::Stub<SecondRootStubAdapter, SecondRootStubRemoteEvent> { +class SecondRootStub: public virtual CommonAPI::Stub<SecondRootStubAdapter, SecondRootStubRemoteEvent> { public: virtual ~SecondRootStub() { } virtual const CommonAPI::Version& getInterfaceVersion(std::shared_ptr<CommonAPI::ClientId> clientId) = 0; @@ -90,6 +90,8 @@ public: using CommonAPI::Stub<SecondRootStubAdapter, SecondRootStubRemoteEvent>::initStubAdapter; typedef CommonAPI::Stub<SecondRootStubAdapter, SecondRootStubRemoteEvent>::StubAdapterType StubAdapterType; typedef CommonAPI::Stub<SecondRootStubAdapter, SecondRootStubRemoteEvent>::RemoteEventHandlerType RemoteEventHandlerType; + typedef SecondRootStubRemoteEvent RemoteEventType; + typedef SecondRoot StubInterface; }; } // namespace managed diff --git a/src/test/commonapi/tests/managed/SecondRootStubDefault.h b/src/test/commonapi/tests/managed/SecondRootStubDefault.h index 22c095b..bf5025e 100644 --- a/src/test/commonapi/tests/managed/SecondRootStubDefault.h +++ b/src/test/commonapi/tests/managed/SecondRootStubDefault.h @@ -45,8 +45,7 @@ public: std::set<std::string>& getLeafInterfaceInstances(); protected: -private: - class RemoteEventHandler: public SecondRootStubRemoteEvent { + class RemoteEventHandler: public virtual SecondRootStubRemoteEvent { public: RemoteEventHandler(SecondRootStubDefault* defaultStub); @@ -54,8 +53,8 @@ private: private: SecondRootStubDefault* defaultStub_; }; - - RemoteEventHandler remoteEventHandler_; +private: + SecondRootStubDefault::RemoteEventHandler remoteEventHandler_; uint32_t autoInstanceCounter_; |