diff options
author | Philip Rauwolf <rauwolf@itestra.de> | 2013-03-22 09:56:23 +0100 |
---|---|---|
committer | Philip Rauwolf <rauwolf@itestra.de> | 2013-03-22 09:56:23 +0100 |
commit | 51daac71ae012c925bf67dcda3192e04f76f76da (patch) | |
tree | 205ff8c7ae1be4421d86419ec4def08f12f6b90c | |
parent | ef3e51d72f30e793d6d894c1642e1063e8226dc6 (diff) | |
download | genivi-common-api-dbus-runtime-51daac71ae012c925bf67dcda3192e04f76f76da.tar.gz |
Updated test files
-rw-r--r-- | src/test/commonapi/tests/DerivedTypeCollection.cpp | 10 | ||||
-rw-r--r-- | src/test/commonapi/tests/DerivedTypeCollection.h | 50 | ||||
-rw-r--r-- | src/test/commonapi/tests/PredefinedTypeCollection.h | 61 | ||||
-rw-r--r-- | src/test/commonapi/tests/TestInterfaceDBusProxy.cpp | 19 | ||||
-rw-r--r-- | src/test/commonapi/tests/TestInterfaceDBusProxy.h | 12 | ||||
-rw-r--r-- | src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp | 27 | ||||
-rw-r--r-- | src/test/commonapi/tests/TestInterfaceDBusStubAdapter.h | 2 | ||||
-rw-r--r-- | src/test/commonapi/tests/TestInterfaceProxy.h | 132 | ||||
-rw-r--r-- | src/test/commonapi/tests/TestInterfaceProxyBase.h | 7 | ||||
-rw-r--r-- | src/test/commonapi/tests/TestInterfaceStub.h | 50 | ||||
-rw-r--r-- | src/test/commonapi/tests/TestInterfaceStubDefault.cpp | 59 | ||||
-rw-r--r-- | src/test/commonapi/tests/TestInterfaceStubDefault.h | 15 | ||||
-rw-r--r-- | src/test/test-derived-types.fidl | 116 | ||||
-rw-r--r-- | src/test/test-interface-proxy.fidl | 119 | ||||
-rw-r--r-- | src/test/test-predefined-types.fidl | 44 |
15 files changed, 456 insertions, 267 deletions
diff --git a/src/test/commonapi/tests/DerivedTypeCollection.cpp b/src/test/commonapi/tests/DerivedTypeCollection.cpp index 1ad1cce..14b083e 100644 --- a/src/test/commonapi/tests/DerivedTypeCollection.cpp +++ b/src/test/commonapi/tests/DerivedTypeCollection.cpp @@ -7,10 +7,9 @@ namespace commonapi { namespace tests { namespace DerivedTypeCollection { -TestStructExtended::TestStructExtended(const PredefinedTypeCollection::TestString& testStringValue, const uint16_t& uintValueValue, const TestEnumExtended2& testEnumExtended2Value, const PredefinedTypeCollection::WeirdStrangeAlienEnum& alienEnumValue): +TestStructExtended::TestStructExtended(const PredefinedTypeCollection::TestString& testStringValue, const uint16_t& uintValueValue, const TestEnumExtended2& testEnumExtended2Value): TestStruct(testStringValue, uintValueValue), - testEnumExtended2(testEnumExtended2Value), - alienEnum(alienEnumValue) + testEnumExtended2(testEnumExtended2Value) { } @@ -20,21 +19,18 @@ bool operator==(const TestStructExtended& lhs, const TestStructExtended& rhs) { return static_cast<TestStructExtended::TestStruct>(lhs) == static_cast<TestStructExtended::TestStruct>(rhs) && - lhs.testEnumExtended2 == rhs.testEnumExtended2 && - lhs.alienEnum == rhs.alienEnum + lhs.testEnumExtended2 == rhs.testEnumExtended2 ; } void TestStructExtended::readFromInputStream(CommonAPI::InputStream& inputStream) { TestStruct::readFromInputStream(inputStream); inputStream >> testEnumExtended2; - inputStream >> alienEnum; } void TestStructExtended::writeToOutputStream(CommonAPI::OutputStream& outputStream) const { TestStruct::writeToOutputStream(outputStream); outputStream << testEnumExtended2; - outputStream << alienEnum; } TestStruct::TestStruct(const PredefinedTypeCollection::TestString& testStringValue, const uint16_t& uintValueValue): testString(testStringValue), diff --git a/src/test/commonapi/tests/DerivedTypeCollection.h b/src/test/commonapi/tests/DerivedTypeCollection.h index b1cd43f..26409d6 100644 --- a/src/test/commonapi/tests/DerivedTypeCollection.h +++ b/src/test/commonapi/tests/DerivedTypeCollection.h @@ -8,7 +8,7 @@ #include <CommonAPI/OutputStream.h> #include <CommonAPI/SerializableStruct.h> #include <CommonAPI/types.h> -#include "PredefinedTypeCollection.h" +#include <commonapi/tests/PredefinedTypeCollection.h> #include <cstdint> #include <string> #include <unordered_map> @@ -18,6 +18,26 @@ namespace commonapi { namespace tests { namespace DerivedTypeCollection { + struct TestStruct: CommonAPI::SerializableStruct { + PredefinedTypeCollection::TestString testString; + uint16_t uintValue; + + TestStruct() = default; + TestStruct(const PredefinedTypeCollection::TestString& testString, const uint16_t& uintValue); + + virtual void readFromInputStream(CommonAPI::InputStream& inputStream); + virtual void writeToOutputStream(CommonAPI::OutputStream& outputStream) const; + + static inline void writeToTypeOutputStream(CommonAPI::TypeOutputStream& typeOutputStream) { + typeOutputStream.writeStringType(); + typeOutputStream.writeUInt16Type(); + } + }; + + typedef std::vector<TestStruct> TestArrayTestStruct; + + typedef std::unordered_map<uint32_t, TestArrayTestStruct> TestMap; + enum class TestEnum: int32_t { E_UNKNOWN = 0, E_OK = 1, @@ -27,6 +47,7 @@ namespace DerivedTypeCollection { // XXX Definition of a comparator still is necessary for GCC 4.4.1, topic is fixed since 4.5.1 struct TestEnumComparator; + enum class TestEnumExtended: int32_t { E_UNKNOWN = TestEnum::E_UNKNOWN, E_OK = TestEnum::E_OK, @@ -38,23 +59,7 @@ namespace DerivedTypeCollection { // XXX Definition of a comparator still is necessary for GCC 4.4.1, topic is fixed since 4.5.1 struct TestEnumExtendedComparator; - typedef std::unordered_map<TestEnum, std::string> TestEnumMap; - struct TestStruct: CommonAPI::SerializableStruct { - PredefinedTypeCollection::TestString testString; - uint16_t uintValue; - - TestStruct() = default; - TestStruct(const PredefinedTypeCollection::TestString& testString, const uint16_t& uintValue); - virtual void readFromInputStream(CommonAPI::InputStream& inputStream); - virtual void writeToOutputStream(CommonAPI::OutputStream& outputStream) const; - - static inline void writeToTypeOutputStream(CommonAPI::TypeOutputStream& typeOutputStream) { - typeOutputStream.writeStringType(); - typeOutputStream.writeUInt16Type(); - } - }; - typedef std::vector<TestStruct> TestArrayTestStruct; enum class TestEnumExtended2: int32_t { E_UNKNOWN = TestEnum::E_UNKNOWN, E_OK = TestEnum::E_OK, @@ -68,12 +73,12 @@ namespace DerivedTypeCollection { // XXX Definition of a comparator still is necessary for GCC 4.4.1, topic is fixed since 4.5.1 struct TestEnumExtended2Comparator; + struct TestStructExtended: TestStruct { TestEnumExtended2 testEnumExtended2; - PredefinedTypeCollection::WeirdStrangeAlienEnum alienEnum; TestStructExtended() = default; - TestStructExtended(const PredefinedTypeCollection::TestString& testString, const uint16_t& uintValue, const TestEnumExtended2& testEnumExtended2, const PredefinedTypeCollection::WeirdStrangeAlienEnum& alienEnum); + TestStructExtended(const PredefinedTypeCollection::TestString& testString, const uint16_t& uintValue, const TestEnumExtended2& testEnumExtended2); virtual void readFromInputStream(CommonAPI::InputStream& inputStream); virtual void writeToOutputStream(CommonAPI::OutputStream& outputStream) const; @@ -81,10 +86,11 @@ namespace DerivedTypeCollection { static inline void writeToTypeOutputStream(CommonAPI::TypeOutputStream& typeOutputStream) { TestStruct::writeToTypeOutputStream(typeOutputStream); typeOutputStream.writeInt32Type(); - typeOutputStream.writeInt32Type(); } }; - typedef std::unordered_map<uint32_t, TestArrayTestStruct> TestMap; + + typedef std::unordered_map<TestEnum, std::string> TestEnumMap; + enum class TestEnumMissingValue: int32_t { E1 = 10, E2, @@ -93,7 +99,9 @@ namespace DerivedTypeCollection { // XXX Definition of a comparator still is necessary for GCC 4.4.1, topic is fixed since 4.5.1 struct TestEnumMissingValueComparator; + typedef std::vector<uint64_t> TestArrayUInt64; + bool operator==(const TestStructExtended& lhs, const TestStructExtended& rhs); inline bool operator!=(const TestStructExtended& lhs, const TestStructExtended& rhs) { diff --git a/src/test/commonapi/tests/PredefinedTypeCollection.h b/src/test/commonapi/tests/PredefinedTypeCollection.h index ee9c1ec..f1d3cc2 100644 --- a/src/test/commonapi/tests/PredefinedTypeCollection.h +++ b/src/test/commonapi/tests/PredefinedTypeCollection.h @@ -5,8 +5,6 @@ #define COMMONAPI_TESTS_PREDEFINED_TYPE_COLLECTION_H_ #include <CommonAPI/ByteBuffer.h> -#include <CommonAPI/InputStream.h> -#include <CommonAPI/OutputStream.h> #include <CommonAPI/types.h> #include <cstdint> #include <string> @@ -16,40 +14,31 @@ namespace tests { namespace PredefinedTypeCollection { typedef uint8_t TestUInt8; + typedef uint16_t TestUInt16; + typedef uint32_t TestUInt32; + typedef uint64_t TestUInt64; + typedef int8_t TestInt8; + typedef int16_t TestInt16; + typedef int32_t TestInt32; + typedef int64_t TestInt64; + typedef bool TestBoolean; + typedef CommonAPI::ByteBuffer TestByteBuffer; + typedef double TestDouble; + typedef float TestFloat; + typedef std::string TestString; - enum class WeirdStrangeAlienEnum: int32_t { - WEIRD, - STRANGE, - ALIEN - }; - // XXX Definition of a comparator still is necessary for GCC 4.4.1, topic is fixed since 4.5.1 - struct WeirdStrangeAlienEnumComparator; - -inline CommonAPI::InputStream& operator>>(CommonAPI::InputStream& inputStream, WeirdStrangeAlienEnum& enumValue) { - return inputStream.readEnumValue<int32_t>(enumValue); -} - -inline CommonAPI::OutputStream& operator<<(CommonAPI::OutputStream& outputStream, const WeirdStrangeAlienEnum& enumValue) { - return outputStream.writeEnumValue(static_cast<int32_t>(enumValue)); -} - -struct WeirdStrangeAlienEnumComparator { - inline bool operator()(const WeirdStrangeAlienEnum& lhs, const WeirdStrangeAlienEnum& rhs) const { - return static_cast<int32_t>(lhs) < static_cast<int32_t>(rhs); - } -}; @@ -65,37 +54,11 @@ static inline const char* getTypeCollectionName() { namespace CommonAPI { - template<> - struct BasicTypeWriter<commonapi::tests::PredefinedTypeCollection::WeirdStrangeAlienEnum> { - inline static void writeType (CommonAPI::TypeOutputStream& typeStream) { - typeStream.writeInt32EnumType(); - } - }; - - template<> - struct InputStreamVectorHelper<commonapi::tests::PredefinedTypeCollection::WeirdStrangeAlienEnum> { - static void beginReadVector(InputStream& inputStream, const std::vector<commonapi::tests::PredefinedTypeCollection::WeirdStrangeAlienEnum>& vectorValue) { - inputStream.beginReadInt32EnumVector(); - } - }; - - template <> - struct OutputStreamVectorHelper<commonapi::tests::PredefinedTypeCollection::WeirdStrangeAlienEnum> { - static void beginWriteVector(OutputStream& outputStream, const std::vector<commonapi::tests::PredefinedTypeCollection::WeirdStrangeAlienEnum>& vectorValue) { - outputStream.beginWriteInt32EnumVector(vectorValue.size()); - } - }; } namespace std { - template<> - struct hash<commonapi::tests::PredefinedTypeCollection::WeirdStrangeAlienEnum> { - inline size_t operator()(const commonapi::tests::PredefinedTypeCollection::WeirdStrangeAlienEnum& weirdStrangeAlienEnum) const { - return static_cast<int32_t>(weirdStrangeAlienEnum); - } - }; } #endif // COMMONAPI_TESTS_PREDEFINED_TYPE_COLLECTION_H_ diff --git a/src/test/commonapi/tests/TestInterfaceDBusProxy.cpp b/src/test/commonapi/tests/TestInterfaceDBusProxy.cpp index 34981e0..f5460d1 100644 --- a/src/test/commonapi/tests/TestInterfaceDBusProxy.cpp +++ b/src/test/commonapi/tests/TestInterfaceDBusProxy.cpp @@ -28,7 +28,7 @@ TestInterfaceDBusProxy::TestInterfaceDBusProxy( const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusProxyconnection): CommonAPI::DBus::DBusProxy(commonApiAddress, interfaceName, busName, objectPath, dbusProxyconnection) , testPredefinedTypeAttribute_(*this, "onTestPredefinedTypeAttributeAttributeChanged", "setTestPredefinedTypeAttributeAttribute", "u", "getTestPredefinedTypeAttributeAttribute"), - testDerivedStructAttribute_(*this, "onTestDerivedStructAttributeAttributeChanged", "setTestDerivedStructAttributeAttribute", "(sqii)", "getTestDerivedStructAttributeAttribute"), + testDerivedStructAttribute_(*this, "onTestDerivedStructAttributeAttributeChanged", "setTestDerivedStructAttributeAttribute", "(sqi)", "getTestDerivedStructAttributeAttribute"), testDerivedArrayAttribute_(*this, "onTestDerivedArrayAttributeAttributeChanged", "setTestDerivedArrayAttributeAttribute", "at", "getTestDerivedArrayAttributeAttribute") , testPredefinedTypeBroadcast_(*this, "TestPredefinedTypeBroadcast", "us") { @@ -48,6 +48,23 @@ TestInterfaceDBusProxy::TestPredefinedTypeBroadcastEvent& TestInterfaceDBusProxy return testPredefinedTypeBroadcast_; } +void TestInterfaceDBusProxy::testEmptyMethod(CommonAPI::CallStatus& callStatus) { + CommonAPI::DBus::DBusProxyHelper<CommonAPI::DBus::DBusSerializableArguments<>, + CommonAPI::DBus::DBusSerializableArguments<> >::callMethodWithReply( + *this, + "testEmptyMethod", + "", + callStatus + ); +} +std::future<CommonAPI::CallStatus> TestInterfaceDBusProxy::testEmptyMethodAsync(TestEmptyMethodAsyncCallback callback) { + return CommonAPI::DBus::DBusProxyHelper<CommonAPI::DBus::DBusSerializableArguments<>, + CommonAPI::DBus::DBusSerializableArguments<> >::callMethodAsync( + *this, + "testEmptyMethod", + "", + std::move(callback)); +} void TestInterfaceDBusProxy::testVoidPredefinedTypeMethod(const uint32_t& uint32Value, const std::string& stringValue, CommonAPI::CallStatus& callStatus) { CommonAPI::DBus::DBusProxyHelper<CommonAPI::DBus::DBusSerializableArguments<uint32_t, std::string>, CommonAPI::DBus::DBusSerializableArguments<> >::callMethodWithReply( diff --git a/src/test/commonapi/tests/TestInterfaceDBusProxy.h b/src/test/commonapi/tests/TestInterfaceDBusProxy.h index cf3fd76..1ec27be 100644 --- a/src/test/commonapi/tests/TestInterfaceDBusProxy.h +++ b/src/test/commonapi/tests/TestInterfaceDBusProxy.h @@ -4,7 +4,7 @@ #ifndef COMMONAPI_TESTS_TEST_INTERFACE_DBUS_PROXY_H_ #define COMMONAPI_TESTS_TEST_INTERFACE_DBUS_PROXY_H_ -#include "TestInterfaceProxyBase.h" +#include <commonapi/tests/TestInterfaceProxyBase.h> #include <CommonAPI/DBus/DBusFactory.h> #include <CommonAPI/DBus/DBusProxy.h> #include <CommonAPI/DBus/DBusAttribute.h> @@ -24,7 +24,7 @@ class TestInterfaceDBusProxy: virtual public TestInterfaceProxyBase, virtual pub const std::string& objectPath, const std::shared_ptr<CommonAPI::DBus::DBusProxyConnection>& dbusProxyconnection); - virtual ~TestInterfaceDBusProxy() { } + virtual ~TestInterfaceDBusProxy() {} virtual TestPredefinedTypeAttributeAttribute& getTestPredefinedTypeAttributeAttribute(); virtual TestDerivedStructAttributeAttribute& getTestDerivedStructAttributeAttribute(); @@ -32,19 +32,17 @@ class TestInterfaceDBusProxy: virtual public TestInterfaceProxyBase, virtual pub virtual TestPredefinedTypeBroadcastEvent& getTestPredefinedTypeBroadcastEvent(); - + virtual void testEmptyMethod(CommonAPI::CallStatus& callStatus); + virtual std::future<CommonAPI::CallStatus> testEmptyMethodAsync(TestEmptyMethodAsyncCallback callback); virtual void testVoidPredefinedTypeMethod(const uint32_t& uint32Value, const std::string& stringValue, CommonAPI::CallStatus& callStatus); virtual std::future<CommonAPI::CallStatus> testVoidPredefinedTypeMethodAsync(const uint32_t& uint32Value, const std::string& stringValue, TestVoidPredefinedTypeMethodAsyncCallback callback); - virtual void testPredefinedTypeMethod(const uint32_t& uint32InValue, const std::string& stringInValue, CommonAPI::CallStatus& callStatus, uint32_t& uint32OutValue, std::string& stringOutValue); virtual std::future<CommonAPI::CallStatus> testPredefinedTypeMethodAsync(const uint32_t& uint32InValue, const std::string& stringInValue, TestPredefinedTypeMethodAsyncCallback callback); - virtual void testVoidDerivedTypeMethod(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2Value, const DerivedTypeCollection::TestMap& testMapValue, CommonAPI::CallStatus& callStatus); virtual std::future<CommonAPI::CallStatus> testVoidDerivedTypeMethodAsync(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2Value, const DerivedTypeCollection::TestMap& testMapValue, TestVoidDerivedTypeMethodAsyncCallback callback); - virtual void testDerivedTypeMethod(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2InValue, const DerivedTypeCollection::TestMap& testMapInValue, CommonAPI::CallStatus& callStatus, DerivedTypeCollection::TestEnumExtended2& testEnumExtended2OutValue, DerivedTypeCollection::TestMap& testMapOutValue); virtual std::future<CommonAPI::CallStatus> testDerivedTypeMethodAsync(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2InValue, const DerivedTypeCollection::TestMap& testMapInValue, TestDerivedTypeMethodAsyncCallback callback); - + virtual void getOwnVersion(uint16_t& ownVersionMajor, uint16_t& ownVersionMinor) const; private: diff --git a/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp b/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp index 869560e..9145d2c 100644 --- a/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp +++ b/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.cpp @@ -2,7 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "TestInterfaceDBusStubAdapter.h" -#include "TestInterface.h" +#include <commonapi/tests/TestInterface.h> namespace commonapi { namespace tests { @@ -45,14 +45,14 @@ const char* TestInterfaceDBusStubAdapter::getMethodsDBusIntrospectionXmlData() c "<arg name=\"changedValue\" type=\"u\" />\n" "</signal>\n" "<method name=\"getTestDerivedStructAttributeAttribute\">\n" - "<arg name=\"value\" type=\"(sqii)\" direction=\"out\" />" + "<arg name=\"value\" type=\"(sqi)\" direction=\"out\" />" "</method>\n" "<method name=\"setTestDerivedStructAttributeAttribute\">\n" - "<arg name=\"requestedValue\" type=\"(sqii)\" direction=\"in\" />\n" - "<arg name=\"setValue\" type=\"(sqii)\" direction=\"out\" />\n" + "<arg name=\"requestedValue\" type=\"(sqi)\" direction=\"in\" />\n" + "<arg name=\"setValue\" type=\"(sqi)\" direction=\"out\" />\n" "</method>\n" "<signal name=\"onTestDerivedStructAttributeAttributeChanged\">\n" - "<arg name=\"changedValue\" type=\"(sqii)\" />\n" + "<arg name=\"changedValue\" type=\"(sqi)\" />\n" "</signal>\n" "<method name=\"getTestDerivedArrayAttributeAttribute\">\n" "<arg name=\"value\" type=\"at\" direction=\"out\" />" @@ -68,6 +68,8 @@ const char* TestInterfaceDBusStubAdapter::getMethodsDBusIntrospectionXmlData() c "<arg name=\"uint32Value\" type=\"u\" />\n" "<arg name=\"stringValue\" type=\"s\" />\n" "</signal>\n" + "<method name=\"testEmptyMethod\">\n" + "</method>\n" "<method name=\"testVoidPredefinedTypeMethod\">\n" "<arg name=\"uint32Value\" type=\"u\" direction=\"in\" />\n" "<arg name=\"stringValue\" type=\"s\" direction=\"in\" />\n" @@ -109,7 +111,7 @@ static CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< static CommonAPI::DBus::DBusGetAttributeStubDispatcher< TestInterfaceStub, DerivedTypeCollection::TestStructExtended - > getTestDerivedStructAttributeAttributeStubDispatcher(&TestInterfaceStub::getTestDerivedStructAttributeAttribute, "(sqii)"); + > getTestDerivedStructAttributeAttributeStubDispatcher(&TestInterfaceStub::getTestDerivedStructAttributeAttribute, "(sqi)"); static CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< TestInterfaceStub, DerivedTypeCollection::TestStructExtended @@ -118,7 +120,7 @@ static CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< &TestInterfaceStubRemoteEvent::onRemoteSetTestDerivedStructAttributeAttribute, &TestInterfaceStubRemoteEvent::onRemoteTestDerivedStructAttributeAttributeChanged, &TestInterfaceStubAdapter::fireTestDerivedStructAttributeAttributeChanged, - "(sqii)"); + "(sqi)"); static CommonAPI::DBus::DBusGetAttributeStubDispatcher< TestInterfaceStub, @@ -137,6 +139,12 @@ static CommonAPI::DBus::DBusSetObservableAttributeStubDispatcher< static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< TestInterfaceStub, + std::tuple<>, + std::tuple<> + > testEmptyMethodStubDispatcher(&TestInterfaceStub::testEmptyMethod, ""); + +static CommonAPI::DBus::DBusMethodWithReplyStubDispatcher< + TestInterfaceStub, std::tuple<uint32_t, std::string>, std::tuple<> > testVoidPredefinedTypeMethodStubDispatcher(&TestInterfaceStub::testVoidPredefinedTypeMethod, ""); @@ -165,10 +173,11 @@ const TestInterfaceDBusStubAdapterHelper::StubDispatcherTable TestInterfaceDBusS { { "getTestPredefinedTypeAttributeAttribute", "" }, &commonapi::tests::getTestPredefinedTypeAttributeAttributeStubDispatcher } , { { "setTestPredefinedTypeAttributeAttribute", "u" }, &commonapi::tests::setTestPredefinedTypeAttributeAttributeStubDispatcher }, { { "getTestDerivedStructAttributeAttribute", "" }, &commonapi::tests::getTestDerivedStructAttributeAttributeStubDispatcher } - , { { "setTestDerivedStructAttributeAttribute", "(sqii)" }, &commonapi::tests::setTestDerivedStructAttributeAttributeStubDispatcher }, + , { { "setTestDerivedStructAttributeAttribute", "(sqi)" }, &commonapi::tests::setTestDerivedStructAttributeAttributeStubDispatcher }, { { "getTestDerivedArrayAttributeAttribute", "" }, &commonapi::tests::getTestDerivedArrayAttributeAttributeStubDispatcher } , { { "setTestDerivedArrayAttributeAttribute", "at" }, &commonapi::tests::setTestDerivedArrayAttributeAttributeStubDispatcher } , + { { "testEmptyMethod", "" }, &commonapi::tests::testEmptyMethodStubDispatcher }, { { "testVoidPredefinedTypeMethod", "us" }, &commonapi::tests::testVoidPredefinedTypeMethodStubDispatcher }, { { "testPredefinedTypeMethod", "us" }, &commonapi::tests::testPredefinedTypeMethodStubDispatcher }, { { "testVoidDerivedTypeMethod", "ia{ua(sq)}" }, &commonapi::tests::testVoidDerivedTypeMethodStubDispatcher }, @@ -189,7 +198,7 @@ void TestInterfaceDBusStubAdapter::fireTestDerivedStructAttributeAttributeChange ::sendSignal( *this, "onTestDerivedStructAttributeAttributeChanged", - "(sqii)", + "(sqi)", value ); } diff --git a/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.h b/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.h index 7a809ad..651a22b 100644 --- a/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.h +++ b/src/test/commonapi/tests/TestInterfaceDBusStubAdapter.h @@ -4,7 +4,7 @@ #ifndef COMMONAPI_TESTS_TEST_INTERFACE_DBUS_STUB_ADAPTER_H_ #define COMMONAPI_TESTS_TEST_INTERFACE_DBUS_STUB_ADAPTER_H_ -#include "TestInterfaceStub.h" +#include <commonapi/tests/TestInterfaceStub.h> #include <CommonAPI/DBus/DBusStubAdapterHelper.h> #include <CommonAPI/DBus/DBusFactory.h> diff --git a/src/test/commonapi/tests/TestInterfaceProxy.h b/src/test/commonapi/tests/TestInterfaceProxy.h index 0e0c54c..7ab5cdc 100644 --- a/src/test/commonapi/tests/TestInterfaceProxy.h +++ b/src/test/commonapi/tests/TestInterfaceProxy.h @@ -17,31 +17,153 @@ class TestInterfaceProxy: virtual public TestInterface, virtual public TestInter TestInterfaceProxy(std::shared_ptr<CommonAPI::Proxy> delegate); ~TestInterfaceProxy(); + /// Returns the wrapper class that provides access to the attribute TestPredefinedTypeAttribute. virtual TestPredefinedTypeAttributeAttribute& getTestPredefinedTypeAttributeAttribute(); + /// Returns the wrapper class that provides access to the attribute TestDerivedStructAttribute. virtual TestDerivedStructAttributeAttribute& getTestDerivedStructAttributeAttribute(); + /// Returns the wrapper class that provides access to the attribute TestDerivedArrayAttribute. virtual TestDerivedArrayAttributeAttribute& getTestDerivedArrayAttributeAttribute(); + /// Returns the wrapper class that provides access to the broadcast TestPredefinedTypeBroadcast. virtual TestPredefinedTypeBroadcastEvent& getTestPredefinedTypeBroadcastEvent(); + /** + * Calls testEmptyMethod with synchronous semantics. + * + * The CallStatus will be filled when the method returns and indicate either + * "SUCCESS" or which type of error has occurred. In case of an error, ONLY the CallStatus + * will be set. + * Synchronous calls are not supported (will block indefinitely) when mainloop integration is used. + */ + virtual void testEmptyMethod(CommonAPI::CallStatus& callStatus); + /** + * Calls testEmptyMethod with asynchronous semantics. + * + * The provided callback will be called when the reply to this call arrives or + * an error occurs during the call. The CallStatus will indicate either "SUCCESS" + * or which type of error has occurred. In case of any error, ONLY the CallStatus + * will have a defined value. + * The std::future returned by this method will be fulfilled at arrival of the reply. + * It will provide the same value for CallStatus as will be handed to the callback. + */ + virtual std::future<CommonAPI::CallStatus> testEmptyMethodAsync(TestEmptyMethodAsyncCallback callback); + + /** + * Calls testVoidPredefinedTypeMethod with synchronous semantics. + * + * All const parameters are input parameters to this method. + * The CallStatus will be filled when the method returns and indicate either + * "SUCCESS" or which type of error has occurred. In case of an error, ONLY the CallStatus + * will be set. + * Synchronous calls are not supported (will block indefinitely) when mainloop integration is used. + */ virtual void testVoidPredefinedTypeMethod(const uint32_t& uint32Value, const std::string& stringValue, CommonAPI::CallStatus& callStatus); + /** + * Calls testVoidPredefinedTypeMethod with asynchronous semantics. + * + * The provided callback will be called when the reply to this call arrives or + * an error occurs during the call. The CallStatus will indicate either "SUCCESS" + * or which type of error has occurred. In case of any error, ONLY the CallStatus + * will have a defined value. + * The std::future returned by this method will be fulfilled at arrival of the reply. + * It will provide the same value for CallStatus as will be handed to the callback. + */ virtual std::future<CommonAPI::CallStatus> testVoidPredefinedTypeMethodAsync(const uint32_t& uint32Value, const std::string& stringValue, TestVoidPredefinedTypeMethodAsyncCallback callback); + /** + * Calls testPredefinedTypeMethod with synchronous semantics. + * + * All const parameters are input parameters to this method. + * All non-const parameters will be filled with the returned values. + * The CallStatus will be filled when the method returns and indicate either + * "SUCCESS" or which type of error has occurred. In case of an error, ONLY the CallStatus + * will be set. + * Synchronous calls are not supported (will block indefinitely) when mainloop integration is used. + */ virtual void testPredefinedTypeMethod(const uint32_t& uint32InValue, const std::string& stringInValue, CommonAPI::CallStatus& callStatus, uint32_t& uint32OutValue, std::string& stringOutValue); + /** + * Calls testPredefinedTypeMethod with asynchronous semantics. + * + * The provided callback will be called when the reply to this call arrives or + * an error occurs during the call. The CallStatus will indicate either "SUCCESS" + * or which type of error has occurred. In case of any error, ONLY the CallStatus + * will have a defined value. + * The std::future returned by this method will be fulfilled at arrival of the reply. + * It will provide the same value for CallStatus as will be handed to the callback. + */ virtual std::future<CommonAPI::CallStatus> testPredefinedTypeMethodAsync(const uint32_t& uint32InValue, const std::string& stringInValue, TestPredefinedTypeMethodAsyncCallback callback); + /** + * Calls testVoidDerivedTypeMethod with synchronous semantics. + * + * All const parameters are input parameters to this method. + * The CallStatus will be filled when the method returns and indicate either + * "SUCCESS" or which type of error has occurred. In case of an error, ONLY the CallStatus + * will be set. + * Synchronous calls are not supported (will block indefinitely) when mainloop integration is used. + */ virtual void testVoidDerivedTypeMethod(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2Value, const DerivedTypeCollection::TestMap& testMapValue, CommonAPI::CallStatus& callStatus); + /** + * Calls testVoidDerivedTypeMethod with asynchronous semantics. + * + * The provided callback will be called when the reply to this call arrives or + * an error occurs during the call. The CallStatus will indicate either "SUCCESS" + * or which type of error has occurred. In case of any error, ONLY the CallStatus + * will have a defined value. + * The std::future returned by this method will be fulfilled at arrival of the reply. + * It will provide the same value for CallStatus as will be handed to the callback. + */ virtual std::future<CommonAPI::CallStatus> testVoidDerivedTypeMethodAsync(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2Value, const DerivedTypeCollection::TestMap& testMapValue, TestVoidDerivedTypeMethodAsyncCallback callback); + /** + * Calls testDerivedTypeMethod with synchronous semantics. + * + * All const parameters are input parameters to this method. + * All non-const parameters will be filled with the returned values. + * The CallStatus will be filled when the method returns and indicate either + * "SUCCESS" or which type of error has occurred. In case of an error, ONLY the CallStatus + * will be set. + * Synchronous calls are not supported (will block indefinitely) when mainloop integration is used. + */ virtual void testDerivedTypeMethod(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2InValue, const DerivedTypeCollection::TestMap& testMapInValue, CommonAPI::CallStatus& callStatus, DerivedTypeCollection::TestEnumExtended2& testEnumExtended2OutValue, DerivedTypeCollection::TestMap& testMapOutValue); + /** + * Calls testDerivedTypeMethod with asynchronous semantics. + * + * The provided callback will be called when the reply to this call arrives or + * an error occurs during the call. The CallStatus will indicate either "SUCCESS" + * or which type of error has occurred. In case of any error, ONLY the CallStatus + * will have a defined value. + * The std::future returned by this method will be fulfilled at arrival of the reply. + * It will provide the same value for CallStatus as will be handed to the callback. + */ virtual std::future<CommonAPI::CallStatus> testDerivedTypeMethodAsync(const DerivedTypeCollection::TestEnumExtended2& testEnumExtended2InValue, const DerivedTypeCollection::TestMap& testMapInValue, TestDerivedTypeMethodAsyncCallback callback); + /// Returns the CommonAPI address of the remote partner this proxy communicates with. virtual std::string getAddress() const; + + /// Returns the domain of the remote partner this proxy communicates with. virtual const std::string& getDomain() const; + + /// Returns the service ID of the remote partner this proxy communicates with. virtual const std::string& getServiceId() const; + + /// Returns the instance ID of the remote partner this proxy communicates with. virtual const std::string& getInstanceId() const; + + /// Returns true if the remote partner for this proxy is available. virtual bool isAvailable() const; + + /** + * Returns the wrapper class that is used to (de-)register for notifications about + * the availability of the remote partner of this proxy. + */ virtual CommonAPI::ProxyStatusEvent& getProxyStatusEvent(); + + /** + * Returns the wrapper class that is used to access version information of the remote + * partner of this proxy. + */ virtual CommonAPI::InterfaceVersionAttribute& getInterfaceVersionAttribute(); private: @@ -144,6 +266,16 @@ typename TestInterfaceProxy<_AttributeExtensions...>::TestPredefinedTypeBroadcas template <typename ... _AttributeExtensions> +void TestInterfaceProxy<_AttributeExtensions...>::testEmptyMethod(CommonAPI::CallStatus& callStatus) { + delegate_->testEmptyMethod(callStatus); +} + +template <typename ... _AttributeExtensions> +std::future<CommonAPI::CallStatus> TestInterfaceProxy<_AttributeExtensions...>::testEmptyMethodAsync(TestEmptyMethodAsyncCallback callback) { + return delegate_->testEmptyMethodAsync(callback); +} + +template <typename ... _AttributeExtensions> void TestInterfaceProxy<_AttributeExtensions...>::testVoidPredefinedTypeMethod(const uint32_t& uint32Value, const std::string& stringValue, CommonAPI::CallStatus& callStatus) { delegate_->testVoidPredefinedTypeMethod(uint32Value, stringValue, callStatus); } diff --git a/src/test/commonapi/tests/TestInterfaceProxyBase.h b/src/test/commonapi/tests/TestInterfaceProxyBase.h index 4210e25..6ae5263 100644 --- a/src/test/commonapi/tests/TestInterfaceProxyBase.h +++ b/src/test/commonapi/tests/TestInterfaceProxyBase.h @@ -7,8 +7,7 @@ #include "TestInterface.h" #include <unordered_map> #include <cstdint> -#include "PredefinedTypeCollection.h" -#include "DerivedTypeCollection.h" +#include <commonapi/tests/DerivedTypeCollection.h> #include <CommonAPI/InputStream.h> #include <vector> #include <CommonAPI/OutputStream.h> @@ -27,6 +26,7 @@ class TestInterfaceProxyBase: virtual public CommonAPI::Proxy { typedef CommonAPI::ObservableAttribute<DerivedTypeCollection::TestStructExtended> TestDerivedStructAttributeAttribute; typedef CommonAPI::ObservableAttribute<DerivedTypeCollection::TestArrayUInt64> TestDerivedArrayAttributeAttribute; typedef CommonAPI::Event<uint32_t, std::string> TestPredefinedTypeBroadcastEvent; + typedef std::function<void(const CommonAPI::CallStatus&)> TestEmptyMethodAsyncCallback; typedef std::function<void(const CommonAPI::CallStatus&)> TestVoidPredefinedTypeMethodAsyncCallback; typedef std::function<void(const CommonAPI::CallStatus&, const uint32_t&, const std::string&)> TestPredefinedTypeMethodAsyncCallback; typedef std::function<void(const CommonAPI::CallStatus&)> TestVoidDerivedTypeMethodAsyncCallback; @@ -39,6 +39,9 @@ class TestInterfaceProxyBase: virtual public CommonAPI::Proxy { virtual TestPredefinedTypeBroadcastEvent& getTestPredefinedTypeBroadcastEvent() = 0; + virtual void testEmptyMethod(CommonAPI::CallStatus& callStatus) = 0; + virtual std::future<CommonAPI::CallStatus> testEmptyMethodAsync(TestEmptyMethodAsyncCallback callback) = 0; + virtual void testVoidPredefinedTypeMethod(const uint32_t& uint32Value, const std::string& stringValue, CommonAPI::CallStatus& callStatus) = 0; virtual std::future<CommonAPI::CallStatus> testVoidPredefinedTypeMethodAsync(const uint32_t& uint32Value, const std::string& stringValue, TestVoidPredefinedTypeMethodAsyncCallback callback) = 0; diff --git a/src/test/commonapi/tests/TestInterfaceStub.h b/src/test/commonapi/tests/TestInterfaceStub.h index ac34f79..6d078ed 100644 --- a/src/test/commonapi/tests/TestInterfaceStub.h +++ b/src/test/commonapi/tests/TestInterfaceStub.h @@ -6,8 +6,7 @@ #include <unordered_map> #include <cstdint> -#include "PredefinedTypeCollection.h" -#include "DerivedTypeCollection.h" +#include <commonapi/tests/DerivedTypeCollection.h> #include <CommonAPI/InputStream.h> #include <vector> #include <CommonAPI/OutputStream.h> @@ -17,45 +16,92 @@ namespace commonapi { namespace tests { +/** + * Receives messages from remote and handles all dispatching of deserialized calls + * to a stub for the service TestInterface. Also provides means to send broadcasts + * and attribute-changed-notifications of observable attributes as defined by this service. + * An application developer should not need to bother with this class. + */ class TestInterfaceStubAdapter: virtual public CommonAPI::StubAdapter, public TestInterface { public: + ///Notifies all remote listeners about a change of value of the attribute TestPredefinedTypeAttribute. virtual void fireTestPredefinedTypeAttributeAttributeChanged(const uint32_t& TestPredefinedTypeAttribute) = 0; + ///Notifies all remote listeners about a change of value of the attribute TestDerivedStructAttribute. virtual void fireTestDerivedStructAttributeAttributeChanged(const DerivedTypeCollection::TestStructExtended& TestDerivedStructAttribute) = 0; + ///Notifies all remote listeners about a change of value of the attribute TestDerivedArrayAttribute. virtual void fireTestDerivedArrayAttributeAttributeChanged(const DerivedTypeCollection::TestArrayUInt64& TestDerivedArrayAttribute) = 0; + /** + * Sends a broadcast event for TestPredefinedTypeBroadcast. Should not be called directly. + * Instead, the "fire<broadcastName>Event" methods of the stub should be used. + */ virtual void fireTestPredefinedTypeBroadcastEvent(const uint32_t& uint32Value, const std::string& stringValue) = 0; }; +/** + * Defines the necessary callbacks to handle remote set events related to the attributes + * defined in the IDL description for TestInterface. + * For each attribute two callbacks are defined: + * - a verification callback that allows to verify the requested value and to prevent setting + * e.g. an invalid value ("onRemoteSet<AttributeName>"). + * - an action callback to do local work after the attribute value has been changed + * ("onRemote<AttributeName>Changed"). + * + * 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 TestInterfaceStubRemoteEvent { public: virtual ~TestInterfaceStubRemoteEvent() { } + /// Verification callback for remote set requests on the attribute TestPredefinedTypeAttribute. virtual bool onRemoteSetTestPredefinedTypeAttributeAttribute(uint32_t TestPredefinedTypeAttribute) = 0; + /// Action callback for remote set requests on the attribute TestPredefinedTypeAttribute. virtual void onRemoteTestPredefinedTypeAttributeAttributeChanged() = 0; + /// Verification callback for remote set requests on the attribute TestDerivedStructAttribute. virtual bool onRemoteSetTestDerivedStructAttributeAttribute(DerivedTypeCollection::TestStructExtended TestDerivedStructAttribute) = 0; + /// Action callback for remote set requests on the attribute TestDerivedStructAttribute. virtual void onRemoteTestDerivedStructAttributeAttributeChanged() = 0; + /// Verification callback for remote set requests on the attribute TestDerivedArrayAttribute. virtual bool onRemoteSetTestDerivedArrayAttributeAttribute(DerivedTypeCollection::TestArrayUInt64 TestDerivedArrayAttribute) = 0; + /// Action callback for remote set requests on the attribute TestDerivedArrayAttribute. virtual void onRemoteTestDerivedArrayAttributeAttributeChanged() = 0; }; +/** + * Defines the interface that must be implemented by any class that should provide + * the service TestInterface to remote clients. + * 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 CommonAPI::Stub<TestInterfaceStubAdapter , TestInterfaceStubRemoteEvent> { public: virtual ~TestInterfaceStub() { } + /// Provides getter access to the attribute TestPredefinedTypeAttribute. virtual const uint32_t& getTestPredefinedTypeAttributeAttribute() = 0; + /// Provides getter access to the attribute TestDerivedStructAttribute. virtual const DerivedTypeCollection::TestStructExtended& getTestDerivedStructAttributeAttribute() = 0; + /// Provides getter access to the attribute TestDerivedArrayAttribute. virtual const DerivedTypeCollection::TestArrayUInt64& getTestDerivedArrayAttributeAttribute() = 0; + /// This is the method that will be called on remote calls on the method testEmptyMethod. + virtual void testEmptyMethod() = 0; + /// This is the method that will be called on remote calls on the method testVoidPredefinedTypeMethod. virtual void testVoidPredefinedTypeMethod(uint32_t uint32Value, std::string stringValue) = 0; + /// This is the method that will be called on remote calls on the method testPredefinedTypeMethod. virtual void testPredefinedTypeMethod(uint32_t uint32InValue, std::string stringInValue, uint32_t& uint32OutValue, std::string& stringOutValue) = 0; + /// This is the method that will be called on remote calls on the method testVoidDerivedTypeMethod. virtual void testVoidDerivedTypeMethod(DerivedTypeCollection::TestEnumExtended2 testEnumExtended2Value, DerivedTypeCollection::TestMap testMapValue) = 0; + /// This is the method that will be called on remote calls on the method testDerivedTypeMethod. virtual void testDerivedTypeMethod(DerivedTypeCollection::TestEnumExtended2 testEnumExtended2InValue, DerivedTypeCollection::TestMap testMapInValue, DerivedTypeCollection::TestEnumExtended2& testEnumExtended2OutValue, DerivedTypeCollection::TestMap& testMapOutValue) = 0; + /// Sends a broadcast event for TestPredefinedTypeBroadcast. virtual void fireTestPredefinedTypeBroadcastEvent(const uint32_t& uint32Value, const std::string& stringValue) = 0; }; diff --git a/src/test/commonapi/tests/TestInterfaceStubDefault.cpp b/src/test/commonapi/tests/TestInterfaceStubDefault.cpp index c5e7e35..d852c0c 100644 --- a/src/test/commonapi/tests/TestInterfaceStubDefault.cpp +++ b/src/test/commonapi/tests/TestInterfaceStubDefault.cpp @@ -1,7 +1,7 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "TestInterfaceStubDefault.h" +#include <commonapi/tests/TestInterfaceStubDefault.h> namespace commonapi { namespace tests { @@ -15,10 +15,6 @@ TestInterfaceStubRemoteEvent* TestInterfaceStubDefault::initStubAdapter(const st return &remoteEventHandler_; } -void TestInterfaceStubDefault::deinitStubAdapter() { - stubAdapter_.reset(); -} - const uint32_t& TestInterfaceStubDefault::getTestPredefinedTypeAttributeAttribute() { return testPredefinedTypeAttributeAttributeValue_; } @@ -46,6 +42,14 @@ bool TestInterfaceStubDefault::validateTestPredefinedTypeAttributeAttributeReque return true; } +bool TestInterfaceStubDefault::RemoteEventHandler::onRemoteSetTestPredefinedTypeAttributeAttribute(uint32_t value) { + return defaultStub_->trySetTestPredefinedTypeAttributeAttribute(std::move(value)); +} + +void TestInterfaceStubDefault::RemoteEventHandler::onRemoteTestPredefinedTypeAttributeAttributeChanged() { + defaultStub_->onRemoteTestPredefinedTypeAttributeAttributeChanged(); +} + const DerivedTypeCollection::TestStructExtended& TestInterfaceStubDefault::getTestDerivedStructAttributeAttribute() { return testDerivedStructAttributeAttributeValue_; } @@ -73,6 +77,14 @@ bool TestInterfaceStubDefault::validateTestDerivedStructAttributeAttributeReques return true; } +bool TestInterfaceStubDefault::RemoteEventHandler::onRemoteSetTestDerivedStructAttributeAttribute(DerivedTypeCollection::TestStructExtended value) { + return defaultStub_->trySetTestDerivedStructAttributeAttribute(std::move(value)); +} + +void TestInterfaceStubDefault::RemoteEventHandler::onRemoteTestDerivedStructAttributeAttributeChanged() { + defaultStub_->onRemoteTestDerivedStructAttributeAttributeChanged(); +} + const DerivedTypeCollection::TestArrayUInt64& TestInterfaceStubDefault::getTestDerivedArrayAttributeAttribute() { return testDerivedArrayAttributeAttributeValue_; } @@ -100,6 +112,18 @@ bool TestInterfaceStubDefault::validateTestDerivedArrayAttributeAttributeRequest return true; } +bool TestInterfaceStubDefault::RemoteEventHandler::onRemoteSetTestDerivedArrayAttributeAttribute(DerivedTypeCollection::TestArrayUInt64 value) { + return defaultStub_->trySetTestDerivedArrayAttributeAttribute(std::move(value)); +} + +void TestInterfaceStubDefault::RemoteEventHandler::onRemoteTestDerivedArrayAttributeAttributeChanged() { + defaultStub_->onRemoteTestDerivedArrayAttributeAttributeChanged(); +} + + +void TestInterfaceStubDefault::testEmptyMethod() { + // No operation in default +} void TestInterfaceStubDefault::testVoidPredefinedTypeMethod(uint32_t uint32Value, std::string stringValue) { // No operation in default @@ -126,30 +150,5 @@ TestInterfaceStubDefault::RemoteEventHandler::RemoteEventHandler(TestInterfaceSt defaultStub_(defaultStub) { } -bool TestInterfaceStubDefault::RemoteEventHandler::onRemoteSetTestPredefinedTypeAttributeAttribute(uint32_t value) { - return defaultStub_->trySetTestPredefinedTypeAttributeAttribute(std::move(value)); -} - -void TestInterfaceStubDefault::RemoteEventHandler::onRemoteTestPredefinedTypeAttributeAttributeChanged() { - defaultStub_->onRemoteTestPredefinedTypeAttributeAttributeChanged(); -} - -bool TestInterfaceStubDefault::RemoteEventHandler::onRemoteSetTestDerivedStructAttributeAttribute(DerivedTypeCollection::TestStructExtended value) { - return defaultStub_->trySetTestDerivedStructAttributeAttribute(std::move(value)); -} - -void TestInterfaceStubDefault::RemoteEventHandler::onRemoteTestDerivedStructAttributeAttributeChanged() { - defaultStub_->onRemoteTestDerivedStructAttributeAttributeChanged(); -} - -bool TestInterfaceStubDefault::RemoteEventHandler::onRemoteSetTestDerivedArrayAttributeAttribute(DerivedTypeCollection::TestArrayUInt64 value) { - return defaultStub_->trySetTestDerivedArrayAttributeAttribute(std::move(value)); -} - -void TestInterfaceStubDefault::RemoteEventHandler::onRemoteTestDerivedArrayAttributeAttributeChanged() { - defaultStub_->onRemoteTestDerivedArrayAttributeAttributeChanged(); -} - - } // namespace tests } // namespace commonapi diff --git a/src/test/commonapi/tests/TestInterfaceStubDefault.h b/src/test/commonapi/tests/TestInterfaceStubDefault.h index bc5cdff..3f0aeff 100644 --- a/src/test/commonapi/tests/TestInterfaceStubDefault.h +++ b/src/test/commonapi/tests/TestInterfaceStubDefault.h @@ -4,17 +4,26 @@ #ifndef COMMONAPI_TESTS_TEST_INTERFACE_STUB_DEFAULT_H_ #define COMMONAPI_TESTS_TEST_INTERFACE_STUB_DEFAULT_H_ -#include "TestInterfaceStub.h" +#include <commonapi/tests/TestInterfaceStub.h> namespace commonapi { namespace tests { +/** + * Provides a default implementation for TestInterfaceStubRemoteEvent and + * TestInterfaceStub. Method callbacks have an empty implementation, + * remote set calls on attributes will always change the value of the attribute + * to the one received. + * + * Override this stub if you only want to provide a subset of the functionality + * that would be defined for this service, and/or if you do not need any non-default + * behaviour. + */ class TestInterfaceStubDefault : public TestInterfaceStub { public: TestInterfaceStubDefault(); TestInterfaceStubRemoteEvent* initStubAdapter(const std::shared_ptr<TestInterfaceStubAdapter>& stubAdapter); - void deinitStubAdapter(); virtual const uint32_t& getTestPredefinedTypeAttributeAttribute(); virtual void setTestPredefinedTypeAttributeAttribute(uint32_t value); @@ -26,6 +35,8 @@ class TestInterfaceStubDefault : public TestInterfaceStub { virtual void setTestDerivedArrayAttributeAttribute(DerivedTypeCollection::TestArrayUInt64 value); + virtual void testEmptyMethod(); + virtual void testVoidPredefinedTypeMethod(uint32_t uint32Value, std::string stringValue); virtual void testPredefinedTypeMethod(uint32_t uint32InValue, std::string stringInValue, uint32_t& uint32OutValue, std::string& stringOutValue); diff --git a/src/test/test-derived-types.fidl b/src/test/test-derived-types.fidl index 7b8c477..48343f9 100644 --- a/src/test/test-derived-types.fidl +++ b/src/test/test-derived-types.fidl @@ -1,56 +1,60 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package commonapi.tests - -import commonapi.tests.* from "test-predefined-types.fidl" - -typeCollection DerivedTypeCollection { - <** @description : Common errors. **> - enumeration TestEnum { - <** @description : default **> - E_UNKNOWN = "0x00" - <** @description : no error - positive reply **> - E_OK = "0x01" - <** @description : value out of range **> - E_OUT_OF_RANGE = "0x02" - <** @description : not used **> - E_NOT_USED = "0x03" - } - - enumeration TestEnumMissingValue { - <** @description : default **> - E1 = "A" - E2 - E3 = "2" - } - - enumeration TestEnumExtended extends TestEnum { - <** @description : new error **> - E_NEW = "0x04" - } - - enumeration TestEnumExtended2 extends TestEnumExtended { - <** @description : new error **> - E_NEW2 = "0x05" - } - - struct TestStruct { - <** @description : the name of the property **> - PredefinedTypeCollection.TestString testString - - <** @description : the actual value **> - UInt16 uintValue - } - - struct TestStructExtended extends TestStruct { - TestEnumExtended2 testEnumExtended2 - } - - array TestArrayUInt64 of UInt64 - array TestArrayTestStruct of TestStruct - - map TestMap { UInt32 to TestArrayTestStruct } -} - - +/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+package commonapi.tests
+
+import commonapi.tests.* from "test-predefined-types.fidl"
+
+typeCollection DerivedTypeCollection {
+
+ map TestMap { UInt32 to TestArrayTestStruct }
+
+ struct TestStructExtended extends TestStruct {
+ TestEnumExtended2 testEnumExtended2
+ }
+
+ map TestEnumMap { TestEnum to String }
+
+ <** @description : Common errors. **>
+ enumeration TestEnum {
+ <** @description : default **>
+ E_UNKNOWN = "0x00"
+ <** @description : no error - positive reply **>
+ E_OK = "0x01"
+ <** @description : value out of range **>
+ E_OUT_OF_RANGE = "0x02"
+ <** @description : not used **>
+ E_NOT_USED = "0x03"
+ }
+
+ array TestArrayTestStruct of TestStruct
+
+ enumeration TestEnumExtended2 extends TestEnumExtended {
+ <** @description : new error **>
+ E_NEW2 = "0x05"
+ }
+
+ enumeration TestEnumMissingValue {
+ <** @description : default **>
+ E1 = "A"
+ E2
+ E3 = "2"
+ }
+
+ enumeration TestEnumExtended extends TestEnum {
+ <** @description : new error **>
+ E_NEW = "0x04"
+ }
+
+ array TestArrayUInt64 of UInt64
+
+ struct TestStruct {
+ <** @description : the name of the property **>
+ PredefinedTypeCollection.TestString testString
+
+ <** @description : the actual value **>
+ UInt16 uintValue
+ }
+}
+
+
diff --git a/src/test/test-interface-proxy.fidl b/src/test/test-interface-proxy.fidl index 88d4874..094897b 100644 --- a/src/test/test-interface-proxy.fidl +++ b/src/test/test-interface-proxy.fidl @@ -1,58 +1,61 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package commonapi.tests - -import commonapi.tests.* from "test-derived-types.fidl" - -interface TestInterface { - version { major 1 minor 0 } - - attribute UInt32 TestPredefinedTypeAttribute - attribute DerivedTypeCollection.TestStructExtended TestDerivedStructAttribute - attribute DerivedTypeCollection.TestArrayUInt64 TestDerivedArrayAttribute - - method testVoidPredefinedTypeMethod { - in { - UInt32 uint32Value - String stringValue - } - } - - method testPredefinedTypeMethod { - in { - UInt32 uint32InValue - String stringInValue - } - out { - UInt32 uint32OutValue - String stringOutValue - } - } - - method testVoidDerivedTypeMethod { - in { - DerivedTypeCollection.TestEnumExtended2 testEnumExtended2Value - DerivedTypeCollection.TestMap testMapValue - } - } - - method testDerivedTypeMethod { - in { - DerivedTypeCollection.TestEnumExtended2 testEnumExtended2InValue - DerivedTypeCollection.TestMap testMapInValue - } - out { - DerivedTypeCollection.TestEnumExtended2 testEnumExtended2OutValue - DerivedTypeCollection.TestMap testMapOutValue - } - } - - broadcast TestPredefinedTypeBroadcast { - out { - UInt32 uint32Value - String stringValue - } - } -} - +/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+package commonapi.tests
+
+import commonapi.tests.* from "test-derived-types.fidl"
+
+interface TestInterface {
+ version { major 1 minor 0 }
+
+ attribute UInt32 TestPredefinedTypeAttribute
+ attribute DerivedTypeCollection.TestStructExtended TestDerivedStructAttribute
+ attribute DerivedTypeCollection.TestArrayUInt64 TestDerivedArrayAttribute
+
+ method testEmptyMethod {
+ }
+
+ method testVoidPredefinedTypeMethod {
+ in {
+ UInt32 uint32Value
+ String stringValue
+ }
+ }
+
+ method testPredefinedTypeMethod {
+ in {
+ UInt32 uint32InValue
+ String stringInValue
+ }
+ out {
+ UInt32 uint32OutValue
+ String stringOutValue
+ }
+ }
+
+ method testVoidDerivedTypeMethod {
+ in {
+ DerivedTypeCollection.TestEnumExtended2 testEnumExtended2Value
+ DerivedTypeCollection.TestMap testMapValue
+ }
+ }
+
+ method testDerivedTypeMethod {
+ in {
+ DerivedTypeCollection.TestEnumExtended2 testEnumExtended2InValue
+ DerivedTypeCollection.TestMap testMapInValue
+ }
+ out {
+ DerivedTypeCollection.TestEnumExtended2 testEnumExtended2OutValue
+ DerivedTypeCollection.TestMap testMapOutValue
+ }
+ }
+
+ broadcast TestPredefinedTypeBroadcast {
+ out {
+ UInt32 uint32Value
+ String stringValue
+ }
+ }
+}
+
diff --git a/src/test/test-predefined-types.fidl b/src/test/test-predefined-types.fidl index 6226ed2..8a69103 100644 --- a/src/test/test-predefined-types.fidl +++ b/src/test/test-predefined-types.fidl @@ -1,22 +1,22 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package commonapi.tests - -typeCollection PredefinedTypeCollection { - typedef TestUInt8 is UInt8 - typedef TestUInt16 is UInt16 - typedef TestUInt32 is UInt32 - typedef TestUInt64 is UInt64 - typedef TestInt8 is Int8 - typedef TestInt16 is Int16 - typedef TestInt32 is Int32 - typedef TestInt64 is Int64 - typedef TestBoolean is Boolean - typedef TestByteBuffer is ByteBuffer - typedef TestDouble is Double - typedef TestFloat is Float - typedef TestString is String -} - - +/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+package commonapi.tests
+
+typeCollection PredefinedTypeCollection {
+ typedef TestUInt8 is UInt8
+ typedef TestUInt16 is UInt16
+ typedef TestUInt32 is UInt32
+ typedef TestUInt64 is UInt64
+ typedef TestInt8 is Int8
+ typedef TestInt16 is Int16
+ typedef TestInt32 is Int32
+ typedef TestInt64 is Int64
+ typedef TestBoolean is Boolean
+ typedef TestByteBuffer is ByteBuffer
+ typedef TestDouble is Double
+ typedef TestFloat is Float
+ typedef TestString is String
+}
+
+
|