mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Convert light hal test to use VtsHalHidlTargetTestEnvBase
Bug: 64203181
Test: make vts
vts-tradefed run vts -m VtsHalLightV2_0Target
Change-Id: I76eaac300697e25739c7ea0d2fb07b5b005a3040
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user