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

Commit 7344af9e authored by Anthony Stange's avatar Anthony Stange
Browse files

Add support for new APIs in default/vts code

Bug: 229888878
Test: presubmits
Change-Id: Ifc1ce761cc211d165b2f2f9315beffbb47f8fb85
parent 84f02c13
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -87,6 +87,10 @@ ScopedAStatus ContextHub::getPreloadedNanoappIds(std::vector<int64_t>* out_prelo
    return ndk::ScopedAStatus::ok();
}

ScopedAStatus ContextHub::onNanSessionStateChanged(bool /*sin_state*/) {
    return ndk::ScopedAStatus::ok();
}

ScopedAStatus ContextHub::registerCallback(int32_t in_contextHubId,
                                           const std::shared_ptr<IContextHubCallback>& in_cb) {
    if (in_contextHubId == kMockHubId) {
+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ class ContextHub : public BnContextHub {
    ::ndk::ScopedAStatus onHostEndpointConnected(const HostEndpointInfo& in_info) override;

    ::ndk::ScopedAStatus onHostEndpointDisconnected(char16_t in_hostEndpointId) override;
    ::ndk::ScopedAStatus onNanSessionStateChanged(bool in_state) override;

  private:
    static constexpr uint32_t kMockHubId = 0;
+11 −0
Original line number Diff line number Diff line
@@ -100,6 +100,8 @@ class EmptyContextHubCallback : public android::hardware::contexthub::BnContextH
    Status handleTransactionResult(int32_t /* transactionId */, bool /* success */) override {
        return Status::ok();
    }

    Status handleNanSessionRequest(bool /* enable */) override { return Status::ok(); }
};

TEST_P(ContextHubAidl, TestRegisterCallback) {
@@ -131,6 +133,8 @@ class QueryAppsCallback : public android::hardware::contexthub::BnContextHubCall
        return Status::ok();
    }

    Status handleNanSessionRequest(bool /* enable */) override { return Status::ok(); }

    std::promise<std::vector<NanoappInfo>> promise;
};

@@ -194,6 +198,8 @@ class TransactionResultCallback : public android::hardware::contexthub::BnContex
        return Status::ok();
    }

    Status handleNanSessionRequest(bool /* enable */) override { return Status::ok(); }

    uint32_t expectedTransactionId = 0;
    std::promise<bool> promise;
};
@@ -354,6 +360,11 @@ TEST_P(ContextHubAidl, TestInvalidHostConnection) {
    ASSERT_TRUE(contextHub->onHostEndpointDisconnected(kHostEndpointId).isOk());
}

TEST_P(ContextHubAidl, TestNanSessionStateChange) {
    ASSERT_TRUE(contextHub->onNanSessionStateChanged(true /*state*/).isOk());
    ASSERT_TRUE(contextHub->onNanSessionStateChanged(false /*state*/).isOk());
}

std::string PrintGeneratedTest(const testing::TestParamInfo<ContextHubAidl::ParamType>& info) {
    return std::string("CONTEXT_HUB_ID_") + std::to_string(std::get<1>(info.param));
}