Add test for bitset/mask type.

Test: hidl_test
Change-Id: I8bcd304184ff6b7794a9d0b5d3999f071604471d
This commit is contained in:
Yifan Hong 2016-12-05 12:34:42 -08:00
parent 961e625526
commit e7ce822b96
5 changed files with 43 additions and 0 deletions

View file

@ -31,4 +31,6 @@ interface IBar extends android.hardware.tests.foo@1.0::IFoo {
thisIsNew();
expectNullHandle(handle h, Abc xyz) generates (bool hIsNull, bool xyzHasNull);
takeAMask(BitField bf, bitfield<BitField> first, MyMask second, Mask third)
generates (BitField bf, uint8_t first, uint8_t second, uint8_t third);
};

View file

@ -185,6 +185,12 @@ Return<void> Bar::expectNullHandle(const hidl_handle& h, const Abc& xyz, expectN
return Void();
}
Return<void> Bar::takeAMask(BitField bf, uint8_t first, const MyMask& second, uint8_t third,
takeAMask_cb _hidl_cb) {
_hidl_cb(bf, bf | first, second.value & bf, (bf | bf) & third);
return Void();
}
IBar* HIDL_FETCH_IBar(const char* /* name */) {
return new Bar();
}

View file

@ -23,6 +23,9 @@ using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::sp;
using BitField = ::android::hardware::tests::foo::V1_0::IFoo::BitField;
using MyMask = ::android::hardware::tests::foo::V1_0::IFoo::MyMask;
struct Bar : public IBar {
Bar();
@ -66,6 +69,9 @@ struct Bar : public IBar {
Return<void> thisIsNew() override;
Return<void> expectNullHandle(const hidl_handle& h, const Abc& xyz, expectNullHandle_cb _hidl_cb) override;
Return<void> takeAMask(BitField bf, uint8_t first, const MyMask& second, uint8_t third,
takeAMask_cb _hidl_cb) override;
private:
sp<IFoo> mFoo;
};

View file

@ -64,6 +64,19 @@ interface IBase {
vec<MacAddress> addresses;
};
enum BitField : uint8_t {
V0 = 1 << 0,
V1 = 1 << 1,
V2 = 1 << 2,
V3 = 1 << 3,
};
struct MyMask {
bitfield<BitField> value;
};
typedef bitfield<BitField> Mask;
someBaseMethod();
someBoolMethod(bool x) generates (bool y);
@ -81,4 +94,7 @@ interface IBase {
transpose(StringMatrix5x3 in) generates (StringMatrix3x5 out);
transpose2(ThreeStrings[5] in) generates (FiveStrings[3] out);
takeAMask(BitField bf, bitfield<BitField> first, MyMask second, Mask third)
generates (BitField out, uint8_t f, uint8_t s, uint8_t t);
};

View file

@ -33,6 +33,13 @@ interface IFoo {
blah = goober
};
enum BitField : uint8_t {
V0 = 1 << 0,
V1 = 1 << 1,
V2 = 1 << 2,
V3 = 1 << 3,
};
struct Fumble {
Outer.Inner data;
};
@ -85,6 +92,12 @@ interface IFoo {
int32_t guard;
};
struct MyMask {
bitfield<BitField> value;
};
typedef bitfield<BitField> Mask;
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);