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

Commit 0f6e77ca authored by Zhuoyao Zhang's avatar Zhuoyao Zhang
Browse files

Convert light hal test to use VtsHalHidlTargetTestEnvBase

Bug: 64203181
Test: make vts
      vts-tradefed run vts -m VtsHalLightV2_0Target

Change-Id: I76eaac300697e25739c7ea0d2fb07b5b005a3040
parent 8f7ff573
Loading
Loading
Loading
Loading
+21 −3
Original line number Diff line number Diff line
@@ -16,12 +16,13 @@

#define LOG_TAG "light_hidl_hal_test"

#include <VtsHalHidlTargetTestBase.h>
#include <VtsHalHidlTargetTestEnvBase.h>
#include <android-base/logging.h>
#include <android/hardware/light/2.0/ILight.h>
#include <android/hardware/light/2.0/types.h>
#include <VtsHalHidlTargetTestBase.h>
#include <set>
#include <unistd.h>
#include <set>

using ::android::hardware::light::V2_0::Brightness;
using ::android::hardware::light::V2_0::Flash;
@@ -72,10 +73,25 @@ const static std::set<Type> kAllTypes = {
    Type::WIFI
};

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

    virtual void registerTestServices() override { registerTestService<ILight>(); }
   private:
    LightHidlEnvironment() {}
};

class LightHidlTest : public ::testing::VtsHalHidlTargetTestBase {
public:
    virtual void SetUp() override {
        light = ::testing::VtsHalHidlTargetTestBase::getService<ILight>();
        light = ::testing::VtsHalHidlTargetTestBase::getService<ILight>(
            LightHidlEnvironment::Instance()->getServiceName<ILight>());

        ASSERT_NE(light, nullptr);
        LOG(INFO) << "Test is remote " << light->isRemote();
@@ -149,7 +165,9 @@ TEST_F(LightHidlTest, TestUnsupported) {
}

int main(int argc, char **argv) {
    ::testing::AddGlobalTestEnvironment(LightHidlEnvironment::Instance());
    ::testing::InitGoogleTest(&argc, argv);
    LightHidlEnvironment::Instance()->init(&argc, argv);
    int status = RUN_ALL_TESTS();
    LOG(INFO) << "Test result = " << status;
    return status;