Convert GraphicsMapper Hal test to test against each of the service

names.

Bug:64203181
Test: vts-tradefed run vts -m VtsHalGraphicsMapperV2_0Target
Change-Id: Icbef0f0575183033c069d8ec097ab774207c40de
This commit is contained in:
Zhuoyao Zhang
2017-11-13 13:50:20 -08:00
parent f097a56a2c
commit 94b11ca19f
3 changed files with 27 additions and 8 deletions

View File

@@ -30,10 +30,12 @@ Gralloc::Gralloc() {
}
void Gralloc::init() {
mAllocator = ::testing::VtsHalHidlTargetTestBase::getService<IAllocator>();
mAllocator = ::testing::VtsHalHidlTargetTestBase::getService<IAllocator>(
GraphicsMapperHidlEnvironment::Instance()->getServiceName<IAllocator>());
ASSERT_NE(nullptr, mAllocator.get()) << "failed to get allocator service";
mMapper = ::testing::VtsHalHidlTargetTestBase::getService<IMapper>();
mMapper = ::testing::VtsHalHidlTargetTestBase::getService<IMapper>(
GraphicsMapperHidlEnvironment::Instance()->getServiceName<IMapper>());
ASSERT_NE(nullptr, mMapper.get()) << "failed to get mapper service";
ASSERT_FALSE(mMapper->isRemote()) << "mapper is not in passthrough mode";
}

View File

@@ -19,6 +19,7 @@
#include <unordered_set>
#include <VtsHalHidlTargetTestEnvBase.h>
#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
#include <android/hardware/graphics/mapper/2.0/IMapper.h>
#include <utils/StrongPointer.h>
@@ -88,6 +89,21 @@ class Gralloc {
std::unordered_set<const native_handle_t*> 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<IAllocator>();
registerTestService<IMapper>();
}
};
} // namespace tests
} // namespace V2_0
} // namespace mapper

View File

@@ -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;
}