Convert GraphicsMapper Hal test to test against each of the service names. am: 94b11ca19f

am: c8c5001b00

Change-Id: Iec2365f86d51388a2fdcb69eba35e8d746d1ba78
This commit is contained in:
Zhuoyao Zhang
2017-11-15 01:47:25 +00:00
committed by android-build-merger
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;
}