在编写 c++的单体测试,但是在用 mock 的时候出了点问题。
//在 mock 类里面,函数已经被 mock 了
MOCK_METHOD1(unRegisterListener, Return<EnCommonFuncResult>(EnCommonListenerID));
//unRegisterListener 的函数签名是
virtual Return<EnMeterFuncResult> unRegisterListener(EnMeterListenerID serviceId)//这个 Return 是 android::hardware::Return
//现在想进行插桩,EnCommonFuncResult 就是一个 enum class EnCommonFuncResult : uint8_t
Return<EnCommonFuncResult> returnOk= EnCommonFuncResult::EN_COMMON_RESULT_OK;//这个 Return 是 android::hardware::Return
EXPECT_CALL(mockICommon, unRegisterListener(_)).WillOnce(::testing::Return(returnOk));//这儿出错
//以下为报错信息
error: call to implicitly-deleted copy constructor of 'android::hardware::Return<iauto::hardware::ucom::common::V1_0::EnCommonFuncResult>'
system/libhidl/base/include/hidl/Status.h:200:5: note: copy constructor is implicitly deleted because 'Return<iauto::hardware::ucom::common::V1_0::EnCommonFuncResult>' has a user-declared move constructor
Return(Return &&other) = default;
抱歉 c++有点菜,实在没搞懂这个 android::hardware::Return 该怎么用