Test for vec<union> vec<struct w/ union>.
Bug: 31973802 Test: hidl_test Change-Id: I4367f1f525caa8d1edb95b7bfdac78f21b234576
This commit is contained in:
parent
e514a4b8a8
commit
3bcfa475e2
5 changed files with 59 additions and 0 deletions
|
@ -19,6 +19,11 @@ Bar::Bar() {
|
|||
}
|
||||
|
||||
// Methods from ::android::hardware::tests::foo::V1_0::IFoo follow.
|
||||
Return<void> Bar::convertToBoolIfSmall(Discriminator d, const hidl_vec<Union>& u,
|
||||
convertToBoolIfSmall_cb _hidl_cb) {
|
||||
return mFoo->convertToBoolIfSmall(d, u, _hidl_cb);
|
||||
}
|
||||
|
||||
Return<void> Bar::doThis(float param) {
|
||||
return mFoo->doThis(param);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ struct Bar : public IBar {
|
|||
Bar();
|
||||
|
||||
// Methods from ::android::hardware::tests::foo::V1_0::IFoo follow.
|
||||
virtual Return<void> convertToBoolIfSmall(Discriminator d, const hidl_vec<Union>& u,
|
||||
convertToBoolIfSmall_cb _hidl_cb) override;
|
||||
virtual Return<void> doThis(float param) override;
|
||||
virtual Return<int32_t> doThatAndReturnSomething(int64_t param) override;
|
||||
virtual Return<double> doQuiteABit(int32_t a, int64_t b, float c, double d) override;
|
||||
|
|
|
@ -122,6 +122,19 @@ interface IFoo {
|
|||
bitfield<BitField> bf;
|
||||
};
|
||||
|
||||
enum Discriminator : uint8_t {
|
||||
BOOL,
|
||||
INT,
|
||||
};
|
||||
union Union {
|
||||
bool boolValue;
|
||||
int64_t intValue;
|
||||
};
|
||||
struct ContainsUnion {
|
||||
Discriminator discriminator;
|
||||
Union value;
|
||||
};
|
||||
|
||||
typedef int32_t[5][6][7] multidimArrayOne;
|
||||
typedef multidimArrayOne[8][9][10] multidimArrayTwo;
|
||||
typedef multidimArrayTwo[2][3][4] multidimArrayThree;
|
||||
|
@ -144,6 +157,16 @@ interface IFoo {
|
|||
InnerTestEnumTypedef foo;
|
||||
};
|
||||
|
||||
/**
|
||||
* If d is INT, converts all values to bools which are small enough (0 or 1).
|
||||
* If d is BOOL, should leave all values as BOOLs.
|
||||
*
|
||||
* @param d discriminator for all values in u
|
||||
* @param u values to be expanded
|
||||
* @return c must have same length as u unless there is an error in which case it will be empty.
|
||||
*/
|
||||
convertToBoolIfSmall(Discriminator d, vec<Union> u) generates (vec<ContainsUnion> c);
|
||||
|
||||
doThis(float param);
|
||||
doThatAndReturnSomething(int64_t param) generates (int32_t result);
|
||||
doQuiteABit(int32_t a, int64_t b, float c, double d) generates (double something);
|
||||
|
|
|
@ -15,6 +15,30 @@ namespace V1_0 {
|
|||
namespace implementation {
|
||||
|
||||
// Methods from ::android::hardware::tests::foo::V1_0::IFoo follow.
|
||||
Return<void> Foo::convertToBoolIfSmall(Discriminator d, const hidl_vec<Union>& u,
|
||||
convertToBoolIfSmall_cb _hidl_cb) {
|
||||
hidl_vec<ContainsUnion> res(u.size());
|
||||
for (size_t i = 0; i < u.size(); i++) {
|
||||
ContainsUnion& outValue = res[i];
|
||||
|
||||
if (d == Discriminator::BOOL) {
|
||||
outValue.discriminator = Discriminator::BOOL;
|
||||
outValue.value.boolValue = u[i].boolValue;
|
||||
} else {
|
||||
uint64_t value = u[i].intValue;
|
||||
if (value == 0 || value == 1) {
|
||||
outValue.discriminator = Discriminator::BOOL;
|
||||
outValue.value.boolValue = static_cast<bool>(value);
|
||||
} else {
|
||||
outValue.discriminator = Discriminator::INT;
|
||||
outValue.value.intValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
_hidl_cb(res);
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> Foo::doThis(float param) {
|
||||
LOG(INFO) << "SERVER(Foo) doThis(" << param << ")";
|
||||
|
||||
|
|
|
@ -22,9 +22,14 @@ using ::android::hardware::Void;
|
|||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::sp;
|
||||
using ContainsUnion = ::android::hardware::tests::foo::V1_0::IFoo::ContainsUnion;
|
||||
using Discriminator = ::android::hardware::tests::foo::V1_0::IFoo::Discriminator;
|
||||
using Union = ::android::hardware::tests::foo::V1_0::IFoo::Union;
|
||||
|
||||
struct Foo : public IFoo {
|
||||
// Methods from ::android::hardware::tests::foo::V1_0::IFoo follow.
|
||||
virtual Return<void> convertToBoolIfSmall(Discriminator d, const hidl_vec<Union>& u,
|
||||
convertToBoolIfSmall_cb _hidl_cb) override;
|
||||
virtual Return<void> doThis(float param) override;
|
||||
virtual Return<int32_t> doThatAndReturnSomething(int64_t param) override;
|
||||
virtual Return<double> doQuiteABit(int32_t a, int64_t b, float c, double d) override;
|
||||
|
|
Loading…
Reference in a new issue