Merge "Convert vr hal test to use VtsHalHidlTargetTestEnvBase"
This commit is contained in:
commit
f82e0825b6
1 changed files with 17 additions and 12 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue