diff options
Diffstat (limited to 'transport/allocator/1.0/vts/functional/VtsHidlAllocatorV1_0TargetTest.cpp')
-rw-r--r-- | transport/allocator/1.0/vts/functional/VtsHidlAllocatorV1_0TargetTest.cpp | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/transport/allocator/1.0/vts/functional/VtsHidlAllocatorV1_0TargetTest.cpp b/transport/allocator/1.0/vts/functional/VtsHidlAllocatorV1_0TargetTest.cpp index 39ce606..340ec0c 100644 --- a/transport/allocator/1.0/vts/functional/VtsHidlAllocatorV1_0TargetTest.cpp +++ b/transport/allocator/1.0/vts/functional/VtsHidlAllocatorV1_0TargetTest.cpp @@ -14,11 +14,12 @@ * limitations under the License. */ -#include <VtsHalHidlTargetTestBase.h> -#include <VtsHalHidlTargetTestEnvBase.h> #include <android-base/logging.h> #include <android/hidl/allocator/1.0/IAllocator.h> #include <android/hidl/memory/1.0/IMemory.h> +#include <gtest/gtest.h> +#include <hidl/GtestPrinter.h> +#include <hidl/ServiceManagement.h> #include <hidlmemory/mapping.h> using ::android::sp; @@ -32,20 +33,10 @@ using ::android::hidl::memory::V1_0::IMemory; #define ASSERT_OK(ret) ASSERT_TRUE((ret).isOk()) #define EXPECT_OK(ret) EXPECT_TRUE((ret).isOk()) -class AllocatorEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { - public: - virtual void registerTestServices() override { registerTestService<IAllocator>(); } - - static AllocatorEnvironment* instance() { - static AllocatorEnvironment* instance = new AllocatorEnvironment(); - return instance; - }; -}; - -class AllocatorHidlTest : public ::testing::VtsHalHidlTargetTestBase { - public: +class AllocatorHidlTest : public ::testing::TestWithParam<std::string> { + public: virtual void SetUp() override { - allocator = getService<IAllocator>(AllocatorEnvironment::instance()); + allocator = IAllocator::getService(GetParam()); ASSERT_NE(allocator, nullptr); } @@ -88,13 +79,13 @@ class AllocatorHidlTest : public ::testing::VtsHalHidlTargetTestBase { sp<IAllocator> allocator; }; -TEST_F(AllocatorHidlTest, TestAllocateSizes) { +TEST_P(AllocatorHidlTest, TestAllocateSizes) { for (size_t size : {1, 1023, 1024, 1025, 4096}) { expectAllocateSuccess(size); } } -TEST_F(AllocatorHidlTest, TestBatchAllocateSizes) { +TEST_P(AllocatorHidlTest, TestBatchAllocateSizes) { for (size_t count : {1, 1, 2, 3, 10}) { for (size_t size : {1, 1023, 1024, 1025, 4096}) { expectBatchAllocateSuccess(size, count); @@ -102,7 +93,7 @@ TEST_F(AllocatorHidlTest, TestBatchAllocateSizes) { } } -TEST_F(AllocatorHidlTest, TestCommit) { +TEST_P(AllocatorHidlTest, TestCommit) { constexpr size_t kSize = 1337; sp<IMemory> memory = expectAllocateSuccess(kSize); @@ -131,9 +122,7 @@ TEST_F(AllocatorHidlTest, TestCommit) { } } -int main(int argc, char** argv) { - ::testing::AddGlobalTestEnvironment(AllocatorEnvironment::instance()); - ::testing::InitGoogleTest(&argc, argv); - AllocatorEnvironment::instance()->init(&argc, argv); - return RUN_ALL_TESTS(); -} +INSTANTIATE_TEST_SUITE_P( + PerInstance, AllocatorHidlTest, + testing::ValuesIn(android::hardware::getAllHalInstanceNames(IAllocator::descriptor)), + android::hardware::PrintInstanceNameToString); |