From 847b14511a973be167af465491226a86492a10c6 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Wed, 19 Oct 2016 14:10:55 -0700 Subject: [PATCH] Adds tests to verify proper marshaling of vectors of interface types. Bug: 30570663 Test: hidl_test Change-Id: I1e4d1f826773abbde6b9019eb6af90ac64007e38 --- tests/bar/1.0/default/Bar.cpp | 16 ++++++++++++++++ tests/bar/1.0/default/Bar.h | 9 +++++++++ tests/foo/1.0/Android.bp | 8 ++++++++ tests/foo/1.0/IFoo.hal | 6 ++++++ tests/foo/1.0/ISimple.hal | 21 +++++++++++++++++++++ tests/foo/1.0/default/Foo.cpp | 15 +++++++++++++++ tests/foo/1.0/default/Foo.h | 8 ++++++++ 7 files changed, 83 insertions(+) create mode 100644 tests/foo/1.0/ISimple.hal diff --git a/tests/bar/1.0/default/Bar.cpp b/tests/bar/1.0/default/Bar.cpp index 44338028d0..6da9eec4e5 100644 --- a/tests/bar/1.0/default/Bar.cpp +++ b/tests/bar/1.0/default/Bar.cpp @@ -118,6 +118,22 @@ Return Bar::sendVecVec(sendVecVec_cb _hidl_cb) { return mFoo->sendVecVec(_hidl_cb); } +Return Bar::haveAVectorOfInterfaces( + const hidl_vec > &in, + haveAVectorOfInterfaces_cb _hidl_cb) { + _hidl_cb(in); + + return Void(); +} + +Return Bar::haveAVectorOfGenericInterfaces( + const hidl_vec > &in, + haveAVectorOfGenericInterfaces_cb _hidl_cb) { + _hidl_cb(in); + + return Void(); +} + // Methods from ::android::hardware::tests::bar::V1_0::IBar follow. Return Bar::thisIsNew() { ALOGI("SERVER(Bar) thisIsNew"); diff --git a/tests/bar/1.0/default/Bar.h b/tests/bar/1.0/default/Bar.h index 58d9f9a1ba..ae18d93ce6 100644 --- a/tests/bar/1.0/default/Bar.h +++ b/tests/bar/1.0/default/Bar.h @@ -16,6 +16,7 @@ using ::android::hardware::tests::bar::V1_0::IBar; using ::android::hardware::tests::foo::V1_0::Abc; using ::android::hardware::tests::foo::V1_0::IFoo; using ::android::hardware::tests::foo::V1_0::IFooCallback; +using ::android::hardware::tests::foo::V1_0::ISimple; using ::android::hardware::Return; using ::android::hardware::Void; using ::android::hardware::hidl_vec; @@ -49,6 +50,14 @@ struct Bar : public IBar { virtual Return sendVec(const hidl_vec& data, sendVec_cb _hidl_cb) override; virtual Return sendVecVec(sendVecVec_cb _hidl_cb) override; + Return haveAVectorOfInterfaces( + const hidl_vec > &in, + haveAVectorOfInterfaces_cb _hidl_cb) override; + + Return haveAVectorOfGenericInterfaces( + const hidl_vec > &in, + haveAVectorOfGenericInterfaces_cb _hidl_cb) override; + // Methods from ::android::hardware::tests::bar::V1_0::IBar follow. Return thisIsNew() override; diff --git a/tests/foo/1.0/Android.bp b/tests/foo/1.0/Android.bp index 1fbb7bd5fd..e7bcad245c 100644 --- a/tests/foo/1.0/Android.bp +++ b/tests/foo/1.0/Android.bp @@ -9,6 +9,7 @@ genrule { "IFoo.hal", "IFooCallback.hal", "IMyTypes.hal", + "ISimple.hal", "ITheirTypes.hal", ], out: [ @@ -16,6 +17,7 @@ genrule { "android/hardware/tests/foo/1.0/FooAll.cpp", "android/hardware/tests/foo/1.0/FooCallbackAll.cpp", "android/hardware/tests/foo/1.0/MyTypesAll.cpp", + "android/hardware/tests/foo/1.0/SimpleAll.cpp", "android/hardware/tests/foo/1.0/TheirTypesAll.cpp", ], } @@ -29,6 +31,7 @@ genrule { "IFoo.hal", "IFooCallback.hal", "IMyTypes.hal", + "ISimple.hal", "ITheirTypes.hal", ], out: [ @@ -48,6 +51,11 @@ genrule { "android/hardware/tests/foo/1.0/BnMyTypes.h", "android/hardware/tests/foo/1.0/BpMyTypes.h", "android/hardware/tests/foo/1.0/BsMyTypes.h", + "android/hardware/tests/foo/1.0/ISimple.h", + "android/hardware/tests/foo/1.0/IHwSimple.h", + "android/hardware/tests/foo/1.0/BnSimple.h", + "android/hardware/tests/foo/1.0/BpSimple.h", + "android/hardware/tests/foo/1.0/BsSimple.h", "android/hardware/tests/foo/1.0/ITheirTypes.h", "android/hardware/tests/foo/1.0/IHwTheirTypes.h", "android/hardware/tests/foo/1.0/BnTheirTypes.h", diff --git a/tests/foo/1.0/IFoo.hal b/tests/foo/1.0/IFoo.hal index 614f1e45aa..b6ef5c8799 100644 --- a/tests/foo/1.0/IFoo.hal +++ b/tests/foo/1.0/IFoo.hal @@ -18,6 +18,7 @@ package android.hardware.tests.foo@1.0; import IFooCallback; import IMyTypes.SomeStruct; +import ISimple; import ITheirTypes.FloatArray; interface IFoo { @@ -107,4 +108,9 @@ interface IFoo { sendVec(vec data) generates (vec data); sendVecVec() generates (vec> vecvec); + + haveAVectorOfInterfaces(vec in) generates (vec out); + + haveAVectorOfGenericInterfaces(vec in) + generates (vec out); }; diff --git a/tests/foo/1.0/ISimple.hal b/tests/foo/1.0/ISimple.hal new file mode 100644 index 0000000000..92e9d95ea0 --- /dev/null +++ b/tests/foo/1.0/ISimple.hal @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.hardware.tests.foo@1.0; + +interface ISimple { + getCookie() generates (int32_t cookie); +}; diff --git a/tests/foo/1.0/default/Foo.cpp b/tests/foo/1.0/default/Foo.cpp index 81aa78b3b0..57d4b6b660 100644 --- a/tests/foo/1.0/default/Foo.cpp +++ b/tests/foo/1.0/default/Foo.cpp @@ -396,6 +396,21 @@ Return Foo::sendVecVec(sendVecVec_cb _hidl_cb) { return Void(); } +Return Foo::haveAVectorOfInterfaces( + const hidl_vec > &in, + haveAVectorOfInterfaces_cb _hidl_cb) { + _hidl_cb(in); + + return Void(); +} + +Return Foo::haveAVectorOfGenericInterfaces( + const hidl_vec > &in, + haveAVectorOfGenericInterfaces_cb _hidl_cb) { + _hidl_cb(in); + + return Void(); +} IFoo* HIDL_FETCH_IFoo(const char* /* name */) { return new Foo(); diff --git a/tests/foo/1.0/default/Foo.h b/tests/foo/1.0/default/Foo.h index 00a29f5db5..804a6a3d5e 100644 --- a/tests/foo/1.0/default/Foo.h +++ b/tests/foo/1.0/default/Foo.h @@ -15,6 +15,7 @@ namespace implementation { using ::android::hardware::tests::foo::V1_0::Abc; using ::android::hardware::tests::foo::V1_0::IFoo; using ::android::hardware::tests::foo::V1_0::IFooCallback; +using ::android::hardware::tests::foo::V1_0::ISimple; using ::android::hardware::Return; using ::android::hardware::Void; using ::android::hardware::hidl_vec; @@ -45,6 +46,13 @@ struct Foo : public IFoo { virtual Return sendVec(const hidl_vec& data, sendVec_cb _hidl_cb) override; virtual Return sendVecVec(sendVecVec_cb _hidl_cb) override; + Return haveAVectorOfInterfaces( + const hidl_vec > &in, + haveAVectorOfInterfaces_cb _hidl_cb) override; + + Return haveAVectorOfGenericInterfaces( + const hidl_vec > &in, + haveAVectorOfGenericInterfaces_cb _hidl_cb) override; }; extern "C" IFoo* HIDL_FETCH_IFoo(const char* name);