IFace: fix VTS test to match the interface contract

Bug: 193849101
Test: atest VtsHalBiometricsFaceTargetTest
Change-Id: I5b3ed1b87244d6265d23c15ef2c2efe4f6155973
This commit is contained in:
Ilya Matyukhin 2021-07-21 13:22:45 -07:00
parent 997554db63
commit 61a6d8d72e

View file

@ -60,9 +60,10 @@ class SessionCallback : public BnSessionCallback {
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus onError(Error error, int32_t /*vendorCode*/) override {
ndk::ScopedAStatus onError(Error error, int32_t vendorCode) override {
auto lock = std::lock_guard<std::mutex>{mMutex};
mError = error;
mVendorCode = vendorCode;
mOnErrorInvoked = true;
mCv.notify_one();
return ndk::ScopedAStatus::ok();
@ -141,6 +142,7 @@ class SessionCallback : public BnSessionCallback {
std::mutex mMutex;
std::condition_variable mCv;
Error mError = Error::UNKNOWN;
int32_t mVendorCode = 0;
int64_t mGeneratedChallenge = 0;
int64_t mRevokedChallenge = 0;
bool mOnChallengeGeneratedInvoked = false;
@ -218,6 +220,8 @@ TEST_P(Face, EnrollWithBadHatResultsInErrorTest) {
// Make sure an error is returned.
auto lock = std::unique_lock{mCb->mMutex};
mCb->mCv.wait(lock, [this] { return mCb->mOnErrorInvoked; });
EXPECT_EQ(mCb->mError, Error::UNABLE_TO_PROCESS);
EXPECT_EQ(mCb->mVendorCode, 0);
}
TEST_P(Face, GenerateChallengeProducesUniqueChallengesTest) {
@ -287,13 +291,15 @@ TEST_P(Face, RemoveEnrollmentsWorksTest) {
mCb->mCv.wait(lock, [this] { return mCb->mOnEnrollmentsRemovedInvoked; });
}
TEST_P(Face, GetFeaturesWorksTest) {
TEST_P(Face, GetFeaturesWithoutEnrollmentsResultsInUnableToProcess) {
// Call the method.
ASSERT_TRUE(mSession->getFeatures().isOk());
// Wait for the result.
auto lock = std::unique_lock{mCb->mMutex};
mCb->mCv.wait(lock, [this] { return mCb->mOnFeaturesRetrievedInvoked; });
mCb->mCv.wait(lock, [this] { return mCb->mOnErrorInvoked; });
EXPECT_EQ(mCb->mError, Error::UNABLE_TO_PROCESS);
EXPECT_EQ(mCb->mVendorCode, 0);
}
TEST_P(Face, GetAuthenticatorIdWorksTest) {