Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5afc3be6 authored by Hridya Valsaraju's avatar Hridya Valsaraju Committed by Wonsik Kim
Browse files

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
parent 96de95d9
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -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 @@ class C2BufferTest : public ::testing::Test {
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 @@ public:
    }

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;