diff options
author | Patrick Sattler <sattler@itestra.de> | 2014-03-10 17:39:29 +0100 |
---|---|---|
committer | Stefan Laner <laner@itestra.de> | 2014-03-13 18:13:53 +0100 |
commit | 36ab027dff0662bf178443dc0c67e75f950a31b2 (patch) | |
tree | 64abc003b2fd229ae76798da8a35b0ca5e948035 | |
parent | 6ac4fb4bb2498bfa7cab8af0d1a1884d810c012b (diff) | |
download | genivi-common-api-dbus-runtime-36ab027dff0662bf178443dc0c67e75f950a31b2.tar.gz |
Added a test to control if it isnt possible to access the Stubadapter
-added also the generated files from the updated generator
Change-Id: I0cb0a025167d5945dec6c6ecb7d814cf6c5982c1
-rw-r--r-- | src/test/DBusCommunicationTest.cpp | 33 | ||||
-rw-r--r-- | src/test/commonapi/tests/DerivedTypeCollection.h | 3 | ||||
-rw-r--r-- | src/test/commonapi/tests/PredefinedTypeCollection.h | 3 | ||||
-rw-r--r-- | src/test/commonapi/tests/TestInterfaceStubDefault.cpp | 6 |
4 files changed, 36 insertions, 9 deletions
diff --git a/src/test/DBusCommunicationTest.cpp b/src/test/DBusCommunicationTest.cpp index a693ceb..dee5c42 100644 --- a/src/test/DBusCommunicationTest.cpp +++ b/src/test/DBusCommunicationTest.cpp @@ -112,6 +112,39 @@ TEST_F(DBusCommunicationTest, RemoteMethodCallSucceeds) { servicePublisher_->unregisterService(serviceAddress_); } +TEST_F(DBusCommunicationTest, AccessStubAdapterAfterInitialised) { + auto stub = std::make_shared<commonapi::tests::TestInterfaceStubDefault>(); + bool serviceRegistered = servicePublisher_->registerService(stub, serviceAddress_, stubFactory_); + + unsigned int in = 5; + stub->setTestPredefinedTypeAttributeAttribute(in); + + for (unsigned int i = 0; !serviceRegistered && i < 100; i++) { + if (!serviceRegistered) { + serviceRegistered = servicePublisher_->registerService(stub, serviceAddress_, stubFactory_); + } + usleep(10000); + } + ASSERT_TRUE(serviceRegistered); + ASSERT_EQ(in, stub->getTestPredefinedTypeAttributeAttribute()); +} + +TEST_F(DBusCommunicationTest, AccessStubAdapterBeforeInitialised) { + auto stub = std::make_shared<commonapi::tests::TestInterfaceStubDefault>(); + + unsigned int in = 5; + stub->setTestPredefinedTypeAttributeAttribute(in); + + bool serviceRegistered = servicePublisher_->registerService(stub, serviceAddress_, stubFactory_); + + for (unsigned int i = 0; !serviceRegistered && i < 100; i++) { + if (!serviceRegistered) { + serviceRegistered = servicePublisher_->registerService(stub, serviceAddress_, stubFactory_); + } + usleep(10000); + } + ASSERT_TRUE(serviceRegistered); +} TEST_F(DBusCommunicationTest, SameStubCanBeRegisteredSeveralTimes) { auto defaultTestProxy = proxyFactory_->buildProxy<commonapi::tests::TestInterfaceProxy>(serviceAddress_); diff --git a/src/test/commonapi/tests/DerivedTypeCollection.h b/src/test/commonapi/tests/DerivedTypeCollection.h index e0cacd1..9e43d78 100644 --- a/src/test/commonapi/tests/DerivedTypeCollection.h +++ b/src/test/commonapi/tests/DerivedTypeCollection.h @@ -350,9 +350,6 @@ static inline const char* getTypeCollectionName() { return typeCollectionName; } -inline CommonAPI::Version getTypeCollectionVersion() { - return CommonAPI::Version(1, 0); -} } // namespace DerivedTypeCollection diff --git a/src/test/commonapi/tests/PredefinedTypeCollection.h b/src/test/commonapi/tests/PredefinedTypeCollection.h index 653a4f1..7ccf60d 100644 --- a/src/test/commonapi/tests/PredefinedTypeCollection.h +++ b/src/test/commonapi/tests/PredefinedTypeCollection.h @@ -48,9 +48,6 @@ static inline const char* getTypeCollectionName() { return typeCollectionName; } -inline CommonAPI::Version getTypeCollectionVersion() { - return CommonAPI::Version(1, 0); -} } // namespace PredefinedTypeCollection diff --git a/src/test/commonapi/tests/TestInterfaceStubDefault.cpp b/src/test/commonapi/tests/TestInterfaceStubDefault.cpp index b834f1b..764e1b8 100644 --- a/src/test/commonapi/tests/TestInterfaceStubDefault.cpp +++ b/src/test/commonapi/tests/TestInterfaceStubDefault.cpp @@ -36,7 +36,7 @@ const uint32_t& TestInterfaceStubDefault::getTestPredefinedTypeAttributeAttribut void TestInterfaceStubDefault::setTestPredefinedTypeAttributeAttribute(uint32_t value) { const bool valueChanged = trySetTestPredefinedTypeAttributeAttribute(std::move(value)); - if (valueChanged) { + if (valueChanged && stubAdapter_ != NULL) { stubAdapter_->fireTestPredefinedTypeAttributeAttributeChanged(testPredefinedTypeAttributeAttributeValue_); } } @@ -84,7 +84,7 @@ const DerivedTypeCollection::TestStructExtended& TestInterfaceStubDefault::getTe void TestInterfaceStubDefault::setTestDerivedStructAttributeAttribute(DerivedTypeCollection::TestStructExtended value) { const bool valueChanged = trySetTestDerivedStructAttributeAttribute(std::move(value)); - if (valueChanged) { + if (valueChanged && stubAdapter_ != NULL) { stubAdapter_->fireTestDerivedStructAttributeAttributeChanged(testDerivedStructAttributeAttributeValue_); } } @@ -132,7 +132,7 @@ const DerivedTypeCollection::TestArrayUInt64& TestInterfaceStubDefault::getTestD void TestInterfaceStubDefault::setTestDerivedArrayAttributeAttribute(DerivedTypeCollection::TestArrayUInt64 value) { const bool valueChanged = trySetTestDerivedArrayAttributeAttribute(std::move(value)); - if (valueChanged) { + if (valueChanged && stubAdapter_ != NULL) { stubAdapter_->fireTestDerivedArrayAttributeAttributeChanged(testDerivedArrayAttributeAttributeValue_); } } |