mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Merge "Convert health hal test to use VtsHalHidlTargetTestEnvBase"
am: 8a5a99ca3b
Change-Id: Iaebf1c1c55ec12907d7dc4298feef1d42a3ad06d
This commit is contained in:
@@ -19,7 +19,9 @@
|
|||||||
#include <android/hardware/health/1.0/IHealth.h>
|
#include <android/hardware/health/1.0/IHealth.h>
|
||||||
#include <android/hardware/health/1.0/types.h>
|
#include <android/hardware/health/1.0/types.h>
|
||||||
#include <log/log.h>
|
#include <log/log.h>
|
||||||
|
|
||||||
#include <VtsHalHidlTargetTestBase.h>
|
#include <VtsHalHidlTargetTestBase.h>
|
||||||
|
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||||
|
|
||||||
using HealthConfig = ::android::hardware::health::V1_0::HealthConfig;
|
using HealthConfig = ::android::hardware::health::V1_0::HealthConfig;
|
||||||
using HealthInfo = ::android::hardware::health::V1_0::HealthInfo;
|
using HealthInfo = ::android::hardware::health::V1_0::HealthInfo;
|
||||||
@@ -28,10 +30,25 @@ using Result = ::android::hardware::health::V1_0::Result;
|
|||||||
|
|
||||||
using ::android::sp;
|
using ::android::sp;
|
||||||
|
|
||||||
|
// Test environment for Health HIDL HAL.
|
||||||
|
class HealthHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||||
|
public:
|
||||||
|
// get the test environment singleton
|
||||||
|
static HealthHidlEnvironment* Instance() {
|
||||||
|
static HealthHidlEnvironment* instance = new HealthHidlEnvironment;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void registerTestServices() override { registerTestService<IHealth>(); }
|
||||||
|
private:
|
||||||
|
HealthHidlEnvironment() {}
|
||||||
|
};
|
||||||
|
|
||||||
class HealthHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
class HealthHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||||
public:
|
public:
|
||||||
virtual void SetUp() override {
|
virtual void SetUp() override {
|
||||||
health = ::testing::VtsHalHidlTargetTestBase::getService<IHealth>();
|
health = ::testing::VtsHalHidlTargetTestBase::getService<IHealth>(
|
||||||
|
HealthHidlEnvironment::Instance()->getServiceName<IHealth>());
|
||||||
ASSERT_NE(health, nullptr);
|
ASSERT_NE(health, nullptr);
|
||||||
health->init(config,
|
health->init(config,
|
||||||
[&](const auto& halConfigOut) { config = halConfigOut; });
|
[&](const auto& halConfigOut) { config = halConfigOut; });
|
||||||
@@ -57,7 +74,9 @@ TEST_F(HealthHidlTest, TestEnergyCounter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
::testing::AddGlobalTestEnvironment(HealthHidlEnvironment::Instance());
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
::testing::InitGoogleTest(&argc, argv);
|
||||||
|
HealthHidlEnvironment::Instance()->init(&argc, argv);
|
||||||
int status = RUN_ALL_TESTS();
|
int status = RUN_ALL_TESTS();
|
||||||
ALOGI("Test result = %d", status);
|
ALOGI("Test result = %d", status);
|
||||||
return status;
|
return status;
|
||||||
|
|||||||
Reference in New Issue
Block a user