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

Commit 94b11ca1 authored by Zhuoyao Zhang's avatar Zhuoyao Zhang
Browse files

Convert GraphicsMapper Hal test to test against each of the service

names.

Bug:64203181
Test: vts-tradefed run vts -m VtsHalGraphicsMapperV2_0Target
Change-Id: Icbef0f0575183033c069d8ec097ab774207c40de
parent f097a56a
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -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";
}
+16 −0
Original line number Diff line number Diff line
@@ -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
+7 −6
Original line number Diff line number Diff line
@@ -403,10 +403,11 @@ TEST_F(GraphicsMapperHidlTest, UnlockNegative) {
}  // namespace android

int main(int argc, char** argv) {
    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;
}