mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:09:42 +00:00
Merge "Convert vr hal test to use VtsHalHidlTargetTestEnvBase" am: f82e0825b6 am: a587d66b53
am: 92a1fbfe6e
Change-Id: I9e81601fe9e5cce64e1f9c6a83b424a21e394385
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
#define LOG_TAG "vr_hidl_hal_test"
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android/hardware/vr/1.0/IVr.h>
|
||||
#include <hardware/vr.h>
|
||||
@@ -26,11 +27,24 @@ using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::sp;
|
||||
|
||||
// Test environment for Vr HIDL HAL.
|
||||
class VrHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||
public:
|
||||
// get the test environment singleton
|
||||
static VrHidlEnvironment* Instance() {
|
||||
static VrHidlEnvironment* instance = new VrHidlEnvironment;
|
||||
return instance;
|
||||
}
|
||||
|
||||
virtual void registerTestServices() override { registerTestService<IVr>(); }
|
||||
};
|
||||
|
||||
// The main test class for VR HIDL HAL.
|
||||
class VrHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
public:
|
||||
void SetUp() override {
|
||||
vr = ::testing::VtsHalHidlTargetTestBase::getService<IVr>();
|
||||
vr = ::testing::VtsHalHidlTargetTestBase::getService<IVr>(
|
||||
VrHidlEnvironment::Instance()->getServiceName<IVr>());
|
||||
ASSERT_NE(vr, nullptr);
|
||||
}
|
||||
|
||||
@@ -39,16 +53,6 @@ class VrHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
sp<IVr> vr;
|
||||
};
|
||||
|
||||
|
||||
// A class for test environment setup (kept since this file is a template).
|
||||
class VrHidlEnvironment : public ::testing::Environment {
|
||||
public:
|
||||
void SetUp() {}
|
||||
void TearDown() {}
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
// Sanity check that Vr::init does not crash.
|
||||
TEST_F(VrHidlTest, Init) {
|
||||
EXPECT_TRUE(vr->init().isOk());
|
||||
@@ -72,8 +76,9 @@ TEST_F(VrHidlTest, ReInit) {
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
::testing::AddGlobalTestEnvironment(new VrHidlEnvironment);
|
||||
::testing::AddGlobalTestEnvironment(VrHidlEnvironment::Instance());
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
VrHidlEnvironment::Instance()->init(&argc, argv);
|
||||
int status = RUN_ALL_TESTS();
|
||||
ALOGI("Test result = %d", status);
|
||||
return status;
|
||||
|
||||
Reference in New Issue
Block a user