diff options
Diffstat (limited to 'src/test')
60 files changed, 1215 insertions, 399 deletions
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_; |