18 #ifndef PRBT_HARDWARE_SUPPORT_ROS_TEST_HELPER_H 19 #define PRBT_HARDWARE_SUPPORT_ROS_TEST_HELPER_H 25 #include <gtest/gtest.h> 36 std::vector<std::string> node_names;
38 std::find(node_names.begin(), node_names.end(), node_name) == node_names.end());
46 inline ::testing::AssertionResult
waitForNode(
const std::string node_name,
const double loop_frequency = 10.0,
50 std::vector<std::string> node_names;
54 std::find(node_names.begin(), node_names.end(), node_name) == node_names.end())
58 return ::testing::AssertionFailure() <<
"Timeout while waiting for node: \"" << node_name <<
"\"";
62 return ::testing::AssertionSuccess() <<
"Found note \"" << node_name <<
"\"";
72 const unsigned int subscriber_count = 1,
73 const double loop_frequency = 10.0,
76 ROS_INFO_STREAM(
"Waiting for " << subscriber_count <<
" subscriber to topic \"" << publisher.
getTopic() <<
"\"");
83 return ::testing::AssertionFailure() <<
"Timeout while waiting for " << subscriber_count
84 <<
" subscriber to topic \"" << publisher.
getTopic() <<
"\"";
88 return ::testing::AssertionSuccess() <<
"Registered " << subscriber_count <<
" subscriber to topic \"" 99 double loop_frequency = 10.0)
101 std::vector<std::string> node_names;
104 std::find(node_names.begin(), node_names.end(), node_name) != node_names.end())
109 return ::testing::AssertionFailure() <<
"Timed out waiting for shutdown of Node " << node_name;
113 return ::testing::AssertionSuccess();
119 if (!obj.init(ip, port))
131 #endif // PRBT_HARDWARE_SUPPORT_ROS_TEST_HELPER_H
static void initalizeAndRun(T &obj, const char *ip, unsigned int port)
bool checkForNode(std::string node_name)
Checks if a node is up and running.
inline ::testing::AssertionResult waitForNode(const std::string node_name, const double loop_frequency=10.0, const ros::Duration timeout=ros::Duration(10.0))
Blocks until a node defined by node_name comes up.
std::string getTopic() const
#define ROS_INFO_STREAM(args)
inline ::testing::AssertionResult waitForSubscriber(const ros::Publisher &publisher, const unsigned int subscriber_count=1, const double loop_frequency=10.0, const ros::Duration timeout=ros::Duration(10.0))
Blocks until the specified number of subscribers is registered on a topic.
ROSCPP_DECL bool getNodes(V_string &nodes)
inline ::testing::AssertionResult waitForNodeShutdown(std::string node_name, double timeout=1.0, double loop_frequency=10.0)
Blocks until a node defined by node_name can no longer be found.
uint32_t getNumSubscribers() const