29 #include <gtest/gtest.h> 33 #include <swri_roscpp/TestTopicServiceRequest.h> 34 #include <swri_roscpp/TestTopicServiceResponse.h> 57 static const std::string
topic_name =
"/test_topic_service";
77 ROS_INFO(
"TopicServiceHandler::handleTopicServiceRequest");
78 resp.response_value = req.request_value;
80 if (call_count_ >= value_count || (test_values[call_count_] != req.request_value))
86 if (req.request_value == test_values[value_count-1])
102 TEST(TopicServiceClientTests, testTopicServiceClient)
112 while (!client.
exists() && checks < 20)
114 ROS_INFO(
"Waiting for server to exist...");
118 ASSERT_TRUE(client.
exists());
126 bool result = client.
call(srv);
128 if (i + 1 < swri_roscpp::value_count)
135 ASSERT_FALSE(result);
141 TEST(TopicServiceServerTests, testTopicServiceServer)
162 ASSERT_FALSE(handler.
error_);
170 int main(
int argc,
char** argv)
176 testing::InitGoogleTest(&argc, argv);
177 retval = RUN_ALL_TESTS();
TestTopicServiceResponse Response
TestTopicServiceRequest Request
void initialize(ros::NodeHandle &nh, const std::string &service, bool(T::*srv_func)(const MReq &, MRes &), T *obj)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
TEST(TopicServiceClientTests, testTopicServiceClient)
static const size_t value_count
bool handleTopicServiceRequest(const swri_roscpp::TestTopicService::Request &req, swri_roscpp::TestTopicService::Response &resp)
static const std::string topic_name
void initialize(ros::NodeHandle &nh, const std::string &service, const std::string &client_name="")
static const int test_values[]
ROSCPP_DECL void shutdown()
int main(int argc, char **argv)
ROSCPP_DECL void spinOnce()