Convert VtsHalGraphicsMapperV4_0TargetTest to be parameterized test
Bug: 142397658
Test: atest VtsHalGraphicsMapperV4_0TargetTest
Change-Id: I3854f9d4e601d37952e41a5c503f3b1d833c47a5
diff --git a/graphics/mapper/4.0/utils/vts/MapperVts.cpp b/graphics/mapper/4.0/utils/vts/MapperVts.cpp
index c317ed2..8a5f54e 100644
--- a/graphics/mapper/4.0/utils/vts/MapperVts.cpp
+++ b/graphics/mapper/4.0/utils/vts/MapperVts.cpp
@@ -17,8 +17,6 @@
#include <gralloctypes/Gralloc4.h>
#include <mapper-vts/4.0/MapperVts.h>
-#include <VtsHalHidlTargetTestBase.h>
-
namespace android {
namespace hardware {
namespace graphics {
@@ -36,19 +34,19 @@
}
void Gralloc::init(const std::string& allocatorServiceName, const std::string& mapperServiceName) {
- mAllocator = ::testing::VtsHalHidlTargetTestBase::getService<IAllocator>(allocatorServiceName);
+ mAllocator = IAllocator::getService(allocatorServiceName);
ASSERT_NE(nullptr, mAllocator.get()) << "failed to get allocator service";
- mMapper = ::testing::VtsHalHidlTargetTestBase::getService<IMapper>(mapperServiceName);
+ mMapper = IMapper::getService(mapperServiceName);
ASSERT_NE(nullptr, mMapper.get()) << "failed to get mapper service";
ASSERT_FALSE(mMapper->isRemote()) << "mapper is not in passthrough mode";
}
void Gralloc::initNoErr(const std::string& allocatorServiceName,
const std::string& mapperServiceName) {
- mAllocator = ::testing::VtsHalHidlTargetTestBase::getService<IAllocator>(allocatorServiceName);
+ mAllocator = IAllocator::getService(allocatorServiceName);
- mMapper = ::testing::VtsHalHidlTargetTestBase::getService<IMapper>(mapperServiceName);
+ mMapper = IMapper::getService(mapperServiceName);
if (mMapper.get()) {
ASSERT_FALSE(mMapper->isRemote()) << "mapper is not in passthrough mode";
}
diff --git a/graphics/mapper/4.0/utils/vts/include/mapper-vts/4.0/MapperVts.h b/graphics/mapper/4.0/utils/vts/include/mapper-vts/4.0/MapperVts.h
index eed043f..1c635c4 100644
--- a/graphics/mapper/4.0/utils/vts/include/mapper-vts/4.0/MapperVts.h
+++ b/graphics/mapper/4.0/utils/vts/include/mapper-vts/4.0/MapperVts.h
@@ -22,6 +22,7 @@
#include <android/hardware/graphics/allocator/4.0/IAllocator.h>
#include <android/hardware/graphics/mapper/4.0/IMapper.h>
+#include <gtest/gtest.h>
#include <utils/StrongPointer.h>
namespace android {
diff --git a/graphics/mapper/4.0/vts/functional/Android.bp b/graphics/mapper/4.0/vts/functional/Android.bp
index 506026d..926cf31 100644
--- a/graphics/mapper/4.0/vts/functional/Android.bp
+++ b/graphics/mapper/4.0/vts/functional/Android.bp
@@ -20,7 +20,9 @@
srcs: ["VtsHalGraphicsMapperV4_0TargetTest.cpp"],
static_libs: [
"android.hardware.graphics.mapper@4.0-vts",
+ "libgralloctypes",
"libsync",
+ "vintf-graphics-common-ndk_platform",
],
shared_libs: [
"android.hardware.graphics.allocator@4.0",
@@ -28,11 +30,9 @@
"android.hardware.graphics.common@1.1",
"android.hardware.graphics.common@1.2",
"android.hardware.graphics.mapper@4.0",
- "libgralloctypes",
- "vintf-graphics-common-ndk_platform",
],
header_libs: [
"libsystem_headers",
],
- test_suites: ["general-tests"],
+ test_suites: ["general-tests", "vts-core"],
}
diff --git a/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp b/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp
index 347eca6..4ca5e7e 100644
--- a/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp
+++ b/graphics/mapper/4.0/vts/functional/VtsHalGraphicsMapperV4_0TargetTest.cpp
@@ -23,10 +23,12 @@
#include <aidl/android/hardware/graphics/common/PlaneLayoutComponentType.h>
-#include <VtsHalHidlTargetTestBase.h>
#include <android-base/logging.h>
#include <android/sync.h>
#include <gralloctypes/Gralloc4.h>
+#include <gtest/gtest.h>
+#include <hidl/GtestPrinter.h>
+#include <hidl/ServiceManagement.h>
#include <mapper-vts/4.0/MapperVts.h>
#include <system/graphics.h>
@@ -52,28 +54,12 @@
using DecodeFunction = std::function<void(const IMapper::BufferDescriptorInfo& descriptorInfo,
const hidl_vec<uint8_t>& vec)>;
-// 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>();
- }
-};
-
-class GraphicsMapperHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+class GraphicsMapperHidlTest
+ : public ::testing::TestWithParam<std::tuple<std::string, std::string>> {
protected:
void SetUp() override {
- ASSERT_NO_FATAL_FAILURE(
- mGralloc = std::make_unique<Gralloc>(
- GraphicsMapperHidlEnvironment::Instance()->getServiceName<IAllocator>(),
- GraphicsMapperHidlEnvironment::Instance()->getServiceName<IMapper>()));
+ ASSERT_NO_FATAL_FAILURE(mGralloc = std::make_unique<Gralloc>(std::get<0>(GetParam()),
+ std::get<1>(GetParam())));
ASSERT_NE(nullptr, mGralloc->getAllocator().get());
ASSERT_NE(nullptr, mGralloc->getMapper().get());
@@ -322,14 +308,14 @@
/**
* Test IAllocator::dumpDebugInfo by calling it.
*/
-TEST_F(GraphicsMapperHidlTest, AllocatorDumpDebugInfo) {
+TEST_P(GraphicsMapperHidlTest, AllocatorDumpDebugInfo) {
mGralloc->dumpDebugInfo();
}
/**
* Test IAllocator::allocate with valid buffer descriptors.
*/
-TEST_F(GraphicsMapperHidlTest, AllocatorAllocate) {
+TEST_P(GraphicsMapperHidlTest, AllocatorAllocate) {
BufferDescriptor descriptor;
ASSERT_NO_FATAL_FAILURE(descriptor = mGralloc->createDescriptor(mDummyDescriptorInfo));
@@ -352,7 +338,7 @@
/**
* Test IAllocator::allocate with invalid buffer descriptors.
*/
-TEST_F(GraphicsMapperHidlTest, AllocatorAllocateNegative) {
+TEST_P(GraphicsMapperHidlTest, AllocatorAllocateNegative) {
// this assumes any valid descriptor is non-empty
BufferDescriptor descriptor;
mGralloc->getAllocator()->allocate(descriptor, 1,
@@ -364,7 +350,7 @@
/**
* Test IAllocator::allocate does not leak.
*/
-TEST_F(GraphicsMapperHidlTest, AllocatorAllocateNoLeak) {
+TEST_P(GraphicsMapperHidlTest, AllocatorAllocateNoLeak) {
auto info = mDummyDescriptorInfo;
info.width = 1024;
info.height = 1024;
@@ -378,7 +364,7 @@
/**
* Test that IAllocator::allocate is thread-safe.
*/
-TEST_F(GraphicsMapperHidlTest, AllocatorAllocateThreaded) {
+TEST_P(GraphicsMapperHidlTest, AllocatorAllocateThreaded) {
BufferDescriptor descriptor;
ASSERT_NO_FATAL_FAILURE(descriptor = mGralloc->createDescriptor(mDummyDescriptorInfo));
@@ -409,14 +395,14 @@
/**
* Test IMapper::createDescriptor with valid descriptor info.
*/
-TEST_F(GraphicsMapperHidlTest, CreateDescriptorBasic) {
+TEST_P(GraphicsMapperHidlTest, CreateDescriptorBasic) {
ASSERT_NO_FATAL_FAILURE(mGralloc->createDescriptor(mDummyDescriptorInfo));
}
/**
* Test IMapper::createDescriptor with invalid descriptor info.
*/
-TEST_F(GraphicsMapperHidlTest, CreateDescriptorNegative) {
+TEST_P(GraphicsMapperHidlTest, CreateDescriptorNegative) {
auto info = mDummyDescriptorInfo;
info.width = 0;
mGralloc->getMapper()->createDescriptor(info, [&](const auto& tmpError, const auto&) {
@@ -427,7 +413,7 @@
/**
* Test IMapper::importBuffer and IMapper::freeBuffer with allocated buffers.
*/
-TEST_F(GraphicsMapperHidlTest, ImportFreeBufferBasic) {
+TEST_P(GraphicsMapperHidlTest, ImportFreeBufferBasic) {
const native_handle_t* bufferHandle;
ASSERT_NO_FATAL_FAILURE(bufferHandle = mGralloc->allocate(mDummyDescriptorInfo, true));
ASSERT_NO_FATAL_FAILURE(mGralloc->freeBuffer(bufferHandle));
@@ -436,7 +422,7 @@
/**
* Test IMapper::importBuffer and IMapper::freeBuffer with cloned buffers.
*/
-TEST_F(GraphicsMapperHidlTest, ImportFreeBufferClone) {
+TEST_P(GraphicsMapperHidlTest, ImportFreeBufferClone) {
const native_handle_t* clonedBufferHandle;
ASSERT_NO_FATAL_FAILURE(clonedBufferHandle = mGralloc->allocate(mDummyDescriptorInfo, false));
@@ -454,7 +440,7 @@
/**
* Test IMapper::importBuffer and IMapper::freeBuffer cross mapper instances.
*/
-TEST_F(GraphicsMapperHidlTest, ImportFreeBufferSingleton) {
+TEST_P(GraphicsMapperHidlTest, ImportFreeBufferSingleton) {
const native_handle_t* rawHandle;
ASSERT_NO_FATAL_FAILURE(rawHandle = mGralloc->allocate(mDummyDescriptorInfo, false));
@@ -466,10 +452,8 @@
// free the imported handle with another mapper
std::unique_ptr<Gralloc> anotherGralloc;
- ASSERT_NO_FATAL_FAILURE(
- anotherGralloc = std::make_unique<Gralloc>(
- GraphicsMapperHidlEnvironment::Instance()->getServiceName<IAllocator>(),
- GraphicsMapperHidlEnvironment::Instance()->getServiceName<IMapper>()));
+ ASSERT_NO_FATAL_FAILURE(anotherGralloc = std::make_unique<Gralloc>(std::get<0>(GetParam()),
+ std::get<1>(GetParam())));
Error error = mGralloc->getMapper()->freeBuffer(importedHandle);
ASSERT_EQ(Error::NONE, error);
@@ -479,7 +463,7 @@
/**
* Test IMapper::importBuffer and IMapper::freeBuffer do not leak.
*/
-TEST_F(GraphicsMapperHidlTest, ImportFreeBufferNoLeak) {
+TEST_P(GraphicsMapperHidlTest, ImportFreeBufferNoLeak) {
auto info = mDummyDescriptorInfo;
info.width = 1024;
info.height = 1024;
@@ -493,7 +477,7 @@
/**
* Test IMapper::importBuffer with invalid buffers.
*/
-TEST_F(GraphicsMapperHidlTest, ImportBufferNegative) {
+TEST_P(GraphicsMapperHidlTest, ImportBufferNegative) {
native_handle_t* invalidHandle = nullptr;
mGralloc->getMapper()->importBuffer(invalidHandle, [&](const auto& tmpError, const auto&) {
EXPECT_EQ(Error::BAD_BUFFER, tmpError)
@@ -511,7 +495,7 @@
/**
* Test IMapper::freeBuffer with invalid buffers.
*/
-TEST_F(GraphicsMapperHidlTest, FreeBufferNegative) {
+TEST_P(GraphicsMapperHidlTest, FreeBufferNegative) {
native_handle_t* invalidHandle = nullptr;
Error error = mGralloc->getMapper()->freeBuffer(invalidHandle);
EXPECT_EQ(Error::BAD_BUFFER, error) << "freeBuffer with nullptr did not fail with BAD_BUFFER";
@@ -534,7 +518,7 @@
/**
* Test IMapper::lock and IMapper::unlock.
*/
-TEST_F(GraphicsMapperHidlTest, LockUnlockBasic) {
+TEST_P(GraphicsMapperHidlTest, LockUnlockBasic) {
const auto& info = mDummyDescriptorInfo;
const native_handle_t* bufferHandle;
@@ -565,7 +549,7 @@
}
}
-TEST_F(GraphicsMapperHidlTest, Lock_YCBCR_420_888) {
+TEST_P(GraphicsMapperHidlTest, Lock_YCBCR_420_888) {
auto info = mDummyDescriptorInfo;
info.format = PixelFormat::YCBCR_420_888;
@@ -638,7 +622,7 @@
/**
* Test IMapper::unlock with bad access region
*/
-TEST_F(GraphicsMapperHidlTest, LockBadAccessRegion) {
+TEST_P(GraphicsMapperHidlTest, LockBadAccessRegion) {
const auto& info = mDummyDescriptorInfo;
const native_handle_t* bufferHandle;
@@ -680,7 +664,7 @@
/**
* Test IMapper::unlock with invalid buffers.
*/
-TEST_F(GraphicsMapperHidlTest, UnlockNegative) {
+TEST_P(GraphicsMapperHidlTest, UnlockNegative) {
native_handle_t* invalidHandle = nullptr;
mGralloc->getMapper()->unlock(invalidHandle, [&](const auto& tmpError, const auto&) {
EXPECT_EQ(Error::BAD_BUFFER, tmpError)
@@ -718,7 +702,7 @@
/**
* Test IMapper::flush and IMapper::reread.
*/
-TEST_F(GraphicsMapperHidlTest, FlushRereadBasic) {
+TEST_P(GraphicsMapperHidlTest, FlushRereadBasic) {
const auto& info = mDummyDescriptorInfo;
const native_handle_t* rawHandle;
@@ -770,7 +754,7 @@
/**
* Test IMapper::flushLockedBuffer with bad buffer
*/
-TEST_F(GraphicsMapperHidlTest, FlushLockedBufferBadBuffer) {
+TEST_P(GraphicsMapperHidlTest, FlushLockedBufferBadBuffer) {
ASSERT_NO_FATAL_FAILURE(mGralloc->getMapper()->flushLockedBuffer(
nullptr, [&](const auto& tmpError, const auto& /*tmpReleaseFence*/) {
ASSERT_EQ(Error::BAD_BUFFER, tmpError);
@@ -780,14 +764,14 @@
/**
* Test IMapper::rereadLockedBuffer with bad buffer
*/
-TEST_F(GraphicsMapperHidlTest, RereadLockedBufferBadBuffer) {
+TEST_P(GraphicsMapperHidlTest, RereadLockedBufferBadBuffer) {
ASSERT_EQ(Error::BAD_BUFFER, mGralloc->getMapper()->rereadLockedBuffer(nullptr));
}
/**
* Test IMapper::isSupported with required format RGBA_8888
*/
-TEST_F(GraphicsMapperHidlTest, IsSupportedRGBA8888) {
+TEST_P(GraphicsMapperHidlTest, IsSupportedRGBA8888) {
const auto& info = mDummyDescriptorInfo;
bool supported = false;
@@ -798,7 +782,7 @@
/**
* Test IMapper::isSupported with required format YV12
*/
-TEST_F(GraphicsMapperHidlTest, IsSupportedYV12) {
+TEST_P(GraphicsMapperHidlTest, IsSupportedYV12) {
auto info = mDummyDescriptorInfo;
info.format = PixelFormat::YV12;
bool supported = false;
@@ -810,7 +794,7 @@
/**
* Test IMapper::isSupported with optional format Y16
*/
-TEST_F(GraphicsMapperHidlTest, IsSupportedY16) {
+TEST_P(GraphicsMapperHidlTest, IsSupportedY16) {
auto info = mDummyDescriptorInfo;
info.format = PixelFormat::Y16;
bool supported = false;
@@ -821,7 +805,7 @@
/**
* Test IMapper::get(BufferId)
*/
-TEST_F(GraphicsMapperHidlTest, GetBufferId) {
+TEST_P(GraphicsMapperHidlTest, GetBufferId) {
testGet(mDummyDescriptorInfo, gralloc4::MetadataType_BufferId,
[](const IMapper::BufferDescriptorInfo& /*info*/, const hidl_vec<uint8_t>& vec) {
uint64_t bufferId = 0;
@@ -832,7 +816,7 @@
/**
* Test IMapper::get(Name)
*/
-TEST_F(GraphicsMapperHidlTest, GetName) {
+TEST_P(GraphicsMapperHidlTest, GetName) {
testGet(mDummyDescriptorInfo, gralloc4::MetadataType_Name,
[](const IMapper::BufferDescriptorInfo& info, const hidl_vec<uint8_t>& vec) {
std::string name;
@@ -844,7 +828,7 @@
/**
* Test IMapper::get(Width)
*/
-TEST_F(GraphicsMapperHidlTest, GetWidth) {
+TEST_P(GraphicsMapperHidlTest, GetWidth) {
testGet(mDummyDescriptorInfo, gralloc4::MetadataType_Width,
[](const IMapper::BufferDescriptorInfo& info, const hidl_vec<uint8_t>& vec) {
uint64_t width = 0;
@@ -856,7 +840,7 @@
/**
* Test IMapper::get(Height)
*/
-TEST_F(GraphicsMapperHidlTest, GetHeight) {
+TEST_P(GraphicsMapperHidlTest, GetHeight) {
testGet(mDummyDescriptorInfo, gralloc4::MetadataType_Height,
[](const IMapper::BufferDescriptorInfo& info, const hidl_vec<uint8_t>& vec) {
uint64_t height = 0;
@@ -868,7 +852,7 @@
/**
* Test IMapper::get(LayerCount)
*/
-TEST_F(GraphicsMapperHidlTest, GetLayerCount) {
+TEST_P(GraphicsMapperHidlTest, GetLayerCount) {
testGet(mDummyDescriptorInfo, gralloc4::MetadataType_LayerCount,
[](const IMapper::BufferDescriptorInfo& info, const hidl_vec<uint8_t>& vec) {
uint64_t layerCount = 0;
@@ -880,7 +864,7 @@
/**
* Test IMapper::get(PixelFormatRequested)
*/
-TEST_F(GraphicsMapperHidlTest, GetPixelFormatRequested) {
+TEST_P(GraphicsMapperHidlTest, GetPixelFormatRequested) {
testGet(mDummyDescriptorInfo, gralloc4::MetadataType_PixelFormatRequested,
[](const IMapper::BufferDescriptorInfo& info, const hidl_vec<uint8_t>& vec) {
PixelFormat pixelFormatRequested = PixelFormat::BLOB;
@@ -893,7 +877,7 @@
/**
* Test IMapper::get(PixelFormatFourCC)
*/
-TEST_F(GraphicsMapperHidlTest, GetPixelFormatFourCC) {
+TEST_P(GraphicsMapperHidlTest, GetPixelFormatFourCC) {
testGet(mDummyDescriptorInfo, gralloc4::MetadataType_PixelFormatFourCC,
[](const IMapper::BufferDescriptorInfo& /*info*/, const hidl_vec<uint8_t>& vec) {
uint32_t pixelFormatFourCC = 0;
@@ -904,7 +888,7 @@
/**
* Test IMapper::get(PixelFormatModifier)
*/
-TEST_F(GraphicsMapperHidlTest, GetPixelFormatModifier) {
+TEST_P(GraphicsMapperHidlTest, GetPixelFormatModifier) {
testGet(mDummyDescriptorInfo, gralloc4::MetadataType_PixelFormatModifier,
[](const IMapper::BufferDescriptorInfo& /*info*/, const hidl_vec<uint8_t>& vec) {
uint64_t pixelFormatModifier = 0;
@@ -915,7 +899,7 @@
/**
* Test IMapper::get(Usage)
*/
-TEST_F(GraphicsMapperHidlTest, GetUsage) {
+TEST_P(GraphicsMapperHidlTest, GetUsage) {
testGet(mDummyDescriptorInfo, gralloc4::MetadataType_Usage,
[](const IMapper::BufferDescriptorInfo& info, const hidl_vec<uint8_t>& vec) {
uint64_t usage = 0;
@@ -927,7 +911,7 @@
/**
* Test IMapper::get(AllocationSize)
*/
-TEST_F(GraphicsMapperHidlTest, GetAllocationSize) {
+TEST_P(GraphicsMapperHidlTest, GetAllocationSize) {
testGet(mDummyDescriptorInfo, gralloc4::MetadataType_AllocationSize,
[](const IMapper::BufferDescriptorInfo& /*info*/, const hidl_vec<uint8_t>& vec) {
uint64_t allocationSize = 0;
@@ -938,7 +922,7 @@
/**
* Test IMapper::get(ProtectedContent)
*/
-TEST_F(GraphicsMapperHidlTest, GetProtectedContent) {
+TEST_P(GraphicsMapperHidlTest, GetProtectedContent) {
auto info = mDummyDescriptorInfo;
info.usage = BufferUsage::PROTECTED | BufferUsage::COMPOSER_OVERLAY;
@@ -960,7 +944,7 @@
/**
* Test IMapper::get(Compression)
*/
-TEST_F(GraphicsMapperHidlTest, GetCompression) {
+TEST_P(GraphicsMapperHidlTest, GetCompression) {
auto info = mDummyDescriptorInfo;
info.usage = static_cast<uint64_t>(BufferUsage::CPU_WRITE_OFTEN | BufferUsage::CPU_READ_OFTEN);
@@ -977,7 +961,7 @@
/**
* Test IMapper::get(Interlaced)
*/
-TEST_F(GraphicsMapperHidlTest, GetInterlaced) {
+TEST_P(GraphicsMapperHidlTest, GetInterlaced) {
testGet(mDummyDescriptorInfo, gralloc4::MetadataType_Interlaced,
[](const IMapper::BufferDescriptorInfo& /*info*/, const hidl_vec<uint8_t>& vec) {
ExtendableType interlaced = gralloc4::Interlaced_TopBottom;
@@ -991,7 +975,7 @@
/**
* Test IMapper::get(ChromaSiting)
*/
-TEST_F(GraphicsMapperHidlTest, GetChromaSiting) {
+TEST_P(GraphicsMapperHidlTest, GetChromaSiting) {
testGet(mDummyDescriptorInfo, gralloc4::MetadataType_ChromaSiting,
[](const IMapper::BufferDescriptorInfo& /*info*/, const hidl_vec<uint8_t>& vec) {
ExtendableType chromaSiting = gralloc4::ChromaSiting_Unknown;
@@ -1005,7 +989,7 @@
/**
* Test IMapper::get(PlaneLayouts)
*/
-TEST_F(GraphicsMapperHidlTest, GetPlaneLayouts) {
+TEST_P(GraphicsMapperHidlTest, GetPlaneLayouts) {
const native_handle_t* bufferHandle = nullptr;
ASSERT_NO_FATAL_FAILURE(bufferHandle = mGralloc->allocate(mDummyDescriptorInfo, true));
@@ -1021,7 +1005,7 @@
/**
* Test IMapper::get(Dataspace)
*/
-TEST_F(GraphicsMapperHidlTest, GetDataspace) {
+TEST_P(GraphicsMapperHidlTest, GetDataspace) {
testGet(mDummyDescriptorInfo, gralloc4::MetadataType_Dataspace,
[](const IMapper::BufferDescriptorInfo& /*info*/, const hidl_vec<uint8_t>& vec) {
Dataspace dataspace = Dataspace::DISPLAY_P3;
@@ -1033,7 +1017,7 @@
/**
* Test IMapper::get(BlendMode)
*/
-TEST_F(GraphicsMapperHidlTest, GetBlendMode) {
+TEST_P(GraphicsMapperHidlTest, GetBlendMode) {
testGet(mDummyDescriptorInfo, gralloc4::MetadataType_BlendMode,
[](const IMapper::BufferDescriptorInfo& /*info*/, const hidl_vec<uint8_t>& vec) {
BlendMode blendMode = BlendMode::NONE;
@@ -1045,7 +1029,7 @@
/**
* Test IMapper::get(metadata) with a bad buffer
*/
-TEST_F(GraphicsMapperHidlTest, GetMetadataBadValue) {
+TEST_P(GraphicsMapperHidlTest, GetMetadataBadValue) {
const native_handle_t* bufferHandle = nullptr;
hidl_vec<uint8_t> vec;
ASSERT_EQ(Error::BAD_BUFFER,
@@ -1100,7 +1084,7 @@
/**
* Test IMapper::get(metadata) for unsupported metadata
*/
-TEST_F(GraphicsMapperHidlTest, GetUnsupportedMetadata) {
+TEST_P(GraphicsMapperHidlTest, GetUnsupportedMetadata) {
const native_handle_t* bufferHandle = nullptr;
ASSERT_NO_FATAL_FAILURE(bufferHandle = mGralloc->allocate(mDummyDescriptorInfo, true));
@@ -1114,7 +1098,7 @@
/**
* Test IMapper::get(metadata) for unsupported standard metadata
*/
-TEST_F(GraphicsMapperHidlTest, GetUnsupportedStandardMetadata) {
+TEST_P(GraphicsMapperHidlTest, GetUnsupportedStandardMetadata) {
const native_handle_t* bufferHandle = nullptr;
ASSERT_NO_FATAL_FAILURE(bufferHandle = mGralloc->allocate(mDummyDescriptorInfo, true));
@@ -1128,7 +1112,7 @@
/**
* Test IMapper::set(PixelFormatFourCC)
*/
-TEST_F(GraphicsMapperHidlTest, SetPixelFormatFourCC) {
+TEST_P(GraphicsMapperHidlTest, SetPixelFormatFourCC) {
uint32_t pixelFormatFourCC = 0x34324142; // DRM_FORMAT_BGRA8888
hidl_vec<uint8_t> vec;
ASSERT_EQ(NO_ERROR, gralloc4::encodePixelFormatFourCC(pixelFormatFourCC, &vec));
@@ -1144,7 +1128,7 @@
/**
* Test IMapper::set(PixelFormatModifier)
*/
-TEST_F(GraphicsMapperHidlTest, SetPixelFormatModifier) {
+TEST_P(GraphicsMapperHidlTest, SetPixelFormatModifier) {
uint64_t pixelFormatModifier = 10;
hidl_vec<uint8_t> vec;
ASSERT_EQ(NO_ERROR, gralloc4::encodePixelFormatModifier(pixelFormatModifier, &vec));
@@ -1161,7 +1145,7 @@
/**
* Test IMapper::set(Usage) remove flag
*/
-TEST_F(GraphicsMapperHidlTest, SetUsageRemoveBit) {
+TEST_P(GraphicsMapperHidlTest, SetUsageRemoveBit) {
uint64_t usage = static_cast<uint64_t>(BufferUsage::CPU_WRITE_OFTEN);
hidl_vec<uint8_t> vec;
ASSERT_EQ(NO_ERROR, gralloc4::encodeUsage(usage, &vec));
@@ -1176,7 +1160,7 @@
/**
* Test IMapper::set(Usage) add flag
*/
-TEST_F(GraphicsMapperHidlTest, SetUsageAddBit) {
+TEST_P(GraphicsMapperHidlTest, SetUsageAddBit) {
uint64_t usage = mDummyDescriptorInfo.usage | static_cast<uint64_t>(BufferUsage::GPU_TEXTURE);
hidl_vec<uint8_t> vec;
ASSERT_EQ(NO_ERROR, gralloc4::encodeUsage(usage, &vec));
@@ -1192,7 +1176,7 @@
/**
* Test IMapper::set(Usage) to test protected content
*/
-TEST_F(GraphicsMapperHidlTest, SetUsageProtected) {
+TEST_P(GraphicsMapperHidlTest, SetUsageProtected) {
const native_handle_t* bufferHandle = nullptr;
auto info = mDummyDescriptorInfo;
info.usage = BufferUsage::PROTECTED | BufferUsage::COMPOSER_OVERLAY;
@@ -1219,7 +1203,7 @@
/**
* Test IMapper::set(AllocationSize)
*/
-TEST_F(GraphicsMapperHidlTest, SetAllocationSize) {
+TEST_P(GraphicsMapperHidlTest, SetAllocationSize) {
uint64_t allocationSize = 1000000;
hidl_vec<uint8_t> vec;
ASSERT_EQ(NO_ERROR, gralloc4::encodeAllocationSize(allocationSize, &vec));
@@ -1235,7 +1219,7 @@
/**
* Test IMapper::set(ProtectedContent)
*/
-TEST_F(GraphicsMapperHidlTest, SetProtectedContent) {
+TEST_P(GraphicsMapperHidlTest, SetProtectedContent) {
const native_handle_t* bufferHandle = nullptr;
auto info = mDummyDescriptorInfo;
info.usage = BufferUsage::PROTECTED | BufferUsage::COMPOSER_OVERLAY;
@@ -1263,7 +1247,7 @@
/**
* Test IMapper::set(Compression)
*/
-TEST_F(GraphicsMapperHidlTest, SetCompression) {
+TEST_P(GraphicsMapperHidlTest, SetCompression) {
auto info = mDummyDescriptorInfo;
info.usage = static_cast<uint64_t>(BufferUsage::CPU_WRITE_OFTEN | BufferUsage::CPU_READ_OFTEN);
@@ -1284,7 +1268,7 @@
/**
* Test IMapper::set(Interlaced)
*/
-TEST_F(GraphicsMapperHidlTest, SetInterlaced) {
+TEST_P(GraphicsMapperHidlTest, SetInterlaced) {
ExtendableType interlaced = gralloc4::Interlaced_RightLeft;
hidl_vec<uint8_t> vec;
ASSERT_EQ(NO_ERROR, gralloc4::encodeInterlaced(interlaced, &vec));
@@ -1302,7 +1286,7 @@
/**
* Test IMapper::set(ChromaSiting)
*/
-TEST_F(GraphicsMapperHidlTest, SetChromaSiting) {
+TEST_P(GraphicsMapperHidlTest, SetChromaSiting) {
ExtendableType chromaSiting = gralloc4::ChromaSiting_SitedInterstitial;
hidl_vec<uint8_t> vec;
ASSERT_EQ(NO_ERROR, gralloc4::encodeChromaSiting(chromaSiting, &vec));
@@ -1320,7 +1304,7 @@
/**
* Test IMapper::set(PlaneLayouts)
*/
-TEST_F(GraphicsMapperHidlTest, SetPlaneLayouts) {
+TEST_P(GraphicsMapperHidlTest, SetPlaneLayouts) {
const native_handle_t* bufferHandle = nullptr;
auto info = mDummyDescriptorInfo;
ASSERT_NO_FATAL_FAILURE(bufferHandle = mGralloc->allocate(info, true));
@@ -1421,7 +1405,7 @@
/**
* Test IMapper::set(Dataspace)
*/
-TEST_F(GraphicsMapperHidlTest, SetDataspace) {
+TEST_P(GraphicsMapperHidlTest, SetDataspace) {
Dataspace dataspace = Dataspace::V0_SRGB_LINEAR;
hidl_vec<uint8_t> vec;
ASSERT_EQ(NO_ERROR, gralloc4::encodeDataspace(dataspace, &vec));
@@ -1437,7 +1421,7 @@
/**
* Test IMapper::set(BlendMode)
*/
-TEST_F(GraphicsMapperHidlTest, SetBlendMode) {
+TEST_P(GraphicsMapperHidlTest, SetBlendMode) {
BlendMode blendMode = BlendMode::PREMULTIPLIED;
hidl_vec<uint8_t> vec;
ASSERT_EQ(NO_ERROR, gralloc4::encodeBlendMode(blendMode, &vec));
@@ -1453,7 +1437,7 @@
/**
* Test IMapper::set(metadata) with a bad buffer
*/
-TEST_F(GraphicsMapperHidlTest, SetMetadataNullBuffer) {
+TEST_P(GraphicsMapperHidlTest, SetMetadataNullBuffer) {
const native_handle_t* bufferHandle = nullptr;
hidl_vec<uint8_t> vec;
ASSERT_EQ(Error::BAD_BUFFER, mGralloc->set(bufferHandle, gralloc4::MetadataType_BufferId, vec));
@@ -1490,7 +1474,7 @@
/**
* Test IMapper::set(metadata) for constant metadata
*/
-TEST_F(GraphicsMapperHidlTest, SetConstantMetadata) {
+TEST_P(GraphicsMapperHidlTest, SetConstantMetadata) {
const native_handle_t* bufferHandle = nullptr;
ASSERT_NO_FATAL_FAILURE(bufferHandle = mGralloc->allocate(mDummyDescriptorInfo, true));
@@ -1509,7 +1493,7 @@
/**
* Test IMapper::set(metadata) for bad metadata
*/
-TEST_F(GraphicsMapperHidlTest, SetBadMetadata) {
+TEST_P(GraphicsMapperHidlTest, SetBadMetadata) {
const native_handle_t* bufferHandle = nullptr;
ASSERT_NO_FATAL_FAILURE(bufferHandle = mGralloc->allocate(mDummyDescriptorInfo, true));
@@ -1549,7 +1533,7 @@
/**
* Test IMapper::getFromBufferDescriptorInfo(BufferId)
*/
-TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoBufferId) {
+TEST_P(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoBufferId) {
hidl_vec<uint8_t> vec;
ASSERT_EQ(Error::UNSUPPORTED,
mGralloc->getFromBufferDescriptorInfo(mDummyDescriptorInfo,
@@ -1559,7 +1543,7 @@
/**
* Test IMapper::getFromBufferDescriptorInfo(Name)
*/
-TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoName) {
+TEST_P(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoName) {
hidl_vec<uint8_t> vec;
ASSERT_EQ(Error::NONE, mGralloc->getFromBufferDescriptorInfo(
mDummyDescriptorInfo, gralloc4::MetadataType_Name, &vec));
@@ -1572,7 +1556,7 @@
/**
* Test IMapper::getFromBufferDescriptorInfo(Width)
*/
-TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoWidth) {
+TEST_P(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoWidth) {
hidl_vec<uint8_t> vec;
ASSERT_EQ(Error::NONE, mGralloc->getFromBufferDescriptorInfo(
mDummyDescriptorInfo, gralloc4::MetadataType_Width, &vec));
@@ -1585,7 +1569,7 @@
/**
* Test IMapper::getFromBufferDescriptorInfo(Height)
*/
-TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoHeight) {
+TEST_P(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoHeight) {
hidl_vec<uint8_t> vec;
ASSERT_EQ(Error::NONE, mGralloc->getFromBufferDescriptorInfo(
mDummyDescriptorInfo, gralloc4::MetadataType_Height, &vec));
@@ -1598,7 +1582,7 @@
/**
* Test IMapper::getFromBufferDescriptorInfo(PixelFormatRequested)
*/
-TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoPixelFormatRequested) {
+TEST_P(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoPixelFormatRequested) {
hidl_vec<uint8_t> vec;
ASSERT_EQ(Error::NONE,
mGralloc->getFromBufferDescriptorInfo(
@@ -1612,7 +1596,7 @@
/**
* Test IMapper::getFromBufferDescriptorInfo(PixelFormatFourCC)
*/
-TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoPixelFormatFourCC) {
+TEST_P(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoPixelFormatFourCC) {
hidl_vec<uint8_t> vec;
Error err = mGralloc->getFromBufferDescriptorInfo(
mDummyDescriptorInfo, gralloc4::MetadataType_PixelFormatFourCC, &vec);
@@ -1628,7 +1612,7 @@
/**
* Test IMapper::getFromBufferDescriptorInfo(PixelFormatModifier)
*/
-TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoPixelFormatModifier) {
+TEST_P(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoPixelFormatModifier) {
hidl_vec<uint8_t> vec;
Error err = mGralloc->getFromBufferDescriptorInfo(
mDummyDescriptorInfo, gralloc4::MetadataType_PixelFormatModifier, &vec);
@@ -1644,7 +1628,7 @@
/**
* Test IMapper::getFromBufferDescriptorInfo(Usage)
*/
-TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoUsage) {
+TEST_P(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoUsage) {
hidl_vec<uint8_t> vec;
ASSERT_EQ(Error::NONE, mGralloc->getFromBufferDescriptorInfo(
mDummyDescriptorInfo, gralloc4::MetadataType_Usage, &vec));
@@ -1657,7 +1641,7 @@
/**
* Test IMapper::getFromBufferDescriptorInfo(AllocationSize)
*/
-TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoAllocationSize) {
+TEST_P(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoAllocationSize) {
hidl_vec<uint8_t> vec;
Error err = mGralloc->getFromBufferDescriptorInfo(mDummyDescriptorInfo,
gralloc4::MetadataType_AllocationSize, &vec);
@@ -1673,7 +1657,7 @@
/**
* Test IMapper::getFromBufferDescriptorInfo(ProtectedContent)
*/
-TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoProtectedContent) {
+TEST_P(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoProtectedContent) {
auto info = mDummyDescriptorInfo;
info.usage = BufferUsage::PROTECTED | BufferUsage::COMPOSER_OVERLAY;
@@ -1689,7 +1673,7 @@
/**
* Test IMapper::getFromBufferDescriptorInfo(Compression)
*/
-TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoCompression) {
+TEST_P(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoCompression) {
auto info = mDummyDescriptorInfo;
info.usage = static_cast<uint64_t>(BufferUsage::CPU_WRITE_OFTEN | BufferUsage::CPU_READ_OFTEN);
@@ -1707,7 +1691,7 @@
/**
* Test IMapper::getFromBufferDescriptorInfo(Interlaced)
*/
-TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoInterlaced) {
+TEST_P(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoInterlaced) {
hidl_vec<uint8_t> vec;
ASSERT_EQ(Error::NONE, mGralloc->getFromBufferDescriptorInfo(
mDummyDescriptorInfo, gralloc4::MetadataType_Interlaced, &vec));
@@ -1722,7 +1706,7 @@
/**
* Test IMapper::getFromBufferDescriptorInfo(ChromaSiting)
*/
-TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoChromaSiting) {
+TEST_P(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoChromaSiting) {
hidl_vec<uint8_t> vec;
ASSERT_EQ(Error::NONE,
mGralloc->getFromBufferDescriptorInfo(mDummyDescriptorInfo,
@@ -1738,7 +1722,7 @@
/**
* Test IMapper::getFromBufferDescriptorInfo(PlaneLayouts)
*/
-TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoPlaneLayouts) {
+TEST_P(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoPlaneLayouts) {
hidl_vec<uint8_t> vec;
ASSERT_EQ(Error::NONE,
mGralloc->getFromBufferDescriptorInfo(mDummyDescriptorInfo,
@@ -1752,7 +1736,7 @@
/**
* Test IMapper::getFromBufferDescriptorInfo(Dataspace)
*/
-TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoDataspace) {
+TEST_P(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoDataspace) {
hidl_vec<uint8_t> vec;
ASSERT_EQ(Error::NONE, mGralloc->getFromBufferDescriptorInfo(
mDummyDescriptorInfo, gralloc4::MetadataType_Dataspace, &vec));
@@ -1765,7 +1749,7 @@
/**
* Test IMapper::getFromBufferDescriptorInfo(BlendMode)
*/
-TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoBlendMode) {
+TEST_P(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoBlendMode) {
hidl_vec<uint8_t> vec;
ASSERT_EQ(Error::NONE, mGralloc->getFromBufferDescriptorInfo(
mDummyDescriptorInfo, gralloc4::MetadataType_BlendMode, &vec));
@@ -1778,7 +1762,7 @@
/**
* Test IMapper::getFromBufferDescriptorInfo(metadata) for unsupported metadata
*/
-TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoUnsupportedMetadata) {
+TEST_P(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoUnsupportedMetadata) {
MetadataType metadataTypeFake = {"FAKE", 1};
hidl_vec<uint8_t> vec;
@@ -1790,7 +1774,7 @@
/**
* Test IMapper::getFromBufferDescriptorInfo(metadata) for unsupported standard metadata
*/
-TEST_F(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoUnsupportedStandardMetadata) {
+TEST_P(GraphicsMapperHidlTest, GetFromBufferDescriptorInfoUnsupportedStandardMetadata) {
MetadataType metadataTypeFake = {GRALLOC4_STANDARD_METADATA_TYPE, 9999};
hidl_vec<uint8_t> vec;
@@ -1802,7 +1786,7 @@
/**
* Test IMapper::listSupportedMetadataTypes()
*/
-TEST_F(GraphicsMapperHidlTest, ListSupportedMetadataTypes) {
+TEST_P(GraphicsMapperHidlTest, ListSupportedMetadataTypes) {
hidl_vec<IMapper::MetadataTypeDescription> descriptions;
mGralloc->getMapper()->listSupportedMetadataTypes(
[&](const auto& tmpError, const auto& tmpDescriptions) {
@@ -1850,7 +1834,7 @@
/**
* Test IMapper::dumpBuffer()
*/
-TEST_F(GraphicsMapperHidlTest, DumpBuffer) {
+TEST_P(GraphicsMapperHidlTest, DumpBuffer) {
const native_handle_t* bufferHandle = nullptr;
ASSERT_NO_FATAL_FAILURE(bufferHandle = mGralloc->allocate(mDummyDescriptorInfo, true));
auto buffer = const_cast<native_handle_t*>(bufferHandle);
@@ -1867,7 +1851,7 @@
/**
* Test IMapper::dumpBuffer() with an invalid buffer
*/
-TEST_F(GraphicsMapperHidlTest, DumpBufferNullBuffer) {
+TEST_P(GraphicsMapperHidlTest, DumpBufferNullBuffer) {
native_handle_t* bufferHandle = nullptr;
auto buffer = const_cast<native_handle_t*>(bufferHandle);
@@ -1880,7 +1864,7 @@
/**
* Test IMapper::dumpBuffer() multiple
*/
-TEST_F(GraphicsMapperHidlTest, DumpBuffers) {
+TEST_P(GraphicsMapperHidlTest, DumpBuffers) {
size_t bufferCount = 10;
for (int i = 0; i < bufferCount; i++) {
@@ -1903,7 +1887,7 @@
/**
* Test IMapper::getReservedRegion()
*/
-TEST_F(GraphicsMapperHidlTest, GetReservedRegion) {
+TEST_P(GraphicsMapperHidlTest, GetReservedRegion) {
const native_handle_t* bufferHandle = nullptr;
auto info = mDummyDescriptorInfo;
@@ -1935,7 +1919,7 @@
/**
* Test IMapper::getReservedRegion() request over a page
*/
-TEST_F(GraphicsMapperHidlTest, GetLargeReservedRegion) {
+TEST_P(GraphicsMapperHidlTest, GetLargeReservedRegion) {
const native_handle_t* bufferHandle = nullptr;
auto info = mDummyDescriptorInfo;
@@ -1973,7 +1957,7 @@
/**
* Test IMapper::getReservedRegion() across multiple mappers
*/
-TEST_F(GraphicsMapperHidlTest, GetReservedRegionMultiple) {
+TEST_P(GraphicsMapperHidlTest, GetReservedRegionMultiple) {
const native_handle_t* bufferHandle = nullptr;
auto info = mDummyDescriptorInfo;
@@ -1991,10 +1975,8 @@
ASSERT_EQ(info.reservedSize, reservedSize1);
std::unique_ptr<Gralloc> anotherGralloc;
- ASSERT_NO_FATAL_FAILURE(
- anotherGralloc = std::make_unique<Gralloc>(
- GraphicsMapperHidlEnvironment::Instance()->getServiceName<IAllocator>(),
- GraphicsMapperHidlEnvironment::Instance()->getServiceName<IMapper>()));
+ ASSERT_NO_FATAL_FAILURE(anotherGralloc = std::make_unique<Gralloc>(std::get<0>(GetParam()),
+ std::get<1>(GetParam())));
void* reservedRegion2 = nullptr;
uint64_t reservedSize2 = 0;
@@ -2007,7 +1989,7 @@
/**
* Test IMapper::getReservedRegion() with a bad buffer
*/
-TEST_F(GraphicsMapperHidlTest, GetReservedRegionBadBuffer) {
+TEST_P(GraphicsMapperHidlTest, GetReservedRegionBadBuffer) {
const native_handle_t* bufferHandle = nullptr;
void* reservedRegion = nullptr;
@@ -2018,6 +2000,14 @@
ASSERT_EQ(0, reservedSize);
}
+INSTANTIATE_TEST_CASE_P(
+ PerInstance, GraphicsMapperHidlTest,
+ testing::Combine(
+ testing::ValuesIn(
+ android::hardware::getAllHalInstanceNames(IAllocator::descriptor)),
+ testing::ValuesIn(android::hardware::getAllHalInstanceNames(IMapper::descriptor))),
+ android::hardware::PrintInstanceTupleNameToString<>);
+
} // namespace
} // namespace vts
} // namespace V4_0
@@ -2025,13 +2015,3 @@
} // namespace graphics
} // namespace hardware
} // namespace android
-
-int main(int argc, char** argv) {
- using android::hardware::graphics::mapper::V4_0::vts::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;
-}