Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 022bb405 authored by Yifan Hong's avatar Yifan Hong Committed by android-build-merger
Browse files

Add test for bitset/mask type.

am: e7ce822b

Change-Id: I178f54900b0a80bc44ca146380ab68ae7cf9f0cf
parents f9874a12 e7ce822b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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);
};
+6 −0
Original line number Diff line number Diff line
@@ -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();
}
+6 −0
Original line number Diff line number Diff line
@@ -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;
};
+16 −0
Original line number Diff line number Diff line
@@ -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);
};
+13 −0
Original line number Diff line number Diff line
@@ -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);