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

Commit cc5c6957 authored by Zhuoyao Zhang's avatar Zhuoyao Zhang Committed by Android (Google) Code Review
Browse files

Merge "Convert auth secret hal test to use VtsHalHidlTargetTestEnvBase"

parents f33265ec 3c3b000d
Loading
Loading
Loading
Loading
+27 −1
Original line number Diff line number Diff line
@@ -17,18 +17,35 @@
#include <android/hardware/authsecret/1.0/IAuthSecret.h>

#include <VtsHalHidlTargetTestBase.h>
#include <VtsHalHidlTargetTestEnvBase.h>

using ::android::hardware::hidl_vec;
using ::android::hardware::authsecret::V1_0::IAuthSecret;
using ::android::sp;

// Test environment for Boot HIDL HAL.
class AuthSecretHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
   public:
    // get the test environment singleton
    static AuthSecretHidlEnvironment* Instance() {
        static AuthSecretHidlEnvironment* instance = new AuthSecretHidlEnvironment;
        return instance;
    }

    virtual void registerTestServices() override { registerTestService<IAuthSecret>(); }

   private:
    AuthSecretHidlEnvironment() {}
};

/**
 * There is no expected behaviour that can be tested so these tests check the
 * HAL doesn't crash with different execution orders.
 */
struct AuthSecretHidlTest : public ::testing::VtsHalHidlTargetTestBase {
    virtual void SetUp() override {
        authsecret = ::testing::VtsHalHidlTargetTestBase::getService<IAuthSecret>();
        authsecret = ::testing::VtsHalHidlTargetTestBase::getService<IAuthSecret>(
            AuthSecretHidlEnvironment::Instance()->getServiceName<IAuthSecret>());
        ASSERT_NE(authsecret, nullptr);

        // All tests must enroll the correct secret first as this cannot be changed
@@ -69,3 +86,12 @@ TEST_F(AuthSecretHidlTest, provisionPrimaryUserCredentialAndWrongSecret) {
    // Secret provisioned by SetUp()
    authsecret->primaryUserCredential(WRONG_SECRET);
}

int main(int argc, char** argv) {
    ::testing::AddGlobalTestEnvironment(AuthSecretHidlEnvironment::Instance());
    ::testing::InitGoogleTest(&argc, argv);
    AuthSecretHidlEnvironment::Instance()->init(&argc, argv);
    int status = RUN_ALL_TESTS();
    ALOGI("Test result = %d", status);
    return status;
}