From 1d747311b3aa3d208aedf3dfce97d134d57db723 Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Mon, 28 Nov 2016 14:50:15 -0800 Subject: [PATCH] Fix tests for using IBase instead of IBinder. Echoed interfaces cannot be casted properly, because interfaceChain cannot be called. So the given vector of interfaces is re-wrapped. This is temporary; when b/33173166 is fixed, this change should be reverted. Test: hidl_test Generates: b/33173166 Change-Id: I12166f69cf04abf7485dc2455ad731b87c80b3d1 --- tests/bar/1.0/default/Bar.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/bar/1.0/default/Bar.cpp b/tests/bar/1.0/default/Bar.cpp index d3f6b91a75..cac0845c92 100644 --- a/tests/bar/1.0/default/Bar.cpp +++ b/tests/bar/1.0/default/Bar.cpp @@ -122,10 +122,36 @@ Return Bar::haveAVectorOfInterfaces( return Void(); } +// TODO: remove after b/33173166 is fixed. +struct Simple : public ISimple { + Simple(int32_t cookie) + : mCookie(cookie) { + } + + Return getCookie() override { + return mCookie; + } + +private: + int32_t mCookie; +}; + +// TODO: use _hidl_cb(in) after b/33173166 is fixed. Return Bar::haveAVectorOfGenericInterfaces( const hidl_vec > &in, haveAVectorOfGenericInterfaces_cb _hidl_cb) { - _hidl_cb(in); + // _hidl_cb(in); + hidl_vec > out; + out.resize(in.size()); + for (size_t i = 0; i < in.size(); ++i) { + sp s = ISimple::castFrom(in[i]); + if (s.get() == nullptr) { + out[i] = new Simple(-1); + } else { + out[i] = new Simple(s->getCookie()); + } + } + _hidl_cb(out); return Void(); }