libmm dbus 프록시 API를 에뮬레이트하는 방법

libmm dbus 프록시 API를 에뮬레이트하는 방법

DBUS 프록시 API를 사용하여 call_syncDBUS에서 데이터를 읽고 있으며 이제 단위 테스트를 추가하고 이에 대한 모의를 만들었습니다.

코드는 다음과 같습니다.

class MockDBusProxy : public IDBusProxy {
public:
    MOCK_METHOD(Glib::VariantContainerBase, callDBusMethod,
                (const Glib::ustring& busName, const Glib::ustring& objectPath,
                 const Glib::ustring& interfaceName, const Glib::ustring& methodName,
                 Glib::VariantContainerBase& tuple, int timeout), (override));
};

class TestSystemOperationsTranslation : public ::testing::Test
{
public:
    MockDBusProxy mockDBusProxy;
    SystemOperationsTranslation testSysOperations;

    TestSystemOperationsTranslation() : testSysOperations(mockDBusProxy) {}
};
    
bool compareVariantContainers(const Glib::VariantContainerBase& container1, const Glib::VariantContainerBase& container2) {
    return container1.equal(container2);;
}
    
MATCHER_P(VariantContainerEq, expected, "") {
    return arg.equal(expected);
}
    
    
    
TEST_F(TestSystemOperationsTranslation, testGetData)
{
    Glib::ustring busName = "bus_name";
    Glib::ustring objectPath = "object_path";
    Glib::ustring interfaceName = "interface_name";
    Glib::ustring methodName = "method_name";
    Glib::VariantContainerBase tuple;
    int timeout = 100; // Example timeout value

    // Set expectations on the mock object
    Glib::VariantContainerBase expectedReturnValue;

    EXPECT_CALL(mockDBusProxy, callDBusMethod(busName, objectPath, interfaceName, methodName, tuple, timeout))
           .WillOnce(testing::Invoke([&expectedReturnValue](const Glib::ustring&, const Glib::ustring&, const Glib::ustring&, const Glib::ustring&, const Glib::VariantContainerBase&, int) {
               return expectedReturnValue;
           }));

    // Act
    Glib::ustring result = testSysOperations.handleGetData();
    std::cout << "result: " << result << std::endl;

    // Validate the result using the custom comparison function
    //ASSERT_TRUE(compareVariantContainers(tuple, expectedReturnValue));
    EXPECT_THAT(tuple, VariantContainerEq(expectedReturnValue));
}

하지만 컴파일 오류가 표시됩니다.

unit/test/gtest/googletest-src/googletest/include/gtest/gtest-matchers.h:179:60:
error: no match for ‘operator==’ (operand types are ‘const
Glib::VariantContainerBase’ and ‘const VariantContainerEq’)   179 |  
bool operator()(const A& a, const B& b) const { return a == b; }

 This may be due to the comparison of Glib::VariantContainerBase
 objects. The Glib::VariantBase::operator== is declared as private,
 causing the compilation error when the compareVariantContainers
 function is used for validation.

하지만 어떻게 해결해야 할지 모르겠습니다. 이 giommDBUS 프록시 API를 실제로 에뮬레이트할 수 있나요 ?

관련 정보