C2BufferTest: Get linear allocator as per device's capability
C2BufferTest must choose the correct linear allocator depending on the
whether the device supports ION on DMA-BUF heaps.
Test: atest C2BufferTest with and without CONFIG_ION enabled
Bug: 182117764
Change-Id: I9831487bf3eed7e6d5e512c5dd40eb0fe5efbbfb
diff --git a/media/codec2/tests/vndk/C2BufferTest.cpp b/media/codec2/tests/vndk/C2BufferTest.cpp
index a9f8e17..0cfb465 100644
--- a/media/codec2/tests/vndk/C2BufferTest.cpp
+++ b/media/codec2/tests/vndk/C2BufferTest.cpp
@@ -16,11 +16,12 @@
#include <gtest/gtest.h>
-#include <C2AllocatorIon.h>
#include <C2AllocatorGralloc.h>
#include <C2Buffer.h>
#include <C2BufferPriv.h>
+#include <C2Config.h>
#include <C2ParamDef.h>
+#include <C2PlatformSupport.h>
#include <system/graphics.h>
@@ -233,10 +234,10 @@
public:
C2BufferTest()
: mBlockPoolId(C2BlockPool::PLATFORM_START),
- mLinearAllocator(std::make_shared<C2AllocatorIon>('i')),
mSize(0u),
mAddr(nullptr),
mGraphicAllocator(std::make_shared<C2AllocatorGralloc>('g')) {
+ getLinearAllocator(&mLinearAllocator);
}
~C2BufferTest() = default;
@@ -329,6 +330,11 @@
}
private:
+ void getLinearAllocator(std::shared_ptr<C2Allocator>* mLinearAllocator) {
+ std::shared_ptr<C2AllocatorStore> store = android::GetCodec2PlatformAllocatorStore();
+ ASSERT_EQ(store->fetchAllocator(C2AllocatorStore::DEFAULT_LINEAR, mLinearAllocator), C2_OK);
+ }
+
C2BlockPool::local_id_t mBlockPoolId;
std::shared_ptr<C2Allocator> mLinearAllocator;
std::shared_ptr<C2LinearAllocation> mLinearAllocation;