diff --git a/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.cpp b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.cpp index c534889fca..671c4b14ec 100644 --- a/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.cpp +++ b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.cpp @@ -30,10 +30,12 @@ Gralloc::Gralloc() { } void Gralloc::init() { - mAllocator = ::testing::VtsHalHidlTargetTestBase::getService(); + mAllocator = ::testing::VtsHalHidlTargetTestBase::getService( + GraphicsMapperHidlEnvironment::Instance()->getServiceName()); ASSERT_NE(nullptr, mAllocator.get()) << "failed to get allocator service"; - mMapper = ::testing::VtsHalHidlTargetTestBase::getService(); + mMapper = ::testing::VtsHalHidlTargetTestBase::getService( + GraphicsMapperHidlEnvironment::Instance()->getServiceName()); ASSERT_NE(nullptr, mMapper.get()) << "failed to get mapper service"; ASSERT_FALSE(mMapper->isRemote()) << "mapper is not in passthrough mode"; } diff --git a/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.h b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.h index 757f20bcd2..9cf60a375a 100644 --- a/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.h +++ b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperTestUtils.h @@ -19,6 +19,7 @@ #include +#include #include #include #include @@ -88,6 +89,21 @@ class Gralloc { std::unordered_set mImportedBuffers; }; +// Test environment for graphics.mapper. +class GraphicsMapperHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { + public: + // get the test environment singleton + static GraphicsMapperHidlEnvironment* Instance() { + static GraphicsMapperHidlEnvironment* instance = new GraphicsMapperHidlEnvironment; + return instance; + } + + virtual void registerTestServices() override { + registerTestService(); + registerTestService(); + } +}; + } // namespace tests } // namespace V2_0 } // namespace mapper diff --git a/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperV2_0TargetTest.cpp b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperV2_0TargetTest.cpp index c74013b336..1f9489851f 100644 --- a/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperV2_0TargetTest.cpp +++ b/graphics/mapper/2.0/vts/functional/VtsHalGraphicsMapperV2_0TargetTest.cpp @@ -403,10 +403,11 @@ TEST_F(GraphicsMapperHidlTest, UnlockNegative) { } // namespace android int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - - int status = RUN_ALL_TESTS(); - LOG(INFO) << "Test result = " << status; - - return status; + using android::hardware::graphics::mapper::V2_0::tests::GraphicsMapperHidlEnvironment; + ::testing::AddGlobalTestEnvironment(GraphicsMapperHidlEnvironment::Instance()); + ::testing::InitGoogleTest(&argc, argv); + GraphicsMapperHidlEnvironment::Instance()->init(&argc, argv); + int status = RUN_ALL_TESTS(); + LOG(INFO) << "Test result = " << status; + return status; }