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

Commit d202400f authored by Junyu Lai's avatar Junyu Lai Committed by Gerrit Code Review
Browse files

Merge changes from topic "sp14-ipahal"

* changes:
  Update VTS tests for setDataWarningAndLimit
  Add VTS tests for setDataWarningAndLimit HAL interface
  Create VTS folder and put necessary setup code
  [SP14] Add HAL to set warning quota to tehtering offload hardware
parents fa085b5a 36292630
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -507,7 +507,7 @@
    </hal>
    <hal format="hidl" optional="true">
        <name>android.hardware.tetheroffload.control</name>
        <version>1.0</version>
        <version>1.1</version>
        <interface>
            <name>IOffloadControl</name>
            <instance>default</instance>
+14 −0
Original line number Diff line number Diff line
@@ -30,3 +30,17 @@ cc_test {
        "vts",
    ],
}

cc_test_library {
    name: "VtsHalTetheroffloadControlV1_0TargetTest-lib",
    defaults: ["VtsHalTargetTestDefaults"],
    export_include_dirs: ["include"],
    static_libs: [
        "android.hardware.tetheroffload.config@1.0",
        "android.hardware.tetheroffload.control@1.0",
    ],
    srcs: [
        "OffloadControlTestBase.cpp",
        "OffloadControlTestUtils.cpp",
    ],
}
+0 −23
Original line number Diff line number Diff line
@@ -53,29 +53,6 @@ void OffloadControlTestBase::setupConfigHal() {
    ASSERT_TRUE(ret.isOk());
}

void OffloadControlTestBase::prepareControlHal() {
    control = createControl(std::get<1>(GetParam()));
    ASSERT_NE(nullptr, control.get()) << "Could not get HIDL instance";

    control_cb = new TetheringOffloadCallback();
    ASSERT_NE(nullptr, control_cb.get()) << "Could not get get offload callback";
}

void OffloadControlTestBase::initOffload(const bool expected_result) {
    auto init_cb = [&](bool success, std::string errMsg) {
        std::string msg = StringPrintf("Unexpectedly %s to init offload: %s",
                                       success ? "succeeded" : "failed", errMsg.c_str());
        ASSERT_EQ(expected_result, success) << msg;
    };
    const Return<void> ret = control->initOffload(control_cb, init_cb);
    ASSERT_TRUE(ret.isOk());
}

void OffloadControlTestBase::setupControlHal() {
    prepareControlHal();
    initOffload(true);
}

void OffloadControlTestBase::stopOffload(const ExpectBoolean value) {
    auto cb = [&](bool success, const hidl_string& errMsg) {
        switch (value) {
+9 −6
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ using android::hardware::hidl_vec;
using android::hardware::Return;
using android::hardware::Void;
using android::hardware::tetheroffload::config::V1_0::IOffloadConfig;
using android::hardware::tetheroffload::control::V1_0::IOffloadControl;
using android::hardware::tetheroffload::control::V1_0::ITetheringOffloadCallback;
using android::hardware::tetheroffload::control::V1_0::NatTimeoutUpdate;
using android::hardware::tetheroffload::control::V1_0::OffloadCallbackEvent;
@@ -64,17 +63,21 @@ class OffloadControlTestBase : public testing::TestWithParam<std::tuple<std::str

    // Called once in setup stage to retrieve correct version of
    // IOffloadControl object.
    virtual sp<IOffloadControl> createControl(const std::string& serviceName) = 0;
    virtual sp<android::hardware::tetheroffload::control::V1_0::IOffloadControl> createControl(
            const std::string& serviceName) = 0;

    // The IOffloadConfig HAL is tested more thoroughly elsewhere. Here the
    // class just setup everything correctly and verify basic readiness.
    void setupConfigHal();

    void prepareControlHal();
    virtual void prepareControlHal() = 0;

    void initOffload(const bool expected_result);
    virtual void initOffload(const bool expected_result) = 0;

    void setupControlHal();
    void setupControlHal() {
        prepareControlHal();
        initOffload(true);
    };

    void stopOffload(const ExpectBoolean value);

@@ -100,6 +103,6 @@ class OffloadControlTestBase : public testing::TestWithParam<std::tuple<std::str
    };

    sp<IOffloadConfig> config;
    sp<IOffloadControl> control;
    sp<android::hardware::tetheroffload::control::V1_0::IOffloadControl> control;
    sp<TetheringOffloadCallback> control_cb;
};
 No newline at end of file
+22 −2
Original line number Diff line number Diff line
@@ -26,8 +26,28 @@ class OffloadControlTestV1_0_HalNotStarted : public OffloadControlTestBase {
        prepareControlHal();
    }

    virtual sp<IOffloadControl> createControl(const std::string& serviceName) override {
        return IOffloadControl::getService(serviceName);
    virtual sp<android::hardware::tetheroffload::control::V1_0::IOffloadControl> createControl(
            const std::string& serviceName) override {
        return android::hardware::tetheroffload::control::V1_0::IOffloadControl::getService(
                serviceName);
    }

    virtual void prepareControlHal() override {
        control = createControl(std::get<1>(GetParam()));
        ASSERT_NE(nullptr, control.get()) << "Could not get HIDL instance";

        control_cb = new TetheringOffloadCallback();
        ASSERT_NE(nullptr, control_cb.get()) << "Could not get get offload callback";
    }

    virtual void initOffload(const bool expected_result) override {
        auto init_cb = [&](bool success, std::string errMsg) {
            std::string msg = StringPrintf("Unexpectedly %s to init offload: %s",
                                           success ? "succeeded" : "failed", errMsg.c_str());
            ASSERT_EQ(expected_result, success) << msg;
        };
        const Return<void> ret = control->initOffload(control_cb, init_cb);
        ASSERT_TRUE(ret.isOk());
    }
};

Loading