From: Patrick Sattler Date: Mon, 10 Mar 2014 16:39:29 +0000 (+0100) Subject: Added a test to control if it isnt possible to access the Stubadapter X-Git-Tag: 2.1.6~18 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=36ab027dff0662bf178443dc0c67e75f950a31b2;p=profile%2Fivi%2Fcommon-api-dbus-runtime.git 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 --- 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(); + 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(); + + 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(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_); } }