8 #include "gmock/gmock.h"
9 #include "gtest/gtest.h"
14 #include "EoProtocolAS.h"
21 using ::testing::InSequence;
22 using ::testing::InvokeArgument;
23 using ::testing::Matcher;
24 using ::testing::Pointee;
25 using ::testing::Return;
26 using ::testing::TypedEq;
27 using testing::internal::operator==;
30 using namespace yarp::os;
41 using yarp::dev::embObjMultipleFTsensors::embObjMultipleFTsensors::calculateBoardTime;
42 using yarp::dev::embObjMultipleFTsensors::embObjMultipleFTsensors::getSixAxisForceTorqueSensorMeasure;
43 using yarp::dev::embObjMultipleFTsensors::embObjMultipleFTsensors::update;
60 MOCK_METHOD(
bool, setcheckRemoteValue, (
const eOprotID32_t,
void *,
const unsigned int,
const double,
const double), (
override));
61 MOCK_METHOD(
bool, serviceSetRegulars, (eOmn_serv_category_t, vector<eOprotID32_t> &,
double), (
override));
64 TEST(MultiplembObjMultipleFTsensor, sendConfig2boards_simple_positive_001)
69 parser.
ftInfo_ = {{
"fakeId", {10, 200, eoas_ft_mode_calibrated, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0}}};
71 uint32_t id32First = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_ft, 0, eoprot_tag_as_ft_config);
73 EXPECT_CALL(deviceRes, setcheckRemoteValue(id32First, _, 10, 0.010, 0.050)).WillOnce(Return(
true));
81 TEST(MultiplembObjMultipleFTsensor, sendConfig2boards_double_sensor_positive_001)
86 parser.
ftInfo_ = {{
"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0}}, {
"fakeId2", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0}}};
88 eOas_ft_config_t cfg = {eoas_ft_mode_calibrated, 10, 0, 100};
89 uint32_t id32First = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_ft, 0, eoprot_tag_as_ft_config);
90 uint32_t id32Second = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_ft, 1, eoprot_tag_as_ft_config);
94 EXPECT_CALL(deviceRes, setcheckRemoteValue(id32First, _, 10, 0.010, 0.050)).WillOnce(Return(
true));
95 EXPECT_CALL(deviceRes, setcheckRemoteValue(id32Second, _, 10, 0.010, 0.050)).WillOnce(Return(
true));
102 TEST(MultiplembObjMultipleFTsensor, sendConfig2boards_simple_negative_001)
107 parser.
ftInfo_ = {{
"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0}}};
109 uint32_t id32First = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_ft, 0, eoprot_tag_as_ft_config);
111 EXPECT_CALL(deviceRes, setcheckRemoteValue(id32First, _, 10, 0.010, 0.050)).WillOnce(Return(
false));
118 TEST(MultiplembObjMultipleFTsensor, sendStart2boards_simple_positive_001)
123 parser.
ftInfo_ = {{
"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0}}};
125 uint32_t id32First = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_ft, 0, eoprot_tag_as_ft_cmmnds_enable);
129 EXPECT_CALL(deviceRes, setcheckRemoteValue(id32First, _, 10, 0.010, 0.050)).WillOnce(Return(
true));
136 TEST(MultiplembObjMultipleFTsensor, sendStart2boards_double_positive_001)
141 parser.
ftInfo_ = {{
"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0}}, {
"fakeId1", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0}}};
143 uint32_t id32First = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_ft, 0, eoprot_tag_as_ft_cmmnds_enable);
144 uint32_t id32Second = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_ft, 1, eoprot_tag_as_ft_cmmnds_enable);
148 EXPECT_CALL(deviceRes, setcheckRemoteValue(id32First, _, 10, 0.010, 0.050)).WillOnce(Return(
true));
149 EXPECT_CALL(deviceRes, setcheckRemoteValue(id32Second, _, 10, 0.010, 0.050)).WillOnce(Return(
true));
156 TEST(MultiplembObjMultipleFTsensor, serviceSetRegulars_simple_positive_001)
161 parser.
ftInfo_ = {{
"fakeId", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0}}, {
"fakeId1", {10, 100, eoas_ft_mode_calibrated, eobrd_unknown, 0, 0, 0, 0, 0, 0, 0}}};
163 uint32_t id32First = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_ft, 0, eoprot_tag_as_ft_status_timedvalue);
164 uint32_t id32Second = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_ft, 1, eoprot_tag_as_ft_status_timedvalue);
165 vector<eOprotID32_t> ids = {id32First, id32Second};
167 EXPECT_CALL(deviceRes, serviceSetRegulars(eomn_serv_category_ft, ids, _)).WillOnce(Return(
true));
174 TEST(MultiplembObjMultipleFTsensor, update_simple_positive_001)
177 yarp::os::Network::init();
178 std::shared_ptr<embObjDevPrivData_Mock> privateData = std::make_shared<embObjDevPrivData_Mock>(
"test");
180 uint32_t id32First = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_ft, 0, eoprot_tag_as_ft_status_timedvalue);
181 eOas_ft_timedvalue_t
data = {100, 1, 2, 3, {5, 6, 7, 8, 9, 10}};
182 yarp::sig::Vector expected = {5, 6, 7, 8, 9, 10};
184 EXPECT_CALL(*privateData, isOpen()).WillRepeatedly(Return(
true));
187 bool ret = device.
update(id32First, 1, (
void *)&
data);
193 TEST(MultiplembObjMultipleFTsensor, update_simple_positive_002)
196 yarp::os::Network::init();
197 std::shared_ptr<embObjDevPrivData_Mock> privateData = std::make_shared<embObjDevPrivData_Mock>(
"test");
199 uint32_t id32First = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_ft, 1, eoprot_tag_as_ft_status_timedvalue);
200 eOas_ft_timedvalue_t
data = {100, 1, 2, 3, {5, 6, 7, 8, 9, 10}};
201 yarp::sig::Vector expected = {5, 6, 7, 8, 9, 10};
202 yarp::sig::Vector expectedEmpty = {0, 0, 0, 0, 0, 0};
204 EXPECT_CALL(*privateData, isOpen()).WillRepeatedly(Return(
true));
207 bool ret = device.
update(id32First, 1, (
void *)&
data);
215 TEST(MultiplembObjMultipleFTsensor, update_negative_001)
218 std::shared_ptr<embObjDevPrivData_Mock> privateData = std::make_shared<embObjDevPrivData_Mock>(
"test");
220 uint32_t id32First = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_ft, 4, eoprot_tag_as_ft_status_timedvalue);
221 eOas_ft_timedvalue_t
data = {100, 1, 2, 3, {5, 6, 7, 8, 9, 10}};
222 yarp::sig::Vector expected = {5, 6, 7, 8, 9, 10};
223 yarp::sig::Vector expectedEmpty = {0, 0, 0, 0, 0, 0};
225 EXPECT_CALL(*privateData, isOpen()).WillRepeatedly(Return(
true));
228 bool ret = device.
update(id32First, 1, (
void *)&
data);
232 TEST(MultiplembObjMultipleFTsensor, update_negative_002)
235 std::shared_ptr<embObjDevPrivData_Mock> privateData = std::make_shared<embObjDevPrivData_Mock>(
"test");
237 uint32_t id32First = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_pos, 3, eoprot_tag_as_ft_status_timedvalue);
238 eOas_ft_timedvalue_t
data = {100, 1, 2, 3, {5, 6, 7, 8, 9, 10}};
239 yarp::sig::Vector expected = {5, 6, 7, 8, 9, 10};
240 yarp::sig::Vector expectedEmpty = {0, 0, 0, 0, 0, 0};
242 EXPECT_CALL(*privateData, isOpen()).WillRepeatedly(Return(
true));
245 bool ret = device.
update(id32First, 3, (
void *)&
data);
249 TEST(MultiplembObjMultipleFTsensor, update_negative_003)
252 std::shared_ptr<embObjDevPrivData_Mock> privateData = std::make_shared<embObjDevPrivData_Mock>(
"test");
254 uint32_t id32First = eoprot_ID_get(eoprot_endpoint_analogsensors, eoprot_entity_as_ft, 3, eoprot_tag_as_ft_status);
255 eOas_ft_timedvalue_t
data = {100, 1, 2, 3, {5, 6, 7, 8, 9, 10}};
256 yarp::sig::Vector expected = {5, 6, 7, 8, 9, 10};
257 yarp::sig::Vector expectedEmpty = {0, 0, 0, 0, 0, 0};
259 EXPECT_CALL(*privateData, isOpen()).WillRepeatedly(Return(
true));
262 bool ret = device.
update(id32First, 3, (
void *)&
data);
266 TEST(MultiplembObjMultipleFTsensor, getNrOfSixAxisForceTorqueSensors_positive_001)
269 std::shared_ptr<embObjDevPrivData_Mock> privateData = std::make_shared<embObjDevPrivData_Mock>(
"test");
274 EXPECT_CALL(*privateData, isOpen()).WillRepeatedly(Return(
true));
277 yarp::sig::Vector
data;
281 yarp::sig::Vector expected = {1, 2, 3, 4, 5, 6};
282 EXPECT_EQ(expected,
data);
283 EXPECT_EQ(99.49, timestamp);
286 TEST(MultiplembObjMultipleFTsensor, getNrOfSixAxisForceTorqueSensors_double_positive_001)
289 std::shared_ptr<embObjDevPrivData_Mock> privateData = std::make_shared<embObjDevPrivData_Mock>(
"test");
292 device.
ftSensorsData_ = {{{0}, {{1, 2, 3, 4, 5, 6}, 99.49}}, {{1}, {{10, 20, 30, 40, 50, 60}, 99.49}}};
294 EXPECT_CALL(*privateData, isOpen()).WillRepeatedly(Return(
true));
297 yarp::sig::Vector
data;
301 yarp::sig::Vector expected = {10, 20, 30, 40, 50, 60};
302 EXPECT_EQ(expected,
data);
303 EXPECT_EQ(99.49, timestamp);
306 TEST(MultiplembObjMultipleFTsensor, getNrOfSgetTemperatureSensorMeasure_positive_001)
309 std::shared_ptr<embObjDevPrivData_Mock> privateData = std::make_shared<embObjDevPrivData_Mock>(
"test");
314 EXPECT_CALL(*privateData, isOpen()).WillRepeatedly(Return(
true));
321 double expected = 3.4;
322 EXPECT_DOUBLE_EQ(expected,
data);
323 EXPECT_EQ(99.49, timestamp);
326 TEST(MultiplembObjMultipleFTsensor, calculateBoardTime_positive_001)
329 yarp::os::Network::init();
330 std::shared_ptr<embObjDevPrivData_Mock> privateData = std::make_shared<embObjDevPrivData_Mock>(
"test");
333 EXPECT_CALL(*privateData, isOpen()).WillRepeatedly(Return(
true));
340 double diff = second - first;
342 EXPECT_DOUBLE_EQ(1.0,diff);
MOCK_METHOD(bool, setcheckRemoteValue,(const eOprotID32_t, void *, const unsigned int, const double, const double),(override))
MOCK_METHOD(bool, serviceSetRegulars,(eOmn_serv_category_t, vector< eOprotID32_t > &, double),(override))
std::map< std::string, FtInfo > ftInfo_
embObjDevPrivData_Mock(std::string name)
MOCK_METHOD(bool, isOpen,(),(const, override))
embObjMultipleFTsensor_Mock()
embObjMultipleFTsensor_Mock(std::shared_ptr< yarp::dev::embObjDevPrivData > device)
bool initRegulars(ServiceParserMultipleFt &parser, eth::AbstractEthResource *deviceRes)
std::map< eOprotID32_t, FtData > ftSensorsData_
bool sendStart2boards(ServiceParserMultipleFt &parser, eth::AbstractEthResource *deviceRes)
virtual bool getTemperatureSensorMeasure(size_t sensorindex, double &out, double ×tamp) const override
double calculateBoardTime(eOabstime_t current)
virtual bool update(eOprotID32_t id32, double timestamp, void *rxdata)
std::map< eOprotID32_t, TemperatureData > temperaturesensordata_
bool sendConfig2boards(ServiceParserMultipleFt &parser, eth::AbstractEthResource *deviceRes)
virtual bool getSixAxisForceTorqueSensorMeasure(size_t sensorindex, yarp::sig::Vector &out, double ×tamp) const override
Copyright (C) 2008 RobotCub Consortium.
TEST(MultiplembObjMultipleFTsensor, sendConfig2boards_simple_positive_001)