summaryrefslogtreecommitdiff
path: root/automotive/vehicle/aidl/impl/vhal/test/ConnectedClientTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'automotive/vehicle/aidl/impl/vhal/test/ConnectedClientTest.cpp')
-rw-r--r--automotive/vehicle/aidl/impl/vhal/test/ConnectedClientTest.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/automotive/vehicle/aidl/impl/vhal/test/ConnectedClientTest.cpp b/automotive/vehicle/aidl/impl/vhal/test/ConnectedClientTest.cpp
index ddd0c65ec5..bdb0d31cdb 100644
--- a/automotive/vehicle/aidl/impl/vhal/test/ConnectedClientTest.cpp
+++ b/automotive/vehicle/aidl/impl/vhal/test/ConnectedClientTest.cpp
@@ -39,12 +39,17 @@ class ConnectedClientTest : public ::testing::Test {
void SetUp() override {
mCallback = ndk::SharedRefBase::make<MockVehicleCallback>();
mCallbackClient = IVehicleCallback::fromBinder(mCallback->asBinder());
+ // timeout: 1s.
+ int64_t timeout = 1000000000;
+ mPool = std::make_shared<PendingRequestPool>(timeout);
}
std::shared_ptr<IVehicleCallback> getCallbackClient() { return mCallbackClient; }
MockVehicleCallback* getCallback() { return mCallback.get(); }
+ std::shared_ptr<PendingRequestPool> getPool() { return mPool; }
+
protected:
using GetValuesClient = GetSetValuesClient<GetValueResult, GetValueResults>;
using SetValuesClient = GetSetValuesClient<SetValueResult, SetValueResults>;
@@ -52,6 +57,7 @@ class ConnectedClientTest : public ::testing::Test {
private:
std::shared_ptr<MockVehicleCallback> mCallback;
std::shared_ptr<IVehicleCallback> mCallbackClient;
+ std::shared_ptr<PendingRequestPool> mPool;
};
TEST_F(ConnectedClientTest, testSendGetValueResults) {
@@ -72,9 +78,10 @@ TEST_F(ConnectedClientTest, testSendGetValueResults) {
},
}};
- GetValuesClient client(getCallbackClient());
+ GetValuesClient client(getPool(), getCallbackClient());
- client.sendResults(results);
+ auto resultsCopy = results;
+ client.sendResults(std::move(resultsCopy));
auto maybeGetValueResults = getCallback()->nextGetValueResults();
ASSERT_TRUE(maybeGetValueResults.has_value());
@@ -99,7 +106,7 @@ TEST_F(ConnectedClientTest, testSendGetValueResultsSeparately) {
},
}};
- GetValuesClient client(getCallbackClient());
+ GetValuesClient client(getPool(), getCallbackClient());
client.sendResultsSeparately(results);
@@ -131,7 +138,9 @@ TEST_F(ConnectedClientTest, testGetValuesGnResultCallback) {
},
}};
- GetValuesClient client(getCallbackClient());
+ GetValuesClient client(getPool(), getCallbackClient());
+
+ client.addRequests({0, 1});
(*(client.getResultCallback()))(results);
@@ -150,9 +159,10 @@ TEST_F(ConnectedClientTest, testSendSetValueResults) {
.status = StatusCode::OK,
}};
- SetValuesClient client(getCallbackClient());
+ SetValuesClient client(getPool(), getCallbackClient());
- client.sendResults(results);
+ auto resultsCopy = results;
+ client.sendResults(std::move(resultsCopy));
auto maybeSetValueResults = getCallback()->nextSetValueResults();
ASSERT_TRUE(maybeSetValueResults.has_value());
@@ -169,7 +179,7 @@ TEST_F(ConnectedClientTest, testSendSetValueResultsSeparately) {
.status = StatusCode::OK,
}};
- SetValuesClient client(getCallbackClient());
+ SetValuesClient client(getPool(), getCallbackClient());
client.sendResultsSeparately(results);
@@ -193,7 +203,9 @@ TEST_F(ConnectedClientTest, testSetValuesGetResultCallback) {
.status = StatusCode::OK,
}};
- SetValuesClient client(getCallbackClient());
+ SetValuesClient client(getPool(), getCallbackClient());
+
+ client.addRequests({0, 1});
(*(client.getResultCallback()))(results);