Adds tests to verify proper marshaling of vectors of interface types.

Bug: 30570663
Test: hidl_test
Change-Id: I1e4d1f826773abbde6b9019eb6af90ac64007e38
diff --git a/tests/foo/1.0/Android.bp b/tests/foo/1.0/Android.bp
index 1fbb7bd..e7bcad2 100644
--- a/tests/foo/1.0/Android.bp
+++ b/tests/foo/1.0/Android.bp
@@ -9,6 +9,7 @@
         "IFoo.hal",
         "IFooCallback.hal",
         "IMyTypes.hal",
+        "ISimple.hal",
         "ITheirTypes.hal",
     ],
     out: [
@@ -16,6 +17,7 @@
         "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 @@
         "IFoo.hal",
         "IFooCallback.hal",
         "IMyTypes.hal",
+        "ISimple.hal",
         "ITheirTypes.hal",
     ],
     out: [
@@ -48,6 +51,11 @@
         "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 614f1e4..b6ef5c8 100644
--- a/tests/foo/1.0/IFoo.hal
+++ b/tests/foo/1.0/IFoo.hal
@@ -18,6 +18,7 @@
 
 import IFooCallback;
 import IMyTypes.SomeStruct;
+import ISimple;
 import ITheirTypes.FloatArray;
 
 interface IFoo {
@@ -107,4 +108,9 @@
     sendVec(vec<uint8_t> data) generates (vec<uint8_t> data);
 
     sendVecVec() generates (vec<vec<uint8_t>> vecvec);
+
+    haveAVectorOfInterfaces(vec<ISimple> in) generates (vec<ISimple> out);
+
+    haveAVectorOfGenericInterfaces(vec<interface> in)
+        generates (vec<interface> out);
 };
diff --git a/tests/foo/1.0/ISimple.hal b/tests/foo/1.0/ISimple.hal
new file mode 100644
index 0000000..92e9d95
--- /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 81aa78b..57d4b6b 100644
--- a/tests/foo/1.0/default/Foo.cpp
+++ b/tests/foo/1.0/default/Foo.cpp
@@ -396,6 +396,21 @@
     return Void();
 }
 
+Return<void> Foo::haveAVectorOfInterfaces(
+        const hidl_vec<sp<ISimple> > &in,
+        haveAVectorOfInterfaces_cb _hidl_cb) {
+    _hidl_cb(in);
+
+    return Void();
+}
+
+Return<void> Foo::haveAVectorOfGenericInterfaces(
+        const hidl_vec<sp<android::hardware::IBinder> > &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 00a29f5..804a6a3 100644
--- a/tests/foo/1.0/default/Foo.h
+++ b/tests/foo/1.0/default/Foo.h
@@ -15,6 +15,7 @@
 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 @@
     virtual Return<void> sendVec(const hidl_vec<uint8_t>& data, sendVec_cb _hidl_cb)  override;
     virtual Return<void> sendVecVec(sendVecVec_cb _hidl_cb)  override;
 
+    Return<void> haveAVectorOfInterfaces(
+            const hidl_vec<sp<ISimple> > &in,
+            haveAVectorOfInterfaces_cb _hidl_cb) override;
+
+    Return<void> haveAVectorOfGenericInterfaces(
+            const hidl_vec<sp<android::hardware::IBinder> > &in,
+            haveAVectorOfGenericInterfaces_cb _hidl_cb) override;
 };
 
 extern "C" IFoo* HIDL_FETCH_IFoo(const char* name);